babylon.module.d.ts 5.8 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444
  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. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module "babylonjs/Misc/observable" {
  51. import { Nullable } from "babylonjs/types";
  52. /**
  53. * A class serves as a medium between the observable and its observers
  54. */
  55. export class EventState {
  56. /**
  57. * Create a new EventState
  58. * @param mask defines the mask associated with this state
  59. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60. * @param target defines the original target of the state
  61. * @param currentTarget defines the current target of the state
  62. */
  63. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64. /**
  65. * Initialize the current event state
  66. * @param mask defines the mask associated with this state
  67. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68. * @param target defines the original target of the state
  69. * @param currentTarget defines the current target of the state
  70. * @returns the current event state
  71. */
  72. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73. /**
  74. * An Observer can set this property to true to prevent subsequent observers of being notified
  75. */
  76. skipNextObservers: boolean;
  77. /**
  78. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79. */
  80. mask: number;
  81. /**
  82. * The object that originally notified the event
  83. */
  84. target?: any;
  85. /**
  86. * The current object in the bubbling phase
  87. */
  88. currentTarget?: any;
  89. /**
  90. * This will be populated with the return value of the last function that was executed.
  91. * If it is the first function in the callback chain it will be the event data.
  92. */
  93. lastReturnValue?: any;
  94. }
  95. /**
  96. * Represent an Observer registered to a given Observable object.
  97. */
  98. export class Observer<T> {
  99. /**
  100. * Defines the callback to call when the observer is notified
  101. */
  102. callback: (eventData: T, eventState: EventState) => void;
  103. /**
  104. * Defines the mask of the observer (used to filter notifications)
  105. */
  106. mask: number;
  107. /**
  108. * Defines the current scope used to restore the JS context
  109. */
  110. scope: any;
  111. /** @hidden */
  112. _willBeUnregistered: boolean;
  113. /**
  114. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  115. */
  116. unregisterOnNextCall: boolean;
  117. /**
  118. * Creates a new observer
  119. * @param callback defines the callback to call when the observer is notified
  120. * @param mask defines the mask of the observer (used to filter notifications)
  121. * @param scope defines the current scope used to restore the JS context
  122. */
  123. constructor(
  124. /**
  125. * Defines the callback to call when the observer is notified
  126. */
  127. callback: (eventData: T, eventState: EventState) => void,
  128. /**
  129. * Defines the mask of the observer (used to filter notifications)
  130. */
  131. mask: number,
  132. /**
  133. * Defines the current scope used to restore the JS context
  134. */
  135. scope?: any);
  136. }
  137. /**
  138. * Represent a list of observers registered to multiple Observables object.
  139. */
  140. export class MultiObserver<T> {
  141. private _observers;
  142. private _observables;
  143. /**
  144. * Release associated resources
  145. */
  146. dispose(): void;
  147. /**
  148. * Raise a callback when one of the observable will notify
  149. * @param observables defines a list of observables to watch
  150. * @param callback defines the callback to call on notification
  151. * @param mask defines the mask used to filter notifications
  152. * @param scope defines the current scope used to restore the JS context
  153. * @returns the new MultiObserver
  154. */
  155. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  156. }
  157. /**
  158. * The Observable class is a simple implementation of the Observable pattern.
  159. *
  160. * 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.
  161. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  162. * 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).
  163. * 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.
  164. */
  165. export class Observable<T> {
  166. private _observers;
  167. private _eventState;
  168. private _onObserverAdded;
  169. /**
  170. * Gets the list of observers
  171. */
  172. readonly observers: Array<Observer<T>>;
  173. /**
  174. * Creates a new observable
  175. * @param onObserverAdded defines a callback to call when a new observer is added
  176. */
  177. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  178. /**
  179. * Create a new Observer with the specified callback
  180. * @param callback the callback that will be executed for that Observer
  181. * @param mask the mask used to filter observers
  182. * @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.
  183. * @param scope optional scope for the callback to be called from
  184. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  185. * @returns the new observer created for the callback
  186. */
  187. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  188. /**
  189. * Create a new Observer with the specified callback and unregisters after the next notification
  190. * @param callback the callback that will be executed for that Observer
  191. * @returns the new observer created for the callback
  192. */
  193. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  194. /**
  195. * Remove an Observer from the Observable object
  196. * @param observer the instance of the Observer to remove
  197. * @returns false if it doesn't belong to this Observable
  198. */
  199. remove(observer: Nullable<Observer<T>>): boolean;
  200. /**
  201. * Remove a callback from the Observable object
  202. * @param callback the callback to remove
  203. * @param scope optional scope. If used only the callbacks with this scope will be removed
  204. * @returns false if it doesn't belong to this Observable
  205. */
  206. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  207. private _deferUnregister;
  208. private _remove;
  209. /**
  210. * Moves the observable to the top of the observer list making it get called first when notified
  211. * @param observer the observer to move
  212. */
  213. makeObserverTopPriority(observer: Observer<T>): void;
  214. /**
  215. * Moves the observable to the bottom of the observer list making it get called last when notified
  216. * @param observer the observer to move
  217. */
  218. makeObserverBottomPriority(observer: Observer<T>): void;
  219. /**
  220. * Notify all Observers by calling their respective callback with the given data
  221. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  222. * @param eventData defines the data to send to all observers
  223. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  224. * @param target defines the original target of the state
  225. * @param currentTarget defines the current target of the state
  226. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  227. */
  228. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  229. /**
  230. * Calling this will execute each callback, expecting it to be a promise or return a value.
  231. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  232. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  233. * and it is crucial that all callbacks will be executed.
  234. * The order of the callbacks is kept, callbacks are not executed parallel.
  235. *
  236. * @param eventData The data to be sent to each callback
  237. * @param mask is used to filter observers defaults to -1
  238. * @param target defines the callback target (see EventState)
  239. * @param currentTarget defines he current object in the bubbling phase
  240. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  241. */
  242. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  243. /**
  244. * Notify a specific observer
  245. * @param observer defines the observer to notify
  246. * @param eventData defines the data to be sent to each callback
  247. * @param mask is used to filter observers defaults to -1
  248. */
  249. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  250. /**
  251. * Gets a boolean indicating if the observable has at least one observer
  252. * @returns true is the Observable has at least one Observer registered
  253. */
  254. hasObservers(): boolean;
  255. /**
  256. * Clear the list of observers
  257. */
  258. clear(): void;
  259. /**
  260. * Clone the current observable
  261. * @returns a new observable
  262. */
  263. clone(): Observable<T>;
  264. /**
  265. * Does this observable handles observer registered with a given mask
  266. * @param mask defines the mask to be tested
  267. * @return whether or not one observer registered with the given mask is handeled
  268. **/
  269. hasSpecificMask(mask?: number): boolean;
  270. }
  271. }
  272. declare module "babylonjs/Misc/domManagement" {
  273. /**
  274. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  275. * Babylon.js
  276. */
  277. export class DomManagement {
  278. /**
  279. * Checks if the window object exists
  280. * @returns true if the window object exists
  281. */
  282. static IsWindowObjectExist(): boolean;
  283. /**
  284. * Checks if the navigator object exists
  285. * @returns true if the navigator object exists
  286. */
  287. static IsNavigatorAvailable(): boolean;
  288. /**
  289. * Extracts text content from a DOM element hierarchy
  290. * @param element defines the root element
  291. * @returns a string
  292. */
  293. static GetDOMTextContent(element: HTMLElement): string;
  294. }
  295. }
  296. declare module "babylonjs/Misc/logger" {
  297. /**
  298. * Logger used througouht the application to allow configuration of
  299. * the log level required for the messages.
  300. */
  301. export class Logger {
  302. /**
  303. * No log
  304. */
  305. static readonly NoneLogLevel: number;
  306. /**
  307. * Only message logs
  308. */
  309. static readonly MessageLogLevel: number;
  310. /**
  311. * Only warning logs
  312. */
  313. static readonly WarningLogLevel: number;
  314. /**
  315. * Only error logs
  316. */
  317. static readonly ErrorLogLevel: number;
  318. /**
  319. * All logs
  320. */
  321. static readonly AllLogLevel: number;
  322. private static _LogCache;
  323. /**
  324. * Gets a value indicating the number of loading errors
  325. * @ignorenaming
  326. */
  327. static errorsCount: number;
  328. /**
  329. * Callback called when a new log is added
  330. */
  331. static OnNewCacheEntry: (entry: string) => void;
  332. private static _AddLogEntry;
  333. private static _FormatMessage;
  334. private static _LogDisabled;
  335. private static _LogEnabled;
  336. private static _WarnDisabled;
  337. private static _WarnEnabled;
  338. private static _ErrorDisabled;
  339. private static _ErrorEnabled;
  340. /**
  341. * Log a message to the console
  342. */
  343. static Log: (message: string) => void;
  344. /**
  345. * Write a warning message to the console
  346. */
  347. static Warn: (message: string) => void;
  348. /**
  349. * Write an error message to the console
  350. */
  351. static Error: (message: string) => void;
  352. /**
  353. * Gets current log cache (list of logs)
  354. */
  355. static readonly LogCache: string;
  356. /**
  357. * Clears the log cache
  358. */
  359. static ClearLogCache(): void;
  360. /**
  361. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  362. */
  363. static LogLevels: number;
  364. }
  365. }
  366. declare module "babylonjs/Misc/typeStore" {
  367. /** @hidden */
  368. export class _TypeStore {
  369. /** @hidden */
  370. static RegisteredTypes: {
  371. [key: string]: Object;
  372. };
  373. /** @hidden */
  374. static GetClass(fqdn: string): any;
  375. }
  376. }
  377. declare module "babylonjs/Misc/stringTools" {
  378. /**
  379. * Helper to manipulate strings
  380. */
  381. export class StringTools {
  382. /**
  383. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  384. * @param str Source string
  385. * @param suffix Suffix to search for in the source string
  386. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  387. */
  388. static EndsWith(str: string, suffix: string): boolean;
  389. /**
  390. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  391. * @param str Source string
  392. * @param suffix Suffix to search for in the source string
  393. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  394. */
  395. static StartsWith(str: string, suffix: string): boolean;
  396. /**
  397. * Decodes a buffer into a string
  398. * @param buffer The buffer to decode
  399. * @returns The decoded string
  400. */
  401. static Decode(buffer: Uint8Array | Uint16Array): string;
  402. /**
  403. * Encode a buffer to a base64 string
  404. * @param buffer defines the buffer to encode
  405. * @returns the encoded string
  406. */
  407. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  408. }
  409. }
  410. declare module "babylonjs/Misc/deepCopier" {
  411. /**
  412. * Class containing a set of static utilities functions for deep copy.
  413. */
  414. export class DeepCopier {
  415. /**
  416. * Tries to copy an object by duplicating every property
  417. * @param source defines the source object
  418. * @param destination defines the target object
  419. * @param doNotCopyList defines a list of properties to avoid
  420. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  421. */
  422. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  423. }
  424. }
  425. declare module "babylonjs/Misc/precisionDate" {
  426. /**
  427. * Class containing a set of static utilities functions for precision date
  428. */
  429. export class PrecisionDate {
  430. /**
  431. * Gets either window.performance.now() if supported or Date.now() else
  432. */
  433. static readonly Now: number;
  434. }
  435. }
  436. declare module "babylonjs/Misc/devTools" {
  437. /** @hidden */
  438. export class _DevTools {
  439. static WarnImport(name: string): string;
  440. }
  441. }
  442. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  443. /**
  444. * Interface used to define the mechanism to get data from the network
  445. */
  446. export interface IWebRequest {
  447. /**
  448. * Returns client's response url
  449. */
  450. responseURL: string;
  451. /**
  452. * Returns client's status
  453. */
  454. status: number;
  455. /**
  456. * Returns client's status as a text
  457. */
  458. statusText: string;
  459. }
  460. }
  461. declare module "babylonjs/Misc/webRequest" {
  462. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  463. import { Nullable } from "babylonjs/types";
  464. /**
  465. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  466. */
  467. export class WebRequest implements IWebRequest {
  468. private _xhr;
  469. /**
  470. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  471. * i.e. when loading files, where the server/service expects an Authorization header
  472. */
  473. static CustomRequestHeaders: {
  474. [key: string]: string;
  475. };
  476. /**
  477. * Add callback functions in this array to update all the requests before they get sent to the network
  478. */
  479. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  480. private _injectCustomRequestHeaders;
  481. /**
  482. * Gets or sets a function to be called when loading progress changes
  483. */
  484. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  485. /**
  486. * Returns client's state
  487. */
  488. readonly readyState: number;
  489. /**
  490. * Returns client's status
  491. */
  492. readonly status: number;
  493. /**
  494. * Returns client's status as a text
  495. */
  496. readonly statusText: string;
  497. /**
  498. * Returns client's response
  499. */
  500. readonly response: any;
  501. /**
  502. * Returns client's response url
  503. */
  504. readonly responseURL: string;
  505. /**
  506. * Returns client's response as text
  507. */
  508. readonly responseText: string;
  509. /**
  510. * Gets or sets the expected response type
  511. */
  512. responseType: XMLHttpRequestResponseType;
  513. /** @hidden */
  514. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  515. /** @hidden */
  516. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  517. /**
  518. * Cancels any network activity
  519. */
  520. abort(): void;
  521. /**
  522. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  523. * @param body defines an optional request body
  524. */
  525. send(body?: Document | BodyInit | null): void;
  526. /**
  527. * Sets the request method, request URL
  528. * @param method defines the method to use (GET, POST, etc..)
  529. * @param url defines the url to connect with
  530. */
  531. open(method: string, url: string): void;
  532. /**
  533. * Sets the value of a request header.
  534. * @param name The name of the header whose value is to be set
  535. * @param value The value to set as the body of the header
  536. */
  537. setRequestHeader(name: string, value: string): void;
  538. /**
  539. * Get the string containing the text of a particular header's value.
  540. * @param name The name of the header
  541. * @returns The string containing the text of the given header name
  542. */
  543. getResponseHeader(name: string): Nullable<string>;
  544. }
  545. }
  546. declare module "babylonjs/Misc/fileRequest" {
  547. import { Observable } from "babylonjs/Misc/observable";
  548. /**
  549. * File request interface
  550. */
  551. export interface IFileRequest {
  552. /**
  553. * Raised when the request is complete (success or error).
  554. */
  555. onCompleteObservable: Observable<IFileRequest>;
  556. /**
  557. * Aborts the request for a file.
  558. */
  559. abort: () => void;
  560. }
  561. }
  562. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  563. /**
  564. * Define options used to create a render target texture
  565. */
  566. export class RenderTargetCreationOptions {
  567. /**
  568. * Specifies is mipmaps must be generated
  569. */
  570. generateMipMaps?: boolean;
  571. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  572. generateDepthBuffer?: boolean;
  573. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  574. generateStencilBuffer?: boolean;
  575. /** Defines texture type (int by default) */
  576. type?: number;
  577. /** Defines sampling mode (trilinear by default) */
  578. samplingMode?: number;
  579. /** Defines format (RGBA by default) */
  580. format?: number;
  581. }
  582. }
  583. declare module "babylonjs/Instrumentation/timeToken" {
  584. import { Nullable } from "babylonjs/types";
  585. /**
  586. * @hidden
  587. **/
  588. export class _TimeToken {
  589. _startTimeQuery: Nullable<WebGLQuery>;
  590. _endTimeQuery: Nullable<WebGLQuery>;
  591. _timeElapsedQuery: Nullable<WebGLQuery>;
  592. _timeElapsedQueryEnded: boolean;
  593. }
  594. }
  595. declare module "babylonjs/Engines/constants" {
  596. /** Defines the cross module used constants to avoid circular dependncies */
  597. export class Constants {
  598. /** Defines that alpha blending is disabled */
  599. static readonly ALPHA_DISABLE: number;
  600. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  601. static readonly ALPHA_ADD: number;
  602. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  603. static readonly ALPHA_COMBINE: number;
  604. /** Defines that alpha blending to DEST - SRC * DEST */
  605. static readonly ALPHA_SUBTRACT: number;
  606. /** Defines that alpha blending to SRC * DEST */
  607. static readonly ALPHA_MULTIPLY: number;
  608. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  609. static readonly ALPHA_MAXIMIZED: number;
  610. /** Defines that alpha blending to SRC + DEST */
  611. static readonly ALPHA_ONEONE: number;
  612. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  613. static readonly ALPHA_PREMULTIPLIED: number;
  614. /**
  615. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  616. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  617. */
  618. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  619. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  620. static readonly ALPHA_INTERPOLATE: number;
  621. /**
  622. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  623. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  624. */
  625. static readonly ALPHA_SCREENMODE: number;
  626. /**
  627. * Defines that alpha blending to SRC + DST
  628. * Alpha will be set to SRC ALPHA + DST ALPHA
  629. */
  630. static readonly ALPHA_ONEONE_ONEONE: number;
  631. /**
  632. * Defines that alpha blending to SRC * DST ALPHA + DST
  633. * Alpha will be set to 0
  634. */
  635. static readonly ALPHA_ALPHATOCOLOR: number;
  636. /**
  637. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  638. */
  639. static readonly ALPHA_REVERSEONEMINUS: number;
  640. /**
  641. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  642. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  643. */
  644. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  645. /**
  646. * Defines that alpha blending to SRC + DST
  647. * Alpha will be set to SRC ALPHA
  648. */
  649. static readonly ALPHA_ONEONE_ONEZERO: number;
  650. /** Defines that alpha blending equation a SUM */
  651. static readonly ALPHA_EQUATION_ADD: number;
  652. /** Defines that alpha blending equation a SUBSTRACTION */
  653. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  654. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  655. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  656. /** Defines that alpha blending equation a MAX operation */
  657. static readonly ALPHA_EQUATION_MAX: number;
  658. /** Defines that alpha blending equation a MIN operation */
  659. static readonly ALPHA_EQUATION_MIN: number;
  660. /**
  661. * Defines that alpha blending equation a DARKEN operation:
  662. * It takes the min of the src and sums the alpha channels.
  663. */
  664. static readonly ALPHA_EQUATION_DARKEN: number;
  665. /** Defines that the ressource is not delayed*/
  666. static readonly DELAYLOADSTATE_NONE: number;
  667. /** Defines that the ressource was successfully delay loaded */
  668. static readonly DELAYLOADSTATE_LOADED: number;
  669. /** Defines that the ressource is currently delay loading */
  670. static readonly DELAYLOADSTATE_LOADING: number;
  671. /** Defines that the ressource is delayed and has not started loading */
  672. static readonly DELAYLOADSTATE_NOTLOADED: number;
  673. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  674. static readonly NEVER: number;
  675. /** 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 */
  676. static readonly ALWAYS: number;
  677. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  678. static readonly LESS: number;
  679. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  680. static readonly EQUAL: number;
  681. /** 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 */
  682. static readonly LEQUAL: number;
  683. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  684. static readonly GREATER: number;
  685. /** 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 */
  686. static readonly GEQUAL: number;
  687. /** 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 */
  688. static readonly NOTEQUAL: number;
  689. /** Passed to stencilOperation to specify that stencil value must be kept */
  690. static readonly KEEP: number;
  691. /** Passed to stencilOperation to specify that stencil value must be replaced */
  692. static readonly REPLACE: number;
  693. /** Passed to stencilOperation to specify that stencil value must be incremented */
  694. static readonly INCR: number;
  695. /** Passed to stencilOperation to specify that stencil value must be decremented */
  696. static readonly DECR: number;
  697. /** Passed to stencilOperation to specify that stencil value must be inverted */
  698. static readonly INVERT: number;
  699. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  700. static readonly INCR_WRAP: number;
  701. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  702. static readonly DECR_WRAP: number;
  703. /** Texture is not repeating outside of 0..1 UVs */
  704. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  705. /** Texture is repeating outside of 0..1 UVs */
  706. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  707. /** Texture is repeating and mirrored */
  708. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  709. /** ALPHA */
  710. static readonly TEXTUREFORMAT_ALPHA: number;
  711. /** LUMINANCE */
  712. static readonly TEXTUREFORMAT_LUMINANCE: number;
  713. /** LUMINANCE_ALPHA */
  714. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  715. /** RGB */
  716. static readonly TEXTUREFORMAT_RGB: number;
  717. /** RGBA */
  718. static readonly TEXTUREFORMAT_RGBA: number;
  719. /** RED */
  720. static readonly TEXTUREFORMAT_RED: number;
  721. /** RED (2nd reference) */
  722. static readonly TEXTUREFORMAT_R: number;
  723. /** RG */
  724. static readonly TEXTUREFORMAT_RG: number;
  725. /** RED_INTEGER */
  726. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  727. /** RED_INTEGER (2nd reference) */
  728. static readonly TEXTUREFORMAT_R_INTEGER: number;
  729. /** RG_INTEGER */
  730. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  731. /** RGB_INTEGER */
  732. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  733. /** RGBA_INTEGER */
  734. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  735. /** UNSIGNED_BYTE */
  736. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  737. /** UNSIGNED_BYTE (2nd reference) */
  738. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  739. /** FLOAT */
  740. static readonly TEXTURETYPE_FLOAT: number;
  741. /** HALF_FLOAT */
  742. static readonly TEXTURETYPE_HALF_FLOAT: number;
  743. /** BYTE */
  744. static readonly TEXTURETYPE_BYTE: number;
  745. /** SHORT */
  746. static readonly TEXTURETYPE_SHORT: number;
  747. /** UNSIGNED_SHORT */
  748. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  749. /** INT */
  750. static readonly TEXTURETYPE_INT: number;
  751. /** UNSIGNED_INT */
  752. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  753. /** UNSIGNED_SHORT_4_4_4_4 */
  754. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  755. /** UNSIGNED_SHORT_5_5_5_1 */
  756. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  757. /** UNSIGNED_SHORT_5_6_5 */
  758. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  759. /** UNSIGNED_INT_2_10_10_10_REV */
  760. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  761. /** UNSIGNED_INT_24_8 */
  762. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  763. /** UNSIGNED_INT_10F_11F_11F_REV */
  764. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  765. /** UNSIGNED_INT_5_9_9_9_REV */
  766. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  767. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  768. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  769. /** nearest is mag = nearest and min = nearest and mip = nearest */
  770. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  771. /** Bilinear is mag = linear and min = linear and mip = nearest */
  772. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  773. /** Trilinear is mag = linear and min = linear and mip = linear */
  774. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  775. /** nearest is mag = nearest and min = nearest and mip = linear */
  776. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  777. /** Bilinear is mag = linear and min = linear and mip = nearest */
  778. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  779. /** Trilinear is mag = linear and min = linear and mip = linear */
  780. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  781. /** mag = nearest and min = nearest and mip = nearest */
  782. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  783. /** mag = nearest and min = linear and mip = nearest */
  784. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  785. /** mag = nearest and min = linear and mip = linear */
  786. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  787. /** mag = nearest and min = linear and mip = none */
  788. static readonly TEXTURE_NEAREST_LINEAR: number;
  789. /** mag = nearest and min = nearest and mip = none */
  790. static readonly TEXTURE_NEAREST_NEAREST: number;
  791. /** mag = linear and min = nearest and mip = nearest */
  792. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  793. /** mag = linear and min = nearest and mip = linear */
  794. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  795. /** mag = linear and min = linear and mip = none */
  796. static readonly TEXTURE_LINEAR_LINEAR: number;
  797. /** mag = linear and min = nearest and mip = none */
  798. static readonly TEXTURE_LINEAR_NEAREST: number;
  799. /** Explicit coordinates mode */
  800. static readonly TEXTURE_EXPLICIT_MODE: number;
  801. /** Spherical coordinates mode */
  802. static readonly TEXTURE_SPHERICAL_MODE: number;
  803. /** Planar coordinates mode */
  804. static readonly TEXTURE_PLANAR_MODE: number;
  805. /** Cubic coordinates mode */
  806. static readonly TEXTURE_CUBIC_MODE: number;
  807. /** Projection coordinates mode */
  808. static readonly TEXTURE_PROJECTION_MODE: number;
  809. /** Skybox coordinates mode */
  810. static readonly TEXTURE_SKYBOX_MODE: number;
  811. /** Inverse Cubic coordinates mode */
  812. static readonly TEXTURE_INVCUBIC_MODE: number;
  813. /** Equirectangular coordinates mode */
  814. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  815. /** Equirectangular Fixed coordinates mode */
  816. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  817. /** Equirectangular Fixed Mirrored coordinates mode */
  818. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  819. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  820. static readonly SCALEMODE_FLOOR: number;
  821. /** Defines that texture rescaling will look for the nearest power of 2 size */
  822. static readonly SCALEMODE_NEAREST: number;
  823. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  824. static readonly SCALEMODE_CEILING: number;
  825. /**
  826. * The dirty texture flag value
  827. */
  828. static readonly MATERIAL_TextureDirtyFlag: number;
  829. /**
  830. * The dirty light flag value
  831. */
  832. static readonly MATERIAL_LightDirtyFlag: number;
  833. /**
  834. * The dirty fresnel flag value
  835. */
  836. static readonly MATERIAL_FresnelDirtyFlag: number;
  837. /**
  838. * The dirty attribute flag value
  839. */
  840. static readonly MATERIAL_AttributesDirtyFlag: number;
  841. /**
  842. * The dirty misc flag value
  843. */
  844. static readonly MATERIAL_MiscDirtyFlag: number;
  845. /**
  846. * The all dirty flag value
  847. */
  848. static readonly MATERIAL_AllDirtyFlag: number;
  849. /**
  850. * Returns the triangle fill mode
  851. */
  852. static readonly MATERIAL_TriangleFillMode: number;
  853. /**
  854. * Returns the wireframe mode
  855. */
  856. static readonly MATERIAL_WireFrameFillMode: number;
  857. /**
  858. * Returns the point fill mode
  859. */
  860. static readonly MATERIAL_PointFillMode: number;
  861. /**
  862. * Returns the point list draw mode
  863. */
  864. static readonly MATERIAL_PointListDrawMode: number;
  865. /**
  866. * Returns the line list draw mode
  867. */
  868. static readonly MATERIAL_LineListDrawMode: number;
  869. /**
  870. * Returns the line loop draw mode
  871. */
  872. static readonly MATERIAL_LineLoopDrawMode: number;
  873. /**
  874. * Returns the line strip draw mode
  875. */
  876. static readonly MATERIAL_LineStripDrawMode: number;
  877. /**
  878. * Returns the triangle strip draw mode
  879. */
  880. static readonly MATERIAL_TriangleStripDrawMode: number;
  881. /**
  882. * Returns the triangle fan draw mode
  883. */
  884. static readonly MATERIAL_TriangleFanDrawMode: number;
  885. /**
  886. * Stores the clock-wise side orientation
  887. */
  888. static readonly MATERIAL_ClockWiseSideOrientation: number;
  889. /**
  890. * Stores the counter clock-wise side orientation
  891. */
  892. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  893. /**
  894. * Nothing
  895. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  896. */
  897. static readonly ACTION_NothingTrigger: number;
  898. /**
  899. * On pick
  900. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  901. */
  902. static readonly ACTION_OnPickTrigger: number;
  903. /**
  904. * On left pick
  905. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  906. */
  907. static readonly ACTION_OnLeftPickTrigger: number;
  908. /**
  909. * On right pick
  910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  911. */
  912. static readonly ACTION_OnRightPickTrigger: number;
  913. /**
  914. * On center pick
  915. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  916. */
  917. static readonly ACTION_OnCenterPickTrigger: number;
  918. /**
  919. * On pick down
  920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_OnPickDownTrigger: number;
  923. /**
  924. * On double pick
  925. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  926. */
  927. static readonly ACTION_OnDoublePickTrigger: number;
  928. /**
  929. * On pick up
  930. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  931. */
  932. static readonly ACTION_OnPickUpTrigger: number;
  933. /**
  934. * On pick out.
  935. * This trigger will only be raised if you also declared a OnPickDown
  936. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  937. */
  938. static readonly ACTION_OnPickOutTrigger: number;
  939. /**
  940. * On long press
  941. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  942. */
  943. static readonly ACTION_OnLongPressTrigger: number;
  944. /**
  945. * On pointer over
  946. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  947. */
  948. static readonly ACTION_OnPointerOverTrigger: number;
  949. /**
  950. * On pointer out
  951. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  952. */
  953. static readonly ACTION_OnPointerOutTrigger: number;
  954. /**
  955. * On every frame
  956. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  957. */
  958. static readonly ACTION_OnEveryFrameTrigger: number;
  959. /**
  960. * On intersection enter
  961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  962. */
  963. static readonly ACTION_OnIntersectionEnterTrigger: number;
  964. /**
  965. * On intersection exit
  966. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  967. */
  968. static readonly ACTION_OnIntersectionExitTrigger: number;
  969. /**
  970. * On key down
  971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  972. */
  973. static readonly ACTION_OnKeyDownTrigger: number;
  974. /**
  975. * On key up
  976. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  977. */
  978. static readonly ACTION_OnKeyUpTrigger: number;
  979. /**
  980. * Billboard mode will only apply to Y axis
  981. */
  982. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  983. /**
  984. * Billboard mode will apply to all axes
  985. */
  986. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  987. /**
  988. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  989. */
  990. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  991. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  992. * Test order :
  993. * Is the bounding sphere outside the frustum ?
  994. * If not, are the bounding box vertices outside the frustum ?
  995. * It not, then the cullable object is in the frustum.
  996. */
  997. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  998. /** Culling strategy : Bounding Sphere Only.
  999. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1000. * It's also less accurate than the standard because some not visible objects can still be selected.
  1001. * Test : is the bounding sphere outside the frustum ?
  1002. * If not, then the cullable object is in the frustum.
  1003. */
  1004. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1005. /** Culling strategy : Optimistic Inclusion.
  1006. * This in an inclusion test first, then the standard exclusion test.
  1007. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1008. * 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.
  1009. * Anyway, it's as accurate as the standard strategy.
  1010. * Test :
  1011. * Is the cullable object bounding sphere center in the frustum ?
  1012. * If not, apply the default culling strategy.
  1013. */
  1014. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1015. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1016. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1017. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1018. * 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.
  1019. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1020. * Test :
  1021. * Is the cullable object bounding sphere center in the frustum ?
  1022. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1023. */
  1024. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1025. /**
  1026. * No logging while loading
  1027. */
  1028. static readonly SCENELOADER_NO_LOGGING: number;
  1029. /**
  1030. * Minimal logging while loading
  1031. */
  1032. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1033. /**
  1034. * Summary logging while loading
  1035. */
  1036. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1037. /**
  1038. * Detailled logging while loading
  1039. */
  1040. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1041. }
  1042. }
  1043. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1044. import { Nullable } from "babylonjs/types";
  1045. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1046. /**
  1047. * This represents the required contract to create a new type of texture loader.
  1048. */
  1049. export interface IInternalTextureLoader {
  1050. /**
  1051. * Defines wether the loader supports cascade loading the different faces.
  1052. */
  1053. supportCascades: boolean;
  1054. /**
  1055. * This returns if the loader support the current file information.
  1056. * @param extension defines the file extension of the file being loaded
  1057. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1058. * @param fallback defines the fallback internal texture if any
  1059. * @param isBase64 defines whether the texture is encoded as a base64
  1060. * @param isBuffer defines whether the texture data are stored as a buffer
  1061. * @returns true if the loader can load the specified file
  1062. */
  1063. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  1064. /**
  1065. * Transform the url before loading if required.
  1066. * @param rootUrl the url of the texture
  1067. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1068. * @returns the transformed texture
  1069. */
  1070. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  1071. /**
  1072. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  1073. * @param rootUrl the url of the texture
  1074. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1075. * @returns the fallback texture
  1076. */
  1077. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  1078. /**
  1079. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  1080. * @param data contains the texture data
  1081. * @param texture defines the BabylonJS internal texture
  1082. * @param createPolynomials will be true if polynomials have been requested
  1083. * @param onLoad defines the callback to trigger once the texture is ready
  1084. * @param onError defines the callback to trigger in case of error
  1085. */
  1086. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1087. /**
  1088. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  1089. * @param data contains the texture data
  1090. * @param texture defines the BabylonJS internal texture
  1091. * @param callback defines the method to call once ready to upload
  1092. */
  1093. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1094. }
  1095. }
  1096. declare module "babylonjs/Engines/IPipelineContext" {
  1097. /**
  1098. * Class used to store and describe the pipeline context associated with an effect
  1099. */
  1100. export interface IPipelineContext {
  1101. /**
  1102. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1103. */
  1104. isAsync: boolean;
  1105. /**
  1106. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1107. */
  1108. isReady: boolean;
  1109. /** @hidden */
  1110. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1111. }
  1112. }
  1113. declare module "babylonjs/Meshes/dataBuffer" {
  1114. /**
  1115. * Class used to store gfx data (like WebGLBuffer)
  1116. */
  1117. export class DataBuffer {
  1118. /**
  1119. * Gets or sets the number of objects referencing this buffer
  1120. */
  1121. references: number;
  1122. /** Gets or sets the size of the underlying buffer */
  1123. capacity: number;
  1124. /**
  1125. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1126. */
  1127. is32Bits: boolean;
  1128. /**
  1129. * Gets the underlying buffer
  1130. */
  1131. readonly underlyingResource: any;
  1132. }
  1133. }
  1134. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1135. /** @hidden */
  1136. export interface IShaderProcessor {
  1137. attributeProcessor?: (attribute: string) => string;
  1138. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1139. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1140. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1141. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1142. lineProcessor?: (line: string, isFragment: boolean) => string;
  1143. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1144. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1145. }
  1146. }
  1147. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1148. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1149. /** @hidden */
  1150. export interface ProcessingOptions {
  1151. defines: string[];
  1152. indexParameters: any;
  1153. isFragment: boolean;
  1154. shouldUseHighPrecisionShader: boolean;
  1155. supportsUniformBuffers: boolean;
  1156. shadersRepository: string;
  1157. includesShadersStore: {
  1158. [key: string]: string;
  1159. };
  1160. processor?: IShaderProcessor;
  1161. version: string;
  1162. platformName: string;
  1163. lookForClosingBracketForUniformBuffer?: boolean;
  1164. }
  1165. }
  1166. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1167. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1168. /** @hidden */
  1169. export class ShaderCodeNode {
  1170. line: string;
  1171. children: ShaderCodeNode[];
  1172. additionalDefineKey?: string;
  1173. additionalDefineValue?: string;
  1174. isValid(preprocessors: {
  1175. [key: string]: string;
  1176. }): boolean;
  1177. process(preprocessors: {
  1178. [key: string]: string;
  1179. }, options: ProcessingOptions): string;
  1180. }
  1181. }
  1182. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1183. /** @hidden */
  1184. export class ShaderCodeCursor {
  1185. private _lines;
  1186. lineIndex: number;
  1187. readonly currentLine: string;
  1188. readonly canRead: boolean;
  1189. lines: string[];
  1190. }
  1191. }
  1192. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1193. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1194. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1195. /** @hidden */
  1196. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1197. process(preprocessors: {
  1198. [key: string]: string;
  1199. }, options: ProcessingOptions): string;
  1200. }
  1201. }
  1202. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1203. /** @hidden */
  1204. export class ShaderDefineExpression {
  1205. isTrue(preprocessors: {
  1206. [key: string]: string;
  1207. }): boolean;
  1208. }
  1209. }
  1210. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1211. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1212. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1213. /** @hidden */
  1214. export class ShaderCodeTestNode extends ShaderCodeNode {
  1215. testExpression: ShaderDefineExpression;
  1216. isValid(preprocessors: {
  1217. [key: string]: string;
  1218. }): boolean;
  1219. }
  1220. }
  1221. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1222. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1223. /** @hidden */
  1224. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1225. define: string;
  1226. not: boolean;
  1227. constructor(define: string, not?: boolean);
  1228. isTrue(preprocessors: {
  1229. [key: string]: string;
  1230. }): boolean;
  1231. }
  1232. }
  1233. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1234. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1235. /** @hidden */
  1236. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1237. leftOperand: ShaderDefineExpression;
  1238. rightOperand: ShaderDefineExpression;
  1239. isTrue(preprocessors: {
  1240. [key: string]: string;
  1241. }): boolean;
  1242. }
  1243. }
  1244. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1245. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1246. /** @hidden */
  1247. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1248. leftOperand: ShaderDefineExpression;
  1249. rightOperand: ShaderDefineExpression;
  1250. isTrue(preprocessors: {
  1251. [key: string]: string;
  1252. }): boolean;
  1253. }
  1254. }
  1255. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1256. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1257. /** @hidden */
  1258. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1259. define: string;
  1260. operand: string;
  1261. testValue: string;
  1262. constructor(define: string, operand: string, testValue: string);
  1263. isTrue(preprocessors: {
  1264. [key: string]: string;
  1265. }): boolean;
  1266. }
  1267. }
  1268. declare module "babylonjs/Offline/IOfflineProvider" {
  1269. /**
  1270. * Class used to enable access to offline support
  1271. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1272. */
  1273. export interface IOfflineProvider {
  1274. /**
  1275. * Gets a boolean indicating if scene must be saved in the database
  1276. */
  1277. enableSceneOffline: boolean;
  1278. /**
  1279. * Gets a boolean indicating if textures must be saved in the database
  1280. */
  1281. enableTexturesOffline: boolean;
  1282. /**
  1283. * Open the offline support and make it available
  1284. * @param successCallback defines the callback to call on success
  1285. * @param errorCallback defines the callback to call on error
  1286. */
  1287. open(successCallback: () => void, errorCallback: () => void): void;
  1288. /**
  1289. * Loads an image from the offline support
  1290. * @param url defines the url to load from
  1291. * @param image defines the target DOM image
  1292. */
  1293. loadImage(url: string, image: HTMLImageElement): void;
  1294. /**
  1295. * Loads a file from offline support
  1296. * @param url defines the URL to load from
  1297. * @param sceneLoaded defines a callback to call on success
  1298. * @param progressCallBack defines a callback to call when progress changed
  1299. * @param errorCallback defines a callback to call on error
  1300. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1301. */
  1302. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1303. }
  1304. }
  1305. declare module "babylonjs/Misc/filesInputStore" {
  1306. /**
  1307. * Class used to help managing file picking and drag'n'drop
  1308. * File Storage
  1309. */
  1310. export class FilesInputStore {
  1311. /**
  1312. * List of files ready to be loaded
  1313. */
  1314. static FilesToLoad: {
  1315. [key: string]: File;
  1316. };
  1317. }
  1318. }
  1319. declare module "babylonjs/Misc/retryStrategy" {
  1320. import { WebRequest } from "babylonjs/Misc/webRequest";
  1321. /**
  1322. * Class used to define a retry strategy when error happens while loading assets
  1323. */
  1324. export class RetryStrategy {
  1325. /**
  1326. * Function used to defines an exponential back off strategy
  1327. * @param maxRetries defines the maximum number of retries (3 by default)
  1328. * @param baseInterval defines the interval between retries
  1329. * @returns the strategy function to use
  1330. */
  1331. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1332. }
  1333. }
  1334. declare module "babylonjs/Misc/baseError" {
  1335. /**
  1336. * @ignore
  1337. * Application error to support additional information when loading a file
  1338. */
  1339. export abstract class BaseError extends Error {
  1340. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1341. }
  1342. }
  1343. declare module "babylonjs/Misc/fileTools" {
  1344. import { WebRequest } from "babylonjs/Misc/webRequest";
  1345. import { Nullable } from "babylonjs/types";
  1346. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1347. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1348. import { BaseError } from "babylonjs/Misc/baseError";
  1349. /** @ignore */
  1350. export class LoadFileError extends BaseError {
  1351. request?: WebRequest;
  1352. file?: File;
  1353. /**
  1354. * Creates a new LoadFileError
  1355. * @param message defines the message of the error
  1356. * @param request defines the optional web request
  1357. * @param file defines the optional file
  1358. */
  1359. constructor(message: string, object?: WebRequest | File);
  1360. }
  1361. /** @ignore */
  1362. export class RequestFileError extends BaseError {
  1363. request: WebRequest;
  1364. /**
  1365. * Creates a new LoadFileError
  1366. * @param message defines the message of the error
  1367. * @param request defines the optional web request
  1368. */
  1369. constructor(message: string, request: WebRequest);
  1370. }
  1371. /** @ignore */
  1372. export class ReadFileError extends BaseError {
  1373. file: File;
  1374. /**
  1375. * Creates a new ReadFileError
  1376. * @param message defines the message of the error
  1377. * @param file defines the optional file
  1378. */
  1379. constructor(message: string, file: File);
  1380. }
  1381. /**
  1382. * @hidden
  1383. */
  1384. export class FileTools {
  1385. /**
  1386. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1387. */
  1388. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1389. /**
  1390. * Gets or sets the base URL to use to load assets
  1391. */
  1392. static BaseUrl: string;
  1393. /**
  1394. * Default behaviour for cors in the application.
  1395. * It can be a string if the expected behavior is identical in the entire app.
  1396. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1397. */
  1398. static CorsBehavior: string | ((url: string | string[]) => string);
  1399. /**
  1400. * Gets or sets a function used to pre-process url before using them to load assets
  1401. */
  1402. static PreprocessUrl: (url: string) => string;
  1403. /**
  1404. * Removes unwanted characters from an url
  1405. * @param url defines the url to clean
  1406. * @returns the cleaned url
  1407. */
  1408. private static _CleanUrl;
  1409. /**
  1410. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1411. * @param url define the url we are trying
  1412. * @param element define the dom element where to configure the cors policy
  1413. */
  1414. static SetCorsBehavior(url: string | string[], element: {
  1415. crossOrigin: string | null;
  1416. }): void;
  1417. /**
  1418. * Loads an image as an HTMLImageElement.
  1419. * @param input url string, ArrayBuffer, or Blob to load
  1420. * @param onLoad callback called when the image successfully loads
  1421. * @param onError callback called when the image fails to load
  1422. * @param offlineProvider offline provider for caching
  1423. * @param mimeType optional mime type
  1424. * @returns the HTMLImageElement of the loaded image
  1425. */
  1426. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1427. /**
  1428. * Reads a file from a File object
  1429. * @param file defines the file to load
  1430. * @param onSuccess defines the callback to call when data is loaded
  1431. * @param onProgress defines the callback to call during loading process
  1432. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1433. * @param onError defines the callback to call when an error occurs
  1434. * @returns a file request object
  1435. */
  1436. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1437. /**
  1438. * Loads a file from a url
  1439. * @param url url to load
  1440. * @param onSuccess callback called when the file successfully loads
  1441. * @param onProgress callback called while file is loading (if the server supports this mode)
  1442. * @param offlineProvider defines the offline provider for caching
  1443. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1444. * @param onError callback called when the file fails to load
  1445. * @returns a file request object
  1446. */
  1447. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1448. /**
  1449. * Loads a file
  1450. * @param url url to load
  1451. * @param onSuccess callback called when the file successfully loads
  1452. * @param onProgress callback called while file is loading (if the server supports this mode)
  1453. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1454. * @param onError callback called when the file fails to load
  1455. * @param onOpened callback called when the web request is opened
  1456. * @returns a file request object
  1457. */
  1458. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1459. /**
  1460. * Checks if the loaded document was accessed via `file:`-Protocol.
  1461. * @returns boolean
  1462. */
  1463. static IsFileURL(): boolean;
  1464. }
  1465. }
  1466. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1467. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1468. /** @hidden */
  1469. export class ShaderProcessor {
  1470. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1471. private static _ProcessPrecision;
  1472. private static _ExtractOperation;
  1473. private static _BuildSubExpression;
  1474. private static _BuildExpression;
  1475. private static _MoveCursorWithinIf;
  1476. private static _MoveCursor;
  1477. private static _EvaluatePreProcessors;
  1478. private static _PreparePreProcessors;
  1479. private static _ProcessShaderConversion;
  1480. private static _ProcessIncludes;
  1481. }
  1482. }
  1483. declare module "babylonjs/Maths/math.like" {
  1484. import { float, int, DeepImmutable } from "babylonjs/types";
  1485. /**
  1486. * @hidden
  1487. */
  1488. export interface IColor4Like {
  1489. r: float;
  1490. g: float;
  1491. b: float;
  1492. a: float;
  1493. }
  1494. /**
  1495. * @hidden
  1496. */
  1497. export interface IColor3Like {
  1498. r: float;
  1499. g: float;
  1500. b: float;
  1501. }
  1502. /**
  1503. * @hidden
  1504. */
  1505. export interface IVector4Like {
  1506. x: float;
  1507. y: float;
  1508. z: float;
  1509. w: float;
  1510. }
  1511. /**
  1512. * @hidden
  1513. */
  1514. export interface IVector3Like {
  1515. x: float;
  1516. y: float;
  1517. z: float;
  1518. }
  1519. /**
  1520. * @hidden
  1521. */
  1522. export interface IVector2Like {
  1523. x: float;
  1524. y: float;
  1525. }
  1526. /**
  1527. * @hidden
  1528. */
  1529. export interface IMatrixLike {
  1530. toArray(): DeepImmutable<Float32Array>;
  1531. updateFlag: int;
  1532. }
  1533. /**
  1534. * @hidden
  1535. */
  1536. export interface IViewportLike {
  1537. x: float;
  1538. y: float;
  1539. width: float;
  1540. height: float;
  1541. }
  1542. /**
  1543. * @hidden
  1544. */
  1545. export interface IPlaneLike {
  1546. normal: IVector3Like;
  1547. d: float;
  1548. normalize(): void;
  1549. }
  1550. }
  1551. declare module "babylonjs/Materials/iEffectFallbacks" {
  1552. import { Effect } from "babylonjs/Materials/effect";
  1553. /**
  1554. * Interface used to define common properties for effect fallbacks
  1555. */
  1556. export interface IEffectFallbacks {
  1557. /**
  1558. * Removes the defines that should be removed when falling back.
  1559. * @param currentDefines defines the current define statements for the shader.
  1560. * @param effect defines the current effect we try to compile
  1561. * @returns The resulting defines with defines of the current rank removed.
  1562. */
  1563. reduce(currentDefines: string, effect: Effect): string;
  1564. /**
  1565. * Removes the fallback from the bound mesh.
  1566. */
  1567. unBindMesh(): void;
  1568. /**
  1569. * Checks to see if more fallbacks are still availible.
  1570. */
  1571. hasMoreFallbacks: boolean;
  1572. }
  1573. }
  1574. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1575. /**
  1576. * Class used to evalaute queries containing `and` and `or` operators
  1577. */
  1578. export class AndOrNotEvaluator {
  1579. /**
  1580. * Evaluate a query
  1581. * @param query defines the query to evaluate
  1582. * @param evaluateCallback defines the callback used to filter result
  1583. * @returns true if the query matches
  1584. */
  1585. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1586. private static _HandleParenthesisContent;
  1587. private static _SimplifyNegation;
  1588. }
  1589. }
  1590. declare module "babylonjs/Misc/tags" {
  1591. /**
  1592. * Class used to store custom tags
  1593. */
  1594. export class Tags {
  1595. /**
  1596. * Adds support for tags on the given object
  1597. * @param obj defines the object to use
  1598. */
  1599. static EnableFor(obj: any): void;
  1600. /**
  1601. * Removes tags support
  1602. * @param obj defines the object to use
  1603. */
  1604. static DisableFor(obj: any): void;
  1605. /**
  1606. * Gets a boolean indicating if the given object has tags
  1607. * @param obj defines the object to use
  1608. * @returns a boolean
  1609. */
  1610. static HasTags(obj: any): boolean;
  1611. /**
  1612. * Gets the tags available on a given object
  1613. * @param obj defines the object to use
  1614. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1615. * @returns the tags
  1616. */
  1617. static GetTags(obj: any, asString?: boolean): any;
  1618. /**
  1619. * Adds tags to an object
  1620. * @param obj defines the object to use
  1621. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1622. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1623. */
  1624. static AddTagsTo(obj: any, tagsString: string): void;
  1625. /**
  1626. * @hidden
  1627. */
  1628. static _AddTagTo(obj: any, tag: string): void;
  1629. /**
  1630. * Removes specific tags from a specific object
  1631. * @param obj defines the object to use
  1632. * @param tagsString defines the tags to remove
  1633. */
  1634. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1635. /**
  1636. * @hidden
  1637. */
  1638. static _RemoveTagFrom(obj: any, tag: string): void;
  1639. /**
  1640. * Defines if tags hosted on an object match a given query
  1641. * @param obj defines the object to use
  1642. * @param tagsQuery defines the tag query
  1643. * @returns a boolean
  1644. */
  1645. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1646. }
  1647. }
  1648. declare module "babylonjs/Maths/math.scalar" {
  1649. /**
  1650. * Scalar computation library
  1651. */
  1652. export class Scalar {
  1653. /**
  1654. * Two pi constants convenient for computation.
  1655. */
  1656. static TwoPi: number;
  1657. /**
  1658. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1659. * @param a number
  1660. * @param b number
  1661. * @param epsilon (default = 1.401298E-45)
  1662. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1663. */
  1664. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1665. /**
  1666. * Returns a string : the upper case translation of the number i to hexadecimal.
  1667. * @param i number
  1668. * @returns the upper case translation of the number i to hexadecimal.
  1669. */
  1670. static ToHex(i: number): string;
  1671. /**
  1672. * Returns -1 if value is negative and +1 is value is positive.
  1673. * @param value the value
  1674. * @returns the value itself if it's equal to zero.
  1675. */
  1676. static Sign(value: number): number;
  1677. /**
  1678. * Returns the value itself if it's between min and max.
  1679. * Returns min if the value is lower than min.
  1680. * Returns max if the value is greater than max.
  1681. * @param value the value to clmap
  1682. * @param min the min value to clamp to (default: 0)
  1683. * @param max the max value to clamp to (default: 1)
  1684. * @returns the clamped value
  1685. */
  1686. static Clamp(value: number, min?: number, max?: number): number;
  1687. /**
  1688. * the log2 of value.
  1689. * @param value the value to compute log2 of
  1690. * @returns the log2 of value.
  1691. */
  1692. static Log2(value: number): number;
  1693. /**
  1694. * Loops the value, so that it is never larger than length and never smaller than 0.
  1695. *
  1696. * This is similar to the modulo operator but it works with floating point numbers.
  1697. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1698. * With t = 5 and length = 2.5, the result would be 0.0.
  1699. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1700. * @param value the value
  1701. * @param length the length
  1702. * @returns the looped value
  1703. */
  1704. static Repeat(value: number, length: number): number;
  1705. /**
  1706. * Normalize the value between 0.0 and 1.0 using min and max values
  1707. * @param value value to normalize
  1708. * @param min max to normalize between
  1709. * @param max min to normalize between
  1710. * @returns the normalized value
  1711. */
  1712. static Normalize(value: number, min: number, max: number): number;
  1713. /**
  1714. * Denormalize the value from 0.0 and 1.0 using min and max values
  1715. * @param normalized value to denormalize
  1716. * @param min max to denormalize between
  1717. * @param max min to denormalize between
  1718. * @returns the denormalized value
  1719. */
  1720. static Denormalize(normalized: number, min: number, max: number): number;
  1721. /**
  1722. * Calculates the shortest difference between two given angles given in degrees.
  1723. * @param current current angle in degrees
  1724. * @param target target angle in degrees
  1725. * @returns the delta
  1726. */
  1727. static DeltaAngle(current: number, target: number): number;
  1728. /**
  1729. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1730. * @param tx value
  1731. * @param length length
  1732. * @returns The returned value will move back and forth between 0 and length
  1733. */
  1734. static PingPong(tx: number, length: number): number;
  1735. /**
  1736. * Interpolates between min and max with smoothing at the limits.
  1737. *
  1738. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1739. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1740. * @param from from
  1741. * @param to to
  1742. * @param tx value
  1743. * @returns the smooth stepped value
  1744. */
  1745. static SmoothStep(from: number, to: number, tx: number): number;
  1746. /**
  1747. * Moves a value current towards target.
  1748. *
  1749. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1750. * Negative values of maxDelta pushes the value away from target.
  1751. * @param current current value
  1752. * @param target target value
  1753. * @param maxDelta max distance to move
  1754. * @returns resulting value
  1755. */
  1756. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1757. /**
  1758. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1759. *
  1760. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1761. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1762. * @param current current value
  1763. * @param target target value
  1764. * @param maxDelta max distance to move
  1765. * @returns resulting angle
  1766. */
  1767. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1768. /**
  1769. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1770. * @param start start value
  1771. * @param end target value
  1772. * @param amount amount to lerp between
  1773. * @returns the lerped value
  1774. */
  1775. static Lerp(start: number, end: number, amount: number): number;
  1776. /**
  1777. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1778. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1779. * @param start start value
  1780. * @param end target value
  1781. * @param amount amount to lerp between
  1782. * @returns the lerped value
  1783. */
  1784. static LerpAngle(start: number, end: number, amount: number): number;
  1785. /**
  1786. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1787. * @param a start value
  1788. * @param b target value
  1789. * @param value value between a and b
  1790. * @returns the inverseLerp value
  1791. */
  1792. static InverseLerp(a: number, b: number, value: number): number;
  1793. /**
  1794. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1795. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1796. * @param value1 spline value
  1797. * @param tangent1 spline value
  1798. * @param value2 spline value
  1799. * @param tangent2 spline value
  1800. * @param amount input value
  1801. * @returns hermite result
  1802. */
  1803. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1804. /**
  1805. * Returns a random float number between and min and max values
  1806. * @param min min value of random
  1807. * @param max max value of random
  1808. * @returns random value
  1809. */
  1810. static RandomRange(min: number, max: number): number;
  1811. /**
  1812. * This function returns percentage of a number in a given range.
  1813. *
  1814. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1815. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1816. * @param number to convert to percentage
  1817. * @param min min range
  1818. * @param max max range
  1819. * @returns the percentage
  1820. */
  1821. static RangeToPercent(number: number, min: number, max: number): number;
  1822. /**
  1823. * This function returns number that corresponds to the percentage in a given range.
  1824. *
  1825. * PercentToRange(0.34,0,100) will return 34.
  1826. * @param percent to convert to number
  1827. * @param min min range
  1828. * @param max max range
  1829. * @returns the number
  1830. */
  1831. static PercentToRange(percent: number, min: number, max: number): number;
  1832. /**
  1833. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1834. * @param angle The angle to normalize in radian.
  1835. * @return The converted angle.
  1836. */
  1837. static NormalizeRadians(angle: number): number;
  1838. }
  1839. }
  1840. declare module "babylonjs/Maths/math.constants" {
  1841. /**
  1842. * Constant used to convert a value to gamma space
  1843. * @ignorenaming
  1844. */
  1845. export const ToGammaSpace: number;
  1846. /**
  1847. * Constant used to convert a value to linear space
  1848. * @ignorenaming
  1849. */
  1850. export const ToLinearSpace = 2.2;
  1851. /**
  1852. * Constant used to define the minimal number value in Babylon.js
  1853. * @ignorenaming
  1854. */
  1855. let Epsilon: number;
  1856. export { Epsilon };
  1857. }
  1858. declare module "babylonjs/Maths/math.viewport" {
  1859. /**
  1860. * Class used to represent a viewport on screen
  1861. */
  1862. export class Viewport {
  1863. /** viewport left coordinate */
  1864. x: number;
  1865. /** viewport top coordinate */
  1866. y: number;
  1867. /**viewport width */
  1868. width: number;
  1869. /** viewport height */
  1870. height: number;
  1871. /**
  1872. * Creates a Viewport object located at (x, y) and sized (width, height)
  1873. * @param x defines viewport left coordinate
  1874. * @param y defines viewport top coordinate
  1875. * @param width defines the viewport width
  1876. * @param height defines the viewport height
  1877. */
  1878. constructor(
  1879. /** viewport left coordinate */
  1880. x: number,
  1881. /** viewport top coordinate */
  1882. y: number,
  1883. /**viewport width */
  1884. width: number,
  1885. /** viewport height */
  1886. height: number);
  1887. /**
  1888. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1889. * @param renderWidth defines the rendering width
  1890. * @param renderHeight defines the rendering height
  1891. * @returns a new Viewport
  1892. */
  1893. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1894. /**
  1895. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1896. * @param renderWidth defines the rendering width
  1897. * @param renderHeight defines the rendering height
  1898. * @param ref defines the target viewport
  1899. * @returns the current viewport
  1900. */
  1901. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1902. /**
  1903. * Returns a new Viewport copied from the current one
  1904. * @returns a new Viewport
  1905. */
  1906. clone(): Viewport;
  1907. }
  1908. }
  1909. declare module "babylonjs/Misc/arrayTools" {
  1910. /**
  1911. * Class containing a set of static utilities functions for arrays.
  1912. */
  1913. export class ArrayTools {
  1914. /**
  1915. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1916. * @param size the number of element to construct and put in the array
  1917. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1918. * @returns a new array filled with new objects
  1919. */
  1920. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1921. }
  1922. }
  1923. declare module "babylonjs/Maths/math.vector" {
  1924. import { Viewport } from "babylonjs/Maths/math.viewport";
  1925. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1926. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1927. /**
  1928. * Class representing a vector containing 2 coordinates
  1929. */
  1930. export class Vector2 {
  1931. /** defines the first coordinate */
  1932. x: number;
  1933. /** defines the second coordinate */
  1934. y: number;
  1935. /**
  1936. * Creates a new Vector2 from the given x and y coordinates
  1937. * @param x defines the first coordinate
  1938. * @param y defines the second coordinate
  1939. */
  1940. constructor(
  1941. /** defines the first coordinate */
  1942. x?: number,
  1943. /** defines the second coordinate */
  1944. y?: number);
  1945. /**
  1946. * Gets a string with the Vector2 coordinates
  1947. * @returns a string with the Vector2 coordinates
  1948. */
  1949. toString(): string;
  1950. /**
  1951. * Gets class name
  1952. * @returns the string "Vector2"
  1953. */
  1954. getClassName(): string;
  1955. /**
  1956. * Gets current vector hash code
  1957. * @returns the Vector2 hash code as a number
  1958. */
  1959. getHashCode(): number;
  1960. /**
  1961. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1962. * @param array defines the source array
  1963. * @param index defines the offset in source array
  1964. * @returns the current Vector2
  1965. */
  1966. toArray(array: FloatArray, index?: number): Vector2;
  1967. /**
  1968. * Copy the current vector to an array
  1969. * @returns a new array with 2 elements: the Vector2 coordinates.
  1970. */
  1971. asArray(): number[];
  1972. /**
  1973. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1974. * @param source defines the source Vector2
  1975. * @returns the current updated Vector2
  1976. */
  1977. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1978. /**
  1979. * Sets the Vector2 coordinates with the given floats
  1980. * @param x defines the first coordinate
  1981. * @param y defines the second coordinate
  1982. * @returns the current updated Vector2
  1983. */
  1984. copyFromFloats(x: number, y: number): Vector2;
  1985. /**
  1986. * Sets the Vector2 coordinates with the given floats
  1987. * @param x defines the first coordinate
  1988. * @param y defines the second coordinate
  1989. * @returns the current updated Vector2
  1990. */
  1991. set(x: number, y: number): Vector2;
  1992. /**
  1993. * Add another vector with the current one
  1994. * @param otherVector defines the other vector
  1995. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1996. */
  1997. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1998. /**
  1999. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2000. * @param otherVector defines the other vector
  2001. * @param result defines the target vector
  2002. * @returns the unmodified current Vector2
  2003. */
  2004. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2005. /**
  2006. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2007. * @param otherVector defines the other vector
  2008. * @returns the current updated Vector2
  2009. */
  2010. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2011. /**
  2012. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2013. * @param otherVector defines the other vector
  2014. * @returns a new Vector2
  2015. */
  2016. addVector3(otherVector: Vector3): Vector2;
  2017. /**
  2018. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2019. * @param otherVector defines the other vector
  2020. * @returns a new Vector2
  2021. */
  2022. subtract(otherVector: Vector2): Vector2;
  2023. /**
  2024. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2025. * @param otherVector defines the other vector
  2026. * @param result defines the target vector
  2027. * @returns the unmodified current Vector2
  2028. */
  2029. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2030. /**
  2031. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2032. * @param otherVector defines the other vector
  2033. * @returns the current updated Vector2
  2034. */
  2035. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2036. /**
  2037. * Multiplies in place the current Vector2 coordinates by the given ones
  2038. * @param otherVector defines the other vector
  2039. * @returns the current updated Vector2
  2040. */
  2041. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2042. /**
  2043. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2044. * @param otherVector defines the other vector
  2045. * @returns a new Vector2
  2046. */
  2047. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2048. /**
  2049. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2050. * @param otherVector defines the other vector
  2051. * @param result defines the target vector
  2052. * @returns the unmodified current Vector2
  2053. */
  2054. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2055. /**
  2056. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2057. * @param x defines the first coordinate
  2058. * @param y defines the second coordinate
  2059. * @returns a new Vector2
  2060. */
  2061. multiplyByFloats(x: number, y: number): Vector2;
  2062. /**
  2063. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2064. * @param otherVector defines the other vector
  2065. * @returns a new Vector2
  2066. */
  2067. divide(otherVector: Vector2): Vector2;
  2068. /**
  2069. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2070. * @param otherVector defines the other vector
  2071. * @param result defines the target vector
  2072. * @returns the unmodified current Vector2
  2073. */
  2074. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2075. /**
  2076. * Divides the current Vector2 coordinates by the given ones
  2077. * @param otherVector defines the other vector
  2078. * @returns the current updated Vector2
  2079. */
  2080. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2081. /**
  2082. * Gets a new Vector2 with current Vector2 negated coordinates
  2083. * @returns a new Vector2
  2084. */
  2085. negate(): Vector2;
  2086. /**
  2087. * Multiply the Vector2 coordinates by scale
  2088. * @param scale defines the scaling factor
  2089. * @returns the current updated Vector2
  2090. */
  2091. scaleInPlace(scale: number): Vector2;
  2092. /**
  2093. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2094. * @param scale defines the scaling factor
  2095. * @returns a new Vector2
  2096. */
  2097. scale(scale: number): Vector2;
  2098. /**
  2099. * Scale the current Vector2 values by a factor to a given Vector2
  2100. * @param scale defines the scale factor
  2101. * @param result defines the Vector2 object where to store the result
  2102. * @returns the unmodified current Vector2
  2103. */
  2104. scaleToRef(scale: number, result: Vector2): Vector2;
  2105. /**
  2106. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2107. * @param scale defines the scale factor
  2108. * @param result defines the Vector2 object where to store the result
  2109. * @returns the unmodified current Vector2
  2110. */
  2111. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2112. /**
  2113. * Gets a boolean if two vectors are equals
  2114. * @param otherVector defines the other vector
  2115. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2116. */
  2117. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2118. /**
  2119. * Gets a boolean if two vectors are equals (using an epsilon value)
  2120. * @param otherVector defines the other vector
  2121. * @param epsilon defines the minimal distance to consider equality
  2122. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2123. */
  2124. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2125. /**
  2126. * Gets a new Vector2 from current Vector2 floored values
  2127. * @returns a new Vector2
  2128. */
  2129. floor(): Vector2;
  2130. /**
  2131. * Gets a new Vector2 from current Vector2 floored values
  2132. * @returns a new Vector2
  2133. */
  2134. fract(): Vector2;
  2135. /**
  2136. * Gets the length of the vector
  2137. * @returns the vector length (float)
  2138. */
  2139. length(): number;
  2140. /**
  2141. * Gets the vector squared length
  2142. * @returns the vector squared length (float)
  2143. */
  2144. lengthSquared(): number;
  2145. /**
  2146. * Normalize the vector
  2147. * @returns the current updated Vector2
  2148. */
  2149. normalize(): Vector2;
  2150. /**
  2151. * Gets a new Vector2 copied from the Vector2
  2152. * @returns a new Vector2
  2153. */
  2154. clone(): Vector2;
  2155. /**
  2156. * Gets a new Vector2(0, 0)
  2157. * @returns a new Vector2
  2158. */
  2159. static Zero(): Vector2;
  2160. /**
  2161. * Gets a new Vector2(1, 1)
  2162. * @returns a new Vector2
  2163. */
  2164. static One(): Vector2;
  2165. /**
  2166. * Gets a new Vector2 set from the given index element of the given array
  2167. * @param array defines the data source
  2168. * @param offset defines the offset in the data source
  2169. * @returns a new Vector2
  2170. */
  2171. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2172. /**
  2173. * Sets "result" from the given index element of the given array
  2174. * @param array defines the data source
  2175. * @param offset defines the offset in the data source
  2176. * @param result defines the target vector
  2177. */
  2178. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2179. /**
  2180. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2181. * @param value1 defines 1st point of control
  2182. * @param value2 defines 2nd point of control
  2183. * @param value3 defines 3rd point of control
  2184. * @param value4 defines 4th point of control
  2185. * @param amount defines the interpolation factor
  2186. * @returns a new Vector2
  2187. */
  2188. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2189. /**
  2190. * 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".
  2191. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2192. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2193. * @param value defines the value to clamp
  2194. * @param min defines the lower limit
  2195. * @param max defines the upper limit
  2196. * @returns a new Vector2
  2197. */
  2198. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2199. /**
  2200. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2201. * @param value1 defines the 1st control point
  2202. * @param tangent1 defines the outgoing tangent
  2203. * @param value2 defines the 2nd control point
  2204. * @param tangent2 defines the incoming tangent
  2205. * @param amount defines the interpolation factor
  2206. * @returns a new Vector2
  2207. */
  2208. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2209. /**
  2210. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2211. * @param start defines the start vector
  2212. * @param end defines the end vector
  2213. * @param amount defines the interpolation factor
  2214. * @returns a new Vector2
  2215. */
  2216. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2217. /**
  2218. * Gets the dot product of the vector "left" and the vector "right"
  2219. * @param left defines first vector
  2220. * @param right defines second vector
  2221. * @returns the dot product (float)
  2222. */
  2223. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2224. /**
  2225. * Returns a new Vector2 equal to the normalized given vector
  2226. * @param vector defines the vector to normalize
  2227. * @returns a new Vector2
  2228. */
  2229. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2230. /**
  2231. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2232. * @param left defines 1st vector
  2233. * @param right defines 2nd vector
  2234. * @returns a new Vector2
  2235. */
  2236. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2237. /**
  2238. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2239. * @param left defines 1st vector
  2240. * @param right defines 2nd vector
  2241. * @returns a new Vector2
  2242. */
  2243. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2244. /**
  2245. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2246. * @param vector defines the vector to transform
  2247. * @param transformation defines the matrix to apply
  2248. * @returns a new Vector2
  2249. */
  2250. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2251. /**
  2252. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2253. * @param vector defines the vector to transform
  2254. * @param transformation defines the matrix to apply
  2255. * @param result defines the target vector
  2256. */
  2257. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2258. /**
  2259. * Determines if a given vector is included in a triangle
  2260. * @param p defines the vector to test
  2261. * @param p0 defines 1st triangle point
  2262. * @param p1 defines 2nd triangle point
  2263. * @param p2 defines 3rd triangle point
  2264. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2265. */
  2266. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2267. /**
  2268. * Gets the distance between the vectors "value1" and "value2"
  2269. * @param value1 defines first vector
  2270. * @param value2 defines second vector
  2271. * @returns the distance between vectors
  2272. */
  2273. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2274. /**
  2275. * Returns the squared distance between the vectors "value1" and "value2"
  2276. * @param value1 defines first vector
  2277. * @param value2 defines second vector
  2278. * @returns the squared distance between vectors
  2279. */
  2280. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2281. /**
  2282. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2283. * @param value1 defines first vector
  2284. * @param value2 defines second vector
  2285. * @returns a new Vector2
  2286. */
  2287. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2288. /**
  2289. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2290. * @param p defines the middle point
  2291. * @param segA defines one point of the segment
  2292. * @param segB defines the other point of the segment
  2293. * @returns the shortest distance
  2294. */
  2295. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2296. }
  2297. /**
  2298. * Class used to store (x,y,z) vector representation
  2299. * A Vector3 is the main object used in 3D geometry
  2300. * It can represent etiher the coordinates of a point the space, either a direction
  2301. * Reminder: js uses a left handed forward facing system
  2302. */
  2303. export class Vector3 {
  2304. /**
  2305. * Defines the first coordinates (on X axis)
  2306. */
  2307. x: number;
  2308. /**
  2309. * Defines the second coordinates (on Y axis)
  2310. */
  2311. y: number;
  2312. /**
  2313. * Defines the third coordinates (on Z axis)
  2314. */
  2315. z: number;
  2316. private static _UpReadOnly;
  2317. private static _ZeroReadOnly;
  2318. /**
  2319. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2320. * @param x defines the first coordinates (on X axis)
  2321. * @param y defines the second coordinates (on Y axis)
  2322. * @param z defines the third coordinates (on Z axis)
  2323. */
  2324. constructor(
  2325. /**
  2326. * Defines the first coordinates (on X axis)
  2327. */
  2328. x?: number,
  2329. /**
  2330. * Defines the second coordinates (on Y axis)
  2331. */
  2332. y?: number,
  2333. /**
  2334. * Defines the third coordinates (on Z axis)
  2335. */
  2336. z?: number);
  2337. /**
  2338. * Creates a string representation of the Vector3
  2339. * @returns a string with the Vector3 coordinates.
  2340. */
  2341. toString(): string;
  2342. /**
  2343. * Gets the class name
  2344. * @returns the string "Vector3"
  2345. */
  2346. getClassName(): string;
  2347. /**
  2348. * Creates the Vector3 hash code
  2349. * @returns a number which tends to be unique between Vector3 instances
  2350. */
  2351. getHashCode(): number;
  2352. /**
  2353. * Creates an array containing three elements : the coordinates of the Vector3
  2354. * @returns a new array of numbers
  2355. */
  2356. asArray(): number[];
  2357. /**
  2358. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2359. * @param array defines the destination array
  2360. * @param index defines the offset in the destination array
  2361. * @returns the current Vector3
  2362. */
  2363. toArray(array: FloatArray, index?: number): Vector3;
  2364. /**
  2365. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2366. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2367. */
  2368. toQuaternion(): Quaternion;
  2369. /**
  2370. * Adds the given vector to the current Vector3
  2371. * @param otherVector defines the second operand
  2372. * @returns the current updated Vector3
  2373. */
  2374. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2375. /**
  2376. * Adds the given coordinates to the current Vector3
  2377. * @param x defines the x coordinate of the operand
  2378. * @param y defines the y coordinate of the operand
  2379. * @param z defines the z coordinate of the operand
  2380. * @returns the current updated Vector3
  2381. */
  2382. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2383. /**
  2384. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2385. * @param otherVector defines the second operand
  2386. * @returns the resulting Vector3
  2387. */
  2388. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2389. /**
  2390. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2391. * @param otherVector defines the second operand
  2392. * @param result defines the Vector3 object where to store the result
  2393. * @returns the current Vector3
  2394. */
  2395. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2396. /**
  2397. * Subtract the given vector from the current Vector3
  2398. * @param otherVector defines the second operand
  2399. * @returns the current updated Vector3
  2400. */
  2401. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2402. /**
  2403. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2404. * @param otherVector defines the second operand
  2405. * @returns the resulting Vector3
  2406. */
  2407. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2408. /**
  2409. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2410. * @param otherVector defines the second operand
  2411. * @param result defines the Vector3 object where to store the result
  2412. * @returns the current Vector3
  2413. */
  2414. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2415. /**
  2416. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2417. * @param x defines the x coordinate of the operand
  2418. * @param y defines the y coordinate of the operand
  2419. * @param z defines the z coordinate of the operand
  2420. * @returns the resulting Vector3
  2421. */
  2422. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2423. /**
  2424. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2425. * @param x defines the x coordinate of the operand
  2426. * @param y defines the y coordinate of the operand
  2427. * @param z defines the z coordinate of the operand
  2428. * @param result defines the Vector3 object where to store the result
  2429. * @returns the current Vector3
  2430. */
  2431. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2432. /**
  2433. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2434. * @returns a new Vector3
  2435. */
  2436. negate(): Vector3;
  2437. /**
  2438. * Multiplies the Vector3 coordinates by the float "scale"
  2439. * @param scale defines the multiplier factor
  2440. * @returns the current updated Vector3
  2441. */
  2442. scaleInPlace(scale: number): Vector3;
  2443. /**
  2444. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2445. * @param scale defines the multiplier factor
  2446. * @returns a new Vector3
  2447. */
  2448. scale(scale: number): Vector3;
  2449. /**
  2450. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2451. * @param scale defines the multiplier factor
  2452. * @param result defines the Vector3 object where to store the result
  2453. * @returns the current Vector3
  2454. */
  2455. scaleToRef(scale: number, result: Vector3): Vector3;
  2456. /**
  2457. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2458. * @param scale defines the scale factor
  2459. * @param result defines the Vector3 object where to store the result
  2460. * @returns the unmodified current Vector3
  2461. */
  2462. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2463. /**
  2464. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2465. * @param otherVector defines the second operand
  2466. * @returns true if both vectors are equals
  2467. */
  2468. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2469. /**
  2470. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2471. * @param otherVector defines the second operand
  2472. * @param epsilon defines the minimal distance to define values as equals
  2473. * @returns true if both vectors are distant less than epsilon
  2474. */
  2475. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2476. /**
  2477. * Returns true if the current Vector3 coordinates equals the given floats
  2478. * @param x defines the x coordinate of the operand
  2479. * @param y defines the y coordinate of the operand
  2480. * @param z defines the z coordinate of the operand
  2481. * @returns true if both vectors are equals
  2482. */
  2483. equalsToFloats(x: number, y: number, z: number): boolean;
  2484. /**
  2485. * Multiplies the current Vector3 coordinates by the given ones
  2486. * @param otherVector defines the second operand
  2487. * @returns the current updated Vector3
  2488. */
  2489. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2490. /**
  2491. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2492. * @param otherVector defines the second operand
  2493. * @returns the new Vector3
  2494. */
  2495. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2496. /**
  2497. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2498. * @param otherVector defines the second operand
  2499. * @param result defines the Vector3 object where to store the result
  2500. * @returns the current Vector3
  2501. */
  2502. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2503. /**
  2504. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2505. * @param x defines the x coordinate of the operand
  2506. * @param y defines the y coordinate of the operand
  2507. * @param z defines the z coordinate of the operand
  2508. * @returns the new Vector3
  2509. */
  2510. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2511. /**
  2512. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2513. * @param otherVector defines the second operand
  2514. * @returns the new Vector3
  2515. */
  2516. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2517. /**
  2518. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2519. * @param otherVector defines the second operand
  2520. * @param result defines the Vector3 object where to store the result
  2521. * @returns the current Vector3
  2522. */
  2523. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2524. /**
  2525. * Divides the current Vector3 coordinates by the given ones.
  2526. * @param otherVector defines the second operand
  2527. * @returns the current updated Vector3
  2528. */
  2529. divideInPlace(otherVector: Vector3): Vector3;
  2530. /**
  2531. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2532. * @param other defines the second operand
  2533. * @returns the current updated Vector3
  2534. */
  2535. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2536. /**
  2537. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2538. * @param other defines the second operand
  2539. * @returns the current updated Vector3
  2540. */
  2541. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2542. /**
  2543. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2544. * @param x defines the x coordinate of the operand
  2545. * @param y defines the y coordinate of the operand
  2546. * @param z defines the z coordinate of the operand
  2547. * @returns the current updated Vector3
  2548. */
  2549. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2550. /**
  2551. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2552. * @param x defines the x coordinate of the operand
  2553. * @param y defines the y coordinate of the operand
  2554. * @param z defines the z coordinate of the operand
  2555. * @returns the current updated Vector3
  2556. */
  2557. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2558. /**
  2559. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2560. * Check if is non uniform within a certain amount of decimal places to account for this
  2561. * @param epsilon the amount the values can differ
  2562. * @returns if the the vector is non uniform to a certain number of decimal places
  2563. */
  2564. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2565. /**
  2566. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2567. */
  2568. readonly isNonUniform: boolean;
  2569. /**
  2570. * Gets a new Vector3 from current Vector3 floored values
  2571. * @returns a new Vector3
  2572. */
  2573. floor(): Vector3;
  2574. /**
  2575. * Gets a new Vector3 from current Vector3 floored values
  2576. * @returns a new Vector3
  2577. */
  2578. fract(): Vector3;
  2579. /**
  2580. * Gets the length of the Vector3
  2581. * @returns the length of the Vector3
  2582. */
  2583. length(): number;
  2584. /**
  2585. * Gets the squared length of the Vector3
  2586. * @returns squared length of the Vector3
  2587. */
  2588. lengthSquared(): number;
  2589. /**
  2590. * Normalize the current Vector3.
  2591. * Please note that this is an in place operation.
  2592. * @returns the current updated Vector3
  2593. */
  2594. normalize(): Vector3;
  2595. /**
  2596. * Reorders the x y z properties of the vector in place
  2597. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2598. * @returns the current updated vector
  2599. */
  2600. reorderInPlace(order: string): this;
  2601. /**
  2602. * Rotates the vector around 0,0,0 by a quaternion
  2603. * @param quaternion the rotation quaternion
  2604. * @param result vector to store the result
  2605. * @returns the resulting vector
  2606. */
  2607. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2608. /**
  2609. * Rotates a vector around a given point
  2610. * @param quaternion the rotation quaternion
  2611. * @param point the point to rotate around
  2612. * @param result vector to store the result
  2613. * @returns the resulting vector
  2614. */
  2615. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2616. /**
  2617. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2618. * The cross product is then orthogonal to both current and "other"
  2619. * @param other defines the right operand
  2620. * @returns the cross product
  2621. */
  2622. cross(other: Vector3): Vector3;
  2623. /**
  2624. * Normalize the current Vector3 with the given input length.
  2625. * Please note that this is an in place operation.
  2626. * @param len the length of the vector
  2627. * @returns the current updated Vector3
  2628. */
  2629. normalizeFromLength(len: number): Vector3;
  2630. /**
  2631. * Normalize the current Vector3 to a new vector
  2632. * @returns the new Vector3
  2633. */
  2634. normalizeToNew(): Vector3;
  2635. /**
  2636. * Normalize the current Vector3 to the reference
  2637. * @param reference define the Vector3 to update
  2638. * @returns the updated Vector3
  2639. */
  2640. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2641. /**
  2642. * Creates a new Vector3 copied from the current Vector3
  2643. * @returns the new Vector3
  2644. */
  2645. clone(): Vector3;
  2646. /**
  2647. * Copies the given vector coordinates to the current Vector3 ones
  2648. * @param source defines the source Vector3
  2649. * @returns the current updated Vector3
  2650. */
  2651. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2652. /**
  2653. * Copies the given floats to the current Vector3 coordinates
  2654. * @param x defines the x coordinate of the operand
  2655. * @param y defines the y coordinate of the operand
  2656. * @param z defines the z coordinate of the operand
  2657. * @returns the current updated Vector3
  2658. */
  2659. copyFromFloats(x: number, y: number, z: number): Vector3;
  2660. /**
  2661. * Copies the given floats to the current Vector3 coordinates
  2662. * @param x defines the x coordinate of the operand
  2663. * @param y defines the y coordinate of the operand
  2664. * @param z defines the z coordinate of the operand
  2665. * @returns the current updated Vector3
  2666. */
  2667. set(x: number, y: number, z: number): Vector3;
  2668. /**
  2669. * Copies the given float to the current Vector3 coordinates
  2670. * @param v defines the x, y and z coordinates of the operand
  2671. * @returns the current updated Vector3
  2672. */
  2673. setAll(v: number): Vector3;
  2674. /**
  2675. * Get the clip factor between two vectors
  2676. * @param vector0 defines the first operand
  2677. * @param vector1 defines the second operand
  2678. * @param axis defines the axis to use
  2679. * @param size defines the size along the axis
  2680. * @returns the clip factor
  2681. */
  2682. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2683. /**
  2684. * Get angle between two vectors
  2685. * @param vector0 angle between vector0 and vector1
  2686. * @param vector1 angle between vector0 and vector1
  2687. * @param normal direction of the normal
  2688. * @return the angle between vector0 and vector1
  2689. */
  2690. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2691. /**
  2692. * Returns a new Vector3 set from the index "offset" of the given array
  2693. * @param array defines the source array
  2694. * @param offset defines the offset in the source array
  2695. * @returns the new Vector3
  2696. */
  2697. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2698. /**
  2699. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2700. * @param array defines the source array
  2701. * @param offset defines the offset in the source array
  2702. * @returns the new Vector3
  2703. * @deprecated Please use FromArray instead.
  2704. */
  2705. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2706. /**
  2707. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2708. * @param array defines the source array
  2709. * @param offset defines the offset in the source array
  2710. * @param result defines the Vector3 where to store the result
  2711. */
  2712. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2713. /**
  2714. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2715. * @param array defines the source array
  2716. * @param offset defines the offset in the source array
  2717. * @param result defines the Vector3 where to store the result
  2718. * @deprecated Please use FromArrayToRef instead.
  2719. */
  2720. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2721. /**
  2722. * Sets the given vector "result" with the given floats.
  2723. * @param x defines the x coordinate of the source
  2724. * @param y defines the y coordinate of the source
  2725. * @param z defines the z coordinate of the source
  2726. * @param result defines the Vector3 where to store the result
  2727. */
  2728. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2729. /**
  2730. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2731. * @returns a new empty Vector3
  2732. */
  2733. static Zero(): Vector3;
  2734. /**
  2735. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2736. * @returns a new unit Vector3
  2737. */
  2738. static One(): Vector3;
  2739. /**
  2740. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2741. * @returns a new up Vector3
  2742. */
  2743. static Up(): Vector3;
  2744. /**
  2745. * Gets a up Vector3 that must not be updated
  2746. */
  2747. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2748. /**
  2749. * Gets a zero Vector3 that must not be updated
  2750. */
  2751. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2752. /**
  2753. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2754. * @returns a new down Vector3
  2755. */
  2756. static Down(): Vector3;
  2757. /**
  2758. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2759. * @returns a new forward Vector3
  2760. */
  2761. static Forward(): Vector3;
  2762. /**
  2763. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2764. * @returns a new forward Vector3
  2765. */
  2766. static Backward(): Vector3;
  2767. /**
  2768. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2769. * @returns a new right Vector3
  2770. */
  2771. static Right(): Vector3;
  2772. /**
  2773. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2774. * @returns a new left Vector3
  2775. */
  2776. static Left(): Vector3;
  2777. /**
  2778. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2779. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2780. * @param vector defines the Vector3 to transform
  2781. * @param transformation defines the transformation matrix
  2782. * @returns the transformed Vector3
  2783. */
  2784. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2785. /**
  2786. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2787. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2788. * @param vector defines the Vector3 to transform
  2789. * @param transformation defines the transformation matrix
  2790. * @param result defines the Vector3 where to store the result
  2791. */
  2792. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2793. /**
  2794. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2795. * This method computes tranformed coordinates only, not transformed direction vectors
  2796. * @param x define the x coordinate of the source vector
  2797. * @param y define the y coordinate of the source vector
  2798. * @param z define the z coordinate of the source vector
  2799. * @param transformation defines the transformation matrix
  2800. * @param result defines the Vector3 where to store the result
  2801. */
  2802. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2803. /**
  2804. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2805. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2806. * @param vector defines the Vector3 to transform
  2807. * @param transformation defines the transformation matrix
  2808. * @returns the new Vector3
  2809. */
  2810. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2811. /**
  2812. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2813. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2814. * @param vector defines the Vector3 to transform
  2815. * @param transformation defines the transformation matrix
  2816. * @param result defines the Vector3 where to store the result
  2817. */
  2818. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2819. /**
  2820. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2821. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2822. * @param x define the x coordinate of the source vector
  2823. * @param y define the y coordinate of the source vector
  2824. * @param z define the z coordinate of the source vector
  2825. * @param transformation defines the transformation matrix
  2826. * @param result defines the Vector3 where to store the result
  2827. */
  2828. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2829. /**
  2830. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2831. * @param value1 defines the first control point
  2832. * @param value2 defines the second control point
  2833. * @param value3 defines the third control point
  2834. * @param value4 defines the fourth control point
  2835. * @param amount defines the amount on the spline to use
  2836. * @returns the new Vector3
  2837. */
  2838. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2839. /**
  2840. * 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"
  2841. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2842. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2843. * @param value defines the current value
  2844. * @param min defines the lower range value
  2845. * @param max defines the upper range value
  2846. * @returns the new Vector3
  2847. */
  2848. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2849. /**
  2850. * 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"
  2851. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2852. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2853. * @param value defines the current value
  2854. * @param min defines the lower range value
  2855. * @param max defines the upper range value
  2856. * @param result defines the Vector3 where to store the result
  2857. */
  2858. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2859. /**
  2860. * Checks if a given vector is inside a specific range
  2861. * @param v defines the vector to test
  2862. * @param min defines the minimum range
  2863. * @param max defines the maximum range
  2864. */
  2865. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2866. /**
  2867. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2868. * @param value1 defines the first control point
  2869. * @param tangent1 defines the first tangent vector
  2870. * @param value2 defines the second control point
  2871. * @param tangent2 defines the second tangent vector
  2872. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2873. * @returns the new Vector3
  2874. */
  2875. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2876. /**
  2877. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2878. * @param start defines the start value
  2879. * @param end defines the end value
  2880. * @param amount max defines amount between both (between 0 and 1)
  2881. * @returns the new Vector3
  2882. */
  2883. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2884. /**
  2885. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2886. * @param start defines the start value
  2887. * @param end defines the end value
  2888. * @param amount max defines amount between both (between 0 and 1)
  2889. * @param result defines the Vector3 where to store the result
  2890. */
  2891. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2892. /**
  2893. * Returns the dot product (float) between the vectors "left" and "right"
  2894. * @param left defines the left operand
  2895. * @param right defines the right operand
  2896. * @returns the dot product
  2897. */
  2898. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2899. /**
  2900. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2901. * The cross product is then orthogonal to both "left" and "right"
  2902. * @param left defines the left operand
  2903. * @param right defines the right operand
  2904. * @returns the cross product
  2905. */
  2906. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2907. /**
  2908. * Sets the given vector "result" with the cross product of "left" and "right"
  2909. * The cross product is then orthogonal to both "left" and "right"
  2910. * @param left defines the left operand
  2911. * @param right defines the right operand
  2912. * @param result defines the Vector3 where to store the result
  2913. */
  2914. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2915. /**
  2916. * Returns a new Vector3 as the normalization of the given vector
  2917. * @param vector defines the Vector3 to normalize
  2918. * @returns the new Vector3
  2919. */
  2920. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2921. /**
  2922. * Sets the given vector "result" with the normalization of the given first vector
  2923. * @param vector defines the Vector3 to normalize
  2924. * @param result defines the Vector3 where to store the result
  2925. */
  2926. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2927. /**
  2928. * Project a Vector3 onto screen space
  2929. * @param vector defines the Vector3 to project
  2930. * @param world defines the world matrix to use
  2931. * @param transform defines the transform (view x projection) matrix to use
  2932. * @param viewport defines the screen viewport to use
  2933. * @returns the new Vector3
  2934. */
  2935. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2936. /** @hidden */
  2937. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2938. /**
  2939. * Unproject from screen space to object space
  2940. * @param source defines the screen space Vector3 to use
  2941. * @param viewportWidth defines the current width of the viewport
  2942. * @param viewportHeight defines the current height of the viewport
  2943. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2944. * @param transform defines the transform (view x projection) matrix to use
  2945. * @returns the new Vector3
  2946. */
  2947. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2948. /**
  2949. * Unproject from screen space to object space
  2950. * @param source defines the screen space Vector3 to use
  2951. * @param viewportWidth defines the current width of the viewport
  2952. * @param viewportHeight defines the current height of the viewport
  2953. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2954. * @param view defines the view matrix to use
  2955. * @param projection defines the projection matrix to use
  2956. * @returns the new Vector3
  2957. */
  2958. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2959. /**
  2960. * Unproject from screen space to object space
  2961. * @param source defines the screen space Vector3 to use
  2962. * @param viewportWidth defines the current width of the viewport
  2963. * @param viewportHeight defines the current height of the viewport
  2964. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2965. * @param view defines the view matrix to use
  2966. * @param projection defines the projection matrix to use
  2967. * @param result defines the Vector3 where to store the result
  2968. */
  2969. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2970. /**
  2971. * Unproject from screen space to object space
  2972. * @param sourceX defines the screen space x coordinate to use
  2973. * @param sourceY defines the screen space y coordinate to use
  2974. * @param sourceZ defines the screen space z coordinate to use
  2975. * @param viewportWidth defines the current width of the viewport
  2976. * @param viewportHeight defines the current height of the viewport
  2977. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2978. * @param view defines the view matrix to use
  2979. * @param projection defines the projection matrix to use
  2980. * @param result defines the Vector3 where to store the result
  2981. */
  2982. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2983. /**
  2984. * Gets the minimal coordinate values between two Vector3
  2985. * @param left defines the first operand
  2986. * @param right defines the second operand
  2987. * @returns the new Vector3
  2988. */
  2989. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2990. /**
  2991. * Gets the maximal coordinate values between two Vector3
  2992. * @param left defines the first operand
  2993. * @param right defines the second operand
  2994. * @returns the new Vector3
  2995. */
  2996. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2997. /**
  2998. * Returns the distance between the vectors "value1" and "value2"
  2999. * @param value1 defines the first operand
  3000. * @param value2 defines the second operand
  3001. * @returns the distance
  3002. */
  3003. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3004. /**
  3005. * Returns the squared distance between the vectors "value1" and "value2"
  3006. * @param value1 defines the first operand
  3007. * @param value2 defines the second operand
  3008. * @returns the squared distance
  3009. */
  3010. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3011. /**
  3012. * Returns a new Vector3 located at the center between "value1" and "value2"
  3013. * @param value1 defines the first operand
  3014. * @param value2 defines the second operand
  3015. * @returns the new Vector3
  3016. */
  3017. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3018. /**
  3019. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3020. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3021. * to something in order to rotate it from its local system to the given target system
  3022. * Note: axis1, axis2 and axis3 are normalized during this operation
  3023. * @param axis1 defines the first axis
  3024. * @param axis2 defines the second axis
  3025. * @param axis3 defines the third axis
  3026. * @returns a new Vector3
  3027. */
  3028. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3029. /**
  3030. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3031. * @param axis1 defines the first axis
  3032. * @param axis2 defines the second axis
  3033. * @param axis3 defines the third axis
  3034. * @param ref defines the Vector3 where to store the result
  3035. */
  3036. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3037. }
  3038. /**
  3039. * Vector4 class created for EulerAngle class conversion to Quaternion
  3040. */
  3041. export class Vector4 {
  3042. /** x value of the vector */
  3043. x: number;
  3044. /** y value of the vector */
  3045. y: number;
  3046. /** z value of the vector */
  3047. z: number;
  3048. /** w value of the vector */
  3049. w: number;
  3050. /**
  3051. * Creates a Vector4 object from the given floats.
  3052. * @param x x value of the vector
  3053. * @param y y value of the vector
  3054. * @param z z value of the vector
  3055. * @param w w value of the vector
  3056. */
  3057. constructor(
  3058. /** x value of the vector */
  3059. x: number,
  3060. /** y value of the vector */
  3061. y: number,
  3062. /** z value of the vector */
  3063. z: number,
  3064. /** w value of the vector */
  3065. w: number);
  3066. /**
  3067. * Returns the string with the Vector4 coordinates.
  3068. * @returns a string containing all the vector values
  3069. */
  3070. toString(): string;
  3071. /**
  3072. * Returns the string "Vector4".
  3073. * @returns "Vector4"
  3074. */
  3075. getClassName(): string;
  3076. /**
  3077. * Returns the Vector4 hash code.
  3078. * @returns a unique hash code
  3079. */
  3080. getHashCode(): number;
  3081. /**
  3082. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3083. * @returns the resulting array
  3084. */
  3085. asArray(): number[];
  3086. /**
  3087. * Populates the given array from the given index with the Vector4 coordinates.
  3088. * @param array array to populate
  3089. * @param index index of the array to start at (default: 0)
  3090. * @returns the Vector4.
  3091. */
  3092. toArray(array: FloatArray, index?: number): Vector4;
  3093. /**
  3094. * Adds the given vector to the current Vector4.
  3095. * @param otherVector the vector to add
  3096. * @returns the updated Vector4.
  3097. */
  3098. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3099. /**
  3100. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3101. * @param otherVector the vector to add
  3102. * @returns the resulting vector
  3103. */
  3104. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3105. /**
  3106. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3107. * @param otherVector the vector to add
  3108. * @param result the vector to store the result
  3109. * @returns the current Vector4.
  3110. */
  3111. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3112. /**
  3113. * Subtract in place the given vector from the current Vector4.
  3114. * @param otherVector the vector to subtract
  3115. * @returns the updated Vector4.
  3116. */
  3117. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3118. /**
  3119. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3120. * @param otherVector the vector to add
  3121. * @returns the new vector with the result
  3122. */
  3123. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3124. /**
  3125. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3126. * @param otherVector the vector to subtract
  3127. * @param result the vector to store the result
  3128. * @returns the current Vector4.
  3129. */
  3130. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3131. /**
  3132. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3133. */
  3134. /**
  3135. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3136. * @param x value to subtract
  3137. * @param y value to subtract
  3138. * @param z value to subtract
  3139. * @param w value to subtract
  3140. * @returns new vector containing the result
  3141. */
  3142. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3143. /**
  3144. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3145. * @param x value to subtract
  3146. * @param y value to subtract
  3147. * @param z value to subtract
  3148. * @param w value to subtract
  3149. * @param result the vector to store the result in
  3150. * @returns the current Vector4.
  3151. */
  3152. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3153. /**
  3154. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3155. * @returns a new vector with the negated values
  3156. */
  3157. negate(): Vector4;
  3158. /**
  3159. * Multiplies the current Vector4 coordinates by scale (float).
  3160. * @param scale the number to scale with
  3161. * @returns the updated Vector4.
  3162. */
  3163. scaleInPlace(scale: number): Vector4;
  3164. /**
  3165. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3166. * @param scale the number to scale with
  3167. * @returns a new vector with the result
  3168. */
  3169. scale(scale: number): Vector4;
  3170. /**
  3171. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3172. * @param scale the number to scale with
  3173. * @param result a vector to store the result in
  3174. * @returns the current Vector4.
  3175. */
  3176. scaleToRef(scale: number, result: Vector4): Vector4;
  3177. /**
  3178. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3179. * @param scale defines the scale factor
  3180. * @param result defines the Vector4 object where to store the result
  3181. * @returns the unmodified current Vector4
  3182. */
  3183. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3184. /**
  3185. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3186. * @param otherVector the vector to compare against
  3187. * @returns true if they are equal
  3188. */
  3189. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3190. /**
  3191. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3192. * @param otherVector vector to compare against
  3193. * @param epsilon (Default: very small number)
  3194. * @returns true if they are equal
  3195. */
  3196. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3197. /**
  3198. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3199. * @param x x value to compare against
  3200. * @param y y value to compare against
  3201. * @param z z value to compare against
  3202. * @param w w value to compare against
  3203. * @returns true if equal
  3204. */
  3205. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3206. /**
  3207. * Multiplies in place the current Vector4 by the given one.
  3208. * @param otherVector vector to multiple with
  3209. * @returns the updated Vector4.
  3210. */
  3211. multiplyInPlace(otherVector: Vector4): Vector4;
  3212. /**
  3213. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3214. * @param otherVector vector to multiple with
  3215. * @returns resulting new vector
  3216. */
  3217. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3218. /**
  3219. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3220. * @param otherVector vector to multiple with
  3221. * @param result vector to store the result
  3222. * @returns the current Vector4.
  3223. */
  3224. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3225. /**
  3226. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3227. * @param x x value multiply with
  3228. * @param y y value multiply with
  3229. * @param z z value multiply with
  3230. * @param w w value multiply with
  3231. * @returns resulting new vector
  3232. */
  3233. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3234. /**
  3235. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3236. * @param otherVector vector to devide with
  3237. * @returns resulting new vector
  3238. */
  3239. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3240. /**
  3241. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3242. * @param otherVector vector to devide with
  3243. * @param result vector to store the result
  3244. * @returns the current Vector4.
  3245. */
  3246. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3247. /**
  3248. * Divides the current Vector3 coordinates by the given ones.
  3249. * @param otherVector vector to devide with
  3250. * @returns the updated Vector3.
  3251. */
  3252. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3253. /**
  3254. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3255. * @param other defines the second operand
  3256. * @returns the current updated Vector4
  3257. */
  3258. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3259. /**
  3260. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3261. * @param other defines the second operand
  3262. * @returns the current updated Vector4
  3263. */
  3264. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3265. /**
  3266. * Gets a new Vector4 from current Vector4 floored values
  3267. * @returns a new Vector4
  3268. */
  3269. floor(): Vector4;
  3270. /**
  3271. * Gets a new Vector4 from current Vector3 floored values
  3272. * @returns a new Vector4
  3273. */
  3274. fract(): Vector4;
  3275. /**
  3276. * Returns the Vector4 length (float).
  3277. * @returns the length
  3278. */
  3279. length(): number;
  3280. /**
  3281. * Returns the Vector4 squared length (float).
  3282. * @returns the length squared
  3283. */
  3284. lengthSquared(): number;
  3285. /**
  3286. * Normalizes in place the Vector4.
  3287. * @returns the updated Vector4.
  3288. */
  3289. normalize(): Vector4;
  3290. /**
  3291. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3292. * @returns this converted to a new vector3
  3293. */
  3294. toVector3(): Vector3;
  3295. /**
  3296. * Returns a new Vector4 copied from the current one.
  3297. * @returns the new cloned vector
  3298. */
  3299. clone(): Vector4;
  3300. /**
  3301. * Updates the current Vector4 with the given one coordinates.
  3302. * @param source the source vector to copy from
  3303. * @returns the updated Vector4.
  3304. */
  3305. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3306. /**
  3307. * Updates the current Vector4 coordinates with the given floats.
  3308. * @param x float to copy from
  3309. * @param y float to copy from
  3310. * @param z float to copy from
  3311. * @param w float to copy from
  3312. * @returns the updated Vector4.
  3313. */
  3314. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3315. /**
  3316. * Updates the current Vector4 coordinates with the given floats.
  3317. * @param x float to set from
  3318. * @param y float to set from
  3319. * @param z float to set from
  3320. * @param w float to set from
  3321. * @returns the updated Vector4.
  3322. */
  3323. set(x: number, y: number, z: number, w: number): Vector4;
  3324. /**
  3325. * Copies the given float to the current Vector3 coordinates
  3326. * @param v defines the x, y, z and w coordinates of the operand
  3327. * @returns the current updated Vector3
  3328. */
  3329. setAll(v: number): Vector4;
  3330. /**
  3331. * Returns a new Vector4 set from the starting index of the given array.
  3332. * @param array the array to pull values from
  3333. * @param offset the offset into the array to start at
  3334. * @returns the new vector
  3335. */
  3336. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3337. /**
  3338. * Updates the given vector "result" from the starting index of the given array.
  3339. * @param array the array to pull values from
  3340. * @param offset the offset into the array to start at
  3341. * @param result the vector to store the result in
  3342. */
  3343. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3344. /**
  3345. * Updates the given vector "result" from the starting index of the given Float32Array.
  3346. * @param array the array to pull values from
  3347. * @param offset the offset into the array to start at
  3348. * @param result the vector to store the result in
  3349. */
  3350. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3351. /**
  3352. * Updates the given vector "result" coordinates from the given floats.
  3353. * @param x float to set from
  3354. * @param y float to set from
  3355. * @param z float to set from
  3356. * @param w float to set from
  3357. * @param result the vector to the floats in
  3358. */
  3359. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3360. /**
  3361. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3362. * @returns the new vector
  3363. */
  3364. static Zero(): Vector4;
  3365. /**
  3366. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3367. * @returns the new vector
  3368. */
  3369. static One(): Vector4;
  3370. /**
  3371. * Returns a new normalized Vector4 from the given one.
  3372. * @param vector the vector to normalize
  3373. * @returns the vector
  3374. */
  3375. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3376. /**
  3377. * Updates the given vector "result" from the normalization of the given one.
  3378. * @param vector the vector to normalize
  3379. * @param result the vector to store the result in
  3380. */
  3381. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3382. /**
  3383. * Returns a vector with the minimum values from the left and right vectors
  3384. * @param left left vector to minimize
  3385. * @param right right vector to minimize
  3386. * @returns a new vector with the minimum of the left and right vector values
  3387. */
  3388. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3389. /**
  3390. * Returns a vector with the maximum values from the left and right vectors
  3391. * @param left left vector to maximize
  3392. * @param right right vector to maximize
  3393. * @returns a new vector with the maximum of the left and right vector values
  3394. */
  3395. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3396. /**
  3397. * Returns the distance (float) between the vectors "value1" and "value2".
  3398. * @param value1 value to calulate the distance between
  3399. * @param value2 value to calulate the distance between
  3400. * @return the distance between the two vectors
  3401. */
  3402. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3403. /**
  3404. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3405. * @param value1 value to calulate the distance between
  3406. * @param value2 value to calulate the distance between
  3407. * @return the distance between the two vectors squared
  3408. */
  3409. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3410. /**
  3411. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3412. * @param value1 value to calulate the center between
  3413. * @param value2 value to calulate the center between
  3414. * @return the center between the two vectors
  3415. */
  3416. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3417. /**
  3418. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3419. * This methods computes transformed normalized direction vectors only.
  3420. * @param vector the vector to transform
  3421. * @param transformation the transformation matrix to apply
  3422. * @returns the new vector
  3423. */
  3424. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3425. /**
  3426. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3427. * This methods computes transformed normalized direction vectors only.
  3428. * @param vector the vector to transform
  3429. * @param transformation the transformation matrix to apply
  3430. * @param result the vector to store the result in
  3431. */
  3432. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3433. /**
  3434. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3435. * This methods computes transformed normalized direction vectors only.
  3436. * @param x value to transform
  3437. * @param y value to transform
  3438. * @param z value to transform
  3439. * @param w value to transform
  3440. * @param transformation the transformation matrix to apply
  3441. * @param result the vector to store the results in
  3442. */
  3443. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3444. /**
  3445. * Creates a new Vector4 from a Vector3
  3446. * @param source defines the source data
  3447. * @param w defines the 4th component (default is 0)
  3448. * @returns a new Vector4
  3449. */
  3450. static FromVector3(source: Vector3, w?: number): Vector4;
  3451. }
  3452. /**
  3453. * Class used to store quaternion data
  3454. * @see https://en.wikipedia.org/wiki/Quaternion
  3455. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3456. */
  3457. export class Quaternion {
  3458. /** defines the first component (0 by default) */
  3459. x: number;
  3460. /** defines the second component (0 by default) */
  3461. y: number;
  3462. /** defines the third component (0 by default) */
  3463. z: number;
  3464. /** defines the fourth component (1.0 by default) */
  3465. w: number;
  3466. /**
  3467. * Creates a new Quaternion from the given floats
  3468. * @param x defines the first component (0 by default)
  3469. * @param y defines the second component (0 by default)
  3470. * @param z defines the third component (0 by default)
  3471. * @param w defines the fourth component (1.0 by default)
  3472. */
  3473. constructor(
  3474. /** defines the first component (0 by default) */
  3475. x?: number,
  3476. /** defines the second component (0 by default) */
  3477. y?: number,
  3478. /** defines the third component (0 by default) */
  3479. z?: number,
  3480. /** defines the fourth component (1.0 by default) */
  3481. w?: number);
  3482. /**
  3483. * Gets a string representation for the current quaternion
  3484. * @returns a string with the Quaternion coordinates
  3485. */
  3486. toString(): string;
  3487. /**
  3488. * Gets the class name of the quaternion
  3489. * @returns the string "Quaternion"
  3490. */
  3491. getClassName(): string;
  3492. /**
  3493. * Gets a hash code for this quaternion
  3494. * @returns the quaternion hash code
  3495. */
  3496. getHashCode(): number;
  3497. /**
  3498. * Copy the quaternion to an array
  3499. * @returns a new array populated with 4 elements from the quaternion coordinates
  3500. */
  3501. asArray(): number[];
  3502. /**
  3503. * Check if two quaternions are equals
  3504. * @param otherQuaternion defines the second operand
  3505. * @return true if the current quaternion and the given one coordinates are strictly equals
  3506. */
  3507. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3508. /**
  3509. * Clone the current quaternion
  3510. * @returns a new quaternion copied from the current one
  3511. */
  3512. clone(): Quaternion;
  3513. /**
  3514. * Copy a quaternion to the current one
  3515. * @param other defines the other quaternion
  3516. * @returns the updated current quaternion
  3517. */
  3518. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3519. /**
  3520. * Updates the current quaternion with the given float coordinates
  3521. * @param x defines the x coordinate
  3522. * @param y defines the y coordinate
  3523. * @param z defines the z coordinate
  3524. * @param w defines the w coordinate
  3525. * @returns the updated current quaternion
  3526. */
  3527. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3528. /**
  3529. * Updates the current quaternion from the given float coordinates
  3530. * @param x defines the x coordinate
  3531. * @param y defines the y coordinate
  3532. * @param z defines the z coordinate
  3533. * @param w defines the w coordinate
  3534. * @returns the updated current quaternion
  3535. */
  3536. set(x: number, y: number, z: number, w: number): Quaternion;
  3537. /**
  3538. * Adds two quaternions
  3539. * @param other defines the second operand
  3540. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3541. */
  3542. add(other: DeepImmutable<Quaternion>): Quaternion;
  3543. /**
  3544. * Add a quaternion to the current one
  3545. * @param other defines the quaternion to add
  3546. * @returns the current quaternion
  3547. */
  3548. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3549. /**
  3550. * Subtract two quaternions
  3551. * @param other defines the second operand
  3552. * @returns a new quaternion as the subtraction result of the given one from the current one
  3553. */
  3554. subtract(other: Quaternion): Quaternion;
  3555. /**
  3556. * Multiplies the current quaternion by a scale factor
  3557. * @param value defines the scale factor
  3558. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3559. */
  3560. scale(value: number): Quaternion;
  3561. /**
  3562. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3563. * @param scale defines the scale factor
  3564. * @param result defines the Quaternion object where to store the result
  3565. * @returns the unmodified current quaternion
  3566. */
  3567. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3568. /**
  3569. * Multiplies in place the current quaternion by a scale factor
  3570. * @param value defines the scale factor
  3571. * @returns the current modified quaternion
  3572. */
  3573. scaleInPlace(value: number): Quaternion;
  3574. /**
  3575. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3576. * @param scale defines the scale factor
  3577. * @param result defines the Quaternion object where to store the result
  3578. * @returns the unmodified current quaternion
  3579. */
  3580. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3581. /**
  3582. * Multiplies two quaternions
  3583. * @param q1 defines the second operand
  3584. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3585. */
  3586. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3587. /**
  3588. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3589. * @param q1 defines the second operand
  3590. * @param result defines the target quaternion
  3591. * @returns the current quaternion
  3592. */
  3593. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3594. /**
  3595. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3596. * @param q1 defines the second operand
  3597. * @returns the currentupdated quaternion
  3598. */
  3599. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3600. /**
  3601. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3602. * @param ref defines the target quaternion
  3603. * @returns the current quaternion
  3604. */
  3605. conjugateToRef(ref: Quaternion): Quaternion;
  3606. /**
  3607. * Conjugates in place (1-q) the current quaternion
  3608. * @returns the current updated quaternion
  3609. */
  3610. conjugateInPlace(): Quaternion;
  3611. /**
  3612. * Conjugates in place (1-q) the current quaternion
  3613. * @returns a new quaternion
  3614. */
  3615. conjugate(): Quaternion;
  3616. /**
  3617. * Gets length of current quaternion
  3618. * @returns the quaternion length (float)
  3619. */
  3620. length(): number;
  3621. /**
  3622. * Normalize in place the current quaternion
  3623. * @returns the current updated quaternion
  3624. */
  3625. normalize(): Quaternion;
  3626. /**
  3627. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3628. * @param order is a reserved parameter and is ignore for now
  3629. * @returns a new Vector3 containing the Euler angles
  3630. */
  3631. toEulerAngles(order?: string): Vector3;
  3632. /**
  3633. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3634. * @param result defines the vector which will be filled with the Euler angles
  3635. * @param order is a reserved parameter and is ignore for now
  3636. * @returns the current unchanged quaternion
  3637. */
  3638. toEulerAnglesToRef(result: Vector3): Quaternion;
  3639. /**
  3640. * Updates the given rotation matrix with the current quaternion values
  3641. * @param result defines the target matrix
  3642. * @returns the current unchanged quaternion
  3643. */
  3644. toRotationMatrix(result: Matrix): Quaternion;
  3645. /**
  3646. * Updates the current quaternion from the given rotation matrix values
  3647. * @param matrix defines the source matrix
  3648. * @returns the current updated quaternion
  3649. */
  3650. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3651. /**
  3652. * Creates a new quaternion from a rotation matrix
  3653. * @param matrix defines the source matrix
  3654. * @returns a new quaternion created from the given rotation matrix values
  3655. */
  3656. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3657. /**
  3658. * Updates the given quaternion with the given rotation matrix values
  3659. * @param matrix defines the source matrix
  3660. * @param result defines the target quaternion
  3661. */
  3662. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3663. /**
  3664. * Returns the dot product (float) between the quaternions "left" and "right"
  3665. * @param left defines the left operand
  3666. * @param right defines the right operand
  3667. * @returns the dot product
  3668. */
  3669. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3670. /**
  3671. * Checks if the two quaternions are close to each other
  3672. * @param quat0 defines the first quaternion to check
  3673. * @param quat1 defines the second quaternion to check
  3674. * @returns true if the two quaternions are close to each other
  3675. */
  3676. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3677. /**
  3678. * Creates an empty quaternion
  3679. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3680. */
  3681. static Zero(): Quaternion;
  3682. /**
  3683. * Inverse a given quaternion
  3684. * @param q defines the source quaternion
  3685. * @returns a new quaternion as the inverted current quaternion
  3686. */
  3687. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3688. /**
  3689. * Inverse a given quaternion
  3690. * @param q defines the source quaternion
  3691. * @param result the quaternion the result will be stored in
  3692. * @returns the result quaternion
  3693. */
  3694. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3695. /**
  3696. * Creates an identity quaternion
  3697. * @returns the identity quaternion
  3698. */
  3699. static Identity(): Quaternion;
  3700. /**
  3701. * Gets a boolean indicating if the given quaternion is identity
  3702. * @param quaternion defines the quaternion to check
  3703. * @returns true if the quaternion is identity
  3704. */
  3705. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3706. /**
  3707. * Creates a quaternion from a rotation around an axis
  3708. * @param axis defines the axis to use
  3709. * @param angle defines the angle to use
  3710. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3711. */
  3712. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3713. /**
  3714. * Creates a rotation around an axis and stores it into the given quaternion
  3715. * @param axis defines the axis to use
  3716. * @param angle defines the angle to use
  3717. * @param result defines the target quaternion
  3718. * @returns the target quaternion
  3719. */
  3720. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3721. /**
  3722. * Creates a new quaternion from data stored into an array
  3723. * @param array defines the data source
  3724. * @param offset defines the offset in the source array where the data starts
  3725. * @returns a new quaternion
  3726. */
  3727. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3728. /**
  3729. * Create a quaternion from Euler rotation angles
  3730. * @param x Pitch
  3731. * @param y Yaw
  3732. * @param z Roll
  3733. * @returns the new Quaternion
  3734. */
  3735. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3736. /**
  3737. * Updates a quaternion from Euler rotation angles
  3738. * @param x Pitch
  3739. * @param y Yaw
  3740. * @param z Roll
  3741. * @param result the quaternion to store the result
  3742. * @returns the updated quaternion
  3743. */
  3744. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3745. /**
  3746. * Create a quaternion from Euler rotation vector
  3747. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3748. * @returns the new Quaternion
  3749. */
  3750. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3751. /**
  3752. * Updates a quaternion from Euler rotation vector
  3753. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3754. * @param result the quaternion to store the result
  3755. * @returns the updated quaternion
  3756. */
  3757. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3758. /**
  3759. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3760. * @param yaw defines the rotation around Y axis
  3761. * @param pitch defines the rotation around X axis
  3762. * @param roll defines the rotation around Z axis
  3763. * @returns the new quaternion
  3764. */
  3765. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3766. /**
  3767. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3768. * @param yaw defines the rotation around Y axis
  3769. * @param pitch defines the rotation around X axis
  3770. * @param roll defines the rotation around Z axis
  3771. * @param result defines the target quaternion
  3772. */
  3773. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3774. /**
  3775. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3776. * @param alpha defines the rotation around first axis
  3777. * @param beta defines the rotation around second axis
  3778. * @param gamma defines the rotation around third axis
  3779. * @returns the new quaternion
  3780. */
  3781. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3782. /**
  3783. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3784. * @param alpha defines the rotation around first axis
  3785. * @param beta defines the rotation around second axis
  3786. * @param gamma defines the rotation around third axis
  3787. * @param result defines the target quaternion
  3788. */
  3789. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3790. /**
  3791. * 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)
  3792. * @param axis1 defines the first axis
  3793. * @param axis2 defines the second axis
  3794. * @param axis3 defines the third axis
  3795. * @returns the new quaternion
  3796. */
  3797. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3798. /**
  3799. * 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
  3800. * @param axis1 defines the first axis
  3801. * @param axis2 defines the second axis
  3802. * @param axis3 defines the third axis
  3803. * @param ref defines the target quaternion
  3804. */
  3805. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3806. /**
  3807. * Interpolates between two quaternions
  3808. * @param left defines first quaternion
  3809. * @param right defines second quaternion
  3810. * @param amount defines the gradient to use
  3811. * @returns the new interpolated quaternion
  3812. */
  3813. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3814. /**
  3815. * Interpolates between two quaternions and stores it into a target quaternion
  3816. * @param left defines first quaternion
  3817. * @param right defines second quaternion
  3818. * @param amount defines the gradient to use
  3819. * @param result defines the target quaternion
  3820. */
  3821. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3822. /**
  3823. * Interpolate between two quaternions using Hermite interpolation
  3824. * @param value1 defines first quaternion
  3825. * @param tangent1 defines the incoming tangent
  3826. * @param value2 defines second quaternion
  3827. * @param tangent2 defines the outgoing tangent
  3828. * @param amount defines the target quaternion
  3829. * @returns the new interpolated quaternion
  3830. */
  3831. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3832. }
  3833. /**
  3834. * Class used to store matrix data (4x4)
  3835. */
  3836. export class Matrix {
  3837. private static _updateFlagSeed;
  3838. private static _identityReadOnly;
  3839. private _isIdentity;
  3840. private _isIdentityDirty;
  3841. private _isIdentity3x2;
  3842. private _isIdentity3x2Dirty;
  3843. /**
  3844. * Gets the update flag of the matrix which is an unique number for the matrix.
  3845. * It will be incremented every time the matrix data change.
  3846. * You can use it to speed the comparison between two versions of the same matrix.
  3847. */
  3848. updateFlag: number;
  3849. private readonly _m;
  3850. /**
  3851. * Gets the internal data of the matrix
  3852. */
  3853. readonly m: DeepImmutable<Float32Array>;
  3854. /** @hidden */
  3855. _markAsUpdated(): void;
  3856. /** @hidden */
  3857. private _updateIdentityStatus;
  3858. /**
  3859. * Creates an empty matrix (filled with zeros)
  3860. */
  3861. constructor();
  3862. /**
  3863. * Check if the current matrix is identity
  3864. * @returns true is the matrix is the identity matrix
  3865. */
  3866. isIdentity(): boolean;
  3867. /**
  3868. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3869. * @returns true is the matrix is the identity matrix
  3870. */
  3871. isIdentityAs3x2(): boolean;
  3872. /**
  3873. * Gets the determinant of the matrix
  3874. * @returns the matrix determinant
  3875. */
  3876. determinant(): number;
  3877. /**
  3878. * Returns the matrix as a Float32Array
  3879. * @returns the matrix underlying array
  3880. */
  3881. toArray(): DeepImmutable<Float32Array>;
  3882. /**
  3883. * Returns the matrix as a Float32Array
  3884. * @returns the matrix underlying array.
  3885. */
  3886. asArray(): DeepImmutable<Float32Array>;
  3887. /**
  3888. * Inverts the current matrix in place
  3889. * @returns the current inverted matrix
  3890. */
  3891. invert(): Matrix;
  3892. /**
  3893. * Sets all the matrix elements to zero
  3894. * @returns the current matrix
  3895. */
  3896. reset(): Matrix;
  3897. /**
  3898. * Adds the current matrix with a second one
  3899. * @param other defines the matrix to add
  3900. * @returns a new matrix as the addition of the current matrix and the given one
  3901. */
  3902. add(other: DeepImmutable<Matrix>): Matrix;
  3903. /**
  3904. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3905. * @param other defines the matrix to add
  3906. * @param result defines the target matrix
  3907. * @returns the current matrix
  3908. */
  3909. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3910. /**
  3911. * Adds in place the given matrix to the current matrix
  3912. * @param other defines the second operand
  3913. * @returns the current updated matrix
  3914. */
  3915. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3916. /**
  3917. * Sets the given matrix to the current inverted Matrix
  3918. * @param other defines the target matrix
  3919. * @returns the unmodified current matrix
  3920. */
  3921. invertToRef(other: Matrix): Matrix;
  3922. /**
  3923. * add a value at the specified position in the current Matrix
  3924. * @param index the index of the value within the matrix. between 0 and 15.
  3925. * @param value the value to be added
  3926. * @returns the current updated matrix
  3927. */
  3928. addAtIndex(index: number, value: number): Matrix;
  3929. /**
  3930. * mutiply the specified position in the current Matrix by a value
  3931. * @param index the index of the value within the matrix. between 0 and 15.
  3932. * @param value the value to be added
  3933. * @returns the current updated matrix
  3934. */
  3935. multiplyAtIndex(index: number, value: number): Matrix;
  3936. /**
  3937. * Inserts the translation vector (using 3 floats) in the current matrix
  3938. * @param x defines the 1st component of the translation
  3939. * @param y defines the 2nd component of the translation
  3940. * @param z defines the 3rd component of the translation
  3941. * @returns the current updated matrix
  3942. */
  3943. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3944. /**
  3945. * Adds the translation vector (using 3 floats) in the current matrix
  3946. * @param x defines the 1st component of the translation
  3947. * @param y defines the 2nd component of the translation
  3948. * @param z defines the 3rd component of the translation
  3949. * @returns the current updated matrix
  3950. */
  3951. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3952. /**
  3953. * Inserts the translation vector in the current matrix
  3954. * @param vector3 defines the translation to insert
  3955. * @returns the current updated matrix
  3956. */
  3957. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3958. /**
  3959. * Gets the translation value of the current matrix
  3960. * @returns a new Vector3 as the extracted translation from the matrix
  3961. */
  3962. getTranslation(): Vector3;
  3963. /**
  3964. * Fill a Vector3 with the extracted translation from the matrix
  3965. * @param result defines the Vector3 where to store the translation
  3966. * @returns the current matrix
  3967. */
  3968. getTranslationToRef(result: Vector3): Matrix;
  3969. /**
  3970. * Remove rotation and scaling part from the matrix
  3971. * @returns the updated matrix
  3972. */
  3973. removeRotationAndScaling(): Matrix;
  3974. /**
  3975. * Multiply two matrices
  3976. * @param other defines the second operand
  3977. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3978. */
  3979. multiply(other: DeepImmutable<Matrix>): Matrix;
  3980. /**
  3981. * Copy the current matrix from the given one
  3982. * @param other defines the source matrix
  3983. * @returns the current updated matrix
  3984. */
  3985. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3986. /**
  3987. * Populates the given array from the starting index with the current matrix values
  3988. * @param array defines the target array
  3989. * @param offset defines the offset in the target array where to start storing values
  3990. * @returns the current matrix
  3991. */
  3992. copyToArray(array: Float32Array, offset?: number): Matrix;
  3993. /**
  3994. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3995. * @param other defines the second operand
  3996. * @param result defines the matrix where to store the multiplication
  3997. * @returns the current matrix
  3998. */
  3999. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4000. /**
  4001. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4002. * @param other defines the second operand
  4003. * @param result defines the array where to store the multiplication
  4004. * @param offset defines the offset in the target array where to start storing values
  4005. * @returns the current matrix
  4006. */
  4007. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4008. /**
  4009. * Check equality between this matrix and a second one
  4010. * @param value defines the second matrix to compare
  4011. * @returns true is the current matrix and the given one values are strictly equal
  4012. */
  4013. equals(value: DeepImmutable<Matrix>): boolean;
  4014. /**
  4015. * Clone the current matrix
  4016. * @returns a new matrix from the current matrix
  4017. */
  4018. clone(): Matrix;
  4019. /**
  4020. * Returns the name of the current matrix class
  4021. * @returns the string "Matrix"
  4022. */
  4023. getClassName(): string;
  4024. /**
  4025. * Gets the hash code of the current matrix
  4026. * @returns the hash code
  4027. */
  4028. getHashCode(): number;
  4029. /**
  4030. * Decomposes the current Matrix into a translation, rotation and scaling components
  4031. * @param scale defines the scale vector3 given as a reference to update
  4032. * @param rotation defines the rotation quaternion given as a reference to update
  4033. * @param translation defines the translation vector3 given as a reference to update
  4034. * @returns true if operation was successful
  4035. */
  4036. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4037. /**
  4038. * Gets specific row of the matrix
  4039. * @param index defines the number of the row to get
  4040. * @returns the index-th row of the current matrix as a new Vector4
  4041. */
  4042. getRow(index: number): Nullable<Vector4>;
  4043. /**
  4044. * Sets the index-th row of the current matrix to the vector4 values
  4045. * @param index defines the number of the row to set
  4046. * @param row defines the target vector4
  4047. * @returns the updated current matrix
  4048. */
  4049. setRow(index: number, row: Vector4): Matrix;
  4050. /**
  4051. * Compute the transpose of the matrix
  4052. * @returns the new transposed matrix
  4053. */
  4054. transpose(): Matrix;
  4055. /**
  4056. * Compute the transpose of the matrix and store it in a given matrix
  4057. * @param result defines the target matrix
  4058. * @returns the current matrix
  4059. */
  4060. transposeToRef(result: Matrix): Matrix;
  4061. /**
  4062. * Sets the index-th row of the current matrix with the given 4 x float values
  4063. * @param index defines the row index
  4064. * @param x defines the x component to set
  4065. * @param y defines the y component to set
  4066. * @param z defines the z component to set
  4067. * @param w defines the w component to set
  4068. * @returns the updated current matrix
  4069. */
  4070. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4071. /**
  4072. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4073. * @param scale defines the scale factor
  4074. * @returns a new matrix
  4075. */
  4076. scale(scale: number): Matrix;
  4077. /**
  4078. * Scale the current matrix values by a factor to a given result matrix
  4079. * @param scale defines the scale factor
  4080. * @param result defines the matrix to store the result
  4081. * @returns the current matrix
  4082. */
  4083. scaleToRef(scale: number, result: Matrix): Matrix;
  4084. /**
  4085. * Scale the current matrix values by a factor and add the result to a given matrix
  4086. * @param scale defines the scale factor
  4087. * @param result defines the Matrix to store the result
  4088. * @returns the current matrix
  4089. */
  4090. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4091. /**
  4092. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4093. * @param ref matrix to store the result
  4094. */
  4095. toNormalMatrix(ref: Matrix): void;
  4096. /**
  4097. * Gets only rotation part of the current matrix
  4098. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4099. */
  4100. getRotationMatrix(): Matrix;
  4101. /**
  4102. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4103. * @param result defines the target matrix to store data to
  4104. * @returns the current matrix
  4105. */
  4106. getRotationMatrixToRef(result: Matrix): Matrix;
  4107. /**
  4108. * Toggles model matrix from being right handed to left handed in place and vice versa
  4109. */
  4110. toggleModelMatrixHandInPlace(): void;
  4111. /**
  4112. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4113. */
  4114. toggleProjectionMatrixHandInPlace(): void;
  4115. /**
  4116. * Creates a matrix from an array
  4117. * @param array defines the source array
  4118. * @param offset defines an offset in the source array
  4119. * @returns a new Matrix set from the starting index of the given array
  4120. */
  4121. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4122. /**
  4123. * Copy the content of an array into a given matrix
  4124. * @param array defines the source array
  4125. * @param offset defines an offset in the source array
  4126. * @param result defines the target matrix
  4127. */
  4128. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4129. /**
  4130. * Stores an array into a matrix after having multiplied each component by a given factor
  4131. * @param array defines the source array
  4132. * @param offset defines the offset in the source array
  4133. * @param scale defines the scaling factor
  4134. * @param result defines the target matrix
  4135. */
  4136. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4137. /**
  4138. * Gets an identity matrix that must not be updated
  4139. */
  4140. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  4141. /**
  4142. * Stores a list of values (16) inside a given matrix
  4143. * @param initialM11 defines 1st value of 1st row
  4144. * @param initialM12 defines 2nd value of 1st row
  4145. * @param initialM13 defines 3rd value of 1st row
  4146. * @param initialM14 defines 4th value of 1st row
  4147. * @param initialM21 defines 1st value of 2nd row
  4148. * @param initialM22 defines 2nd value of 2nd row
  4149. * @param initialM23 defines 3rd value of 2nd row
  4150. * @param initialM24 defines 4th value of 2nd row
  4151. * @param initialM31 defines 1st value of 3rd row
  4152. * @param initialM32 defines 2nd value of 3rd row
  4153. * @param initialM33 defines 3rd value of 3rd row
  4154. * @param initialM34 defines 4th value of 3rd row
  4155. * @param initialM41 defines 1st value of 4th row
  4156. * @param initialM42 defines 2nd value of 4th row
  4157. * @param initialM43 defines 3rd value of 4th row
  4158. * @param initialM44 defines 4th value of 4th row
  4159. * @param result defines the target matrix
  4160. */
  4161. 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;
  4162. /**
  4163. * Creates new matrix from a list of values (16)
  4164. * @param initialM11 defines 1st value of 1st row
  4165. * @param initialM12 defines 2nd value of 1st row
  4166. * @param initialM13 defines 3rd value of 1st row
  4167. * @param initialM14 defines 4th value of 1st row
  4168. * @param initialM21 defines 1st value of 2nd row
  4169. * @param initialM22 defines 2nd value of 2nd row
  4170. * @param initialM23 defines 3rd value of 2nd row
  4171. * @param initialM24 defines 4th value of 2nd row
  4172. * @param initialM31 defines 1st value of 3rd row
  4173. * @param initialM32 defines 2nd value of 3rd row
  4174. * @param initialM33 defines 3rd value of 3rd row
  4175. * @param initialM34 defines 4th value of 3rd row
  4176. * @param initialM41 defines 1st value of 4th row
  4177. * @param initialM42 defines 2nd value of 4th row
  4178. * @param initialM43 defines 3rd value of 4th row
  4179. * @param initialM44 defines 4th value of 4th row
  4180. * @returns the new matrix
  4181. */
  4182. 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;
  4183. /**
  4184. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4185. * @param scale defines the scale vector3
  4186. * @param rotation defines the rotation quaternion
  4187. * @param translation defines the translation vector3
  4188. * @returns a new matrix
  4189. */
  4190. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4191. /**
  4192. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4193. * @param scale defines the scale vector3
  4194. * @param rotation defines the rotation quaternion
  4195. * @param translation defines the translation vector3
  4196. * @param result defines the target matrix
  4197. */
  4198. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4199. /**
  4200. * Creates a new identity matrix
  4201. * @returns a new identity matrix
  4202. */
  4203. static Identity(): Matrix;
  4204. /**
  4205. * Creates a new identity matrix and stores the result in a given matrix
  4206. * @param result defines the target matrix
  4207. */
  4208. static IdentityToRef(result: Matrix): void;
  4209. /**
  4210. * Creates a new zero matrix
  4211. * @returns a new zero matrix
  4212. */
  4213. static Zero(): Matrix;
  4214. /**
  4215. * Creates a new rotation matrix for "angle" radians around the X axis
  4216. * @param angle defines the angle (in radians) to use
  4217. * @return the new matrix
  4218. */
  4219. static RotationX(angle: number): Matrix;
  4220. /**
  4221. * Creates a new matrix as the invert of a given matrix
  4222. * @param source defines the source matrix
  4223. * @returns the new matrix
  4224. */
  4225. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4226. /**
  4227. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4228. * @param angle defines the angle (in radians) to use
  4229. * @param result defines the target matrix
  4230. */
  4231. static RotationXToRef(angle: number, result: Matrix): void;
  4232. /**
  4233. * Creates a new rotation matrix for "angle" radians around the Y axis
  4234. * @param angle defines the angle (in radians) to use
  4235. * @return the new matrix
  4236. */
  4237. static RotationY(angle: number): Matrix;
  4238. /**
  4239. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4240. * @param angle defines the angle (in radians) to use
  4241. * @param result defines the target matrix
  4242. */
  4243. static RotationYToRef(angle: number, result: Matrix): void;
  4244. /**
  4245. * Creates a new rotation matrix for "angle" radians around the Z axis
  4246. * @param angle defines the angle (in radians) to use
  4247. * @return the new matrix
  4248. */
  4249. static RotationZ(angle: number): Matrix;
  4250. /**
  4251. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4252. * @param angle defines the angle (in radians) to use
  4253. * @param result defines the target matrix
  4254. */
  4255. static RotationZToRef(angle: number, result: Matrix): void;
  4256. /**
  4257. * Creates a new rotation matrix for "angle" radians around the given axis
  4258. * @param axis defines the axis to use
  4259. * @param angle defines the angle (in radians) to use
  4260. * @return the new matrix
  4261. */
  4262. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4263. /**
  4264. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4265. * @param axis defines the axis to use
  4266. * @param angle defines the angle (in radians) to use
  4267. * @param result defines the target matrix
  4268. */
  4269. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4270. /**
  4271. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4272. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4273. * @param from defines the vector to align
  4274. * @param to defines the vector to align to
  4275. * @param result defines the target matrix
  4276. */
  4277. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4278. /**
  4279. * Creates a rotation matrix
  4280. * @param yaw defines the yaw angle in radians (Y axis)
  4281. * @param pitch defines the pitch angle in radians (X axis)
  4282. * @param roll defines the roll angle in radians (X axis)
  4283. * @returns the new rotation matrix
  4284. */
  4285. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4286. /**
  4287. * Creates a rotation matrix and stores it in a given matrix
  4288. * @param yaw defines the yaw angle in radians (Y axis)
  4289. * @param pitch defines the pitch angle in radians (X axis)
  4290. * @param roll defines the roll angle in radians (X axis)
  4291. * @param result defines the target matrix
  4292. */
  4293. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4294. /**
  4295. * Creates a scaling matrix
  4296. * @param x defines the scale factor on X axis
  4297. * @param y defines the scale factor on Y axis
  4298. * @param z defines the scale factor on Z axis
  4299. * @returns the new matrix
  4300. */
  4301. static Scaling(x: number, y: number, z: number): Matrix;
  4302. /**
  4303. * Creates a scaling matrix and stores it in a given matrix
  4304. * @param x defines the scale factor on X axis
  4305. * @param y defines the scale factor on Y axis
  4306. * @param z defines the scale factor on Z axis
  4307. * @param result defines the target matrix
  4308. */
  4309. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4310. /**
  4311. * Creates a translation matrix
  4312. * @param x defines the translation on X axis
  4313. * @param y defines the translation on Y axis
  4314. * @param z defines the translationon Z axis
  4315. * @returns the new matrix
  4316. */
  4317. static Translation(x: number, y: number, z: number): Matrix;
  4318. /**
  4319. * Creates a translation matrix and stores it in a given matrix
  4320. * @param x defines the translation on X axis
  4321. * @param y defines the translation on Y axis
  4322. * @param z defines the translationon Z axis
  4323. * @param result defines the target matrix
  4324. */
  4325. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4326. /**
  4327. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4328. * @param startValue defines the start value
  4329. * @param endValue defines the end value
  4330. * @param gradient defines the gradient factor
  4331. * @returns the new matrix
  4332. */
  4333. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4334. /**
  4335. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4336. * @param startValue defines the start value
  4337. * @param endValue defines the end value
  4338. * @param gradient defines the gradient factor
  4339. * @param result defines the Matrix object where to store data
  4340. */
  4341. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4342. /**
  4343. * Builds a new matrix whose values are computed by:
  4344. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4345. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4346. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4347. * @param startValue defines the first matrix
  4348. * @param endValue defines the second matrix
  4349. * @param gradient defines the gradient between the two matrices
  4350. * @returns the new matrix
  4351. */
  4352. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4353. /**
  4354. * Update a matrix to values which are computed by:
  4355. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4356. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4357. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4358. * @param startValue defines the first matrix
  4359. * @param endValue defines the second matrix
  4360. * @param gradient defines the gradient between the two matrices
  4361. * @param result defines the target matrix
  4362. */
  4363. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4364. /**
  4365. * 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"
  4366. * This function works in left handed mode
  4367. * @param eye defines the final position of the entity
  4368. * @param target defines where the entity should look at
  4369. * @param up defines the up vector for the entity
  4370. * @returns the new matrix
  4371. */
  4372. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4373. /**
  4374. * 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".
  4375. * This function works in left handed mode
  4376. * @param eye defines the final position of the entity
  4377. * @param target defines where the entity should look at
  4378. * @param up defines the up vector for the entity
  4379. * @param result defines the target matrix
  4380. */
  4381. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4382. /**
  4383. * 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"
  4384. * This function works in right handed mode
  4385. * @param eye defines the final position of the entity
  4386. * @param target defines where the entity should look at
  4387. * @param up defines the up vector for the entity
  4388. * @returns the new matrix
  4389. */
  4390. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4391. /**
  4392. * 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".
  4393. * This function works in right handed mode
  4394. * @param eye defines the final position of the entity
  4395. * @param target defines where the entity should look at
  4396. * @param up defines the up vector for the entity
  4397. * @param result defines the target matrix
  4398. */
  4399. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4400. /**
  4401. * Create a left-handed orthographic projection matrix
  4402. * @param width defines the viewport width
  4403. * @param height defines the viewport height
  4404. * @param znear defines the near clip plane
  4405. * @param zfar defines the far clip plane
  4406. * @returns a new matrix as a left-handed orthographic projection matrix
  4407. */
  4408. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4409. /**
  4410. * Store a left-handed orthographic projection to a given matrix
  4411. * @param width defines the viewport width
  4412. * @param height defines the viewport height
  4413. * @param znear defines the near clip plane
  4414. * @param zfar defines the far clip plane
  4415. * @param result defines the target matrix
  4416. */
  4417. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4418. /**
  4419. * Create a left-handed orthographic projection matrix
  4420. * @param left defines the viewport left coordinate
  4421. * @param right defines the viewport right coordinate
  4422. * @param bottom defines the viewport bottom coordinate
  4423. * @param top defines the viewport top coordinate
  4424. * @param znear defines the near clip plane
  4425. * @param zfar defines the far clip plane
  4426. * @returns a new matrix as a left-handed orthographic projection matrix
  4427. */
  4428. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4429. /**
  4430. * Stores a left-handed orthographic projection into a given matrix
  4431. * @param left defines the viewport left coordinate
  4432. * @param right defines the viewport right coordinate
  4433. * @param bottom defines the viewport bottom coordinate
  4434. * @param top defines the viewport top coordinate
  4435. * @param znear defines the near clip plane
  4436. * @param zfar defines the far clip plane
  4437. * @param result defines the target matrix
  4438. */
  4439. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4440. /**
  4441. * Creates a right-handed orthographic projection matrix
  4442. * @param left defines the viewport left coordinate
  4443. * @param right defines the viewport right coordinate
  4444. * @param bottom defines the viewport bottom coordinate
  4445. * @param top defines the viewport top coordinate
  4446. * @param znear defines the near clip plane
  4447. * @param zfar defines the far clip plane
  4448. * @returns a new matrix as a right-handed orthographic projection matrix
  4449. */
  4450. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4451. /**
  4452. * Stores a right-handed orthographic projection into a given matrix
  4453. * @param left defines the viewport left coordinate
  4454. * @param right defines the viewport right coordinate
  4455. * @param bottom defines the viewport bottom coordinate
  4456. * @param top defines the viewport top coordinate
  4457. * @param znear defines the near clip plane
  4458. * @param zfar defines the far clip plane
  4459. * @param result defines the target matrix
  4460. */
  4461. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4462. /**
  4463. * Creates a left-handed perspective projection matrix
  4464. * @param width defines the viewport width
  4465. * @param height defines the viewport height
  4466. * @param znear defines the near clip plane
  4467. * @param zfar defines the far clip plane
  4468. * @returns a new matrix as a left-handed perspective projection matrix
  4469. */
  4470. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4471. /**
  4472. * Creates a left-handed perspective projection matrix
  4473. * @param fov defines the horizontal field of view
  4474. * @param aspect defines the aspect ratio
  4475. * @param znear defines the near clip plane
  4476. * @param zfar defines the far clip plane
  4477. * @returns a new matrix as a left-handed perspective projection matrix
  4478. */
  4479. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4480. /**
  4481. * Stores a left-handed perspective projection into a given matrix
  4482. * @param fov defines the horizontal field of view
  4483. * @param aspect defines the aspect ratio
  4484. * @param znear defines the near clip plane
  4485. * @param zfar defines the far clip plane
  4486. * @param result defines the target matrix
  4487. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4488. */
  4489. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4490. /**
  4491. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4492. * @param fov defines the horizontal field of view
  4493. * @param aspect defines the aspect ratio
  4494. * @param znear defines the near clip plane
  4495. * @param zfar not used as infinity is used as far clip
  4496. * @param result defines the target matrix
  4497. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4498. */
  4499. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4500. /**
  4501. * Creates a right-handed perspective projection matrix
  4502. * @param fov defines the horizontal field of view
  4503. * @param aspect defines the aspect ratio
  4504. * @param znear defines the near clip plane
  4505. * @param zfar defines the far clip plane
  4506. * @returns a new matrix as a right-handed perspective projection matrix
  4507. */
  4508. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4509. /**
  4510. * Stores a right-handed perspective projection into a given matrix
  4511. * @param fov defines the horizontal field of view
  4512. * @param aspect defines the aspect ratio
  4513. * @param znear defines the near clip plane
  4514. * @param zfar defines the far clip plane
  4515. * @param result defines the target matrix
  4516. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4517. */
  4518. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4519. /**
  4520. * Stores a right-handed perspective projection into a given matrix
  4521. * @param fov defines the horizontal field of view
  4522. * @param aspect defines the aspect ratio
  4523. * @param znear defines the near clip plane
  4524. * @param zfar not used as infinity is used as far clip
  4525. * @param result defines the target matrix
  4526. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4527. */
  4528. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4529. /**
  4530. * Stores a perspective projection for WebVR info a given matrix
  4531. * @param fov defines the field of view
  4532. * @param znear defines the near clip plane
  4533. * @param zfar defines the far clip plane
  4534. * @param result defines the target matrix
  4535. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4536. */
  4537. static PerspectiveFovWebVRToRef(fov: {
  4538. upDegrees: number;
  4539. downDegrees: number;
  4540. leftDegrees: number;
  4541. rightDegrees: number;
  4542. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4543. /**
  4544. * Computes a complete transformation matrix
  4545. * @param viewport defines the viewport to use
  4546. * @param world defines the world matrix
  4547. * @param view defines the view matrix
  4548. * @param projection defines the projection matrix
  4549. * @param zmin defines the near clip plane
  4550. * @param zmax defines the far clip plane
  4551. * @returns the transformation matrix
  4552. */
  4553. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4554. /**
  4555. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4556. * @param matrix defines the matrix to use
  4557. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4558. */
  4559. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4560. /**
  4561. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4562. * @param matrix defines the matrix to use
  4563. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4564. */
  4565. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4566. /**
  4567. * Compute the transpose of a given matrix
  4568. * @param matrix defines the matrix to transpose
  4569. * @returns the new matrix
  4570. */
  4571. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4572. /**
  4573. * Compute the transpose of a matrix and store it in a target matrix
  4574. * @param matrix defines the matrix to transpose
  4575. * @param result defines the target matrix
  4576. */
  4577. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4578. /**
  4579. * Computes a reflection matrix from a plane
  4580. * @param plane defines the reflection plane
  4581. * @returns a new matrix
  4582. */
  4583. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4584. /**
  4585. * Computes a reflection matrix from a plane
  4586. * @param plane defines the reflection plane
  4587. * @param result defines the target matrix
  4588. */
  4589. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4590. /**
  4591. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4592. * @param xaxis defines the value of the 1st axis
  4593. * @param yaxis defines the value of the 2nd axis
  4594. * @param zaxis defines the value of the 3rd axis
  4595. * @param result defines the target matrix
  4596. */
  4597. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4598. /**
  4599. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4600. * @param quat defines the quaternion to use
  4601. * @param result defines the target matrix
  4602. */
  4603. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4604. }
  4605. /**
  4606. * @hidden
  4607. */
  4608. export class TmpVectors {
  4609. static Vector2: Vector2[];
  4610. static Vector3: Vector3[];
  4611. static Vector4: Vector4[];
  4612. static Quaternion: Quaternion[];
  4613. static Matrix: Matrix[];
  4614. }
  4615. }
  4616. declare module "babylonjs/Maths/math.path" {
  4617. import { DeepImmutable, Nullable } from "babylonjs/types";
  4618. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4619. /**
  4620. * Defines potential orientation for back face culling
  4621. */
  4622. export enum Orientation {
  4623. /**
  4624. * Clockwise
  4625. */
  4626. CW = 0,
  4627. /** Counter clockwise */
  4628. CCW = 1
  4629. }
  4630. /** Class used to represent a Bezier curve */
  4631. export class BezierCurve {
  4632. /**
  4633. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4634. * @param t defines the time
  4635. * @param x1 defines the left coordinate on X axis
  4636. * @param y1 defines the left coordinate on Y axis
  4637. * @param x2 defines the right coordinate on X axis
  4638. * @param y2 defines the right coordinate on Y axis
  4639. * @returns the interpolated value
  4640. */
  4641. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4642. }
  4643. /**
  4644. * Defines angle representation
  4645. */
  4646. export class Angle {
  4647. private _radians;
  4648. /**
  4649. * Creates an Angle object of "radians" radians (float).
  4650. * @param radians the angle in radians
  4651. */
  4652. constructor(radians: number);
  4653. /**
  4654. * Get value in degrees
  4655. * @returns the Angle value in degrees (float)
  4656. */
  4657. degrees(): number;
  4658. /**
  4659. * Get value in radians
  4660. * @returns the Angle value in radians (float)
  4661. */
  4662. radians(): number;
  4663. /**
  4664. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4665. * @param a defines first vector
  4666. * @param b defines second vector
  4667. * @returns a new Angle
  4668. */
  4669. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4670. /**
  4671. * Gets a new Angle object from the given float in radians
  4672. * @param radians defines the angle value in radians
  4673. * @returns a new Angle
  4674. */
  4675. static FromRadians(radians: number): Angle;
  4676. /**
  4677. * Gets a new Angle object from the given float in degrees
  4678. * @param degrees defines the angle value in degrees
  4679. * @returns a new Angle
  4680. */
  4681. static FromDegrees(degrees: number): Angle;
  4682. }
  4683. /**
  4684. * This represents an arc in a 2d space.
  4685. */
  4686. export class Arc2 {
  4687. /** Defines the start point of the arc */
  4688. startPoint: Vector2;
  4689. /** Defines the mid point of the arc */
  4690. midPoint: Vector2;
  4691. /** Defines the end point of the arc */
  4692. endPoint: Vector2;
  4693. /**
  4694. * Defines the center point of the arc.
  4695. */
  4696. centerPoint: Vector2;
  4697. /**
  4698. * Defines the radius of the arc.
  4699. */
  4700. radius: number;
  4701. /**
  4702. * Defines the angle of the arc (from mid point to end point).
  4703. */
  4704. angle: Angle;
  4705. /**
  4706. * Defines the start angle of the arc (from start point to middle point).
  4707. */
  4708. startAngle: Angle;
  4709. /**
  4710. * Defines the orientation of the arc (clock wise/counter clock wise).
  4711. */
  4712. orientation: Orientation;
  4713. /**
  4714. * Creates an Arc object from the three given points : start, middle and end.
  4715. * @param startPoint Defines the start point of the arc
  4716. * @param midPoint Defines the midlle point of the arc
  4717. * @param endPoint Defines the end point of the arc
  4718. */
  4719. constructor(
  4720. /** Defines the start point of the arc */
  4721. startPoint: Vector2,
  4722. /** Defines the mid point of the arc */
  4723. midPoint: Vector2,
  4724. /** Defines the end point of the arc */
  4725. endPoint: Vector2);
  4726. }
  4727. /**
  4728. * Represents a 2D path made up of multiple 2D points
  4729. */
  4730. export class Path2 {
  4731. private _points;
  4732. private _length;
  4733. /**
  4734. * If the path start and end point are the same
  4735. */
  4736. closed: boolean;
  4737. /**
  4738. * Creates a Path2 object from the starting 2D coordinates x and y.
  4739. * @param x the starting points x value
  4740. * @param y the starting points y value
  4741. */
  4742. constructor(x: number, y: number);
  4743. /**
  4744. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4745. * @param x the added points x value
  4746. * @param y the added points y value
  4747. * @returns the updated Path2.
  4748. */
  4749. addLineTo(x: number, y: number): Path2;
  4750. /**
  4751. * 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.
  4752. * @param midX middle point x value
  4753. * @param midY middle point y value
  4754. * @param endX end point x value
  4755. * @param endY end point y value
  4756. * @param numberOfSegments (default: 36)
  4757. * @returns the updated Path2.
  4758. */
  4759. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4760. /**
  4761. * Closes the Path2.
  4762. * @returns the Path2.
  4763. */
  4764. close(): Path2;
  4765. /**
  4766. * Gets the sum of the distance between each sequential point in the path
  4767. * @returns the Path2 total length (float).
  4768. */
  4769. length(): number;
  4770. /**
  4771. * Gets the points which construct the path
  4772. * @returns the Path2 internal array of points.
  4773. */
  4774. getPoints(): Vector2[];
  4775. /**
  4776. * Retreives the point at the distance aways from the starting point
  4777. * @param normalizedLengthPosition the length along the path to retreive the point from
  4778. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4779. */
  4780. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4781. /**
  4782. * Creates a new path starting from an x and y position
  4783. * @param x starting x value
  4784. * @param y starting y value
  4785. * @returns a new Path2 starting at the coordinates (x, y).
  4786. */
  4787. static StartingAt(x: number, y: number): Path2;
  4788. }
  4789. /**
  4790. * Represents a 3D path made up of multiple 3D points
  4791. */
  4792. export class Path3D {
  4793. /**
  4794. * an array of Vector3, the curve axis of the Path3D
  4795. */
  4796. path: Vector3[];
  4797. private _curve;
  4798. private _distances;
  4799. private _tangents;
  4800. private _normals;
  4801. private _binormals;
  4802. private _raw;
  4803. private _alignTangentsWithPath;
  4804. private readonly _pointAtData;
  4805. /**
  4806. * new Path3D(path, normal, raw)
  4807. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4808. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4809. * @param path an array of Vector3, the curve axis of the Path3D
  4810. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4811. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4812. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4813. */
  4814. constructor(
  4815. /**
  4816. * an array of Vector3, the curve axis of the Path3D
  4817. */
  4818. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4819. /**
  4820. * Returns the Path3D array of successive Vector3 designing its curve.
  4821. * @returns the Path3D array of successive Vector3 designing its curve.
  4822. */
  4823. getCurve(): Vector3[];
  4824. /**
  4825. * Returns the Path3D array of successive Vector3 designing its curve.
  4826. * @returns the Path3D array of successive Vector3 designing its curve.
  4827. */
  4828. getPoints(): Vector3[];
  4829. /**
  4830. * @returns the computed length (float) of the path.
  4831. */
  4832. length(): number;
  4833. /**
  4834. * Returns an array populated with tangent vectors on each Path3D curve point.
  4835. * @returns an array populated with tangent vectors on each Path3D curve point.
  4836. */
  4837. getTangents(): Vector3[];
  4838. /**
  4839. * Returns an array populated with normal vectors on each Path3D curve point.
  4840. * @returns an array populated with normal vectors on each Path3D curve point.
  4841. */
  4842. getNormals(): Vector3[];
  4843. /**
  4844. * Returns an array populated with binormal vectors on each Path3D curve point.
  4845. * @returns an array populated with binormal vectors on each Path3D curve point.
  4846. */
  4847. getBinormals(): Vector3[];
  4848. /**
  4849. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4850. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4851. */
  4852. getDistances(): number[];
  4853. /**
  4854. * Returns an interpolated point along this path
  4855. * @param position the position of the point along this path, from 0.0 to 1.0
  4856. * @returns a new Vector3 as the point
  4857. */
  4858. getPointAt(position: number): Vector3;
  4859. /**
  4860. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4861. * @param position the position of the point along this path, from 0.0 to 1.0
  4862. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4863. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4864. */
  4865. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4866. /**
  4867. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4868. * @param position the position of the point along this path, from 0.0 to 1.0
  4869. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4870. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4871. */
  4872. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4873. /**
  4874. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4875. * @param position the position of the point along this path, from 0.0 to 1.0
  4876. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4877. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4878. */
  4879. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4880. /**
  4881. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4882. * @param position the position of the point along this path, from 0.0 to 1.0
  4883. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4884. */
  4885. getDistanceAt(position: number): number;
  4886. /**
  4887. * Returns the array index of the previous point of an interpolated point along this path
  4888. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4889. * @returns the array index
  4890. */
  4891. getPreviousPointIndexAt(position: number): number;
  4892. /**
  4893. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  4894. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4895. * @returns the sub position
  4896. */
  4897. getSubPositionAt(position: number): number;
  4898. /**
  4899. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4900. * @param target the vector of which to get the closest position to
  4901. * @returns the position of the closest virtual point on this path to the target vector
  4902. */
  4903. getClosestPositionTo(target: Vector3): number;
  4904. /**
  4905. * Returns a sub path (slice) of this path
  4906. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4907. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4908. * @returns a sub path (slice) of this path
  4909. */
  4910. slice(start?: number, end?: number): Path3D;
  4911. /**
  4912. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4913. * @param path path which all values are copied into the curves points
  4914. * @param firstNormal which should be projected onto the curve
  4915. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4916. * @returns the same object updated.
  4917. */
  4918. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4919. private _compute;
  4920. private _getFirstNonNullVector;
  4921. private _getLastNonNullVector;
  4922. private _normalVector;
  4923. /**
  4924. * Updates the point at data for an interpolated point along this curve
  4925. * @param position the position of the point along this curve, from 0.0 to 1.0
  4926. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4927. * @returns the (updated) point at data
  4928. */
  4929. private _updatePointAtData;
  4930. /**
  4931. * Updates the point at data from the specified parameters
  4932. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4933. * @param point the interpolated point
  4934. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4935. */
  4936. private _setPointAtData;
  4937. /**
  4938. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4939. */
  4940. private _updateInterpolationMatrix;
  4941. }
  4942. /**
  4943. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4944. * A Curve3 is designed from a series of successive Vector3.
  4945. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4946. */
  4947. export class Curve3 {
  4948. private _points;
  4949. private _length;
  4950. /**
  4951. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4952. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4953. * @param v1 (Vector3) the control point
  4954. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4955. * @param nbPoints (integer) the wanted number of points in the curve
  4956. * @returns the created Curve3
  4957. */
  4958. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4959. /**
  4960. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4961. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4962. * @param v1 (Vector3) the first control point
  4963. * @param v2 (Vector3) the second control point
  4964. * @param v3 (Vector3) the end point of the Cubic Bezier
  4965. * @param nbPoints (integer) the wanted number of points in the curve
  4966. * @returns the created Curve3
  4967. */
  4968. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4969. /**
  4970. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4971. * @param p1 (Vector3) the origin point of the Hermite Spline
  4972. * @param t1 (Vector3) the tangent vector at the origin point
  4973. * @param p2 (Vector3) the end point of the Hermite Spline
  4974. * @param t2 (Vector3) the tangent vector at the end point
  4975. * @param nbPoints (integer) the wanted number of points in the curve
  4976. * @returns the created Curve3
  4977. */
  4978. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4979. /**
  4980. * Returns a Curve3 object along a CatmullRom Spline curve :
  4981. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4982. * @param nbPoints (integer) the wanted number of points between each curve control points
  4983. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4984. * @returns the created Curve3
  4985. */
  4986. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4987. /**
  4988. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4989. * A Curve3 is designed from a series of successive Vector3.
  4990. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4991. * @param points points which make up the curve
  4992. */
  4993. constructor(points: Vector3[]);
  4994. /**
  4995. * @returns the Curve3 stored array of successive Vector3
  4996. */
  4997. getPoints(): Vector3[];
  4998. /**
  4999. * @returns the computed length (float) of the curve.
  5000. */
  5001. length(): number;
  5002. /**
  5003. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5004. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5005. * curveA and curveB keep unchanged.
  5006. * @param curve the curve to continue from this curve
  5007. * @returns the newly constructed curve
  5008. */
  5009. continue(curve: DeepImmutable<Curve3>): Curve3;
  5010. private _computeLength;
  5011. }
  5012. }
  5013. declare module "babylonjs/Animations/easing" {
  5014. /**
  5015. * This represents the main contract an easing function should follow.
  5016. * Easing functions are used throughout the animation system.
  5017. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5018. */
  5019. export interface IEasingFunction {
  5020. /**
  5021. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5022. * of the easing function.
  5023. * The link below provides some of the most common examples of easing functions.
  5024. * @see https://easings.net/
  5025. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5026. * @returns the corresponding value on the curve defined by the easing function
  5027. */
  5028. ease(gradient: number): number;
  5029. }
  5030. /**
  5031. * Base class used for every default easing function.
  5032. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5033. */
  5034. export class EasingFunction implements IEasingFunction {
  5035. /**
  5036. * Interpolation follows the mathematical formula associated with the easing function.
  5037. */
  5038. static readonly EASINGMODE_EASEIN: number;
  5039. /**
  5040. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5041. */
  5042. static readonly EASINGMODE_EASEOUT: number;
  5043. /**
  5044. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5045. */
  5046. static readonly EASINGMODE_EASEINOUT: number;
  5047. private _easingMode;
  5048. /**
  5049. * Sets the easing mode of the current function.
  5050. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5051. */
  5052. setEasingMode(easingMode: number): void;
  5053. /**
  5054. * Gets the current easing mode.
  5055. * @returns the easing mode
  5056. */
  5057. getEasingMode(): number;
  5058. /**
  5059. * @hidden
  5060. */
  5061. easeInCore(gradient: number): number;
  5062. /**
  5063. * Given an input gradient between 0 and 1, this returns the corresponding value
  5064. * of the easing function.
  5065. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5066. * @returns the corresponding value on the curve defined by the easing function
  5067. */
  5068. ease(gradient: number): number;
  5069. }
  5070. /**
  5071. * Easing function with a circle shape (see link below).
  5072. * @see https://easings.net/#easeInCirc
  5073. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5074. */
  5075. export class CircleEase extends EasingFunction implements IEasingFunction {
  5076. /** @hidden */
  5077. easeInCore(gradient: number): number;
  5078. }
  5079. /**
  5080. * Easing function with a ease back shape (see link below).
  5081. * @see https://easings.net/#easeInBack
  5082. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5083. */
  5084. export class BackEase extends EasingFunction implements IEasingFunction {
  5085. /** Defines the amplitude of the function */
  5086. amplitude: number;
  5087. /**
  5088. * Instantiates a back ease easing
  5089. * @see https://easings.net/#easeInBack
  5090. * @param amplitude Defines the amplitude of the function
  5091. */
  5092. constructor(
  5093. /** Defines the amplitude of the function */
  5094. amplitude?: number);
  5095. /** @hidden */
  5096. easeInCore(gradient: number): number;
  5097. }
  5098. /**
  5099. * Easing function with a bouncing shape (see link below).
  5100. * @see https://easings.net/#easeInBounce
  5101. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5102. */
  5103. export class BounceEase extends EasingFunction implements IEasingFunction {
  5104. /** Defines the number of bounces */
  5105. bounces: number;
  5106. /** Defines the amplitude of the bounce */
  5107. bounciness: number;
  5108. /**
  5109. * Instantiates a bounce easing
  5110. * @see https://easings.net/#easeInBounce
  5111. * @param bounces Defines the number of bounces
  5112. * @param bounciness Defines the amplitude of the bounce
  5113. */
  5114. constructor(
  5115. /** Defines the number of bounces */
  5116. bounces?: number,
  5117. /** Defines the amplitude of the bounce */
  5118. bounciness?: number);
  5119. /** @hidden */
  5120. easeInCore(gradient: number): number;
  5121. }
  5122. /**
  5123. * Easing function with a power of 3 shape (see link below).
  5124. * @see https://easings.net/#easeInCubic
  5125. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5126. */
  5127. export class CubicEase extends EasingFunction implements IEasingFunction {
  5128. /** @hidden */
  5129. easeInCore(gradient: number): number;
  5130. }
  5131. /**
  5132. * Easing function with an elastic shape (see link below).
  5133. * @see https://easings.net/#easeInElastic
  5134. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5135. */
  5136. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5137. /** Defines the number of oscillations*/
  5138. oscillations: number;
  5139. /** Defines the amplitude of the oscillations*/
  5140. springiness: number;
  5141. /**
  5142. * Instantiates an elastic easing function
  5143. * @see https://easings.net/#easeInElastic
  5144. * @param oscillations Defines the number of oscillations
  5145. * @param springiness Defines the amplitude of the oscillations
  5146. */
  5147. constructor(
  5148. /** Defines the number of oscillations*/
  5149. oscillations?: number,
  5150. /** Defines the amplitude of the oscillations*/
  5151. springiness?: number);
  5152. /** @hidden */
  5153. easeInCore(gradient: number): number;
  5154. }
  5155. /**
  5156. * Easing function with an exponential shape (see link below).
  5157. * @see https://easings.net/#easeInExpo
  5158. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5159. */
  5160. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5161. /** Defines the exponent of the function */
  5162. exponent: number;
  5163. /**
  5164. * Instantiates an exponential easing function
  5165. * @see https://easings.net/#easeInExpo
  5166. * @param exponent Defines the exponent of the function
  5167. */
  5168. constructor(
  5169. /** Defines the exponent of the function */
  5170. exponent?: number);
  5171. /** @hidden */
  5172. easeInCore(gradient: number): number;
  5173. }
  5174. /**
  5175. * Easing function with a power shape (see link below).
  5176. * @see https://easings.net/#easeInQuad
  5177. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5178. */
  5179. export class PowerEase extends EasingFunction implements IEasingFunction {
  5180. /** Defines the power of the function */
  5181. power: number;
  5182. /**
  5183. * Instantiates an power base easing function
  5184. * @see https://easings.net/#easeInQuad
  5185. * @param power Defines the power of the function
  5186. */
  5187. constructor(
  5188. /** Defines the power of the function */
  5189. power?: number);
  5190. /** @hidden */
  5191. easeInCore(gradient: number): number;
  5192. }
  5193. /**
  5194. * Easing function with a power of 2 shape (see link below).
  5195. * @see https://easings.net/#easeInQuad
  5196. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5197. */
  5198. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5199. /** @hidden */
  5200. easeInCore(gradient: number): number;
  5201. }
  5202. /**
  5203. * Easing function with a power of 4 shape (see link below).
  5204. * @see https://easings.net/#easeInQuart
  5205. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5206. */
  5207. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5208. /** @hidden */
  5209. easeInCore(gradient: number): number;
  5210. }
  5211. /**
  5212. * Easing function with a power of 5 shape (see link below).
  5213. * @see https://easings.net/#easeInQuint
  5214. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5215. */
  5216. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5217. /** @hidden */
  5218. easeInCore(gradient: number): number;
  5219. }
  5220. /**
  5221. * Easing function with a sin shape (see link below).
  5222. * @see https://easings.net/#easeInSine
  5223. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5224. */
  5225. export class SineEase extends EasingFunction implements IEasingFunction {
  5226. /** @hidden */
  5227. easeInCore(gradient: number): number;
  5228. }
  5229. /**
  5230. * Easing function with a bezier shape (see link below).
  5231. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5232. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5233. */
  5234. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5235. /** Defines the x component of the start tangent in the bezier curve */
  5236. x1: number;
  5237. /** Defines the y component of the start tangent in the bezier curve */
  5238. y1: number;
  5239. /** Defines the x component of the end tangent in the bezier curve */
  5240. x2: number;
  5241. /** Defines the y component of the end tangent in the bezier curve */
  5242. y2: number;
  5243. /**
  5244. * Instantiates a bezier function
  5245. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5246. * @param x1 Defines the x component of the start tangent in the bezier curve
  5247. * @param y1 Defines the y component of the start tangent in the bezier curve
  5248. * @param x2 Defines the x component of the end tangent in the bezier curve
  5249. * @param y2 Defines the y component of the end tangent in the bezier curve
  5250. */
  5251. constructor(
  5252. /** Defines the x component of the start tangent in the bezier curve */
  5253. x1?: number,
  5254. /** Defines the y component of the start tangent in the bezier curve */
  5255. y1?: number,
  5256. /** Defines the x component of the end tangent in the bezier curve */
  5257. x2?: number,
  5258. /** Defines the y component of the end tangent in the bezier curve */
  5259. y2?: number);
  5260. /** @hidden */
  5261. easeInCore(gradient: number): number;
  5262. }
  5263. }
  5264. declare module "babylonjs/Maths/math.color" {
  5265. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5266. /**
  5267. * Class used to hold a RBG color
  5268. */
  5269. export class Color3 {
  5270. /**
  5271. * Defines the red component (between 0 and 1, default is 0)
  5272. */
  5273. r: number;
  5274. /**
  5275. * Defines the green component (between 0 and 1, default is 0)
  5276. */
  5277. g: number;
  5278. /**
  5279. * Defines the blue component (between 0 and 1, default is 0)
  5280. */
  5281. b: number;
  5282. /**
  5283. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5284. * @param r defines the red component (between 0 and 1, default is 0)
  5285. * @param g defines the green component (between 0 and 1, default is 0)
  5286. * @param b defines the blue component (between 0 and 1, default is 0)
  5287. */
  5288. constructor(
  5289. /**
  5290. * Defines the red component (between 0 and 1, default is 0)
  5291. */
  5292. r?: number,
  5293. /**
  5294. * Defines the green component (between 0 and 1, default is 0)
  5295. */
  5296. g?: number,
  5297. /**
  5298. * Defines the blue component (between 0 and 1, default is 0)
  5299. */
  5300. b?: number);
  5301. /**
  5302. * Creates a string with the Color3 current values
  5303. * @returns the string representation of the Color3 object
  5304. */
  5305. toString(): string;
  5306. /**
  5307. * Returns the string "Color3"
  5308. * @returns "Color3"
  5309. */
  5310. getClassName(): string;
  5311. /**
  5312. * Compute the Color3 hash code
  5313. * @returns an unique number that can be used to hash Color3 objects
  5314. */
  5315. getHashCode(): number;
  5316. /**
  5317. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5318. * @param array defines the array where to store the r,g,b components
  5319. * @param index defines an optional index in the target array to define where to start storing values
  5320. * @returns the current Color3 object
  5321. */
  5322. toArray(array: FloatArray, index?: number): Color3;
  5323. /**
  5324. * Returns a new Color4 object from the current Color3 and the given alpha
  5325. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5326. * @returns a new Color4 object
  5327. */
  5328. toColor4(alpha?: number): Color4;
  5329. /**
  5330. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5331. * @returns the new array
  5332. */
  5333. asArray(): number[];
  5334. /**
  5335. * Returns the luminance value
  5336. * @returns a float value
  5337. */
  5338. toLuminance(): number;
  5339. /**
  5340. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5341. * @param otherColor defines the second operand
  5342. * @returns the new Color3 object
  5343. */
  5344. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5345. /**
  5346. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5347. * @param otherColor defines the second operand
  5348. * @param result defines the Color3 object where to store the result
  5349. * @returns the current Color3
  5350. */
  5351. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5352. /**
  5353. * Determines equality between Color3 objects
  5354. * @param otherColor defines the second operand
  5355. * @returns true if the rgb values are equal to the given ones
  5356. */
  5357. equals(otherColor: DeepImmutable<Color3>): boolean;
  5358. /**
  5359. * Determines equality between the current Color3 object and a set of r,b,g values
  5360. * @param r defines the red component to check
  5361. * @param g defines the green component to check
  5362. * @param b defines the blue component to check
  5363. * @returns true if the rgb values are equal to the given ones
  5364. */
  5365. equalsFloats(r: number, g: number, b: number): boolean;
  5366. /**
  5367. * Multiplies in place each rgb value by scale
  5368. * @param scale defines the scaling factor
  5369. * @returns the updated Color3
  5370. */
  5371. scale(scale: number): Color3;
  5372. /**
  5373. * Multiplies the rgb values by scale and stores the result into "result"
  5374. * @param scale defines the scaling factor
  5375. * @param result defines the Color3 object where to store the result
  5376. * @returns the unmodified current Color3
  5377. */
  5378. scaleToRef(scale: number, result: Color3): Color3;
  5379. /**
  5380. * Scale the current Color3 values by a factor and add the result to a given Color3
  5381. * @param scale defines the scale factor
  5382. * @param result defines color to store the result into
  5383. * @returns the unmodified current Color3
  5384. */
  5385. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5386. /**
  5387. * Clamps the rgb values by the min and max values and stores the result into "result"
  5388. * @param min defines minimum clamping value (default is 0)
  5389. * @param max defines maximum clamping value (default is 1)
  5390. * @param result defines color to store the result into
  5391. * @returns the original Color3
  5392. */
  5393. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5394. /**
  5395. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5396. * @param otherColor defines the second operand
  5397. * @returns the new Color3
  5398. */
  5399. add(otherColor: DeepImmutable<Color3>): Color3;
  5400. /**
  5401. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5402. * @param otherColor defines the second operand
  5403. * @param result defines Color3 object to store the result into
  5404. * @returns the unmodified current Color3
  5405. */
  5406. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5407. /**
  5408. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5409. * @param otherColor defines the second operand
  5410. * @returns the new Color3
  5411. */
  5412. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5413. /**
  5414. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5415. * @param otherColor defines the second operand
  5416. * @param result defines Color3 object to store the result into
  5417. * @returns the unmodified current Color3
  5418. */
  5419. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5420. /**
  5421. * Copy the current object
  5422. * @returns a new Color3 copied the current one
  5423. */
  5424. clone(): Color3;
  5425. /**
  5426. * Copies the rgb values from the source in the current Color3
  5427. * @param source defines the source Color3 object
  5428. * @returns the updated Color3 object
  5429. */
  5430. copyFrom(source: DeepImmutable<Color3>): Color3;
  5431. /**
  5432. * Updates the Color3 rgb values from the given floats
  5433. * @param r defines the red component to read from
  5434. * @param g defines the green component to read from
  5435. * @param b defines the blue component to read from
  5436. * @returns the current Color3 object
  5437. */
  5438. copyFromFloats(r: number, g: number, b: number): Color3;
  5439. /**
  5440. * Updates the Color3 rgb values from the given floats
  5441. * @param r defines the red component to read from
  5442. * @param g defines the green component to read from
  5443. * @param b defines the blue component to read from
  5444. * @returns the current Color3 object
  5445. */
  5446. set(r: number, g: number, b: number): Color3;
  5447. /**
  5448. * Compute the Color3 hexadecimal code as a string
  5449. * @returns a string containing the hexadecimal representation of the Color3 object
  5450. */
  5451. toHexString(): string;
  5452. /**
  5453. * Computes a new Color3 converted from the current one to linear space
  5454. * @returns a new Color3 object
  5455. */
  5456. toLinearSpace(): Color3;
  5457. /**
  5458. * Converts current color in rgb space to HSV values
  5459. * @returns a new color3 representing the HSV values
  5460. */
  5461. toHSV(): Color3;
  5462. /**
  5463. * Converts current color in rgb space to HSV values
  5464. * @param result defines the Color3 where to store the HSV values
  5465. */
  5466. toHSVToRef(result: Color3): void;
  5467. /**
  5468. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5469. * @param convertedColor defines the Color3 object where to store the linear space version
  5470. * @returns the unmodified Color3
  5471. */
  5472. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5473. /**
  5474. * Computes a new Color3 converted from the current one to gamma space
  5475. * @returns a new Color3 object
  5476. */
  5477. toGammaSpace(): Color3;
  5478. /**
  5479. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5480. * @param convertedColor defines the Color3 object where to store the gamma space version
  5481. * @returns the unmodified Color3
  5482. */
  5483. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5484. private static _BlackReadOnly;
  5485. /**
  5486. * Convert Hue, saturation and value to a Color3 (RGB)
  5487. * @param hue defines the hue
  5488. * @param saturation defines the saturation
  5489. * @param value defines the value
  5490. * @param result defines the Color3 where to store the RGB values
  5491. */
  5492. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5493. /**
  5494. * Creates a new Color3 from the string containing valid hexadecimal values
  5495. * @param hex defines a string containing valid hexadecimal values
  5496. * @returns a new Color3 object
  5497. */
  5498. static FromHexString(hex: string): Color3;
  5499. /**
  5500. * Creates a new Color3 from the starting index of the given array
  5501. * @param array defines the source array
  5502. * @param offset defines an offset in the source array
  5503. * @returns a new Color3 object
  5504. */
  5505. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5506. /**
  5507. * Creates a new Color3 from integer values (< 256)
  5508. * @param r defines the red component to read from (value between 0 and 255)
  5509. * @param g defines the green component to read from (value between 0 and 255)
  5510. * @param b defines the blue component to read from (value between 0 and 255)
  5511. * @returns a new Color3 object
  5512. */
  5513. static FromInts(r: number, g: number, b: number): Color3;
  5514. /**
  5515. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5516. * @param start defines the start Color3 value
  5517. * @param end defines the end Color3 value
  5518. * @param amount defines the gradient value between start and end
  5519. * @returns a new Color3 object
  5520. */
  5521. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5522. /**
  5523. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5524. * @param left defines the start value
  5525. * @param right defines the end value
  5526. * @param amount defines the gradient factor
  5527. * @param result defines the Color3 object where to store the result
  5528. */
  5529. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5530. /**
  5531. * Returns a Color3 value containing a red color
  5532. * @returns a new Color3 object
  5533. */
  5534. static Red(): Color3;
  5535. /**
  5536. * Returns a Color3 value containing a green color
  5537. * @returns a new Color3 object
  5538. */
  5539. static Green(): Color3;
  5540. /**
  5541. * Returns a Color3 value containing a blue color
  5542. * @returns a new Color3 object
  5543. */
  5544. static Blue(): Color3;
  5545. /**
  5546. * Returns a Color3 value containing a black color
  5547. * @returns a new Color3 object
  5548. */
  5549. static Black(): Color3;
  5550. /**
  5551. * Gets a Color3 value containing a black color that must not be updated
  5552. */
  5553. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5554. /**
  5555. * Returns a Color3 value containing a white color
  5556. * @returns a new Color3 object
  5557. */
  5558. static White(): Color3;
  5559. /**
  5560. * Returns a Color3 value containing a purple color
  5561. * @returns a new Color3 object
  5562. */
  5563. static Purple(): Color3;
  5564. /**
  5565. * Returns a Color3 value containing a magenta color
  5566. * @returns a new Color3 object
  5567. */
  5568. static Magenta(): Color3;
  5569. /**
  5570. * Returns a Color3 value containing a yellow color
  5571. * @returns a new Color3 object
  5572. */
  5573. static Yellow(): Color3;
  5574. /**
  5575. * Returns a Color3 value containing a gray color
  5576. * @returns a new Color3 object
  5577. */
  5578. static Gray(): Color3;
  5579. /**
  5580. * Returns a Color3 value containing a teal color
  5581. * @returns a new Color3 object
  5582. */
  5583. static Teal(): Color3;
  5584. /**
  5585. * Returns a Color3 value containing a random color
  5586. * @returns a new Color3 object
  5587. */
  5588. static Random(): Color3;
  5589. }
  5590. /**
  5591. * Class used to hold a RBGA color
  5592. */
  5593. export class Color4 {
  5594. /**
  5595. * Defines the red component (between 0 and 1, default is 0)
  5596. */
  5597. r: number;
  5598. /**
  5599. * Defines the green component (between 0 and 1, default is 0)
  5600. */
  5601. g: number;
  5602. /**
  5603. * Defines the blue component (between 0 and 1, default is 0)
  5604. */
  5605. b: number;
  5606. /**
  5607. * Defines the alpha component (between 0 and 1, default is 1)
  5608. */
  5609. a: number;
  5610. /**
  5611. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5612. * @param r defines the red component (between 0 and 1, default is 0)
  5613. * @param g defines the green component (between 0 and 1, default is 0)
  5614. * @param b defines the blue component (between 0 and 1, default is 0)
  5615. * @param a defines the alpha component (between 0 and 1, default is 1)
  5616. */
  5617. constructor(
  5618. /**
  5619. * Defines the red component (between 0 and 1, default is 0)
  5620. */
  5621. r?: number,
  5622. /**
  5623. * Defines the green component (between 0 and 1, default is 0)
  5624. */
  5625. g?: number,
  5626. /**
  5627. * Defines the blue component (between 0 and 1, default is 0)
  5628. */
  5629. b?: number,
  5630. /**
  5631. * Defines the alpha component (between 0 and 1, default is 1)
  5632. */
  5633. a?: number);
  5634. /**
  5635. * Adds in place the given Color4 values to the current Color4 object
  5636. * @param right defines the second operand
  5637. * @returns the current updated Color4 object
  5638. */
  5639. addInPlace(right: DeepImmutable<Color4>): Color4;
  5640. /**
  5641. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5642. * @returns the new array
  5643. */
  5644. asArray(): number[];
  5645. /**
  5646. * Stores from the starting index in the given array the Color4 successive values
  5647. * @param array defines the array where to store the r,g,b components
  5648. * @param index defines an optional index in the target array to define where to start storing values
  5649. * @returns the current Color4 object
  5650. */
  5651. toArray(array: number[], index?: number): Color4;
  5652. /**
  5653. * Determines equality between Color4 objects
  5654. * @param otherColor defines the second operand
  5655. * @returns true if the rgba values are equal to the given ones
  5656. */
  5657. equals(otherColor: DeepImmutable<Color4>): boolean;
  5658. /**
  5659. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5660. * @param right defines the second operand
  5661. * @returns a new Color4 object
  5662. */
  5663. add(right: DeepImmutable<Color4>): Color4;
  5664. /**
  5665. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5666. * @param right defines the second operand
  5667. * @returns a new Color4 object
  5668. */
  5669. subtract(right: DeepImmutable<Color4>): Color4;
  5670. /**
  5671. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5672. * @param right defines the second operand
  5673. * @param result defines the Color4 object where to store the result
  5674. * @returns the current Color4 object
  5675. */
  5676. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5677. /**
  5678. * Creates a new Color4 with the current Color4 values multiplied by scale
  5679. * @param scale defines the scaling factor to apply
  5680. * @returns a new Color4 object
  5681. */
  5682. scale(scale: number): Color4;
  5683. /**
  5684. * Multiplies the current Color4 values by scale and stores the result in "result"
  5685. * @param scale defines the scaling factor to apply
  5686. * @param result defines the Color4 object where to store the result
  5687. * @returns the current unmodified Color4
  5688. */
  5689. scaleToRef(scale: number, result: Color4): Color4;
  5690. /**
  5691. * Scale the current Color4 values by a factor and add the result to a given Color4
  5692. * @param scale defines the scale factor
  5693. * @param result defines the Color4 object where to store the result
  5694. * @returns the unmodified current Color4
  5695. */
  5696. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5697. /**
  5698. * Clamps the rgb values by the min and max values and stores the result into "result"
  5699. * @param min defines minimum clamping value (default is 0)
  5700. * @param max defines maximum clamping value (default is 1)
  5701. * @param result defines color to store the result into.
  5702. * @returns the cuurent Color4
  5703. */
  5704. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5705. /**
  5706. * Multipy an Color4 value by another and return a new Color4 object
  5707. * @param color defines the Color4 value to multiply by
  5708. * @returns a new Color4 object
  5709. */
  5710. multiply(color: Color4): Color4;
  5711. /**
  5712. * Multipy a Color4 value by another and push the result in a reference value
  5713. * @param color defines the Color4 value to multiply by
  5714. * @param result defines the Color4 to fill the result in
  5715. * @returns the result Color4
  5716. */
  5717. multiplyToRef(color: Color4, result: Color4): Color4;
  5718. /**
  5719. * Creates a string with the Color4 current values
  5720. * @returns the string representation of the Color4 object
  5721. */
  5722. toString(): string;
  5723. /**
  5724. * Returns the string "Color4"
  5725. * @returns "Color4"
  5726. */
  5727. getClassName(): string;
  5728. /**
  5729. * Compute the Color4 hash code
  5730. * @returns an unique number that can be used to hash Color4 objects
  5731. */
  5732. getHashCode(): number;
  5733. /**
  5734. * Creates a new Color4 copied from the current one
  5735. * @returns a new Color4 object
  5736. */
  5737. clone(): Color4;
  5738. /**
  5739. * Copies the given Color4 values into the current one
  5740. * @param source defines the source Color4 object
  5741. * @returns the current updated Color4 object
  5742. */
  5743. copyFrom(source: Color4): Color4;
  5744. /**
  5745. * Copies the given float values into the current one
  5746. * @param r defines the red component to read from
  5747. * @param g defines the green component to read from
  5748. * @param b defines the blue component to read from
  5749. * @param a defines the alpha component to read from
  5750. * @returns the current updated Color4 object
  5751. */
  5752. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5753. /**
  5754. * Copies the given float values into the current one
  5755. * @param r defines the red component to read from
  5756. * @param g defines the green component to read from
  5757. * @param b defines the blue component to read from
  5758. * @param a defines the alpha component to read from
  5759. * @returns the current updated Color4 object
  5760. */
  5761. set(r: number, g: number, b: number, a: number): Color4;
  5762. /**
  5763. * Compute the Color4 hexadecimal code as a string
  5764. * @returns a string containing the hexadecimal representation of the Color4 object
  5765. */
  5766. toHexString(): string;
  5767. /**
  5768. * Computes a new Color4 converted from the current one to linear space
  5769. * @returns a new Color4 object
  5770. */
  5771. toLinearSpace(): Color4;
  5772. /**
  5773. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5774. * @param convertedColor defines the Color4 object where to store the linear space version
  5775. * @returns the unmodified Color4
  5776. */
  5777. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5778. /**
  5779. * Computes a new Color4 converted from the current one to gamma space
  5780. * @returns a new Color4 object
  5781. */
  5782. toGammaSpace(): Color4;
  5783. /**
  5784. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5785. * @param convertedColor defines the Color4 object where to store the gamma space version
  5786. * @returns the unmodified Color4
  5787. */
  5788. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5789. /**
  5790. * Creates a new Color4 from the string containing valid hexadecimal values
  5791. * @param hex defines a string containing valid hexadecimal values
  5792. * @returns a new Color4 object
  5793. */
  5794. static FromHexString(hex: string): Color4;
  5795. /**
  5796. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5797. * @param left defines the start value
  5798. * @param right defines the end value
  5799. * @param amount defines the gradient factor
  5800. * @returns a new Color4 object
  5801. */
  5802. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5803. /**
  5804. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5805. * @param left defines the start value
  5806. * @param right defines the end value
  5807. * @param amount defines the gradient factor
  5808. * @param result defines the Color4 object where to store data
  5809. */
  5810. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5811. /**
  5812. * Creates a new Color4 from a Color3 and an alpha value
  5813. * @param color3 defines the source Color3 to read from
  5814. * @param alpha defines the alpha component (1.0 by default)
  5815. * @returns a new Color4 object
  5816. */
  5817. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5818. /**
  5819. * Creates a new Color4 from the starting index element of the given array
  5820. * @param array defines the source array to read from
  5821. * @param offset defines the offset in the source array
  5822. * @returns a new Color4 object
  5823. */
  5824. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5825. /**
  5826. * Creates a new Color3 from integer values (< 256)
  5827. * @param r defines the red component to read from (value between 0 and 255)
  5828. * @param g defines the green component to read from (value between 0 and 255)
  5829. * @param b defines the blue component to read from (value between 0 and 255)
  5830. * @param a defines the alpha component to read from (value between 0 and 255)
  5831. * @returns a new Color3 object
  5832. */
  5833. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5834. /**
  5835. * Check the content of a given array and convert it to an array containing RGBA data
  5836. * If the original array was already containing count * 4 values then it is returned directly
  5837. * @param colors defines the array to check
  5838. * @param count defines the number of RGBA data to expect
  5839. * @returns an array containing count * 4 values (RGBA)
  5840. */
  5841. static CheckColors4(colors: number[], count: number): number[];
  5842. }
  5843. /**
  5844. * @hidden
  5845. */
  5846. export class TmpColors {
  5847. static Color3: Color3[];
  5848. static Color4: Color4[];
  5849. }
  5850. }
  5851. declare module "babylonjs/Animations/animationKey" {
  5852. /**
  5853. * Defines an interface which represents an animation key frame
  5854. */
  5855. export interface IAnimationKey {
  5856. /**
  5857. * Frame of the key frame
  5858. */
  5859. frame: number;
  5860. /**
  5861. * Value at the specifies key frame
  5862. */
  5863. value: any;
  5864. /**
  5865. * The input tangent for the cubic hermite spline
  5866. */
  5867. inTangent?: any;
  5868. /**
  5869. * The output tangent for the cubic hermite spline
  5870. */
  5871. outTangent?: any;
  5872. /**
  5873. * The animation interpolation type
  5874. */
  5875. interpolation?: AnimationKeyInterpolation;
  5876. }
  5877. /**
  5878. * Enum for the animation key frame interpolation type
  5879. */
  5880. export enum AnimationKeyInterpolation {
  5881. /**
  5882. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5883. */
  5884. STEP = 1
  5885. }
  5886. }
  5887. declare module "babylonjs/Animations/animationRange" {
  5888. /**
  5889. * Represents the range of an animation
  5890. */
  5891. export class AnimationRange {
  5892. /**The name of the animation range**/
  5893. name: string;
  5894. /**The starting frame of the animation */
  5895. from: number;
  5896. /**The ending frame of the animation*/
  5897. to: number;
  5898. /**
  5899. * Initializes the range of an animation
  5900. * @param name The name of the animation range
  5901. * @param from The starting frame of the animation
  5902. * @param to The ending frame of the animation
  5903. */
  5904. constructor(
  5905. /**The name of the animation range**/
  5906. name: string,
  5907. /**The starting frame of the animation */
  5908. from: number,
  5909. /**The ending frame of the animation*/
  5910. to: number);
  5911. /**
  5912. * Makes a copy of the animation range
  5913. * @returns A copy of the animation range
  5914. */
  5915. clone(): AnimationRange;
  5916. }
  5917. }
  5918. declare module "babylonjs/Animations/animationEvent" {
  5919. /**
  5920. * Composed of a frame, and an action function
  5921. */
  5922. export class AnimationEvent {
  5923. /** The frame for which the event is triggered **/
  5924. frame: number;
  5925. /** The event to perform when triggered **/
  5926. action: (currentFrame: number) => void;
  5927. /** Specifies if the event should be triggered only once**/
  5928. onlyOnce?: boolean | undefined;
  5929. /**
  5930. * Specifies if the animation event is done
  5931. */
  5932. isDone: boolean;
  5933. /**
  5934. * Initializes the animation event
  5935. * @param frame The frame for which the event is triggered
  5936. * @param action The event to perform when triggered
  5937. * @param onlyOnce Specifies if the event should be triggered only once
  5938. */
  5939. constructor(
  5940. /** The frame for which the event is triggered **/
  5941. frame: number,
  5942. /** The event to perform when triggered **/
  5943. action: (currentFrame: number) => void,
  5944. /** Specifies if the event should be triggered only once**/
  5945. onlyOnce?: boolean | undefined);
  5946. /** @hidden */
  5947. _clone(): AnimationEvent;
  5948. }
  5949. }
  5950. declare module "babylonjs/Behaviors/behavior" {
  5951. import { Nullable } from "babylonjs/types";
  5952. /**
  5953. * Interface used to define a behavior
  5954. */
  5955. export interface Behavior<T> {
  5956. /** gets or sets behavior's name */
  5957. name: string;
  5958. /**
  5959. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5960. */
  5961. init(): void;
  5962. /**
  5963. * Called when the behavior is attached to a target
  5964. * @param target defines the target where the behavior is attached to
  5965. */
  5966. attach(target: T): void;
  5967. /**
  5968. * Called when the behavior is detached from its target
  5969. */
  5970. detach(): void;
  5971. }
  5972. /**
  5973. * Interface implemented by classes supporting behaviors
  5974. */
  5975. export interface IBehaviorAware<T> {
  5976. /**
  5977. * Attach a behavior
  5978. * @param behavior defines the behavior to attach
  5979. * @returns the current host
  5980. */
  5981. addBehavior(behavior: Behavior<T>): T;
  5982. /**
  5983. * Remove a behavior from the current object
  5984. * @param behavior defines the behavior to detach
  5985. * @returns the current host
  5986. */
  5987. removeBehavior(behavior: Behavior<T>): T;
  5988. /**
  5989. * Gets a behavior using its name to search
  5990. * @param name defines the name to search
  5991. * @returns the behavior or null if not found
  5992. */
  5993. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5994. }
  5995. }
  5996. declare module "babylonjs/Misc/smartArray" {
  5997. /**
  5998. * Defines an array and its length.
  5999. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6000. */
  6001. export interface ISmartArrayLike<T> {
  6002. /**
  6003. * The data of the array.
  6004. */
  6005. data: Array<T>;
  6006. /**
  6007. * The active length of the array.
  6008. */
  6009. length: number;
  6010. }
  6011. /**
  6012. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6013. */
  6014. export class SmartArray<T> implements ISmartArrayLike<T> {
  6015. /**
  6016. * The full set of data from the array.
  6017. */
  6018. data: Array<T>;
  6019. /**
  6020. * The active length of the array.
  6021. */
  6022. length: number;
  6023. protected _id: number;
  6024. /**
  6025. * Instantiates a Smart Array.
  6026. * @param capacity defines the default capacity of the array.
  6027. */
  6028. constructor(capacity: number);
  6029. /**
  6030. * Pushes a value at the end of the active data.
  6031. * @param value defines the object to push in the array.
  6032. */
  6033. push(value: T): void;
  6034. /**
  6035. * Iterates over the active data and apply the lambda to them.
  6036. * @param func defines the action to apply on each value.
  6037. */
  6038. forEach(func: (content: T) => void): void;
  6039. /**
  6040. * Sorts the full sets of data.
  6041. * @param compareFn defines the comparison function to apply.
  6042. */
  6043. sort(compareFn: (a: T, b: T) => number): void;
  6044. /**
  6045. * Resets the active data to an empty array.
  6046. */
  6047. reset(): void;
  6048. /**
  6049. * Releases all the data from the array as well as the array.
  6050. */
  6051. dispose(): void;
  6052. /**
  6053. * Concats the active data with a given array.
  6054. * @param array defines the data to concatenate with.
  6055. */
  6056. concat(array: any): void;
  6057. /**
  6058. * Returns the position of a value in the active data.
  6059. * @param value defines the value to find the index for
  6060. * @returns the index if found in the active data otherwise -1
  6061. */
  6062. indexOf(value: T): number;
  6063. /**
  6064. * Returns whether an element is part of the active data.
  6065. * @param value defines the value to look for
  6066. * @returns true if found in the active data otherwise false
  6067. */
  6068. contains(value: T): boolean;
  6069. private static _GlobalId;
  6070. }
  6071. /**
  6072. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6073. * The data in this array can only be present once
  6074. */
  6075. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6076. private _duplicateId;
  6077. /**
  6078. * Pushes a value at the end of the active data.
  6079. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6080. * @param value defines the object to push in the array.
  6081. */
  6082. push(value: T): void;
  6083. /**
  6084. * Pushes a value at the end of the active data.
  6085. * If the data is already present, it won t be added again
  6086. * @param value defines the object to push in the array.
  6087. * @returns true if added false if it was already present
  6088. */
  6089. pushNoDuplicate(value: T): boolean;
  6090. /**
  6091. * Resets the active data to an empty array.
  6092. */
  6093. reset(): void;
  6094. /**
  6095. * Concats the active data with a given array.
  6096. * This ensures no dupplicate will be present in the result.
  6097. * @param array defines the data to concatenate with.
  6098. */
  6099. concatWithNoDuplicate(array: any): void;
  6100. }
  6101. }
  6102. declare module "babylonjs/Cameras/cameraInputsManager" {
  6103. import { Nullable } from "babylonjs/types";
  6104. import { Camera } from "babylonjs/Cameras/camera";
  6105. /**
  6106. * @ignore
  6107. * This is a list of all the different input types that are available in the application.
  6108. * Fo instance: ArcRotateCameraGamepadInput...
  6109. */
  6110. export var CameraInputTypes: {};
  6111. /**
  6112. * This is the contract to implement in order to create a new input class.
  6113. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6114. */
  6115. export interface ICameraInput<TCamera extends Camera> {
  6116. /**
  6117. * Defines the camera the input is attached to.
  6118. */
  6119. camera: Nullable<TCamera>;
  6120. /**
  6121. * Gets the class name of the current intput.
  6122. * @returns the class name
  6123. */
  6124. getClassName(): string;
  6125. /**
  6126. * Get the friendly name associated with the input class.
  6127. * @returns the input friendly name
  6128. */
  6129. getSimpleName(): string;
  6130. /**
  6131. * Attach the input controls to a specific dom element to get the input from.
  6132. * @param element Defines the element the controls should be listened from
  6133. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6134. */
  6135. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6136. /**
  6137. * Detach the current controls from the specified dom element.
  6138. * @param element Defines the element to stop listening the inputs from
  6139. */
  6140. detachControl(element: Nullable<HTMLElement>): void;
  6141. /**
  6142. * Update the current camera state depending on the inputs that have been used this frame.
  6143. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6144. */
  6145. checkInputs?: () => void;
  6146. }
  6147. /**
  6148. * Represents a map of input types to input instance or input index to input instance.
  6149. */
  6150. export interface CameraInputsMap<TCamera extends Camera> {
  6151. /**
  6152. * Accessor to the input by input type.
  6153. */
  6154. [name: string]: ICameraInput<TCamera>;
  6155. /**
  6156. * Accessor to the input by input index.
  6157. */
  6158. [idx: number]: ICameraInput<TCamera>;
  6159. }
  6160. /**
  6161. * This represents the input manager used within a camera.
  6162. * It helps dealing with all the different kind of input attached to a camera.
  6163. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6164. */
  6165. export class CameraInputsManager<TCamera extends Camera> {
  6166. /**
  6167. * Defines the list of inputs attahed to the camera.
  6168. */
  6169. attached: CameraInputsMap<TCamera>;
  6170. /**
  6171. * Defines the dom element the camera is collecting inputs from.
  6172. * This is null if the controls have not been attached.
  6173. */
  6174. attachedElement: Nullable<HTMLElement>;
  6175. /**
  6176. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6177. */
  6178. noPreventDefault: boolean;
  6179. /**
  6180. * Defined the camera the input manager belongs to.
  6181. */
  6182. camera: TCamera;
  6183. /**
  6184. * Update the current camera state depending on the inputs that have been used this frame.
  6185. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6186. */
  6187. checkInputs: () => void;
  6188. /**
  6189. * Instantiate a new Camera Input Manager.
  6190. * @param camera Defines the camera the input manager blongs to
  6191. */
  6192. constructor(camera: TCamera);
  6193. /**
  6194. * Add an input method to a camera
  6195. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6196. * @param input camera input method
  6197. */
  6198. add(input: ICameraInput<TCamera>): void;
  6199. /**
  6200. * Remove a specific input method from a camera
  6201. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6202. * @param inputToRemove camera input method
  6203. */
  6204. remove(inputToRemove: ICameraInput<TCamera>): void;
  6205. /**
  6206. * Remove a specific input type from a camera
  6207. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6208. * @param inputType the type of the input to remove
  6209. */
  6210. removeByType(inputType: string): void;
  6211. private _addCheckInputs;
  6212. /**
  6213. * Attach the input controls to the currently attached dom element to listen the events from.
  6214. * @param input Defines the input to attach
  6215. */
  6216. attachInput(input: ICameraInput<TCamera>): void;
  6217. /**
  6218. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6219. * @param element Defines the dom element to collect the events from
  6220. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6221. */
  6222. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6223. /**
  6224. * Detach the current manager inputs controls from a specific dom element.
  6225. * @param element Defines the dom element to collect the events from
  6226. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6227. */
  6228. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6229. /**
  6230. * Rebuild the dynamic inputCheck function from the current list of
  6231. * defined inputs in the manager.
  6232. */
  6233. rebuildInputCheck(): void;
  6234. /**
  6235. * Remove all attached input methods from a camera
  6236. */
  6237. clear(): void;
  6238. /**
  6239. * Serialize the current input manager attached to a camera.
  6240. * This ensures than once parsed,
  6241. * the input associated to the camera will be identical to the current ones
  6242. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6243. */
  6244. serialize(serializedCamera: any): void;
  6245. /**
  6246. * Parses an input manager serialized JSON to restore the previous list of inputs
  6247. * and states associated to a camera.
  6248. * @param parsedCamera Defines the JSON to parse
  6249. */
  6250. parse(parsedCamera: any): void;
  6251. }
  6252. }
  6253. declare module "babylonjs/Meshes/buffer" {
  6254. import { Nullable, DataArray } from "babylonjs/types";
  6255. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6256. /**
  6257. * Class used to store data that will be store in GPU memory
  6258. */
  6259. export class Buffer {
  6260. private _engine;
  6261. private _buffer;
  6262. /** @hidden */
  6263. _data: Nullable<DataArray>;
  6264. private _updatable;
  6265. private _instanced;
  6266. private _divisor;
  6267. /**
  6268. * Gets the byte stride.
  6269. */
  6270. readonly byteStride: number;
  6271. /**
  6272. * Constructor
  6273. * @param engine the engine
  6274. * @param data the data to use for this buffer
  6275. * @param updatable whether the data is updatable
  6276. * @param stride the stride (optional)
  6277. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6278. * @param instanced whether the buffer is instanced (optional)
  6279. * @param useBytes set to true if the stride in in bytes (optional)
  6280. * @param divisor sets an optional divisor for instances (1 by default)
  6281. */
  6282. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6283. /**
  6284. * Create a new VertexBuffer based on the current buffer
  6285. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6286. * @param offset defines offset in the buffer (0 by default)
  6287. * @param size defines the size in floats of attributes (position is 3 for instance)
  6288. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6289. * @param instanced defines if the vertex buffer contains indexed data
  6290. * @param useBytes defines if the offset and stride are in bytes *
  6291. * @param divisor sets an optional divisor for instances (1 by default)
  6292. * @returns the new vertex buffer
  6293. */
  6294. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6295. /**
  6296. * Gets a boolean indicating if the Buffer is updatable?
  6297. * @returns true if the buffer is updatable
  6298. */
  6299. isUpdatable(): boolean;
  6300. /**
  6301. * Gets current buffer's data
  6302. * @returns a DataArray or null
  6303. */
  6304. getData(): Nullable<DataArray>;
  6305. /**
  6306. * Gets underlying native buffer
  6307. * @returns underlying native buffer
  6308. */
  6309. getBuffer(): Nullable<DataBuffer>;
  6310. /**
  6311. * Gets the stride in float32 units (i.e. byte stride / 4).
  6312. * May not be an integer if the byte stride is not divisible by 4.
  6313. * @returns the stride in float32 units
  6314. * @deprecated Please use byteStride instead.
  6315. */
  6316. getStrideSize(): number;
  6317. /**
  6318. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6319. * @param data defines the data to store
  6320. */
  6321. create(data?: Nullable<DataArray>): void;
  6322. /** @hidden */
  6323. _rebuild(): void;
  6324. /**
  6325. * Update current buffer data
  6326. * @param data defines the data to store
  6327. */
  6328. update(data: DataArray): void;
  6329. /**
  6330. * Updates the data directly.
  6331. * @param data the new data
  6332. * @param offset the new offset
  6333. * @param vertexCount the vertex count (optional)
  6334. * @param useBytes set to true if the offset is in bytes
  6335. */
  6336. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6337. /**
  6338. * Release all resources
  6339. */
  6340. dispose(): void;
  6341. }
  6342. /**
  6343. * Specialized buffer used to store vertex data
  6344. */
  6345. export class VertexBuffer {
  6346. /** @hidden */
  6347. _buffer: Buffer;
  6348. private _kind;
  6349. private _size;
  6350. private _ownsBuffer;
  6351. private _instanced;
  6352. private _instanceDivisor;
  6353. /**
  6354. * The byte type.
  6355. */
  6356. static readonly BYTE: number;
  6357. /**
  6358. * The unsigned byte type.
  6359. */
  6360. static readonly UNSIGNED_BYTE: number;
  6361. /**
  6362. * The short type.
  6363. */
  6364. static readonly SHORT: number;
  6365. /**
  6366. * The unsigned short type.
  6367. */
  6368. static readonly UNSIGNED_SHORT: number;
  6369. /**
  6370. * The integer type.
  6371. */
  6372. static readonly INT: number;
  6373. /**
  6374. * The unsigned integer type.
  6375. */
  6376. static readonly UNSIGNED_INT: number;
  6377. /**
  6378. * The float type.
  6379. */
  6380. static readonly FLOAT: number;
  6381. /**
  6382. * Gets or sets the instance divisor when in instanced mode
  6383. */
  6384. instanceDivisor: number;
  6385. /**
  6386. * Gets the byte stride.
  6387. */
  6388. readonly byteStride: number;
  6389. /**
  6390. * Gets the byte offset.
  6391. */
  6392. readonly byteOffset: number;
  6393. /**
  6394. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6395. */
  6396. readonly normalized: boolean;
  6397. /**
  6398. * Gets the data type of each component in the array.
  6399. */
  6400. readonly type: number;
  6401. /**
  6402. * Constructor
  6403. * @param engine the engine
  6404. * @param data the data to use for this vertex buffer
  6405. * @param kind the vertex buffer kind
  6406. * @param updatable whether the data is updatable
  6407. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6408. * @param stride the stride (optional)
  6409. * @param instanced whether the buffer is instanced (optional)
  6410. * @param offset the offset of the data (optional)
  6411. * @param size the number of components (optional)
  6412. * @param type the type of the component (optional)
  6413. * @param normalized whether the data contains normalized data (optional)
  6414. * @param useBytes set to true if stride and offset are in bytes (optional)
  6415. * @param divisor defines the instance divisor to use (1 by default)
  6416. */
  6417. 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, divisor?: number);
  6418. /** @hidden */
  6419. _rebuild(): void;
  6420. /**
  6421. * Returns the kind of the VertexBuffer (string)
  6422. * @returns a string
  6423. */
  6424. getKind(): string;
  6425. /**
  6426. * Gets a boolean indicating if the VertexBuffer is updatable?
  6427. * @returns true if the buffer is updatable
  6428. */
  6429. isUpdatable(): boolean;
  6430. /**
  6431. * Gets current buffer's data
  6432. * @returns a DataArray or null
  6433. */
  6434. getData(): Nullable<DataArray>;
  6435. /**
  6436. * Gets underlying native buffer
  6437. * @returns underlying native buffer
  6438. */
  6439. getBuffer(): Nullable<DataBuffer>;
  6440. /**
  6441. * Gets the stride in float32 units (i.e. byte stride / 4).
  6442. * May not be an integer if the byte stride is not divisible by 4.
  6443. * @returns the stride in float32 units
  6444. * @deprecated Please use byteStride instead.
  6445. */
  6446. getStrideSize(): number;
  6447. /**
  6448. * Returns the offset as a multiple of the type byte length.
  6449. * @returns the offset in bytes
  6450. * @deprecated Please use byteOffset instead.
  6451. */
  6452. getOffset(): number;
  6453. /**
  6454. * Returns the number of components per vertex attribute (integer)
  6455. * @returns the size in float
  6456. */
  6457. getSize(): number;
  6458. /**
  6459. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6460. * @returns true if this buffer is instanced
  6461. */
  6462. getIsInstanced(): boolean;
  6463. /**
  6464. * Returns the instancing divisor, zero for non-instanced (integer).
  6465. * @returns a number
  6466. */
  6467. getInstanceDivisor(): number;
  6468. /**
  6469. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6470. * @param data defines the data to store
  6471. */
  6472. create(data?: DataArray): void;
  6473. /**
  6474. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6475. * This function will create a new buffer if the current one is not updatable
  6476. * @param data defines the data to store
  6477. */
  6478. update(data: DataArray): void;
  6479. /**
  6480. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6481. * Returns the directly updated WebGLBuffer.
  6482. * @param data the new data
  6483. * @param offset the new offset
  6484. * @param useBytes set to true if the offset is in bytes
  6485. */
  6486. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6487. /**
  6488. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6489. */
  6490. dispose(): void;
  6491. /**
  6492. * Enumerates each value of this vertex buffer as numbers.
  6493. * @param count the number of values to enumerate
  6494. * @param callback the callback function called for each value
  6495. */
  6496. forEach(count: number, callback: (value: number, index: number) => void): void;
  6497. /**
  6498. * Positions
  6499. */
  6500. static readonly PositionKind: string;
  6501. /**
  6502. * Normals
  6503. */
  6504. static readonly NormalKind: string;
  6505. /**
  6506. * Tangents
  6507. */
  6508. static readonly TangentKind: string;
  6509. /**
  6510. * Texture coordinates
  6511. */
  6512. static readonly UVKind: string;
  6513. /**
  6514. * Texture coordinates 2
  6515. */
  6516. static readonly UV2Kind: string;
  6517. /**
  6518. * Texture coordinates 3
  6519. */
  6520. static readonly UV3Kind: string;
  6521. /**
  6522. * Texture coordinates 4
  6523. */
  6524. static readonly UV4Kind: string;
  6525. /**
  6526. * Texture coordinates 5
  6527. */
  6528. static readonly UV5Kind: string;
  6529. /**
  6530. * Texture coordinates 6
  6531. */
  6532. static readonly UV6Kind: string;
  6533. /**
  6534. * Colors
  6535. */
  6536. static readonly ColorKind: string;
  6537. /**
  6538. * Matrix indices (for bones)
  6539. */
  6540. static readonly MatricesIndicesKind: string;
  6541. /**
  6542. * Matrix weights (for bones)
  6543. */
  6544. static readonly MatricesWeightsKind: string;
  6545. /**
  6546. * Additional matrix indices (for bones)
  6547. */
  6548. static readonly MatricesIndicesExtraKind: string;
  6549. /**
  6550. * Additional matrix weights (for bones)
  6551. */
  6552. static readonly MatricesWeightsExtraKind: string;
  6553. /**
  6554. * Deduces the stride given a kind.
  6555. * @param kind The kind string to deduce
  6556. * @returns The deduced stride
  6557. */
  6558. static DeduceStride(kind: string): number;
  6559. /**
  6560. * Gets the byte length of the given type.
  6561. * @param type the type
  6562. * @returns the number of bytes
  6563. */
  6564. static GetTypeByteLength(type: number): number;
  6565. /**
  6566. * Enumerates each value of the given parameters as numbers.
  6567. * @param data the data to enumerate
  6568. * @param byteOffset the byte offset of the data
  6569. * @param byteStride the byte stride of the data
  6570. * @param componentCount the number of components per element
  6571. * @param componentType the type of the component
  6572. * @param count the number of values to enumerate
  6573. * @param normalized whether the data is normalized
  6574. * @param callback the callback function called for each value
  6575. */
  6576. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6577. private static _GetFloatValue;
  6578. }
  6579. }
  6580. declare module "babylonjs/Collisions/intersectionInfo" {
  6581. import { Nullable } from "babylonjs/types";
  6582. /**
  6583. * @hidden
  6584. */
  6585. export class IntersectionInfo {
  6586. bu: Nullable<number>;
  6587. bv: Nullable<number>;
  6588. distance: number;
  6589. faceId: number;
  6590. subMeshId: number;
  6591. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6592. }
  6593. }
  6594. declare module "babylonjs/Maths/math.plane" {
  6595. import { DeepImmutable } from "babylonjs/types";
  6596. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6597. /**
  6598. * Represens a plane by the equation ax + by + cz + d = 0
  6599. */
  6600. export class Plane {
  6601. private static _TmpMatrix;
  6602. /**
  6603. * Normal of the plane (a,b,c)
  6604. */
  6605. normal: Vector3;
  6606. /**
  6607. * d component of the plane
  6608. */
  6609. d: number;
  6610. /**
  6611. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6612. * @param a a component of the plane
  6613. * @param b b component of the plane
  6614. * @param c c component of the plane
  6615. * @param d d component of the plane
  6616. */
  6617. constructor(a: number, b: number, c: number, d: number);
  6618. /**
  6619. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6620. */
  6621. asArray(): number[];
  6622. /**
  6623. * @returns a new plane copied from the current Plane.
  6624. */
  6625. clone(): Plane;
  6626. /**
  6627. * @returns the string "Plane".
  6628. */
  6629. getClassName(): string;
  6630. /**
  6631. * @returns the Plane hash code.
  6632. */
  6633. getHashCode(): number;
  6634. /**
  6635. * Normalize the current Plane in place.
  6636. * @returns the updated Plane.
  6637. */
  6638. normalize(): Plane;
  6639. /**
  6640. * Applies a transformation the plane and returns the result
  6641. * @param transformation the transformation matrix to be applied to the plane
  6642. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6643. */
  6644. transform(transformation: DeepImmutable<Matrix>): Plane;
  6645. /**
  6646. * Calcualtte the dot product between the point and the plane normal
  6647. * @param point point to calculate the dot product with
  6648. * @returns the dot product (float) of the point coordinates and the plane normal.
  6649. */
  6650. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6651. /**
  6652. * Updates the current Plane from the plane defined by the three given points.
  6653. * @param point1 one of the points used to contruct the plane
  6654. * @param point2 one of the points used to contruct the plane
  6655. * @param point3 one of the points used to contruct the plane
  6656. * @returns the updated Plane.
  6657. */
  6658. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6659. /**
  6660. * Checks if the plane is facing a given direction
  6661. * @param direction the direction to check if the plane is facing
  6662. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6663. * @returns True is the vector "direction" is the same side than the plane normal.
  6664. */
  6665. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6666. /**
  6667. * Calculates the distance to a point
  6668. * @param point point to calculate distance to
  6669. * @returns the signed distance (float) from the given point to the Plane.
  6670. */
  6671. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6672. /**
  6673. * Creates a plane from an array
  6674. * @param array the array to create a plane from
  6675. * @returns a new Plane from the given array.
  6676. */
  6677. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6678. /**
  6679. * Creates a plane from three points
  6680. * @param point1 point used to create the plane
  6681. * @param point2 point used to create the plane
  6682. * @param point3 point used to create the plane
  6683. * @returns a new Plane defined by the three given points.
  6684. */
  6685. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6686. /**
  6687. * Creates a plane from an origin point and a normal
  6688. * @param origin origin of the plane to be constructed
  6689. * @param normal normal of the plane to be constructed
  6690. * @returns a new Plane the normal vector to this plane at the given origin point.
  6691. * Note : the vector "normal" is updated because normalized.
  6692. */
  6693. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6694. /**
  6695. * Calculates the distance from a plane and a point
  6696. * @param origin origin of the plane to be constructed
  6697. * @param normal normal of the plane to be constructed
  6698. * @param point point to calculate distance to
  6699. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6700. */
  6701. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6702. }
  6703. }
  6704. declare module "babylonjs/Culling/boundingSphere" {
  6705. import { DeepImmutable } from "babylonjs/types";
  6706. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6707. import { Plane } from "babylonjs/Maths/math.plane";
  6708. /**
  6709. * Class used to store bounding sphere information
  6710. */
  6711. export class BoundingSphere {
  6712. /**
  6713. * Gets the center of the bounding sphere in local space
  6714. */
  6715. readonly center: Vector3;
  6716. /**
  6717. * Radius of the bounding sphere in local space
  6718. */
  6719. radius: number;
  6720. /**
  6721. * Gets the center of the bounding sphere in world space
  6722. */
  6723. readonly centerWorld: Vector3;
  6724. /**
  6725. * Radius of the bounding sphere in world space
  6726. */
  6727. radiusWorld: number;
  6728. /**
  6729. * Gets the minimum vector in local space
  6730. */
  6731. readonly minimum: Vector3;
  6732. /**
  6733. * Gets the maximum vector in local space
  6734. */
  6735. readonly maximum: Vector3;
  6736. private _worldMatrix;
  6737. private static readonly TmpVector3;
  6738. /**
  6739. * Creates a new bounding sphere
  6740. * @param min defines the minimum vector (in local space)
  6741. * @param max defines the maximum vector (in local space)
  6742. * @param worldMatrix defines the new world matrix
  6743. */
  6744. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6745. /**
  6746. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6747. * @param min defines the new minimum vector (in local space)
  6748. * @param max defines the new maximum vector (in local space)
  6749. * @param worldMatrix defines the new world matrix
  6750. */
  6751. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6752. /**
  6753. * Scale the current bounding sphere by applying a scale factor
  6754. * @param factor defines the scale factor to apply
  6755. * @returns the current bounding box
  6756. */
  6757. scale(factor: number): BoundingSphere;
  6758. /**
  6759. * Gets the world matrix of the bounding box
  6760. * @returns a matrix
  6761. */
  6762. getWorldMatrix(): DeepImmutable<Matrix>;
  6763. /** @hidden */
  6764. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6765. /**
  6766. * Tests if the bounding sphere is intersecting the frustum planes
  6767. * @param frustumPlanes defines the frustum planes to test
  6768. * @returns true if there is an intersection
  6769. */
  6770. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6771. /**
  6772. * Tests if the bounding sphere center is in between the frustum planes.
  6773. * Used for optimistic fast inclusion.
  6774. * @param frustumPlanes defines the frustum planes to test
  6775. * @returns true if the sphere center is in between the frustum planes
  6776. */
  6777. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6778. /**
  6779. * Tests if a point is inside the bounding sphere
  6780. * @param point defines the point to test
  6781. * @returns true if the point is inside the bounding sphere
  6782. */
  6783. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6784. /**
  6785. * Checks if two sphere intersct
  6786. * @param sphere0 sphere 0
  6787. * @param sphere1 sphere 1
  6788. * @returns true if the speres intersect
  6789. */
  6790. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6791. }
  6792. }
  6793. declare module "babylonjs/Culling/boundingBox" {
  6794. import { DeepImmutable } from "babylonjs/types";
  6795. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6796. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6797. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6798. import { Plane } from "babylonjs/Maths/math.plane";
  6799. /**
  6800. * Class used to store bounding box information
  6801. */
  6802. export class BoundingBox implements ICullable {
  6803. /**
  6804. * Gets the 8 vectors representing the bounding box in local space
  6805. */
  6806. readonly vectors: Vector3[];
  6807. /**
  6808. * Gets the center of the bounding box in local space
  6809. */
  6810. readonly center: Vector3;
  6811. /**
  6812. * Gets the center of the bounding box in world space
  6813. */
  6814. readonly centerWorld: Vector3;
  6815. /**
  6816. * Gets the extend size in local space
  6817. */
  6818. readonly extendSize: Vector3;
  6819. /**
  6820. * Gets the extend size in world space
  6821. */
  6822. readonly extendSizeWorld: Vector3;
  6823. /**
  6824. * Gets the OBB (object bounding box) directions
  6825. */
  6826. readonly directions: Vector3[];
  6827. /**
  6828. * Gets the 8 vectors representing the bounding box in world space
  6829. */
  6830. readonly vectorsWorld: Vector3[];
  6831. /**
  6832. * Gets the minimum vector in world space
  6833. */
  6834. readonly minimumWorld: Vector3;
  6835. /**
  6836. * Gets the maximum vector in world space
  6837. */
  6838. readonly maximumWorld: Vector3;
  6839. /**
  6840. * Gets the minimum vector in local space
  6841. */
  6842. readonly minimum: Vector3;
  6843. /**
  6844. * Gets the maximum vector in local space
  6845. */
  6846. readonly maximum: Vector3;
  6847. private _worldMatrix;
  6848. private static readonly TmpVector3;
  6849. /**
  6850. * @hidden
  6851. */
  6852. _tag: number;
  6853. /**
  6854. * Creates a new bounding box
  6855. * @param min defines the minimum vector (in local space)
  6856. * @param max defines the maximum vector (in local space)
  6857. * @param worldMatrix defines the new world matrix
  6858. */
  6859. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6860. /**
  6861. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6862. * @param min defines the new minimum vector (in local space)
  6863. * @param max defines the new maximum vector (in local space)
  6864. * @param worldMatrix defines the new world matrix
  6865. */
  6866. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6867. /**
  6868. * Scale the current bounding box by applying a scale factor
  6869. * @param factor defines the scale factor to apply
  6870. * @returns the current bounding box
  6871. */
  6872. scale(factor: number): BoundingBox;
  6873. /**
  6874. * Gets the world matrix of the bounding box
  6875. * @returns a matrix
  6876. */
  6877. getWorldMatrix(): DeepImmutable<Matrix>;
  6878. /** @hidden */
  6879. _update(world: DeepImmutable<Matrix>): void;
  6880. /**
  6881. * Tests if the bounding box is intersecting the frustum planes
  6882. * @param frustumPlanes defines the frustum planes to test
  6883. * @returns true if there is an intersection
  6884. */
  6885. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6886. /**
  6887. * Tests if the bounding box is entirely inside the frustum planes
  6888. * @param frustumPlanes defines the frustum planes to test
  6889. * @returns true if there is an inclusion
  6890. */
  6891. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6892. /**
  6893. * Tests if a point is inside the bounding box
  6894. * @param point defines the point to test
  6895. * @returns true if the point is inside the bounding box
  6896. */
  6897. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6898. /**
  6899. * Tests if the bounding box intersects with a bounding sphere
  6900. * @param sphere defines the sphere to test
  6901. * @returns true if there is an intersection
  6902. */
  6903. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6904. /**
  6905. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6906. * @param min defines the min vector to use
  6907. * @param max defines the max vector to use
  6908. * @returns true if there is an intersection
  6909. */
  6910. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6911. /**
  6912. * Tests if two bounding boxes are intersections
  6913. * @param box0 defines the first box to test
  6914. * @param box1 defines the second box to test
  6915. * @returns true if there is an intersection
  6916. */
  6917. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6918. /**
  6919. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6920. * @param minPoint defines the minimum vector of the bounding box
  6921. * @param maxPoint defines the maximum vector of the bounding box
  6922. * @param sphereCenter defines the sphere center
  6923. * @param sphereRadius defines the sphere radius
  6924. * @returns true if there is an intersection
  6925. */
  6926. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6927. /**
  6928. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6929. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6930. * @param frustumPlanes defines the frustum planes to test
  6931. * @return true if there is an inclusion
  6932. */
  6933. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6934. /**
  6935. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6936. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6937. * @param frustumPlanes defines the frustum planes to test
  6938. * @return true if there is an intersection
  6939. */
  6940. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6941. }
  6942. }
  6943. declare module "babylonjs/Collisions/collider" {
  6944. import { Nullable, IndicesArray } from "babylonjs/types";
  6945. import { Vector3 } from "babylonjs/Maths/math.vector";
  6946. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  6947. import { Plane } from "babylonjs/Maths/math.plane";
  6948. /** @hidden */
  6949. export class Collider {
  6950. /** Define if a collision was found */
  6951. collisionFound: boolean;
  6952. /**
  6953. * Define last intersection point in local space
  6954. */
  6955. intersectionPoint: Vector3;
  6956. /**
  6957. * Define last collided mesh
  6958. */
  6959. collidedMesh: Nullable<AbstractMesh>;
  6960. private _collisionPoint;
  6961. private _planeIntersectionPoint;
  6962. private _tempVector;
  6963. private _tempVector2;
  6964. private _tempVector3;
  6965. private _tempVector4;
  6966. private _edge;
  6967. private _baseToVertex;
  6968. private _destinationPoint;
  6969. private _slidePlaneNormal;
  6970. private _displacementVector;
  6971. /** @hidden */
  6972. _radius: Vector3;
  6973. /** @hidden */
  6974. _retry: number;
  6975. private _velocity;
  6976. private _basePoint;
  6977. private _epsilon;
  6978. /** @hidden */
  6979. _velocityWorldLength: number;
  6980. /** @hidden */
  6981. _basePointWorld: Vector3;
  6982. private _velocityWorld;
  6983. private _normalizedVelocity;
  6984. /** @hidden */
  6985. _initialVelocity: Vector3;
  6986. /** @hidden */
  6987. _initialPosition: Vector3;
  6988. private _nearestDistance;
  6989. private _collisionMask;
  6990. collisionMask: number;
  6991. /**
  6992. * Gets the plane normal used to compute the sliding response (in local space)
  6993. */
  6994. readonly slidePlaneNormal: Vector3;
  6995. /** @hidden */
  6996. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6997. /** @hidden */
  6998. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6999. /** @hidden */
  7000. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7001. /** @hidden */
  7002. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7003. /** @hidden */
  7004. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7005. /** @hidden */
  7006. _getResponse(pos: Vector3, vel: Vector3): void;
  7007. }
  7008. }
  7009. declare module "babylonjs/Culling/boundingInfo" {
  7010. import { DeepImmutable } from "babylonjs/types";
  7011. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7012. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7013. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7014. import { Plane } from "babylonjs/Maths/math.plane";
  7015. import { Collider } from "babylonjs/Collisions/collider";
  7016. /**
  7017. * Interface for cullable objects
  7018. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7019. */
  7020. export interface ICullable {
  7021. /**
  7022. * Checks if the object or part of the object is in the frustum
  7023. * @param frustumPlanes Camera near/planes
  7024. * @returns true if the object is in frustum otherwise false
  7025. */
  7026. isInFrustum(frustumPlanes: Plane[]): boolean;
  7027. /**
  7028. * Checks if a cullable object (mesh...) is in the camera frustum
  7029. * Unlike isInFrustum this cheks the full bounding box
  7030. * @param frustumPlanes Camera near/planes
  7031. * @returns true if the object is in frustum otherwise false
  7032. */
  7033. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7034. }
  7035. /**
  7036. * Info for a bounding data of a mesh
  7037. */
  7038. export class BoundingInfo implements ICullable {
  7039. /**
  7040. * Bounding box for the mesh
  7041. */
  7042. readonly boundingBox: BoundingBox;
  7043. /**
  7044. * Bounding sphere for the mesh
  7045. */
  7046. readonly boundingSphere: BoundingSphere;
  7047. private _isLocked;
  7048. private static readonly TmpVector3;
  7049. /**
  7050. * Constructs bounding info
  7051. * @param minimum min vector of the bounding box/sphere
  7052. * @param maximum max vector of the bounding box/sphere
  7053. * @param worldMatrix defines the new world matrix
  7054. */
  7055. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7056. /**
  7057. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7058. * @param min defines the new minimum vector (in local space)
  7059. * @param max defines the new maximum vector (in local space)
  7060. * @param worldMatrix defines the new world matrix
  7061. */
  7062. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7063. /**
  7064. * min vector of the bounding box/sphere
  7065. */
  7066. readonly minimum: Vector3;
  7067. /**
  7068. * max vector of the bounding box/sphere
  7069. */
  7070. readonly maximum: Vector3;
  7071. /**
  7072. * If the info is locked and won't be updated to avoid perf overhead
  7073. */
  7074. isLocked: boolean;
  7075. /**
  7076. * Updates the bounding sphere and box
  7077. * @param world world matrix to be used to update
  7078. */
  7079. update(world: DeepImmutable<Matrix>): void;
  7080. /**
  7081. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7082. * @param center New center of the bounding info
  7083. * @param extend New extend of the bounding info
  7084. * @returns the current bounding info
  7085. */
  7086. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7087. /**
  7088. * Scale the current bounding info by applying a scale factor
  7089. * @param factor defines the scale factor to apply
  7090. * @returns the current bounding info
  7091. */
  7092. scale(factor: number): BoundingInfo;
  7093. /**
  7094. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7095. * @param frustumPlanes defines the frustum to test
  7096. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7097. * @returns true if the bounding info is in the frustum planes
  7098. */
  7099. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7100. /**
  7101. * Gets the world distance between the min and max points of the bounding box
  7102. */
  7103. readonly diagonalLength: number;
  7104. /**
  7105. * Checks if a cullable object (mesh...) is in the camera frustum
  7106. * Unlike isInFrustum this cheks the full bounding box
  7107. * @param frustumPlanes Camera near/planes
  7108. * @returns true if the object is in frustum otherwise false
  7109. */
  7110. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7111. /** @hidden */
  7112. _checkCollision(collider: Collider): boolean;
  7113. /**
  7114. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7115. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7116. * @param point the point to check intersection with
  7117. * @returns if the point intersects
  7118. */
  7119. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7120. /**
  7121. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7122. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7123. * @param boundingInfo the bounding info to check intersection with
  7124. * @param precise if the intersection should be done using OBB
  7125. * @returns if the bounding info intersects
  7126. */
  7127. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7128. }
  7129. }
  7130. declare module "babylonjs/Maths/math.functions" {
  7131. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7132. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7133. /**
  7134. * Extracts minimum and maximum values from a list of indexed positions
  7135. * @param positions defines the positions to use
  7136. * @param indices defines the indices to the positions
  7137. * @param indexStart defines the start index
  7138. * @param indexCount defines the end index
  7139. * @param bias defines bias value to add to the result
  7140. * @return minimum and maximum values
  7141. */
  7142. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7143. minimum: Vector3;
  7144. maximum: Vector3;
  7145. };
  7146. /**
  7147. * Extracts minimum and maximum values from a list of positions
  7148. * @param positions defines the positions to use
  7149. * @param start defines the start index in the positions array
  7150. * @param count defines the number of positions to handle
  7151. * @param bias defines bias value to add to the result
  7152. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7153. * @return minimum and maximum values
  7154. */
  7155. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7156. minimum: Vector3;
  7157. maximum: Vector3;
  7158. };
  7159. }
  7160. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7161. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7162. /** @hidden */
  7163. export class WebGLDataBuffer extends DataBuffer {
  7164. private _buffer;
  7165. constructor(resource: WebGLBuffer);
  7166. readonly underlyingResource: any;
  7167. }
  7168. }
  7169. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7170. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7171. import { Nullable } from "babylonjs/types";
  7172. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7173. /** @hidden */
  7174. export class WebGLPipelineContext implements IPipelineContext {
  7175. engine: ThinEngine;
  7176. program: Nullable<WebGLProgram>;
  7177. context?: WebGLRenderingContext;
  7178. vertexShader?: WebGLShader;
  7179. fragmentShader?: WebGLShader;
  7180. isParallelCompiled: boolean;
  7181. onCompiled?: () => void;
  7182. transformFeedback?: WebGLTransformFeedback | null;
  7183. readonly isAsync: boolean;
  7184. readonly isReady: boolean;
  7185. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7186. }
  7187. }
  7188. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7189. import { FloatArray, Nullable } from "babylonjs/types";
  7190. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7191. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7192. module "babylonjs/Engines/thinEngine" {
  7193. interface ThinEngine {
  7194. /**
  7195. * Create an uniform buffer
  7196. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7197. * @param elements defines the content of the uniform buffer
  7198. * @returns the webGL uniform buffer
  7199. */
  7200. createUniformBuffer(elements: FloatArray): DataBuffer;
  7201. /**
  7202. * Create a dynamic uniform buffer
  7203. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7204. * @param elements defines the content of the uniform buffer
  7205. * @returns the webGL uniform buffer
  7206. */
  7207. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7208. /**
  7209. * Update an existing uniform buffer
  7210. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7211. * @param uniformBuffer defines the target uniform buffer
  7212. * @param elements defines the content to update
  7213. * @param offset defines the offset in the uniform buffer where update should start
  7214. * @param count defines the size of the data to update
  7215. */
  7216. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7217. /**
  7218. * Bind an uniform buffer to the current webGL context
  7219. * @param buffer defines the buffer to bind
  7220. */
  7221. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7222. /**
  7223. * Bind a buffer to the current webGL context at a given location
  7224. * @param buffer defines the buffer to bind
  7225. * @param location defines the index where to bind the buffer
  7226. */
  7227. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7228. /**
  7229. * Bind a specific block at a given index in a specific shader program
  7230. * @param pipelineContext defines the pipeline context to use
  7231. * @param blockName defines the block name
  7232. * @param index defines the index where to bind the block
  7233. */
  7234. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7235. }
  7236. }
  7237. }
  7238. declare module "babylonjs/Materials/uniformBuffer" {
  7239. import { Nullable, FloatArray } from "babylonjs/types";
  7240. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7241. import { Engine } from "babylonjs/Engines/engine";
  7242. import { Effect } from "babylonjs/Materials/effect";
  7243. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7244. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7245. import { Color3 } from "babylonjs/Maths/math.color";
  7246. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7247. /**
  7248. * Uniform buffer objects.
  7249. *
  7250. * Handles blocks of uniform on the GPU.
  7251. *
  7252. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7253. *
  7254. * For more information, please refer to :
  7255. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7256. */
  7257. export class UniformBuffer {
  7258. private _engine;
  7259. private _buffer;
  7260. private _data;
  7261. private _bufferData;
  7262. private _dynamic?;
  7263. private _uniformLocations;
  7264. private _uniformSizes;
  7265. private _uniformLocationPointer;
  7266. private _needSync;
  7267. private _noUBO;
  7268. private _currentEffect;
  7269. /** @hidden */
  7270. _alreadyBound: boolean;
  7271. private static _MAX_UNIFORM_SIZE;
  7272. private static _tempBuffer;
  7273. /**
  7274. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7275. * This is dynamic to allow compat with webgl 1 and 2.
  7276. * You will need to pass the name of the uniform as well as the value.
  7277. */
  7278. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7279. /**
  7280. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7281. * This is dynamic to allow compat with webgl 1 and 2.
  7282. * You will need to pass the name of the uniform as well as the value.
  7283. */
  7284. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7285. /**
  7286. * Lambda to Update a single float in a uniform buffer.
  7287. * This is dynamic to allow compat with webgl 1 and 2.
  7288. * You will need to pass the name of the uniform as well as the value.
  7289. */
  7290. updateFloat: (name: string, x: number) => void;
  7291. /**
  7292. * Lambda to Update a vec2 of float in a uniform buffer.
  7293. * This is dynamic to allow compat with webgl 1 and 2.
  7294. * You will need to pass the name of the uniform as well as the value.
  7295. */
  7296. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7297. /**
  7298. * Lambda to Update a vec3 of float in a uniform buffer.
  7299. * This is dynamic to allow compat with webgl 1 and 2.
  7300. * You will need to pass the name of the uniform as well as the value.
  7301. */
  7302. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7303. /**
  7304. * Lambda to Update a vec4 of float in a uniform buffer.
  7305. * This is dynamic to allow compat with webgl 1 and 2.
  7306. * You will need to pass the name of the uniform as well as the value.
  7307. */
  7308. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7309. /**
  7310. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7311. * This is dynamic to allow compat with webgl 1 and 2.
  7312. * You will need to pass the name of the uniform as well as the value.
  7313. */
  7314. updateMatrix: (name: string, mat: Matrix) => void;
  7315. /**
  7316. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7317. * This is dynamic to allow compat with webgl 1 and 2.
  7318. * You will need to pass the name of the uniform as well as the value.
  7319. */
  7320. updateVector3: (name: string, vector: Vector3) => void;
  7321. /**
  7322. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7323. * This is dynamic to allow compat with webgl 1 and 2.
  7324. * You will need to pass the name of the uniform as well as the value.
  7325. */
  7326. updateVector4: (name: string, vector: Vector4) => void;
  7327. /**
  7328. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7329. * This is dynamic to allow compat with webgl 1 and 2.
  7330. * You will need to pass the name of the uniform as well as the value.
  7331. */
  7332. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7333. /**
  7334. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7335. * This is dynamic to allow compat with webgl 1 and 2.
  7336. * You will need to pass the name of the uniform as well as the value.
  7337. */
  7338. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7339. /**
  7340. * Instantiates a new Uniform buffer objects.
  7341. *
  7342. * Handles blocks of uniform on the GPU.
  7343. *
  7344. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7345. *
  7346. * For more information, please refer to :
  7347. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7348. * @param engine Define the engine the buffer is associated with
  7349. * @param data Define the data contained in the buffer
  7350. * @param dynamic Define if the buffer is updatable
  7351. */
  7352. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7353. /**
  7354. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7355. * or just falling back on setUniformXXX calls.
  7356. */
  7357. readonly useUbo: boolean;
  7358. /**
  7359. * Indicates if the WebGL underlying uniform buffer is in sync
  7360. * with the javascript cache data.
  7361. */
  7362. readonly isSync: boolean;
  7363. /**
  7364. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7365. * Also, a dynamic UniformBuffer will disable cache verification and always
  7366. * update the underlying WebGL uniform buffer to the GPU.
  7367. * @returns if Dynamic, otherwise false
  7368. */
  7369. isDynamic(): boolean;
  7370. /**
  7371. * The data cache on JS side.
  7372. * @returns the underlying data as a float array
  7373. */
  7374. getData(): Float32Array;
  7375. /**
  7376. * The underlying WebGL Uniform buffer.
  7377. * @returns the webgl buffer
  7378. */
  7379. getBuffer(): Nullable<DataBuffer>;
  7380. /**
  7381. * std140 layout specifies how to align data within an UBO structure.
  7382. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7383. * for specs.
  7384. */
  7385. private _fillAlignment;
  7386. /**
  7387. * Adds an uniform in the buffer.
  7388. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7389. * for the layout to be correct !
  7390. * @param name Name of the uniform, as used in the uniform block in the shader.
  7391. * @param size Data size, or data directly.
  7392. */
  7393. addUniform(name: string, size: number | number[]): void;
  7394. /**
  7395. * Adds a Matrix 4x4 to the uniform buffer.
  7396. * @param name Name of the uniform, as used in the uniform block in the shader.
  7397. * @param mat A 4x4 matrix.
  7398. */
  7399. addMatrix(name: string, mat: Matrix): void;
  7400. /**
  7401. * Adds a vec2 to the uniform buffer.
  7402. * @param name Name of the uniform, as used in the uniform block in the shader.
  7403. * @param x Define the x component value of the vec2
  7404. * @param y Define the y component value of the vec2
  7405. */
  7406. addFloat2(name: string, x: number, y: number): void;
  7407. /**
  7408. * Adds a vec3 to the uniform buffer.
  7409. * @param name Name of the uniform, as used in the uniform block in the shader.
  7410. * @param x Define the x component value of the vec3
  7411. * @param y Define the y component value of the vec3
  7412. * @param z Define the z component value of the vec3
  7413. */
  7414. addFloat3(name: string, x: number, y: number, z: number): void;
  7415. /**
  7416. * Adds a vec3 to the uniform buffer.
  7417. * @param name Name of the uniform, as used in the uniform block in the shader.
  7418. * @param color Define the vec3 from a Color
  7419. */
  7420. addColor3(name: string, color: Color3): void;
  7421. /**
  7422. * Adds a vec4 to the uniform buffer.
  7423. * @param name Name of the uniform, as used in the uniform block in the shader.
  7424. * @param color Define the rgb components from a Color
  7425. * @param alpha Define the a component of the vec4
  7426. */
  7427. addColor4(name: string, color: Color3, alpha: number): void;
  7428. /**
  7429. * Adds a vec3 to the uniform buffer.
  7430. * @param name Name of the uniform, as used in the uniform block in the shader.
  7431. * @param vector Define the vec3 components from a Vector
  7432. */
  7433. addVector3(name: string, vector: Vector3): void;
  7434. /**
  7435. * Adds a Matrix 3x3 to the uniform buffer.
  7436. * @param name Name of the uniform, as used in the uniform block in the shader.
  7437. */
  7438. addMatrix3x3(name: string): void;
  7439. /**
  7440. * Adds a Matrix 2x2 to the uniform buffer.
  7441. * @param name Name of the uniform, as used in the uniform block in the shader.
  7442. */
  7443. addMatrix2x2(name: string): void;
  7444. /**
  7445. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7446. */
  7447. create(): void;
  7448. /** @hidden */
  7449. _rebuild(): void;
  7450. /**
  7451. * Updates the WebGL Uniform Buffer on the GPU.
  7452. * If the `dynamic` flag is set to true, no cache comparison is done.
  7453. * Otherwise, the buffer will be updated only if the cache differs.
  7454. */
  7455. update(): void;
  7456. /**
  7457. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7458. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7459. * @param data Define the flattened data
  7460. * @param size Define the size of the data.
  7461. */
  7462. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7463. private _valueCache;
  7464. private _cacheMatrix;
  7465. private _updateMatrix3x3ForUniform;
  7466. private _updateMatrix3x3ForEffect;
  7467. private _updateMatrix2x2ForEffect;
  7468. private _updateMatrix2x2ForUniform;
  7469. private _updateFloatForEffect;
  7470. private _updateFloatForUniform;
  7471. private _updateFloat2ForEffect;
  7472. private _updateFloat2ForUniform;
  7473. private _updateFloat3ForEffect;
  7474. private _updateFloat3ForUniform;
  7475. private _updateFloat4ForEffect;
  7476. private _updateFloat4ForUniform;
  7477. private _updateMatrixForEffect;
  7478. private _updateMatrixForUniform;
  7479. private _updateVector3ForEffect;
  7480. private _updateVector3ForUniform;
  7481. private _updateVector4ForEffect;
  7482. private _updateVector4ForUniform;
  7483. private _updateColor3ForEffect;
  7484. private _updateColor3ForUniform;
  7485. private _updateColor4ForEffect;
  7486. private _updateColor4ForUniform;
  7487. /**
  7488. * Sets a sampler uniform on the effect.
  7489. * @param name Define the name of the sampler.
  7490. * @param texture Define the texture to set in the sampler
  7491. */
  7492. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7493. /**
  7494. * Directly updates the value of the uniform in the cache AND on the GPU.
  7495. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7496. * @param data Define the flattened data
  7497. */
  7498. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7499. /**
  7500. * Binds this uniform buffer to an effect.
  7501. * @param effect Define the effect to bind the buffer to
  7502. * @param name Name of the uniform block in the shader.
  7503. */
  7504. bindToEffect(effect: Effect, name: string): void;
  7505. /**
  7506. * Disposes the uniform buffer.
  7507. */
  7508. dispose(): void;
  7509. }
  7510. }
  7511. declare module "babylonjs/Misc/iInspectable" {
  7512. /**
  7513. * Enum that determines the text-wrapping mode to use.
  7514. */
  7515. export enum InspectableType {
  7516. /**
  7517. * Checkbox for booleans
  7518. */
  7519. Checkbox = 0,
  7520. /**
  7521. * Sliders for numbers
  7522. */
  7523. Slider = 1,
  7524. /**
  7525. * Vector3
  7526. */
  7527. Vector3 = 2,
  7528. /**
  7529. * Quaternions
  7530. */
  7531. Quaternion = 3,
  7532. /**
  7533. * Color3
  7534. */
  7535. Color3 = 4,
  7536. /**
  7537. * String
  7538. */
  7539. String = 5
  7540. }
  7541. /**
  7542. * Interface used to define custom inspectable properties.
  7543. * This interface is used by the inspector to display custom property grids
  7544. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7545. */
  7546. export interface IInspectable {
  7547. /**
  7548. * Gets the label to display
  7549. */
  7550. label: string;
  7551. /**
  7552. * Gets the name of the property to edit
  7553. */
  7554. propertyName: string;
  7555. /**
  7556. * Gets the type of the editor to use
  7557. */
  7558. type: InspectableType;
  7559. /**
  7560. * Gets the minimum value of the property when using in "slider" mode
  7561. */
  7562. min?: number;
  7563. /**
  7564. * Gets the maximum value of the property when using in "slider" mode
  7565. */
  7566. max?: number;
  7567. /**
  7568. * Gets the setp to use when using in "slider" mode
  7569. */
  7570. step?: number;
  7571. }
  7572. }
  7573. declare module "babylonjs/Misc/timingTools" {
  7574. /**
  7575. * Class used to provide helper for timing
  7576. */
  7577. export class TimingTools {
  7578. /**
  7579. * Polyfill for setImmediate
  7580. * @param action defines the action to execute after the current execution block
  7581. */
  7582. static SetImmediate(action: () => void): void;
  7583. }
  7584. }
  7585. declare module "babylonjs/Misc/instantiationTools" {
  7586. /**
  7587. * Class used to enable instatition of objects by class name
  7588. */
  7589. export class InstantiationTools {
  7590. /**
  7591. * Use this object to register external classes like custom textures or material
  7592. * to allow the laoders to instantiate them
  7593. */
  7594. static RegisteredExternalClasses: {
  7595. [key: string]: Object;
  7596. };
  7597. /**
  7598. * Tries to instantiate a new object from a given class name
  7599. * @param className defines the class name to instantiate
  7600. * @returns the new object or null if the system was not able to do the instantiation
  7601. */
  7602. static Instantiate(className: string): any;
  7603. }
  7604. }
  7605. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7606. /**
  7607. * Define options used to create a depth texture
  7608. */
  7609. export class DepthTextureCreationOptions {
  7610. /** Specifies whether or not a stencil should be allocated in the texture */
  7611. generateStencil?: boolean;
  7612. /** Specifies whether or not bilinear filtering is enable on the texture */
  7613. bilinearFiltering?: boolean;
  7614. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7615. comparisonFunction?: number;
  7616. /** Specifies if the created texture is a cube texture */
  7617. isCube?: boolean;
  7618. }
  7619. }
  7620. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7621. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7622. import { Nullable } from "babylonjs/types";
  7623. import { Scene } from "babylonjs/scene";
  7624. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7625. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7626. module "babylonjs/Engines/thinEngine" {
  7627. interface ThinEngine {
  7628. /**
  7629. * Creates a depth stencil cube texture.
  7630. * This is only available in WebGL 2.
  7631. * @param size The size of face edge in the cube texture.
  7632. * @param options The options defining the cube texture.
  7633. * @returns The cube texture
  7634. */
  7635. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7636. /**
  7637. * Creates a cube texture
  7638. * @param rootUrl defines the url where the files to load is located
  7639. * @param scene defines the current scene
  7640. * @param files defines the list of files to load (1 per face)
  7641. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7642. * @param onLoad defines an optional callback raised when the texture is loaded
  7643. * @param onError defines an optional callback raised if there is an issue to load the texture
  7644. * @param format defines the format of the data
  7645. * @param forcedExtension defines the extension to use to pick the right loader
  7646. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7647. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7648. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7649. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7650. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7651. * @returns the cube texture as an InternalTexture
  7652. */
  7653. 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;
  7654. /**
  7655. * Creates a cube texture
  7656. * @param rootUrl defines the url where the files to load is located
  7657. * @param scene defines the current scene
  7658. * @param files defines the list of files to load (1 per face)
  7659. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7660. * @param onLoad defines an optional callback raised when the texture is loaded
  7661. * @param onError defines an optional callback raised if there is an issue to load the texture
  7662. * @param format defines the format of the data
  7663. * @param forcedExtension defines the extension to use to pick the right loader
  7664. * @returns the cube texture as an InternalTexture
  7665. */
  7666. 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;
  7667. /**
  7668. * Creates a cube texture
  7669. * @param rootUrl defines the url where the files to load is located
  7670. * @param scene defines the current scene
  7671. * @param files defines the list of files to load (1 per face)
  7672. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7673. * @param onLoad defines an optional callback raised when the texture is loaded
  7674. * @param onError defines an optional callback raised if there is an issue to load the texture
  7675. * @param format defines the format of the data
  7676. * @param forcedExtension defines the extension to use to pick the right loader
  7677. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7678. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7679. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7680. * @returns the cube texture as an InternalTexture
  7681. */
  7682. 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;
  7683. /** @hidden */
  7684. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7685. /** @hidden */
  7686. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7687. /** @hidden */
  7688. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7689. /** @hidden */
  7690. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7691. /**
  7692. * @hidden
  7693. */
  7694. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7695. }
  7696. }
  7697. }
  7698. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7699. import { Nullable } from "babylonjs/types";
  7700. import { Scene } from "babylonjs/scene";
  7701. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7702. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7703. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7704. /**
  7705. * Class for creating a cube texture
  7706. */
  7707. export class CubeTexture extends BaseTexture {
  7708. private _delayedOnLoad;
  7709. /**
  7710. * The url of the texture
  7711. */
  7712. url: string;
  7713. /**
  7714. * Gets or sets the center of the bounding box associated with the cube texture.
  7715. * It must define where the camera used to render the texture was set
  7716. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7717. */
  7718. boundingBoxPosition: Vector3;
  7719. private _boundingBoxSize;
  7720. /**
  7721. * Gets or sets the size of the bounding box associated with the cube texture
  7722. * When defined, the cubemap will switch to local mode
  7723. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7724. * @example https://www.babylonjs-playground.com/#RNASML
  7725. */
  7726. /**
  7727. * Returns the bounding box size
  7728. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7729. */
  7730. boundingBoxSize: Vector3;
  7731. protected _rotationY: number;
  7732. /**
  7733. * Sets texture matrix rotation angle around Y axis in radians.
  7734. */
  7735. /**
  7736. * Gets texture matrix rotation angle around Y axis radians.
  7737. */
  7738. rotationY: number;
  7739. /**
  7740. * Are mip maps generated for this texture or not.
  7741. */
  7742. readonly noMipmap: boolean;
  7743. private _noMipmap;
  7744. private _files;
  7745. protected _forcedExtension: Nullable<string>;
  7746. private _extensions;
  7747. private _textureMatrix;
  7748. private _format;
  7749. private _createPolynomials;
  7750. /** @hidden */
  7751. _prefiltered: boolean;
  7752. /**
  7753. * Creates a cube texture from an array of image urls
  7754. * @param files defines an array of image urls
  7755. * @param scene defines the hosting scene
  7756. * @param noMipmap specifies if mip maps are not used
  7757. * @returns a cube texture
  7758. */
  7759. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7760. /**
  7761. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7762. * @param url defines the url of the prefiltered texture
  7763. * @param scene defines the scene the texture is attached to
  7764. * @param forcedExtension defines the extension of the file if different from the url
  7765. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7766. * @return the prefiltered texture
  7767. */
  7768. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7769. /**
  7770. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7771. * as prefiltered data.
  7772. * @param rootUrl defines the url of the texture or the root name of the six images
  7773. * @param scene defines the scene the texture is attached to
  7774. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7775. * @param noMipmap defines if mipmaps should be created or not
  7776. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7777. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7778. * @param onError defines a callback triggered in case of error during load
  7779. * @param format defines the internal format to use for the texture once loaded
  7780. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7781. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7782. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7783. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7784. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7785. * @return the cube texture
  7786. */
  7787. 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);
  7788. /**
  7789. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7790. */
  7791. readonly isPrefiltered: boolean;
  7792. /**
  7793. * Get the current class name of the texture useful for serialization or dynamic coding.
  7794. * @returns "CubeTexture"
  7795. */
  7796. getClassName(): string;
  7797. /**
  7798. * Update the url (and optional buffer) of this texture if url was null during construction.
  7799. * @param url the url of the texture
  7800. * @param forcedExtension defines the extension to use
  7801. * @param onLoad callback called when the texture is loaded (defaults to null)
  7802. */
  7803. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7804. /**
  7805. * Delays loading of the cube texture
  7806. * @param forcedExtension defines the extension to use
  7807. */
  7808. delayLoad(forcedExtension?: string): void;
  7809. /**
  7810. * Returns the reflection texture matrix
  7811. * @returns the reflection texture matrix
  7812. */
  7813. getReflectionTextureMatrix(): Matrix;
  7814. /**
  7815. * Sets the reflection texture matrix
  7816. * @param value Reflection texture matrix
  7817. */
  7818. setReflectionTextureMatrix(value: Matrix): void;
  7819. /**
  7820. * Parses text to create a cube texture
  7821. * @param parsedTexture define the serialized text to read from
  7822. * @param scene defines the hosting scene
  7823. * @param rootUrl defines the root url of the cube texture
  7824. * @returns a cube texture
  7825. */
  7826. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7827. /**
  7828. * Makes a clone, or deep copy, of the cube texture
  7829. * @returns a new cube texture
  7830. */
  7831. clone(): CubeTexture;
  7832. }
  7833. }
  7834. declare module "babylonjs/Materials/materialDefines" {
  7835. /**
  7836. * Manages the defines for the Material
  7837. */
  7838. export class MaterialDefines {
  7839. /** @hidden */
  7840. protected _keys: string[];
  7841. private _isDirty;
  7842. /** @hidden */
  7843. _renderId: number;
  7844. /** @hidden */
  7845. _areLightsDirty: boolean;
  7846. /** @hidden */
  7847. _areLightsDisposed: boolean;
  7848. /** @hidden */
  7849. _areAttributesDirty: boolean;
  7850. /** @hidden */
  7851. _areTexturesDirty: boolean;
  7852. /** @hidden */
  7853. _areFresnelDirty: boolean;
  7854. /** @hidden */
  7855. _areMiscDirty: boolean;
  7856. /** @hidden */
  7857. _areImageProcessingDirty: boolean;
  7858. /** @hidden */
  7859. _normals: boolean;
  7860. /** @hidden */
  7861. _uvs: boolean;
  7862. /** @hidden */
  7863. _needNormals: boolean;
  7864. /** @hidden */
  7865. _needUVs: boolean;
  7866. [id: string]: any;
  7867. /**
  7868. * Specifies if the material needs to be re-calculated
  7869. */
  7870. readonly isDirty: boolean;
  7871. /**
  7872. * Marks the material to indicate that it has been re-calculated
  7873. */
  7874. markAsProcessed(): void;
  7875. /**
  7876. * Marks the material to indicate that it needs to be re-calculated
  7877. */
  7878. markAsUnprocessed(): void;
  7879. /**
  7880. * Marks the material to indicate all of its defines need to be re-calculated
  7881. */
  7882. markAllAsDirty(): void;
  7883. /**
  7884. * Marks the material to indicate that image processing needs to be re-calculated
  7885. */
  7886. markAsImageProcessingDirty(): void;
  7887. /**
  7888. * Marks the material to indicate the lights need to be re-calculated
  7889. * @param disposed Defines whether the light is dirty due to dispose or not
  7890. */
  7891. markAsLightDirty(disposed?: boolean): void;
  7892. /**
  7893. * Marks the attribute state as changed
  7894. */
  7895. markAsAttributesDirty(): void;
  7896. /**
  7897. * Marks the texture state as changed
  7898. */
  7899. markAsTexturesDirty(): void;
  7900. /**
  7901. * Marks the fresnel state as changed
  7902. */
  7903. markAsFresnelDirty(): void;
  7904. /**
  7905. * Marks the misc state as changed
  7906. */
  7907. markAsMiscDirty(): void;
  7908. /**
  7909. * Rebuilds the material defines
  7910. */
  7911. rebuild(): void;
  7912. /**
  7913. * Specifies if two material defines are equal
  7914. * @param other - A material define instance to compare to
  7915. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7916. */
  7917. isEqual(other: MaterialDefines): boolean;
  7918. /**
  7919. * Clones this instance's defines to another instance
  7920. * @param other - material defines to clone values to
  7921. */
  7922. cloneTo(other: MaterialDefines): void;
  7923. /**
  7924. * Resets the material define values
  7925. */
  7926. reset(): void;
  7927. /**
  7928. * Converts the material define values to a string
  7929. * @returns - String of material define information
  7930. */
  7931. toString(): string;
  7932. }
  7933. }
  7934. declare module "babylonjs/Materials/colorCurves" {
  7935. import { Effect } from "babylonjs/Materials/effect";
  7936. /**
  7937. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7938. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7939. * 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;
  7940. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7941. */
  7942. export class ColorCurves {
  7943. private _dirty;
  7944. private _tempColor;
  7945. private _globalCurve;
  7946. private _highlightsCurve;
  7947. private _midtonesCurve;
  7948. private _shadowsCurve;
  7949. private _positiveCurve;
  7950. private _negativeCurve;
  7951. private _globalHue;
  7952. private _globalDensity;
  7953. private _globalSaturation;
  7954. private _globalExposure;
  7955. /**
  7956. * Gets the global Hue value.
  7957. * 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).
  7958. */
  7959. /**
  7960. * Sets the global Hue value.
  7961. * 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).
  7962. */
  7963. globalHue: number;
  7964. /**
  7965. * Gets the global Density value.
  7966. * 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.
  7967. * Values less than zero provide a filter of opposite hue.
  7968. */
  7969. /**
  7970. * Sets the global Density value.
  7971. * 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.
  7972. * Values less than zero provide a filter of opposite hue.
  7973. */
  7974. globalDensity: number;
  7975. /**
  7976. * Gets the global Saturation value.
  7977. * 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.
  7978. */
  7979. /**
  7980. * Sets the global Saturation value.
  7981. * 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.
  7982. */
  7983. globalSaturation: number;
  7984. /**
  7985. * Gets the global Exposure value.
  7986. * 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.
  7987. */
  7988. /**
  7989. * Sets the global Exposure value.
  7990. * 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.
  7991. */
  7992. globalExposure: number;
  7993. private _highlightsHue;
  7994. private _highlightsDensity;
  7995. private _highlightsSaturation;
  7996. private _highlightsExposure;
  7997. /**
  7998. * Gets the highlights Hue value.
  7999. * 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).
  8000. */
  8001. /**
  8002. * Sets the highlights Hue value.
  8003. * 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).
  8004. */
  8005. highlightsHue: number;
  8006. /**
  8007. * Gets the highlights Density value.
  8008. * 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.
  8009. * Values less than zero provide a filter of opposite hue.
  8010. */
  8011. /**
  8012. * Sets the highlights Density value.
  8013. * 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.
  8014. * Values less than zero provide a filter of opposite hue.
  8015. */
  8016. highlightsDensity: number;
  8017. /**
  8018. * Gets the highlights Saturation value.
  8019. * 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.
  8020. */
  8021. /**
  8022. * Sets the highlights Saturation value.
  8023. * 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.
  8024. */
  8025. highlightsSaturation: number;
  8026. /**
  8027. * Gets the highlights Exposure value.
  8028. * 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.
  8029. */
  8030. /**
  8031. * Sets the highlights Exposure value.
  8032. * 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.
  8033. */
  8034. highlightsExposure: number;
  8035. private _midtonesHue;
  8036. private _midtonesDensity;
  8037. private _midtonesSaturation;
  8038. private _midtonesExposure;
  8039. /**
  8040. * Gets the midtones Hue value.
  8041. * 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).
  8042. */
  8043. /**
  8044. * Sets the midtones Hue value.
  8045. * 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).
  8046. */
  8047. midtonesHue: number;
  8048. /**
  8049. * Gets the midtones Density value.
  8050. * 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.
  8051. * Values less than zero provide a filter of opposite hue.
  8052. */
  8053. /**
  8054. * Sets the midtones Density value.
  8055. * 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.
  8056. * Values less than zero provide a filter of opposite hue.
  8057. */
  8058. midtonesDensity: number;
  8059. /**
  8060. * Gets the midtones Saturation value.
  8061. * 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.
  8062. */
  8063. /**
  8064. * Sets the midtones Saturation value.
  8065. * 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.
  8066. */
  8067. midtonesSaturation: number;
  8068. /**
  8069. * Gets the midtones Exposure value.
  8070. * 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.
  8071. */
  8072. /**
  8073. * Sets the midtones Exposure value.
  8074. * 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.
  8075. */
  8076. midtonesExposure: number;
  8077. private _shadowsHue;
  8078. private _shadowsDensity;
  8079. private _shadowsSaturation;
  8080. private _shadowsExposure;
  8081. /**
  8082. * Gets the shadows Hue value.
  8083. * 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).
  8084. */
  8085. /**
  8086. * Sets the shadows Hue value.
  8087. * 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).
  8088. */
  8089. shadowsHue: number;
  8090. /**
  8091. * Gets the shadows Density value.
  8092. * 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.
  8093. * Values less than zero provide a filter of opposite hue.
  8094. */
  8095. /**
  8096. * Sets the shadows Density value.
  8097. * 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.
  8098. * Values less than zero provide a filter of opposite hue.
  8099. */
  8100. shadowsDensity: number;
  8101. /**
  8102. * Gets the shadows Saturation value.
  8103. * 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.
  8104. */
  8105. /**
  8106. * Sets the shadows Saturation value.
  8107. * 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.
  8108. */
  8109. shadowsSaturation: number;
  8110. /**
  8111. * Gets the shadows Exposure value.
  8112. * 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.
  8113. */
  8114. /**
  8115. * Sets the shadows Exposure value.
  8116. * 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.
  8117. */
  8118. shadowsExposure: number;
  8119. /**
  8120. * Returns the class name
  8121. * @returns The class name
  8122. */
  8123. getClassName(): string;
  8124. /**
  8125. * Binds the color curves to the shader.
  8126. * @param colorCurves The color curve to bind
  8127. * @param effect The effect to bind to
  8128. * @param positiveUniform The positive uniform shader parameter
  8129. * @param neutralUniform The neutral uniform shader parameter
  8130. * @param negativeUniform The negative uniform shader parameter
  8131. */
  8132. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8133. /**
  8134. * Prepare the list of uniforms associated with the ColorCurves effects.
  8135. * @param uniformsList The list of uniforms used in the effect
  8136. */
  8137. static PrepareUniforms(uniformsList: string[]): void;
  8138. /**
  8139. * Returns color grading data based on a hue, density, saturation and exposure value.
  8140. * @param filterHue The hue of the color filter.
  8141. * @param filterDensity The density of the color filter.
  8142. * @param saturation The saturation.
  8143. * @param exposure The exposure.
  8144. * @param result The result data container.
  8145. */
  8146. private getColorGradingDataToRef;
  8147. /**
  8148. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8149. * @param value The input slider value in range [-100,100].
  8150. * @returns Adjusted value.
  8151. */
  8152. private static applyColorGradingSliderNonlinear;
  8153. /**
  8154. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8155. * @param hue The hue (H) input.
  8156. * @param saturation The saturation (S) input.
  8157. * @param brightness The brightness (B) input.
  8158. * @result An RGBA color represented as Vector4.
  8159. */
  8160. private static fromHSBToRef;
  8161. /**
  8162. * Returns a value clamped between min and max
  8163. * @param value The value to clamp
  8164. * @param min The minimum of value
  8165. * @param max The maximum of value
  8166. * @returns The clamped value.
  8167. */
  8168. private static clamp;
  8169. /**
  8170. * Clones the current color curve instance.
  8171. * @return The cloned curves
  8172. */
  8173. clone(): ColorCurves;
  8174. /**
  8175. * Serializes the current color curve instance to a json representation.
  8176. * @return a JSON representation
  8177. */
  8178. serialize(): any;
  8179. /**
  8180. * Parses the color curve from a json representation.
  8181. * @param source the JSON source to parse
  8182. * @return The parsed curves
  8183. */
  8184. static Parse(source: any): ColorCurves;
  8185. }
  8186. }
  8187. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8188. import { Observable } from "babylonjs/Misc/observable";
  8189. import { Nullable } from "babylonjs/types";
  8190. import { Color4 } from "babylonjs/Maths/math.color";
  8191. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8192. import { Effect } from "babylonjs/Materials/effect";
  8193. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8194. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8195. /**
  8196. * Interface to follow in your material defines to integrate easily the
  8197. * Image proccessing functions.
  8198. * @hidden
  8199. */
  8200. export interface IImageProcessingConfigurationDefines {
  8201. IMAGEPROCESSING: boolean;
  8202. VIGNETTE: boolean;
  8203. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8204. VIGNETTEBLENDMODEOPAQUE: boolean;
  8205. TONEMAPPING: boolean;
  8206. TONEMAPPING_ACES: boolean;
  8207. CONTRAST: boolean;
  8208. EXPOSURE: boolean;
  8209. COLORCURVES: boolean;
  8210. COLORGRADING: boolean;
  8211. COLORGRADING3D: boolean;
  8212. SAMPLER3DGREENDEPTH: boolean;
  8213. SAMPLER3DBGRMAP: boolean;
  8214. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8215. }
  8216. /**
  8217. * @hidden
  8218. */
  8219. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8220. IMAGEPROCESSING: boolean;
  8221. VIGNETTE: boolean;
  8222. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8223. VIGNETTEBLENDMODEOPAQUE: boolean;
  8224. TONEMAPPING: boolean;
  8225. TONEMAPPING_ACES: boolean;
  8226. CONTRAST: boolean;
  8227. COLORCURVES: boolean;
  8228. COLORGRADING: boolean;
  8229. COLORGRADING3D: boolean;
  8230. SAMPLER3DGREENDEPTH: boolean;
  8231. SAMPLER3DBGRMAP: boolean;
  8232. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8233. EXPOSURE: boolean;
  8234. constructor();
  8235. }
  8236. /**
  8237. * This groups together the common properties used for image processing either in direct forward pass
  8238. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8239. * or not.
  8240. */
  8241. export class ImageProcessingConfiguration {
  8242. /**
  8243. * Default tone mapping applied in BabylonJS.
  8244. */
  8245. static readonly TONEMAPPING_STANDARD: number;
  8246. /**
  8247. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8248. * to other engines rendering to increase portability.
  8249. */
  8250. static readonly TONEMAPPING_ACES: number;
  8251. /**
  8252. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8253. */
  8254. colorCurves: Nullable<ColorCurves>;
  8255. private _colorCurvesEnabled;
  8256. /**
  8257. * Gets wether the color curves effect is enabled.
  8258. */
  8259. /**
  8260. * Sets wether the color curves effect is enabled.
  8261. */
  8262. colorCurvesEnabled: boolean;
  8263. private _colorGradingTexture;
  8264. /**
  8265. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8266. */
  8267. /**
  8268. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8269. */
  8270. colorGradingTexture: Nullable<BaseTexture>;
  8271. private _colorGradingEnabled;
  8272. /**
  8273. * Gets wether the color grading effect is enabled.
  8274. */
  8275. /**
  8276. * Sets wether the color grading effect is enabled.
  8277. */
  8278. colorGradingEnabled: boolean;
  8279. private _colorGradingWithGreenDepth;
  8280. /**
  8281. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8282. */
  8283. /**
  8284. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8285. */
  8286. colorGradingWithGreenDepth: boolean;
  8287. private _colorGradingBGR;
  8288. /**
  8289. * Gets wether the color grading texture contains BGR values.
  8290. */
  8291. /**
  8292. * Sets wether the color grading texture contains BGR values.
  8293. */
  8294. colorGradingBGR: boolean;
  8295. /** @hidden */
  8296. _exposure: number;
  8297. /**
  8298. * Gets the Exposure used in the effect.
  8299. */
  8300. /**
  8301. * Sets the Exposure used in the effect.
  8302. */
  8303. exposure: number;
  8304. private _toneMappingEnabled;
  8305. /**
  8306. * Gets wether the tone mapping effect is enabled.
  8307. */
  8308. /**
  8309. * Sets wether the tone mapping effect is enabled.
  8310. */
  8311. toneMappingEnabled: boolean;
  8312. private _toneMappingType;
  8313. /**
  8314. * Gets the type of tone mapping effect.
  8315. */
  8316. /**
  8317. * Sets the type of tone mapping effect used in BabylonJS.
  8318. */
  8319. toneMappingType: number;
  8320. protected _contrast: number;
  8321. /**
  8322. * Gets the contrast used in the effect.
  8323. */
  8324. /**
  8325. * Sets the contrast used in the effect.
  8326. */
  8327. contrast: number;
  8328. /**
  8329. * Vignette stretch size.
  8330. */
  8331. vignetteStretch: number;
  8332. /**
  8333. * Vignette centre X Offset.
  8334. */
  8335. vignetteCentreX: number;
  8336. /**
  8337. * Vignette centre Y Offset.
  8338. */
  8339. vignetteCentreY: number;
  8340. /**
  8341. * Vignette weight or intensity of the vignette effect.
  8342. */
  8343. vignetteWeight: number;
  8344. /**
  8345. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8346. * if vignetteEnabled is set to true.
  8347. */
  8348. vignetteColor: Color4;
  8349. /**
  8350. * Camera field of view used by the Vignette effect.
  8351. */
  8352. vignetteCameraFov: number;
  8353. private _vignetteBlendMode;
  8354. /**
  8355. * Gets the vignette blend mode allowing different kind of effect.
  8356. */
  8357. /**
  8358. * Sets the vignette blend mode allowing different kind of effect.
  8359. */
  8360. vignetteBlendMode: number;
  8361. private _vignetteEnabled;
  8362. /**
  8363. * Gets wether the vignette effect is enabled.
  8364. */
  8365. /**
  8366. * Sets wether the vignette effect is enabled.
  8367. */
  8368. vignetteEnabled: boolean;
  8369. private _applyByPostProcess;
  8370. /**
  8371. * Gets wether the image processing is applied through a post process or not.
  8372. */
  8373. /**
  8374. * Sets wether the image processing is applied through a post process or not.
  8375. */
  8376. applyByPostProcess: boolean;
  8377. private _isEnabled;
  8378. /**
  8379. * Gets wether the image processing is enabled or not.
  8380. */
  8381. /**
  8382. * Sets wether the image processing is enabled or not.
  8383. */
  8384. isEnabled: boolean;
  8385. /**
  8386. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8387. */
  8388. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8389. /**
  8390. * Method called each time the image processing information changes requires to recompile the effect.
  8391. */
  8392. protected _updateParameters(): void;
  8393. /**
  8394. * Gets the current class name.
  8395. * @return "ImageProcessingConfiguration"
  8396. */
  8397. getClassName(): string;
  8398. /**
  8399. * Prepare the list of uniforms associated with the Image Processing effects.
  8400. * @param uniforms The list of uniforms used in the effect
  8401. * @param defines the list of defines currently in use
  8402. */
  8403. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8404. /**
  8405. * Prepare the list of samplers associated with the Image Processing effects.
  8406. * @param samplersList The list of uniforms used in the effect
  8407. * @param defines the list of defines currently in use
  8408. */
  8409. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8410. /**
  8411. * Prepare the list of defines associated to the shader.
  8412. * @param defines the list of defines to complete
  8413. * @param forPostProcess Define if we are currently in post process mode or not
  8414. */
  8415. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8416. /**
  8417. * Returns true if all the image processing information are ready.
  8418. * @returns True if ready, otherwise, false
  8419. */
  8420. isReady(): boolean;
  8421. /**
  8422. * Binds the image processing to the shader.
  8423. * @param effect The effect to bind to
  8424. * @param overrideAspectRatio Override the aspect ratio of the effect
  8425. */
  8426. bind(effect: Effect, overrideAspectRatio?: number): void;
  8427. /**
  8428. * Clones the current image processing instance.
  8429. * @return The cloned image processing
  8430. */
  8431. clone(): ImageProcessingConfiguration;
  8432. /**
  8433. * Serializes the current image processing instance to a json representation.
  8434. * @return a JSON representation
  8435. */
  8436. serialize(): any;
  8437. /**
  8438. * Parses the image processing from a json representation.
  8439. * @param source the JSON source to parse
  8440. * @return The parsed image processing
  8441. */
  8442. static Parse(source: any): ImageProcessingConfiguration;
  8443. private static _VIGNETTEMODE_MULTIPLY;
  8444. private static _VIGNETTEMODE_OPAQUE;
  8445. /**
  8446. * Used to apply the vignette as a mix with the pixel color.
  8447. */
  8448. static readonly VIGNETTEMODE_MULTIPLY: number;
  8449. /**
  8450. * Used to apply the vignette as a replacement of the pixel color.
  8451. */
  8452. static readonly VIGNETTEMODE_OPAQUE: number;
  8453. }
  8454. }
  8455. declare module "babylonjs/Shaders/postprocess.vertex" {
  8456. /** @hidden */
  8457. export var postprocessVertexShader: {
  8458. name: string;
  8459. shader: string;
  8460. };
  8461. }
  8462. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8463. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8464. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8465. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8466. module "babylonjs/Engines/thinEngine" {
  8467. interface ThinEngine {
  8468. /**
  8469. * Creates a new render target texture
  8470. * @param size defines the size of the texture
  8471. * @param options defines the options used to create the texture
  8472. * @returns a new render target texture stored in an InternalTexture
  8473. */
  8474. createRenderTargetTexture(size: number | {
  8475. width: number;
  8476. height: number;
  8477. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8478. /**
  8479. * Creates a depth stencil texture.
  8480. * This is only available in WebGL 2 or with the depth texture extension available.
  8481. * @param size The size of face edge in the texture.
  8482. * @param options The options defining the texture.
  8483. * @returns The texture
  8484. */
  8485. createDepthStencilTexture(size: number | {
  8486. width: number;
  8487. height: number;
  8488. }, options: DepthTextureCreationOptions): InternalTexture;
  8489. /** @hidden */
  8490. _createDepthStencilTexture(size: number | {
  8491. width: number;
  8492. height: number;
  8493. }, options: DepthTextureCreationOptions): InternalTexture;
  8494. }
  8495. }
  8496. }
  8497. declare module "babylonjs/Maths/math.axis" {
  8498. import { Vector3 } from "babylonjs/Maths/math.vector";
  8499. /** Defines supported spaces */
  8500. export enum Space {
  8501. /** Local (object) space */
  8502. LOCAL = 0,
  8503. /** World space */
  8504. WORLD = 1,
  8505. /** Bone space */
  8506. BONE = 2
  8507. }
  8508. /** Defines the 3 main axes */
  8509. export class Axis {
  8510. /** X axis */
  8511. static X: Vector3;
  8512. /** Y axis */
  8513. static Y: Vector3;
  8514. /** Z axis */
  8515. static Z: Vector3;
  8516. }
  8517. }
  8518. declare module "babylonjs/Cameras/targetCamera" {
  8519. import { Nullable } from "babylonjs/types";
  8520. import { Camera } from "babylonjs/Cameras/camera";
  8521. import { Scene } from "babylonjs/scene";
  8522. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8523. /**
  8524. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8525. * This is the base of the follow, arc rotate cameras and Free camera
  8526. * @see http://doc.babylonjs.com/features/cameras
  8527. */
  8528. export class TargetCamera extends Camera {
  8529. private static _RigCamTransformMatrix;
  8530. private static _TargetTransformMatrix;
  8531. private static _TargetFocalPoint;
  8532. /**
  8533. * Define the current direction the camera is moving to
  8534. */
  8535. cameraDirection: Vector3;
  8536. /**
  8537. * Define the current rotation the camera is rotating to
  8538. */
  8539. cameraRotation: Vector2;
  8540. /**
  8541. * When set, the up vector of the camera will be updated by the rotation of the camera
  8542. */
  8543. updateUpVectorFromRotation: boolean;
  8544. private _tmpQuaternion;
  8545. /**
  8546. * Define the current rotation of the camera
  8547. */
  8548. rotation: Vector3;
  8549. /**
  8550. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8551. */
  8552. rotationQuaternion: Quaternion;
  8553. /**
  8554. * Define the current speed of the camera
  8555. */
  8556. speed: number;
  8557. /**
  8558. * Add constraint to the camera to prevent it to move freely in all directions and
  8559. * around all axis.
  8560. */
  8561. noRotationConstraint: boolean;
  8562. /**
  8563. * Define the current target of the camera as an object or a position.
  8564. */
  8565. lockedTarget: any;
  8566. /** @hidden */
  8567. _currentTarget: Vector3;
  8568. /** @hidden */
  8569. _initialFocalDistance: number;
  8570. /** @hidden */
  8571. _viewMatrix: Matrix;
  8572. /** @hidden */
  8573. _camMatrix: Matrix;
  8574. /** @hidden */
  8575. _cameraTransformMatrix: Matrix;
  8576. /** @hidden */
  8577. _cameraRotationMatrix: Matrix;
  8578. /** @hidden */
  8579. _referencePoint: Vector3;
  8580. /** @hidden */
  8581. _transformedReferencePoint: Vector3;
  8582. protected _globalCurrentTarget: Vector3;
  8583. protected _globalCurrentUpVector: Vector3;
  8584. /** @hidden */
  8585. _reset: () => void;
  8586. private _defaultUp;
  8587. /**
  8588. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8589. * This is the base of the follow, arc rotate cameras and Free camera
  8590. * @see http://doc.babylonjs.com/features/cameras
  8591. * @param name Defines the name of the camera in the scene
  8592. * @param position Defines the start position of the camera in the scene
  8593. * @param scene Defines the scene the camera belongs to
  8594. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8595. */
  8596. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8597. /**
  8598. * Gets the position in front of the camera at a given distance.
  8599. * @param distance The distance from the camera we want the position to be
  8600. * @returns the position
  8601. */
  8602. getFrontPosition(distance: number): Vector3;
  8603. /** @hidden */
  8604. _getLockedTargetPosition(): Nullable<Vector3>;
  8605. private _storedPosition;
  8606. private _storedRotation;
  8607. private _storedRotationQuaternion;
  8608. /**
  8609. * Store current camera state of the camera (fov, position, rotation, etc..)
  8610. * @returns the camera
  8611. */
  8612. storeState(): Camera;
  8613. /**
  8614. * Restored camera state. You must call storeState() first
  8615. * @returns whether it was successful or not
  8616. * @hidden
  8617. */
  8618. _restoreStateValues(): boolean;
  8619. /** @hidden */
  8620. _initCache(): void;
  8621. /** @hidden */
  8622. _updateCache(ignoreParentClass?: boolean): void;
  8623. /** @hidden */
  8624. _isSynchronizedViewMatrix(): boolean;
  8625. /** @hidden */
  8626. _computeLocalCameraSpeed(): number;
  8627. /**
  8628. * Defines the target the camera should look at.
  8629. * @param target Defines the new target as a Vector or a mesh
  8630. */
  8631. setTarget(target: Vector3): void;
  8632. /**
  8633. * Return the current target position of the camera. This value is expressed in local space.
  8634. * @returns the target position
  8635. */
  8636. getTarget(): Vector3;
  8637. /** @hidden */
  8638. _decideIfNeedsToMove(): boolean;
  8639. /** @hidden */
  8640. _updatePosition(): void;
  8641. /** @hidden */
  8642. _checkInputs(): void;
  8643. protected _updateCameraRotationMatrix(): void;
  8644. /**
  8645. * 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)
  8646. * @returns the current camera
  8647. */
  8648. private _rotateUpVectorWithCameraRotationMatrix;
  8649. private _cachedRotationZ;
  8650. private _cachedQuaternionRotationZ;
  8651. /** @hidden */
  8652. _getViewMatrix(): Matrix;
  8653. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8654. /**
  8655. * @hidden
  8656. */
  8657. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8658. /**
  8659. * @hidden
  8660. */
  8661. _updateRigCameras(): void;
  8662. private _getRigCamPositionAndTarget;
  8663. /**
  8664. * Gets the current object class name.
  8665. * @return the class name
  8666. */
  8667. getClassName(): string;
  8668. }
  8669. }
  8670. declare module "babylonjs/Events/keyboardEvents" {
  8671. /**
  8672. * Gather the list of keyboard event types as constants.
  8673. */
  8674. export class KeyboardEventTypes {
  8675. /**
  8676. * The keydown event is fired when a key becomes active (pressed).
  8677. */
  8678. static readonly KEYDOWN: number;
  8679. /**
  8680. * The keyup event is fired when a key has been released.
  8681. */
  8682. static readonly KEYUP: number;
  8683. }
  8684. /**
  8685. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8686. */
  8687. export class KeyboardInfo {
  8688. /**
  8689. * Defines the type of event (KeyboardEventTypes)
  8690. */
  8691. type: number;
  8692. /**
  8693. * Defines the related dom event
  8694. */
  8695. event: KeyboardEvent;
  8696. /**
  8697. * Instantiates a new keyboard info.
  8698. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8699. * @param type Defines the type of event (KeyboardEventTypes)
  8700. * @param event Defines the related dom event
  8701. */
  8702. constructor(
  8703. /**
  8704. * Defines the type of event (KeyboardEventTypes)
  8705. */
  8706. type: number,
  8707. /**
  8708. * Defines the related dom event
  8709. */
  8710. event: KeyboardEvent);
  8711. }
  8712. /**
  8713. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8714. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8715. */
  8716. export class KeyboardInfoPre extends KeyboardInfo {
  8717. /**
  8718. * Defines the type of event (KeyboardEventTypes)
  8719. */
  8720. type: number;
  8721. /**
  8722. * Defines the related dom event
  8723. */
  8724. event: KeyboardEvent;
  8725. /**
  8726. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8727. */
  8728. skipOnPointerObservable: boolean;
  8729. /**
  8730. * Instantiates a new keyboard pre info.
  8731. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8732. * @param type Defines the type of event (KeyboardEventTypes)
  8733. * @param event Defines the related dom event
  8734. */
  8735. constructor(
  8736. /**
  8737. * Defines the type of event (KeyboardEventTypes)
  8738. */
  8739. type: number,
  8740. /**
  8741. * Defines the related dom event
  8742. */
  8743. event: KeyboardEvent);
  8744. }
  8745. }
  8746. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8747. import { Nullable } from "babylonjs/types";
  8748. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8749. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8750. /**
  8751. * Manage the keyboard inputs to control the movement of a free camera.
  8752. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8753. */
  8754. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8755. /**
  8756. * Defines the camera the input is attached to.
  8757. */
  8758. camera: FreeCamera;
  8759. /**
  8760. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8761. */
  8762. keysUp: number[];
  8763. /**
  8764. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8765. */
  8766. keysDown: number[];
  8767. /**
  8768. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8769. */
  8770. keysLeft: number[];
  8771. /**
  8772. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8773. */
  8774. keysRight: number[];
  8775. private _keys;
  8776. private _onCanvasBlurObserver;
  8777. private _onKeyboardObserver;
  8778. private _engine;
  8779. private _scene;
  8780. /**
  8781. * Attach the input controls to a specific dom element to get the input from.
  8782. * @param element Defines the element the controls should be listened from
  8783. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8784. */
  8785. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8786. /**
  8787. * Detach the current controls from the specified dom element.
  8788. * @param element Defines the element to stop listening the inputs from
  8789. */
  8790. detachControl(element: Nullable<HTMLElement>): void;
  8791. /**
  8792. * Update the current camera state depending on the inputs that have been used this frame.
  8793. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8794. */
  8795. checkInputs(): void;
  8796. /**
  8797. * Gets the class name of the current intput.
  8798. * @returns the class name
  8799. */
  8800. getClassName(): string;
  8801. /** @hidden */
  8802. _onLostFocus(): void;
  8803. /**
  8804. * Get the friendly name associated with the input class.
  8805. * @returns the input friendly name
  8806. */
  8807. getSimpleName(): string;
  8808. }
  8809. }
  8810. declare module "babylonjs/Lights/shadowLight" {
  8811. import { Camera } from "babylonjs/Cameras/camera";
  8812. import { Scene } from "babylonjs/scene";
  8813. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8814. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8815. import { Light } from "babylonjs/Lights/light";
  8816. /**
  8817. * Interface describing all the common properties and methods a shadow light needs to implement.
  8818. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8819. * as well as binding the different shadow properties to the effects.
  8820. */
  8821. export interface IShadowLight extends Light {
  8822. /**
  8823. * The light id in the scene (used in scene.findLighById for instance)
  8824. */
  8825. id: string;
  8826. /**
  8827. * The position the shdow will be casted from.
  8828. */
  8829. position: Vector3;
  8830. /**
  8831. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8832. */
  8833. direction: Vector3;
  8834. /**
  8835. * The transformed position. Position of the light in world space taking parenting in account.
  8836. */
  8837. transformedPosition: Vector3;
  8838. /**
  8839. * The transformed direction. Direction of the light in world space taking parenting in account.
  8840. */
  8841. transformedDirection: Vector3;
  8842. /**
  8843. * The friendly name of the light in the scene.
  8844. */
  8845. name: string;
  8846. /**
  8847. * Defines the shadow projection clipping minimum z value.
  8848. */
  8849. shadowMinZ: number;
  8850. /**
  8851. * Defines the shadow projection clipping maximum z value.
  8852. */
  8853. shadowMaxZ: number;
  8854. /**
  8855. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8856. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8857. */
  8858. computeTransformedInformation(): boolean;
  8859. /**
  8860. * Gets the scene the light belongs to.
  8861. * @returns The scene
  8862. */
  8863. getScene(): Scene;
  8864. /**
  8865. * Callback defining a custom Projection Matrix Builder.
  8866. * This can be used to override the default projection matrix computation.
  8867. */
  8868. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8869. /**
  8870. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8871. * @param matrix The materix to updated with the projection information
  8872. * @param viewMatrix The transform matrix of the light
  8873. * @param renderList The list of mesh to render in the map
  8874. * @returns The current light
  8875. */
  8876. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8877. /**
  8878. * Gets the current depth scale used in ESM.
  8879. * @returns The scale
  8880. */
  8881. getDepthScale(): number;
  8882. /**
  8883. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8884. * @returns true if a cube texture needs to be use
  8885. */
  8886. needCube(): boolean;
  8887. /**
  8888. * Detects if the projection matrix requires to be recomputed this frame.
  8889. * @returns true if it requires to be recomputed otherwise, false.
  8890. */
  8891. needProjectionMatrixCompute(): boolean;
  8892. /**
  8893. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8894. */
  8895. forceProjectionMatrixCompute(): void;
  8896. /**
  8897. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8898. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8899. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8900. */
  8901. getShadowDirection(faceIndex?: number): Vector3;
  8902. /**
  8903. * Gets the minZ used for shadow according to both the scene and the light.
  8904. * @param activeCamera The camera we are returning the min for
  8905. * @returns the depth min z
  8906. */
  8907. getDepthMinZ(activeCamera: Camera): number;
  8908. /**
  8909. * Gets the maxZ used for shadow according to both the scene and the light.
  8910. * @param activeCamera The camera we are returning the max for
  8911. * @returns the depth max z
  8912. */
  8913. getDepthMaxZ(activeCamera: Camera): number;
  8914. }
  8915. /**
  8916. * Base implementation IShadowLight
  8917. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8918. */
  8919. export abstract class ShadowLight extends Light implements IShadowLight {
  8920. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8921. protected _position: Vector3;
  8922. protected _setPosition(value: Vector3): void;
  8923. /**
  8924. * Sets the position the shadow will be casted from. Also use as the light position for both
  8925. * point and spot lights.
  8926. */
  8927. /**
  8928. * Sets the position the shadow will be casted from. Also use as the light position for both
  8929. * point and spot lights.
  8930. */
  8931. position: Vector3;
  8932. protected _direction: Vector3;
  8933. protected _setDirection(value: Vector3): void;
  8934. /**
  8935. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8936. * Also use as the light direction on spot and directional lights.
  8937. */
  8938. /**
  8939. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8940. * Also use as the light direction on spot and directional lights.
  8941. */
  8942. direction: Vector3;
  8943. private _shadowMinZ;
  8944. /**
  8945. * Gets the shadow projection clipping minimum z value.
  8946. */
  8947. /**
  8948. * Sets the shadow projection clipping minimum z value.
  8949. */
  8950. shadowMinZ: number;
  8951. private _shadowMaxZ;
  8952. /**
  8953. * Sets the shadow projection clipping maximum z value.
  8954. */
  8955. /**
  8956. * Gets the shadow projection clipping maximum z value.
  8957. */
  8958. shadowMaxZ: number;
  8959. /**
  8960. * Callback defining a custom Projection Matrix Builder.
  8961. * This can be used to override the default projection matrix computation.
  8962. */
  8963. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8964. /**
  8965. * The transformed position. Position of the light in world space taking parenting in account.
  8966. */
  8967. transformedPosition: Vector3;
  8968. /**
  8969. * The transformed direction. Direction of the light in world space taking parenting in account.
  8970. */
  8971. transformedDirection: Vector3;
  8972. private _needProjectionMatrixCompute;
  8973. /**
  8974. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8975. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8976. */
  8977. computeTransformedInformation(): boolean;
  8978. /**
  8979. * Return the depth scale used for the shadow map.
  8980. * @returns the depth scale.
  8981. */
  8982. getDepthScale(): number;
  8983. /**
  8984. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8985. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8986. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8987. */
  8988. getShadowDirection(faceIndex?: number): Vector3;
  8989. /**
  8990. * Returns the ShadowLight absolute position in the World.
  8991. * @returns the position vector in world space
  8992. */
  8993. getAbsolutePosition(): Vector3;
  8994. /**
  8995. * Sets the ShadowLight direction toward the passed target.
  8996. * @param target The point to target in local space
  8997. * @returns the updated ShadowLight direction
  8998. */
  8999. setDirectionToTarget(target: Vector3): Vector3;
  9000. /**
  9001. * Returns the light rotation in euler definition.
  9002. * @returns the x y z rotation in local space.
  9003. */
  9004. getRotation(): Vector3;
  9005. /**
  9006. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9007. * @returns true if a cube texture needs to be use
  9008. */
  9009. needCube(): boolean;
  9010. /**
  9011. * Detects if the projection matrix requires to be recomputed this frame.
  9012. * @returns true if it requires to be recomputed otherwise, false.
  9013. */
  9014. needProjectionMatrixCompute(): boolean;
  9015. /**
  9016. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9017. */
  9018. forceProjectionMatrixCompute(): void;
  9019. /** @hidden */
  9020. _initCache(): void;
  9021. /** @hidden */
  9022. _isSynchronized(): boolean;
  9023. /**
  9024. * Computes the world matrix of the node
  9025. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9026. * @returns the world matrix
  9027. */
  9028. computeWorldMatrix(force?: boolean): Matrix;
  9029. /**
  9030. * Gets the minZ used for shadow according to both the scene and the light.
  9031. * @param activeCamera The camera we are returning the min for
  9032. * @returns the depth min z
  9033. */
  9034. getDepthMinZ(activeCamera: Camera): number;
  9035. /**
  9036. * Gets the maxZ used for shadow according to both the scene and the light.
  9037. * @param activeCamera The camera we are returning the max for
  9038. * @returns the depth max z
  9039. */
  9040. getDepthMaxZ(activeCamera: Camera): number;
  9041. /**
  9042. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9043. * @param matrix The materix to updated with the projection information
  9044. * @param viewMatrix The transform matrix of the light
  9045. * @param renderList The list of mesh to render in the map
  9046. * @returns The current light
  9047. */
  9048. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9049. }
  9050. }
  9051. declare module "babylonjs/Materials/effectFallbacks" {
  9052. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9053. import { Effect } from "babylonjs/Materials/effect";
  9054. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9055. /**
  9056. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9057. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9058. */
  9059. export class EffectFallbacks implements IEffectFallbacks {
  9060. private _defines;
  9061. private _currentRank;
  9062. private _maxRank;
  9063. private _mesh;
  9064. /**
  9065. * Removes the fallback from the bound mesh.
  9066. */
  9067. unBindMesh(): void;
  9068. /**
  9069. * Adds a fallback on the specified property.
  9070. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9071. * @param define The name of the define in the shader
  9072. */
  9073. addFallback(rank: number, define: string): void;
  9074. /**
  9075. * Sets the mesh to use CPU skinning when needing to fallback.
  9076. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9077. * @param mesh The mesh to use the fallbacks.
  9078. */
  9079. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9080. /**
  9081. * Checks to see if more fallbacks are still availible.
  9082. */
  9083. readonly hasMoreFallbacks: boolean;
  9084. /**
  9085. * Removes the defines that should be removed when falling back.
  9086. * @param currentDefines defines the current define statements for the shader.
  9087. * @param effect defines the current effect we try to compile
  9088. * @returns The resulting defines with defines of the current rank removed.
  9089. */
  9090. reduce(currentDefines: string, effect: Effect): string;
  9091. }
  9092. }
  9093. declare module "babylonjs/Materials/materialHelper" {
  9094. import { Nullable } from "babylonjs/types";
  9095. import { Scene } from "babylonjs/scene";
  9096. import { Engine } from "babylonjs/Engines/engine";
  9097. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9098. import { Light } from "babylonjs/Lights/light";
  9099. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9100. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  9101. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9102. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9103. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  9104. /**
  9105. * "Static Class" containing the most commonly used helper while dealing with material for
  9106. * rendering purpose.
  9107. *
  9108. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9109. *
  9110. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9111. */
  9112. export class MaterialHelper {
  9113. /**
  9114. * Bind the current view position to an effect.
  9115. * @param effect The effect to be bound
  9116. * @param scene The scene the eyes position is used from
  9117. */
  9118. static BindEyePosition(effect: Effect, scene: Scene): void;
  9119. /**
  9120. * Helps preparing the defines values about the UVs in used in the effect.
  9121. * UVs are shared as much as we can accross channels in the shaders.
  9122. * @param texture The texture we are preparing the UVs for
  9123. * @param defines The defines to update
  9124. * @param key The channel key "diffuse", "specular"... used in the shader
  9125. */
  9126. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9127. /**
  9128. * Binds a texture matrix value to its corrsponding uniform
  9129. * @param texture The texture to bind the matrix for
  9130. * @param uniformBuffer The uniform buffer receivin the data
  9131. * @param key The channel key "diffuse", "specular"... used in the shader
  9132. */
  9133. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9134. /**
  9135. * Gets the current status of the fog (should it be enabled?)
  9136. * @param mesh defines the mesh to evaluate for fog support
  9137. * @param scene defines the hosting scene
  9138. * @returns true if fog must be enabled
  9139. */
  9140. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9141. /**
  9142. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9143. * @param mesh defines the current mesh
  9144. * @param scene defines the current scene
  9145. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9146. * @param pointsCloud defines if point cloud rendering has to be turned on
  9147. * @param fogEnabled defines if fog has to be turned on
  9148. * @param alphaTest defines if alpha testing has to be turned on
  9149. * @param defines defines the current list of defines
  9150. */
  9151. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9152. /**
  9153. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9154. * @param scene defines the current scene
  9155. * @param engine defines the current engine
  9156. * @param defines specifies the list of active defines
  9157. * @param useInstances defines if instances have to be turned on
  9158. * @param useClipPlane defines if clip plane have to be turned on
  9159. */
  9160. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9161. /**
  9162. * Prepares the defines for bones
  9163. * @param mesh The mesh containing the geometry data we will draw
  9164. * @param defines The defines to update
  9165. */
  9166. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9167. /**
  9168. * Prepares the defines for morph targets
  9169. * @param mesh The mesh containing the geometry data we will draw
  9170. * @param defines The defines to update
  9171. */
  9172. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9173. /**
  9174. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9175. * @param mesh The mesh containing the geometry data we will draw
  9176. * @param defines The defines to update
  9177. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9178. * @param useBones Precise whether bones should be used or not (override mesh info)
  9179. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9180. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9181. * @returns false if defines are considered not dirty and have not been checked
  9182. */
  9183. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9184. /**
  9185. * Prepares the defines related to multiview
  9186. * @param scene The scene we are intending to draw
  9187. * @param defines The defines to update
  9188. */
  9189. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9190. /**
  9191. * Prepares the defines related to the light information passed in parameter
  9192. * @param scene The scene we are intending to draw
  9193. * @param mesh The mesh the effect is compiling for
  9194. * @param light The light the effect is compiling for
  9195. * @param lightIndex The index of the light
  9196. * @param defines The defines to update
  9197. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9198. * @param state Defines the current state regarding what is needed (normals, etc...)
  9199. */
  9200. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9201. needNormals: boolean;
  9202. needRebuild: boolean;
  9203. shadowEnabled: boolean;
  9204. specularEnabled: boolean;
  9205. lightmapMode: boolean;
  9206. }): void;
  9207. /**
  9208. * Prepares the defines related to the light information passed in parameter
  9209. * @param scene The scene we are intending to draw
  9210. * @param mesh The mesh the effect is compiling for
  9211. * @param defines The defines to update
  9212. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9213. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9214. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9215. * @returns true if normals will be required for the rest of the effect
  9216. */
  9217. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9218. /**
  9219. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9220. * @param lightIndex defines the light index
  9221. * @param uniformsList The uniform list
  9222. * @param samplersList The sampler list
  9223. * @param projectedLightTexture defines if projected texture must be used
  9224. * @param uniformBuffersList defines an optional list of uniform buffers
  9225. */
  9226. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9227. /**
  9228. * Prepares the uniforms and samplers list to be used in the effect
  9229. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9230. * @param samplersList The sampler list
  9231. * @param defines The defines helping in the list generation
  9232. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9233. */
  9234. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9235. /**
  9236. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9237. * @param defines The defines to update while falling back
  9238. * @param fallbacks The authorized effect fallbacks
  9239. * @param maxSimultaneousLights The maximum number of lights allowed
  9240. * @param rank the current rank of the Effect
  9241. * @returns The newly affected rank
  9242. */
  9243. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9244. private static _TmpMorphInfluencers;
  9245. /**
  9246. * Prepares the list of attributes required for morph targets according to the effect defines.
  9247. * @param attribs The current list of supported attribs
  9248. * @param mesh The mesh to prepare the morph targets attributes for
  9249. * @param influencers The number of influencers
  9250. */
  9251. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9252. /**
  9253. * Prepares the list of attributes required for morph targets according to the effect defines.
  9254. * @param attribs The current list of supported attribs
  9255. * @param mesh The mesh to prepare the morph targets attributes for
  9256. * @param defines The current Defines of the effect
  9257. */
  9258. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9259. /**
  9260. * Prepares the list of attributes required for bones according to the effect defines.
  9261. * @param attribs The current list of supported attribs
  9262. * @param mesh The mesh to prepare the bones attributes for
  9263. * @param defines The current Defines of the effect
  9264. * @param fallbacks The current efffect fallback strategy
  9265. */
  9266. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9267. /**
  9268. * Check and prepare the list of attributes required for instances according to the effect defines.
  9269. * @param attribs The current list of supported attribs
  9270. * @param defines The current MaterialDefines of the effect
  9271. */
  9272. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9273. /**
  9274. * Add the list of attributes required for instances to the attribs array.
  9275. * @param attribs The current list of supported attribs
  9276. */
  9277. static PushAttributesForInstances(attribs: string[]): void;
  9278. /**
  9279. * Binds the light information to the effect.
  9280. * @param light The light containing the generator
  9281. * @param effect The effect we are binding the data to
  9282. * @param lightIndex The light index in the effect used to render
  9283. */
  9284. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9285. /**
  9286. * Binds the lights information from the scene to the effect for the given mesh.
  9287. * @param light Light to bind
  9288. * @param lightIndex Light index
  9289. * @param scene The scene where the light belongs to
  9290. * @param effect The effect we are binding the data to
  9291. * @param useSpecular Defines if specular is supported
  9292. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9293. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9294. */
  9295. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9296. /**
  9297. * Binds the lights information from the scene to the effect for the given mesh.
  9298. * @param scene The scene the lights belongs to
  9299. * @param mesh The mesh we are binding the information to render
  9300. * @param effect The effect we are binding the data to
  9301. * @param defines The generated defines for the effect
  9302. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9303. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9304. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9305. */
  9306. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9307. private static _tempFogColor;
  9308. /**
  9309. * Binds the fog information from the scene to the effect for the given mesh.
  9310. * @param scene The scene the lights belongs to
  9311. * @param mesh The mesh we are binding the information to render
  9312. * @param effect The effect we are binding the data to
  9313. * @param linearSpace Defines if the fog effect is applied in linear space
  9314. */
  9315. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9316. /**
  9317. * Binds the bones information from the mesh to the effect.
  9318. * @param mesh The mesh we are binding the information to render
  9319. * @param effect The effect we are binding the data to
  9320. */
  9321. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9322. /**
  9323. * Binds the morph targets information from the mesh to the effect.
  9324. * @param abstractMesh The mesh we are binding the information to render
  9325. * @param effect The effect we are binding the data to
  9326. */
  9327. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9328. /**
  9329. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9330. * @param defines The generated defines used in the effect
  9331. * @param effect The effect we are binding the data to
  9332. * @param scene The scene we are willing to render with logarithmic scale for
  9333. */
  9334. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9335. /**
  9336. * Binds the clip plane information from the scene to the effect.
  9337. * @param scene The scene the clip plane information are extracted from
  9338. * @param effect The effect we are binding the data to
  9339. */
  9340. static BindClipPlane(effect: Effect, scene: Scene): void;
  9341. }
  9342. }
  9343. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9344. /** @hidden */
  9345. export var packingFunctions: {
  9346. name: string;
  9347. shader: string;
  9348. };
  9349. }
  9350. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9351. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9352. /** @hidden */
  9353. export var shadowMapPixelShader: {
  9354. name: string;
  9355. shader: string;
  9356. };
  9357. }
  9358. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9359. /** @hidden */
  9360. export var bonesDeclaration: {
  9361. name: string;
  9362. shader: string;
  9363. };
  9364. }
  9365. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9366. /** @hidden */
  9367. export var morphTargetsVertexGlobalDeclaration: {
  9368. name: string;
  9369. shader: string;
  9370. };
  9371. }
  9372. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9373. /** @hidden */
  9374. export var morphTargetsVertexDeclaration: {
  9375. name: string;
  9376. shader: string;
  9377. };
  9378. }
  9379. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9380. /** @hidden */
  9381. export var instancesDeclaration: {
  9382. name: string;
  9383. shader: string;
  9384. };
  9385. }
  9386. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9387. /** @hidden */
  9388. export var helperFunctions: {
  9389. name: string;
  9390. shader: string;
  9391. };
  9392. }
  9393. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9394. /** @hidden */
  9395. export var morphTargetsVertex: {
  9396. name: string;
  9397. shader: string;
  9398. };
  9399. }
  9400. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9401. /** @hidden */
  9402. export var instancesVertex: {
  9403. name: string;
  9404. shader: string;
  9405. };
  9406. }
  9407. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9408. /** @hidden */
  9409. export var bonesVertex: {
  9410. name: string;
  9411. shader: string;
  9412. };
  9413. }
  9414. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9415. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9416. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9417. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9418. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9419. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9420. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9421. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9422. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9423. /** @hidden */
  9424. export var shadowMapVertexShader: {
  9425. name: string;
  9426. shader: string;
  9427. };
  9428. }
  9429. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9430. /** @hidden */
  9431. export var depthBoxBlurPixelShader: {
  9432. name: string;
  9433. shader: string;
  9434. };
  9435. }
  9436. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9437. import { Nullable } from "babylonjs/types";
  9438. import { Scene } from "babylonjs/scene";
  9439. import { Matrix } from "babylonjs/Maths/math.vector";
  9440. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9441. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9442. import { Mesh } from "babylonjs/Meshes/mesh";
  9443. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9444. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9445. import { Effect } from "babylonjs/Materials/effect";
  9446. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9447. import "babylonjs/Shaders/shadowMap.fragment";
  9448. import "babylonjs/Shaders/shadowMap.vertex";
  9449. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9450. import { Observable } from "babylonjs/Misc/observable";
  9451. /**
  9452. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9453. */
  9454. export interface ICustomShaderOptions {
  9455. /**
  9456. * Gets or sets the custom shader name to use
  9457. */
  9458. shaderName: string;
  9459. /**
  9460. * The list of attribute names used in the shader
  9461. */
  9462. attributes?: string[];
  9463. /**
  9464. * The list of unifrom names used in the shader
  9465. */
  9466. uniforms?: string[];
  9467. /**
  9468. * The list of sampler names used in the shader
  9469. */
  9470. samplers?: string[];
  9471. /**
  9472. * The list of defines used in the shader
  9473. */
  9474. defines?: string[];
  9475. }
  9476. /**
  9477. * Interface to implement to create a shadow generator compatible with BJS.
  9478. */
  9479. export interface IShadowGenerator {
  9480. /**
  9481. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9482. * @returns The render target texture if present otherwise, null
  9483. */
  9484. getShadowMap(): Nullable<RenderTargetTexture>;
  9485. /**
  9486. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9487. * @returns The render target texture if the shadow map is present otherwise, null
  9488. */
  9489. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9490. /**
  9491. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9492. * @param subMesh The submesh we want to render in the shadow map
  9493. * @param useInstances Defines wether will draw in the map using instances
  9494. * @returns true if ready otherwise, false
  9495. */
  9496. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9497. /**
  9498. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9499. * @param defines Defines of the material we want to update
  9500. * @param lightIndex Index of the light in the enabled light list of the material
  9501. */
  9502. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9503. /**
  9504. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9505. * defined in the generator but impacting the effect).
  9506. * It implies the unifroms available on the materials are the standard BJS ones.
  9507. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9508. * @param effect The effect we are binfing the information for
  9509. */
  9510. bindShadowLight(lightIndex: string, effect: Effect): void;
  9511. /**
  9512. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9513. * (eq to shadow prjection matrix * light transform matrix)
  9514. * @returns The transform matrix used to create the shadow map
  9515. */
  9516. getTransformMatrix(): Matrix;
  9517. /**
  9518. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9519. * Cube and 2D textures for instance.
  9520. */
  9521. recreateShadowMap(): void;
  9522. /**
  9523. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9524. * @param onCompiled Callback triggered at the and of the effects compilation
  9525. * @param options Sets of optional options forcing the compilation with different modes
  9526. */
  9527. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9528. useInstances: boolean;
  9529. }>): void;
  9530. /**
  9531. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9532. * @param options Sets of optional options forcing the compilation with different modes
  9533. * @returns A promise that resolves when the compilation completes
  9534. */
  9535. forceCompilationAsync(options?: Partial<{
  9536. useInstances: boolean;
  9537. }>): Promise<void>;
  9538. /**
  9539. * Serializes the shadow generator setup to a json object.
  9540. * @returns The serialized JSON object
  9541. */
  9542. serialize(): any;
  9543. /**
  9544. * Disposes the Shadow map and related Textures and effects.
  9545. */
  9546. dispose(): void;
  9547. }
  9548. /**
  9549. * Default implementation IShadowGenerator.
  9550. * This is the main object responsible of generating shadows in the framework.
  9551. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9552. */
  9553. export class ShadowGenerator implements IShadowGenerator {
  9554. /**
  9555. * Shadow generator mode None: no filtering applied.
  9556. */
  9557. static readonly FILTER_NONE: number;
  9558. /**
  9559. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9560. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9561. */
  9562. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9563. /**
  9564. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9565. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9566. */
  9567. static readonly FILTER_POISSONSAMPLING: number;
  9568. /**
  9569. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9570. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9571. */
  9572. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9573. /**
  9574. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9575. * edge artifacts on steep falloff.
  9576. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9577. */
  9578. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9579. /**
  9580. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9581. * edge artifacts on steep falloff.
  9582. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9583. */
  9584. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9585. /**
  9586. * Shadow generator mode PCF: Percentage Closer Filtering
  9587. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9588. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9589. */
  9590. static readonly FILTER_PCF: number;
  9591. /**
  9592. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9593. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9594. * Contact Hardening
  9595. */
  9596. static readonly FILTER_PCSS: number;
  9597. /**
  9598. * Reserved for PCF and PCSS
  9599. * Highest Quality.
  9600. *
  9601. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9602. *
  9603. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9604. */
  9605. static readonly QUALITY_HIGH: number;
  9606. /**
  9607. * Reserved for PCF and PCSS
  9608. * Good tradeoff for quality/perf cross devices
  9609. *
  9610. * Execute PCF on a 3*3 kernel.
  9611. *
  9612. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9613. */
  9614. static readonly QUALITY_MEDIUM: number;
  9615. /**
  9616. * Reserved for PCF and PCSS
  9617. * The lowest quality but the fastest.
  9618. *
  9619. * Execute PCF on a 1*1 kernel.
  9620. *
  9621. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9622. */
  9623. static readonly QUALITY_LOW: number;
  9624. /** Gets or sets the custom shader name to use */
  9625. customShaderOptions: ICustomShaderOptions;
  9626. /**
  9627. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9628. */
  9629. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9630. /**
  9631. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9632. */
  9633. onAfterShadowMapRenderObservable: Observable<Effect>;
  9634. /**
  9635. * Observable triggered before a mesh is rendered in the shadow map.
  9636. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9637. */
  9638. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9639. /**
  9640. * Observable triggered after a mesh is rendered in the shadow map.
  9641. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9642. */
  9643. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9644. private _bias;
  9645. /**
  9646. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9647. */
  9648. /**
  9649. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9650. */
  9651. bias: number;
  9652. private _normalBias;
  9653. /**
  9654. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9655. */
  9656. /**
  9657. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9658. */
  9659. normalBias: number;
  9660. private _blurBoxOffset;
  9661. /**
  9662. * Gets the blur box offset: offset applied during the blur pass.
  9663. * Only useful if useKernelBlur = false
  9664. */
  9665. /**
  9666. * Sets the blur box offset: offset applied during the blur pass.
  9667. * Only useful if useKernelBlur = false
  9668. */
  9669. blurBoxOffset: number;
  9670. private _blurScale;
  9671. /**
  9672. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9673. * 2 means half of the size.
  9674. */
  9675. /**
  9676. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9677. * 2 means half of the size.
  9678. */
  9679. blurScale: number;
  9680. private _blurKernel;
  9681. /**
  9682. * Gets the blur kernel: kernel size of the blur pass.
  9683. * Only useful if useKernelBlur = true
  9684. */
  9685. /**
  9686. * Sets the blur kernel: kernel size of the blur pass.
  9687. * Only useful if useKernelBlur = true
  9688. */
  9689. blurKernel: number;
  9690. private _useKernelBlur;
  9691. /**
  9692. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9693. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9694. */
  9695. /**
  9696. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9697. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9698. */
  9699. useKernelBlur: boolean;
  9700. private _depthScale;
  9701. /**
  9702. * Gets the depth scale used in ESM mode.
  9703. */
  9704. /**
  9705. * Sets the depth scale used in ESM mode.
  9706. * This can override the scale stored on the light.
  9707. */
  9708. depthScale: number;
  9709. private _filter;
  9710. /**
  9711. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9712. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9713. */
  9714. /**
  9715. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9716. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9717. */
  9718. filter: number;
  9719. /**
  9720. * Gets if the current filter is set to Poisson Sampling.
  9721. */
  9722. /**
  9723. * Sets the current filter to Poisson Sampling.
  9724. */
  9725. usePoissonSampling: boolean;
  9726. /**
  9727. * Gets if the current filter is set to ESM.
  9728. */
  9729. /**
  9730. * Sets the current filter is to ESM.
  9731. */
  9732. useExponentialShadowMap: boolean;
  9733. /**
  9734. * Gets if the current filter is set to filtered ESM.
  9735. */
  9736. /**
  9737. * Gets if the current filter is set to filtered ESM.
  9738. */
  9739. useBlurExponentialShadowMap: boolean;
  9740. /**
  9741. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9742. * exponential to prevent steep falloff artifacts).
  9743. */
  9744. /**
  9745. * Sets the current filter to "close ESM" (using the inverse of the
  9746. * exponential to prevent steep falloff artifacts).
  9747. */
  9748. useCloseExponentialShadowMap: boolean;
  9749. /**
  9750. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9751. * exponential to prevent steep falloff artifacts).
  9752. */
  9753. /**
  9754. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9755. * exponential to prevent steep falloff artifacts).
  9756. */
  9757. useBlurCloseExponentialShadowMap: boolean;
  9758. /**
  9759. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9760. */
  9761. /**
  9762. * Sets the current filter to "PCF" (percentage closer filtering).
  9763. */
  9764. usePercentageCloserFiltering: boolean;
  9765. private _filteringQuality;
  9766. /**
  9767. * Gets the PCF or PCSS Quality.
  9768. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9769. */
  9770. /**
  9771. * Sets the PCF or PCSS Quality.
  9772. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9773. */
  9774. filteringQuality: number;
  9775. /**
  9776. * Gets if the current filter is set to "PCSS" (contact hardening).
  9777. */
  9778. /**
  9779. * Sets the current filter to "PCSS" (contact hardening).
  9780. */
  9781. useContactHardeningShadow: boolean;
  9782. private _contactHardeningLightSizeUVRatio;
  9783. /**
  9784. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9785. * Using a ratio helps keeping shape stability independently of the map size.
  9786. *
  9787. * It does not account for the light projection as it was having too much
  9788. * instability during the light setup or during light position changes.
  9789. *
  9790. * Only valid if useContactHardeningShadow is true.
  9791. */
  9792. /**
  9793. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9794. * Using a ratio helps keeping shape stability independently of the map size.
  9795. *
  9796. * It does not account for the light projection as it was having too much
  9797. * instability during the light setup or during light position changes.
  9798. *
  9799. * Only valid if useContactHardeningShadow is true.
  9800. */
  9801. contactHardeningLightSizeUVRatio: number;
  9802. private _darkness;
  9803. /** Gets or sets the actual darkness of a shadow */
  9804. darkness: number;
  9805. /**
  9806. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9807. * 0 means strongest and 1 would means no shadow.
  9808. * @returns the darkness.
  9809. */
  9810. getDarkness(): number;
  9811. /**
  9812. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9813. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9814. * @returns the shadow generator allowing fluent coding.
  9815. */
  9816. setDarkness(darkness: number): ShadowGenerator;
  9817. private _transparencyShadow;
  9818. /** Gets or sets the ability to have transparent shadow */
  9819. transparencyShadow: boolean;
  9820. /**
  9821. * Sets the ability to have transparent shadow (boolean).
  9822. * @param transparent True if transparent else False
  9823. * @returns the shadow generator allowing fluent coding
  9824. */
  9825. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9826. private _shadowMap;
  9827. private _shadowMap2;
  9828. /**
  9829. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9830. * @returns The render target texture if present otherwise, null
  9831. */
  9832. getShadowMap(): Nullable<RenderTargetTexture>;
  9833. /**
  9834. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9835. * @returns The render target texture if the shadow map is present otherwise, null
  9836. */
  9837. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9838. /**
  9839. * Gets the class name of that object
  9840. * @returns "ShadowGenerator"
  9841. */
  9842. getClassName(): string;
  9843. /**
  9844. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9845. * @param mesh Mesh to add
  9846. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9847. * @returns the Shadow Generator itself
  9848. */
  9849. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9850. /**
  9851. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9852. * @param mesh Mesh to remove
  9853. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9854. * @returns the Shadow Generator itself
  9855. */
  9856. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9857. /**
  9858. * Controls the extent to which the shadows fade out at the edge of the frustum
  9859. * Used only by directionals and spots
  9860. */
  9861. frustumEdgeFalloff: number;
  9862. private _light;
  9863. /**
  9864. * Returns the associated light object.
  9865. * @returns the light generating the shadow
  9866. */
  9867. getLight(): IShadowLight;
  9868. /**
  9869. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9870. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9871. * It might on the other hand introduce peter panning.
  9872. */
  9873. forceBackFacesOnly: boolean;
  9874. private _scene;
  9875. private _lightDirection;
  9876. private _effect;
  9877. private _viewMatrix;
  9878. private _projectionMatrix;
  9879. private _transformMatrix;
  9880. private _cachedPosition;
  9881. private _cachedDirection;
  9882. private _cachedDefines;
  9883. private _currentRenderID;
  9884. private _boxBlurPostprocess;
  9885. private _kernelBlurXPostprocess;
  9886. private _kernelBlurYPostprocess;
  9887. private _blurPostProcesses;
  9888. private _mapSize;
  9889. private _currentFaceIndex;
  9890. private _currentFaceIndexCache;
  9891. private _textureType;
  9892. private _defaultTextureMatrix;
  9893. private _storedUniqueId;
  9894. /** @hidden */
  9895. static _SceneComponentInitialization: (scene: Scene) => void;
  9896. /**
  9897. * Creates a ShadowGenerator object.
  9898. * A ShadowGenerator is the required tool to use the shadows.
  9899. * Each light casting shadows needs to use its own ShadowGenerator.
  9900. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9901. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9902. * @param light The light object generating the shadows.
  9903. * @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.
  9904. */
  9905. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9906. private _initializeGenerator;
  9907. private _initializeShadowMap;
  9908. private _initializeBlurRTTAndPostProcesses;
  9909. private _renderForShadowMap;
  9910. private _renderSubMeshForShadowMap;
  9911. private _applyFilterValues;
  9912. /**
  9913. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9914. * @param onCompiled Callback triggered at the and of the effects compilation
  9915. * @param options Sets of optional options forcing the compilation with different modes
  9916. */
  9917. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9918. useInstances: boolean;
  9919. }>): void;
  9920. /**
  9921. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9922. * @param options Sets of optional options forcing the compilation with different modes
  9923. * @returns A promise that resolves when the compilation completes
  9924. */
  9925. forceCompilationAsync(options?: Partial<{
  9926. useInstances: boolean;
  9927. }>): Promise<void>;
  9928. /**
  9929. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9930. * @param subMesh The submesh we want to render in the shadow map
  9931. * @param useInstances Defines wether will draw in the map using instances
  9932. * @returns true if ready otherwise, false
  9933. */
  9934. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9935. /**
  9936. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9937. * @param defines Defines of the material we want to update
  9938. * @param lightIndex Index of the light in the enabled light list of the material
  9939. */
  9940. prepareDefines(defines: any, lightIndex: number): void;
  9941. /**
  9942. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9943. * defined in the generator but impacting the effect).
  9944. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9945. * @param effect The effect we are binfing the information for
  9946. */
  9947. bindShadowLight(lightIndex: string, effect: Effect): void;
  9948. /**
  9949. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9950. * (eq to shadow prjection matrix * light transform matrix)
  9951. * @returns The transform matrix used to create the shadow map
  9952. */
  9953. getTransformMatrix(): Matrix;
  9954. /**
  9955. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9956. * Cube and 2D textures for instance.
  9957. */
  9958. recreateShadowMap(): void;
  9959. private _disposeBlurPostProcesses;
  9960. private _disposeRTTandPostProcesses;
  9961. /**
  9962. * Disposes the ShadowGenerator.
  9963. * Returns nothing.
  9964. */
  9965. dispose(): void;
  9966. /**
  9967. * Serializes the shadow generator setup to a json object.
  9968. * @returns The serialized JSON object
  9969. */
  9970. serialize(): any;
  9971. /**
  9972. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9973. * @param parsedShadowGenerator The JSON object to parse
  9974. * @param scene The scene to create the shadow map for
  9975. * @returns The parsed shadow generator
  9976. */
  9977. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9978. }
  9979. }
  9980. declare module "babylonjs/Lights/light" {
  9981. import { Nullable } from "babylonjs/types";
  9982. import { Scene } from "babylonjs/scene";
  9983. import { Vector3 } from "babylonjs/Maths/math.vector";
  9984. import { Color3 } from "babylonjs/Maths/math.color";
  9985. import { Node } from "babylonjs/node";
  9986. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9987. import { Effect } from "babylonjs/Materials/effect";
  9988. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9989. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9990. /**
  9991. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9992. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9993. * 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.
  9994. */
  9995. export abstract class Light extends Node {
  9996. /**
  9997. * Falloff Default: light is falling off following the material specification:
  9998. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9999. */
  10000. static readonly FALLOFF_DEFAULT: number;
  10001. /**
  10002. * Falloff Physical: light is falling off following the inverse squared distance law.
  10003. */
  10004. static readonly FALLOFF_PHYSICAL: number;
  10005. /**
  10006. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10007. * to enhance interoperability with other engines.
  10008. */
  10009. static readonly FALLOFF_GLTF: number;
  10010. /**
  10011. * Falloff Standard: light is falling off like in the standard material
  10012. * to enhance interoperability with other materials.
  10013. */
  10014. static readonly FALLOFF_STANDARD: number;
  10015. /**
  10016. * If every light affecting the material is in this lightmapMode,
  10017. * material.lightmapTexture adds or multiplies
  10018. * (depends on material.useLightmapAsShadowmap)
  10019. * after every other light calculations.
  10020. */
  10021. static readonly LIGHTMAP_DEFAULT: number;
  10022. /**
  10023. * material.lightmapTexture as only diffuse lighting from this light
  10024. * adds only specular lighting from this light
  10025. * adds dynamic shadows
  10026. */
  10027. static readonly LIGHTMAP_SPECULAR: number;
  10028. /**
  10029. * material.lightmapTexture as only lighting
  10030. * no light calculation from this light
  10031. * only adds dynamic shadows from this light
  10032. */
  10033. static readonly LIGHTMAP_SHADOWSONLY: number;
  10034. /**
  10035. * Each light type uses the default quantity according to its type:
  10036. * point/spot lights use luminous intensity
  10037. * directional lights use illuminance
  10038. */
  10039. static readonly INTENSITYMODE_AUTOMATIC: number;
  10040. /**
  10041. * lumen (lm)
  10042. */
  10043. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10044. /**
  10045. * candela (lm/sr)
  10046. */
  10047. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10048. /**
  10049. * lux (lm/m^2)
  10050. */
  10051. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10052. /**
  10053. * nit (cd/m^2)
  10054. */
  10055. static readonly INTENSITYMODE_LUMINANCE: number;
  10056. /**
  10057. * Light type const id of the point light.
  10058. */
  10059. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10060. /**
  10061. * Light type const id of the directional light.
  10062. */
  10063. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10064. /**
  10065. * Light type const id of the spot light.
  10066. */
  10067. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10068. /**
  10069. * Light type const id of the hemispheric light.
  10070. */
  10071. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10072. /**
  10073. * Diffuse gives the basic color to an object.
  10074. */
  10075. diffuse: Color3;
  10076. /**
  10077. * Specular produces a highlight color on an object.
  10078. * Note: This is note affecting PBR materials.
  10079. */
  10080. specular: Color3;
  10081. /**
  10082. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10083. * falling off base on range or angle.
  10084. * This can be set to any values in Light.FALLOFF_x.
  10085. *
  10086. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10087. * other types of materials.
  10088. */
  10089. falloffType: number;
  10090. /**
  10091. * Strength of the light.
  10092. * Note: By default it is define in the framework own unit.
  10093. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10094. */
  10095. intensity: number;
  10096. private _range;
  10097. protected _inverseSquaredRange: number;
  10098. /**
  10099. * Defines how far from the source the light is impacting in scene units.
  10100. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10101. */
  10102. /**
  10103. * Defines how far from the source the light is impacting in scene units.
  10104. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10105. */
  10106. range: number;
  10107. /**
  10108. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10109. * of light.
  10110. */
  10111. private _photometricScale;
  10112. private _intensityMode;
  10113. /**
  10114. * Gets the photometric scale used to interpret the intensity.
  10115. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10116. */
  10117. /**
  10118. * Sets the photometric scale used to interpret the intensity.
  10119. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10120. */
  10121. intensityMode: number;
  10122. private _radius;
  10123. /**
  10124. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10125. */
  10126. /**
  10127. * sets the light radius used by PBR Materials to simulate soft area lights.
  10128. */
  10129. radius: number;
  10130. private _renderPriority;
  10131. /**
  10132. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10133. * exceeding the number allowed of the materials.
  10134. */
  10135. renderPriority: number;
  10136. private _shadowEnabled;
  10137. /**
  10138. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10139. * the current shadow generator.
  10140. */
  10141. /**
  10142. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10143. * the current shadow generator.
  10144. */
  10145. shadowEnabled: boolean;
  10146. private _includedOnlyMeshes;
  10147. /**
  10148. * Gets the only meshes impacted by this light.
  10149. */
  10150. /**
  10151. * Sets the only meshes impacted by this light.
  10152. */
  10153. includedOnlyMeshes: AbstractMesh[];
  10154. private _excludedMeshes;
  10155. /**
  10156. * Gets the meshes not impacted by this light.
  10157. */
  10158. /**
  10159. * Sets the meshes not impacted by this light.
  10160. */
  10161. excludedMeshes: AbstractMesh[];
  10162. private _excludeWithLayerMask;
  10163. /**
  10164. * Gets the layer id use to find what meshes are not impacted by the light.
  10165. * Inactive if 0
  10166. */
  10167. /**
  10168. * Sets the layer id use to find what meshes are not impacted by the light.
  10169. * Inactive if 0
  10170. */
  10171. excludeWithLayerMask: number;
  10172. private _includeOnlyWithLayerMask;
  10173. /**
  10174. * Gets the layer id use to find what meshes are impacted by the light.
  10175. * Inactive if 0
  10176. */
  10177. /**
  10178. * Sets the layer id use to find what meshes are impacted by the light.
  10179. * Inactive if 0
  10180. */
  10181. includeOnlyWithLayerMask: number;
  10182. private _lightmapMode;
  10183. /**
  10184. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10185. */
  10186. /**
  10187. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10188. */
  10189. lightmapMode: number;
  10190. /**
  10191. * Shadow generator associted to the light.
  10192. * @hidden Internal use only.
  10193. */
  10194. _shadowGenerator: Nullable<IShadowGenerator>;
  10195. /**
  10196. * @hidden Internal use only.
  10197. */
  10198. _excludedMeshesIds: string[];
  10199. /**
  10200. * @hidden Internal use only.
  10201. */
  10202. _includedOnlyMeshesIds: string[];
  10203. /**
  10204. * The current light unifom buffer.
  10205. * @hidden Internal use only.
  10206. */
  10207. _uniformBuffer: UniformBuffer;
  10208. /** @hidden */
  10209. _renderId: number;
  10210. /**
  10211. * Creates a Light object in the scene.
  10212. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10213. * @param name The firendly name of the light
  10214. * @param scene The scene the light belongs too
  10215. */
  10216. constructor(name: string, scene: Scene);
  10217. protected abstract _buildUniformLayout(): void;
  10218. /**
  10219. * Sets the passed Effect "effect" with the Light information.
  10220. * @param effect The effect to update
  10221. * @param lightIndex The index of the light in the effect to update
  10222. * @returns The light
  10223. */
  10224. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10225. /**
  10226. * Sets the passed Effect "effect" with the Light textures.
  10227. * @param effect The effect to update
  10228. * @param lightIndex The index of the light in the effect to update
  10229. * @returns The light
  10230. */
  10231. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  10232. /**
  10233. * Binds the lights information from the scene to the effect for the given mesh.
  10234. * @param lightIndex Light index
  10235. * @param scene The scene where the light belongs to
  10236. * @param effect The effect we are binding the data to
  10237. * @param useSpecular Defines if specular is supported
  10238. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  10239. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  10240. */
  10241. bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  10242. /**
  10243. * Sets the passed Effect "effect" with the Light information.
  10244. * @param effect The effect to update
  10245. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10246. * @returns The light
  10247. */
  10248. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10249. /**
  10250. * Returns the string "Light".
  10251. * @returns the class name
  10252. */
  10253. getClassName(): string;
  10254. /** @hidden */
  10255. readonly _isLight: boolean;
  10256. /**
  10257. * Converts the light information to a readable string for debug purpose.
  10258. * @param fullDetails Supports for multiple levels of logging within scene loading
  10259. * @returns the human readable light info
  10260. */
  10261. toString(fullDetails?: boolean): string;
  10262. /** @hidden */
  10263. protected _syncParentEnabledState(): void;
  10264. /**
  10265. * Set the enabled state of this node.
  10266. * @param value - the new enabled state
  10267. */
  10268. setEnabled(value: boolean): void;
  10269. /**
  10270. * Returns the Light associated shadow generator if any.
  10271. * @return the associated shadow generator.
  10272. */
  10273. getShadowGenerator(): Nullable<IShadowGenerator>;
  10274. /**
  10275. * Returns a Vector3, the absolute light position in the World.
  10276. * @returns the world space position of the light
  10277. */
  10278. getAbsolutePosition(): Vector3;
  10279. /**
  10280. * Specifies if the light will affect the passed mesh.
  10281. * @param mesh The mesh to test against the light
  10282. * @return true the mesh is affected otherwise, false.
  10283. */
  10284. canAffectMesh(mesh: AbstractMesh): boolean;
  10285. /**
  10286. * Sort function to order lights for rendering.
  10287. * @param a First Light object to compare to second.
  10288. * @param b Second Light object to compare first.
  10289. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10290. */
  10291. static CompareLightsPriority(a: Light, b: Light): number;
  10292. /**
  10293. * Releases resources associated with this node.
  10294. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10295. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10296. */
  10297. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10298. /**
  10299. * Returns the light type ID (integer).
  10300. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10301. */
  10302. getTypeID(): number;
  10303. /**
  10304. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10305. * @returns the scaled intensity in intensity mode unit
  10306. */
  10307. getScaledIntensity(): number;
  10308. /**
  10309. * Returns a new Light object, named "name", from the current one.
  10310. * @param name The name of the cloned light
  10311. * @returns the new created light
  10312. */
  10313. clone(name: string): Nullable<Light>;
  10314. /**
  10315. * Serializes the current light into a Serialization object.
  10316. * @returns the serialized object.
  10317. */
  10318. serialize(): any;
  10319. /**
  10320. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10321. * This new light is named "name" and added to the passed scene.
  10322. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10323. * @param name The friendly name of the light
  10324. * @param scene The scene the new light will belong to
  10325. * @returns the constructor function
  10326. */
  10327. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10328. /**
  10329. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10330. * @param parsedLight The JSON representation of the light
  10331. * @param scene The scene to create the parsed light in
  10332. * @returns the created light after parsing
  10333. */
  10334. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10335. private _hookArrayForExcluded;
  10336. private _hookArrayForIncludedOnly;
  10337. private _resyncMeshes;
  10338. /**
  10339. * Forces the meshes to update their light related information in their rendering used effects
  10340. * @hidden Internal Use Only
  10341. */
  10342. _markMeshesAsLightDirty(): void;
  10343. /**
  10344. * Recomputes the cached photometric scale if needed.
  10345. */
  10346. private _computePhotometricScale;
  10347. /**
  10348. * Returns the Photometric Scale according to the light type and intensity mode.
  10349. */
  10350. private _getPhotometricScale;
  10351. /**
  10352. * Reorder the light in the scene according to their defined priority.
  10353. * @hidden Internal Use Only
  10354. */
  10355. _reorderLightsInScene(): void;
  10356. /**
  10357. * Prepares the list of defines specific to the light type.
  10358. * @param defines the list of defines
  10359. * @param lightIndex defines the index of the light for the effect
  10360. */
  10361. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10362. }
  10363. }
  10364. declare module "babylonjs/Actions/action" {
  10365. import { Observable } from "babylonjs/Misc/observable";
  10366. import { Condition } from "babylonjs/Actions/condition";
  10367. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10368. import { ActionManager } from "babylonjs/Actions/actionManager";
  10369. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10370. /**
  10371. * Interface used to define Action
  10372. */
  10373. export interface IAction {
  10374. /**
  10375. * Trigger for the action
  10376. */
  10377. trigger: number;
  10378. /** Options of the trigger */
  10379. triggerOptions: any;
  10380. /**
  10381. * Gets the trigger parameters
  10382. * @returns the trigger parameters
  10383. */
  10384. getTriggerParameter(): any;
  10385. /**
  10386. * Internal only - executes current action event
  10387. * @hidden
  10388. */
  10389. _executeCurrent(evt?: ActionEvent): void;
  10390. /**
  10391. * Serialize placeholder for child classes
  10392. * @param parent of child
  10393. * @returns the serialized object
  10394. */
  10395. serialize(parent: any): any;
  10396. /**
  10397. * Internal only
  10398. * @hidden
  10399. */
  10400. _prepare(): void;
  10401. /**
  10402. * Internal only - manager for action
  10403. * @hidden
  10404. */
  10405. _actionManager: AbstractActionManager;
  10406. /**
  10407. * Adds action to chain of actions, may be a DoNothingAction
  10408. * @param action defines the next action to execute
  10409. * @returns The action passed in
  10410. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10411. */
  10412. then(action: IAction): IAction;
  10413. }
  10414. /**
  10415. * The action to be carried out following a trigger
  10416. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10417. */
  10418. export class Action implements IAction {
  10419. /** the trigger, with or without parameters, for the action */
  10420. triggerOptions: any;
  10421. /**
  10422. * Trigger for the action
  10423. */
  10424. trigger: number;
  10425. /**
  10426. * Internal only - manager for action
  10427. * @hidden
  10428. */
  10429. _actionManager: ActionManager;
  10430. private _nextActiveAction;
  10431. private _child;
  10432. private _condition?;
  10433. private _triggerParameter;
  10434. /**
  10435. * An event triggered prior to action being executed.
  10436. */
  10437. onBeforeExecuteObservable: Observable<Action>;
  10438. /**
  10439. * Creates a new Action
  10440. * @param triggerOptions the trigger, with or without parameters, for the action
  10441. * @param condition an optional determinant of action
  10442. */
  10443. constructor(
  10444. /** the trigger, with or without parameters, for the action */
  10445. triggerOptions: any, condition?: Condition);
  10446. /**
  10447. * Internal only
  10448. * @hidden
  10449. */
  10450. _prepare(): void;
  10451. /**
  10452. * Gets the trigger parameters
  10453. * @returns the trigger parameters
  10454. */
  10455. getTriggerParameter(): any;
  10456. /**
  10457. * Internal only - executes current action event
  10458. * @hidden
  10459. */
  10460. _executeCurrent(evt?: ActionEvent): void;
  10461. /**
  10462. * Execute placeholder for child classes
  10463. * @param evt optional action event
  10464. */
  10465. execute(evt?: ActionEvent): void;
  10466. /**
  10467. * Skips to next active action
  10468. */
  10469. skipToNextActiveAction(): void;
  10470. /**
  10471. * Adds action to chain of actions, may be a DoNothingAction
  10472. * @param action defines the next action to execute
  10473. * @returns The action passed in
  10474. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10475. */
  10476. then(action: Action): Action;
  10477. /**
  10478. * Internal only
  10479. * @hidden
  10480. */
  10481. _getProperty(propertyPath: string): string;
  10482. /**
  10483. * Internal only
  10484. * @hidden
  10485. */
  10486. _getEffectiveTarget(target: any, propertyPath: string): any;
  10487. /**
  10488. * Serialize placeholder for child classes
  10489. * @param parent of child
  10490. * @returns the serialized object
  10491. */
  10492. serialize(parent: any): any;
  10493. /**
  10494. * Internal only called by serialize
  10495. * @hidden
  10496. */
  10497. protected _serialize(serializedAction: any, parent?: any): any;
  10498. /**
  10499. * Internal only
  10500. * @hidden
  10501. */
  10502. static _SerializeValueAsString: (value: any) => string;
  10503. /**
  10504. * Internal only
  10505. * @hidden
  10506. */
  10507. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10508. name: string;
  10509. targetType: string;
  10510. value: string;
  10511. };
  10512. }
  10513. }
  10514. declare module "babylonjs/Actions/condition" {
  10515. import { ActionManager } from "babylonjs/Actions/actionManager";
  10516. /**
  10517. * A Condition applied to an Action
  10518. */
  10519. export class Condition {
  10520. /**
  10521. * Internal only - manager for action
  10522. * @hidden
  10523. */
  10524. _actionManager: ActionManager;
  10525. /**
  10526. * Internal only
  10527. * @hidden
  10528. */
  10529. _evaluationId: number;
  10530. /**
  10531. * Internal only
  10532. * @hidden
  10533. */
  10534. _currentResult: boolean;
  10535. /**
  10536. * Creates a new Condition
  10537. * @param actionManager the manager of the action the condition is applied to
  10538. */
  10539. constructor(actionManager: ActionManager);
  10540. /**
  10541. * Check if the current condition is valid
  10542. * @returns a boolean
  10543. */
  10544. isValid(): boolean;
  10545. /**
  10546. * Internal only
  10547. * @hidden
  10548. */
  10549. _getProperty(propertyPath: string): string;
  10550. /**
  10551. * Internal only
  10552. * @hidden
  10553. */
  10554. _getEffectiveTarget(target: any, propertyPath: string): any;
  10555. /**
  10556. * Serialize placeholder for child classes
  10557. * @returns the serialized object
  10558. */
  10559. serialize(): any;
  10560. /**
  10561. * Internal only
  10562. * @hidden
  10563. */
  10564. protected _serialize(serializedCondition: any): any;
  10565. }
  10566. /**
  10567. * Defines specific conditional operators as extensions of Condition
  10568. */
  10569. export class ValueCondition extends Condition {
  10570. /** path to specify the property of the target the conditional operator uses */
  10571. propertyPath: string;
  10572. /** the value compared by the conditional operator against the current value of the property */
  10573. value: any;
  10574. /** the conditional operator, default ValueCondition.IsEqual */
  10575. operator: number;
  10576. /**
  10577. * Internal only
  10578. * @hidden
  10579. */
  10580. private static _IsEqual;
  10581. /**
  10582. * Internal only
  10583. * @hidden
  10584. */
  10585. private static _IsDifferent;
  10586. /**
  10587. * Internal only
  10588. * @hidden
  10589. */
  10590. private static _IsGreater;
  10591. /**
  10592. * Internal only
  10593. * @hidden
  10594. */
  10595. private static _IsLesser;
  10596. /**
  10597. * returns the number for IsEqual
  10598. */
  10599. static readonly IsEqual: number;
  10600. /**
  10601. * Returns the number for IsDifferent
  10602. */
  10603. static readonly IsDifferent: number;
  10604. /**
  10605. * Returns the number for IsGreater
  10606. */
  10607. static readonly IsGreater: number;
  10608. /**
  10609. * Returns the number for IsLesser
  10610. */
  10611. static readonly IsLesser: number;
  10612. /**
  10613. * Internal only The action manager for the condition
  10614. * @hidden
  10615. */
  10616. _actionManager: ActionManager;
  10617. /**
  10618. * Internal only
  10619. * @hidden
  10620. */
  10621. private _target;
  10622. /**
  10623. * Internal only
  10624. * @hidden
  10625. */
  10626. private _effectiveTarget;
  10627. /**
  10628. * Internal only
  10629. * @hidden
  10630. */
  10631. private _property;
  10632. /**
  10633. * Creates a new ValueCondition
  10634. * @param actionManager manager for the action the condition applies to
  10635. * @param target for the action
  10636. * @param propertyPath path to specify the property of the target the conditional operator uses
  10637. * @param value the value compared by the conditional operator against the current value of the property
  10638. * @param operator the conditional operator, default ValueCondition.IsEqual
  10639. */
  10640. constructor(actionManager: ActionManager, target: any,
  10641. /** path to specify the property of the target the conditional operator uses */
  10642. propertyPath: string,
  10643. /** the value compared by the conditional operator against the current value of the property */
  10644. value: any,
  10645. /** the conditional operator, default ValueCondition.IsEqual */
  10646. operator?: number);
  10647. /**
  10648. * Compares the given value with the property value for the specified conditional operator
  10649. * @returns the result of the comparison
  10650. */
  10651. isValid(): boolean;
  10652. /**
  10653. * Serialize the ValueCondition into a JSON compatible object
  10654. * @returns serialization object
  10655. */
  10656. serialize(): any;
  10657. /**
  10658. * Gets the name of the conditional operator for the ValueCondition
  10659. * @param operator the conditional operator
  10660. * @returns the name
  10661. */
  10662. static GetOperatorName(operator: number): string;
  10663. }
  10664. /**
  10665. * Defines a predicate condition as an extension of Condition
  10666. */
  10667. export class PredicateCondition extends Condition {
  10668. /** defines the predicate function used to validate the condition */
  10669. predicate: () => boolean;
  10670. /**
  10671. * Internal only - manager for action
  10672. * @hidden
  10673. */
  10674. _actionManager: ActionManager;
  10675. /**
  10676. * Creates a new PredicateCondition
  10677. * @param actionManager manager for the action the condition applies to
  10678. * @param predicate defines the predicate function used to validate the condition
  10679. */
  10680. constructor(actionManager: ActionManager,
  10681. /** defines the predicate function used to validate the condition */
  10682. predicate: () => boolean);
  10683. /**
  10684. * @returns the validity of the predicate condition
  10685. */
  10686. isValid(): boolean;
  10687. }
  10688. /**
  10689. * Defines a state condition as an extension of Condition
  10690. */
  10691. export class StateCondition extends Condition {
  10692. /** Value to compare with target state */
  10693. value: string;
  10694. /**
  10695. * Internal only - manager for action
  10696. * @hidden
  10697. */
  10698. _actionManager: ActionManager;
  10699. /**
  10700. * Internal only
  10701. * @hidden
  10702. */
  10703. private _target;
  10704. /**
  10705. * Creates a new StateCondition
  10706. * @param actionManager manager for the action the condition applies to
  10707. * @param target of the condition
  10708. * @param value to compare with target state
  10709. */
  10710. constructor(actionManager: ActionManager, target: any,
  10711. /** Value to compare with target state */
  10712. value: string);
  10713. /**
  10714. * Gets a boolean indicating if the current condition is met
  10715. * @returns the validity of the state
  10716. */
  10717. isValid(): boolean;
  10718. /**
  10719. * Serialize the StateCondition into a JSON compatible object
  10720. * @returns serialization object
  10721. */
  10722. serialize(): any;
  10723. }
  10724. }
  10725. declare module "babylonjs/Actions/directActions" {
  10726. import { Action } from "babylonjs/Actions/action";
  10727. import { Condition } from "babylonjs/Actions/condition";
  10728. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10729. /**
  10730. * This defines an action responsible to toggle a boolean once triggered.
  10731. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10732. */
  10733. export class SwitchBooleanAction extends Action {
  10734. /**
  10735. * The path to the boolean property in the target object
  10736. */
  10737. propertyPath: string;
  10738. private _target;
  10739. private _effectiveTarget;
  10740. private _property;
  10741. /**
  10742. * Instantiate the action
  10743. * @param triggerOptions defines the trigger options
  10744. * @param target defines the object containing the boolean
  10745. * @param propertyPath defines the path to the boolean property in the target object
  10746. * @param condition defines the trigger related conditions
  10747. */
  10748. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10749. /** @hidden */
  10750. _prepare(): void;
  10751. /**
  10752. * Execute the action toggle the boolean value.
  10753. */
  10754. execute(): void;
  10755. /**
  10756. * Serializes the actions and its related information.
  10757. * @param parent defines the object to serialize in
  10758. * @returns the serialized object
  10759. */
  10760. serialize(parent: any): any;
  10761. }
  10762. /**
  10763. * This defines an action responsible to set a the state field of the target
  10764. * to a desired value once triggered.
  10765. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10766. */
  10767. export class SetStateAction extends Action {
  10768. /**
  10769. * The value to store in the state field.
  10770. */
  10771. value: string;
  10772. private _target;
  10773. /**
  10774. * Instantiate the action
  10775. * @param triggerOptions defines the trigger options
  10776. * @param target defines the object containing the state property
  10777. * @param value defines the value to store in the state field
  10778. * @param condition defines the trigger related conditions
  10779. */
  10780. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10781. /**
  10782. * Execute the action and store the value on the target state property.
  10783. */
  10784. execute(): void;
  10785. /**
  10786. * Serializes the actions and its related information.
  10787. * @param parent defines the object to serialize in
  10788. * @returns the serialized object
  10789. */
  10790. serialize(parent: any): any;
  10791. }
  10792. /**
  10793. * This defines an action responsible to set a property of the target
  10794. * to a desired value once triggered.
  10795. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10796. */
  10797. export class SetValueAction extends Action {
  10798. /**
  10799. * The path of the property to set in the target.
  10800. */
  10801. propertyPath: string;
  10802. /**
  10803. * The value to set in the property
  10804. */
  10805. value: any;
  10806. private _target;
  10807. private _effectiveTarget;
  10808. private _property;
  10809. /**
  10810. * Instantiate the action
  10811. * @param triggerOptions defines the trigger options
  10812. * @param target defines the object containing the property
  10813. * @param propertyPath defines the path of the property to set in the target
  10814. * @param value defines the value to set in the property
  10815. * @param condition defines the trigger related conditions
  10816. */
  10817. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10818. /** @hidden */
  10819. _prepare(): void;
  10820. /**
  10821. * Execute the action and set the targetted property to the desired value.
  10822. */
  10823. execute(): void;
  10824. /**
  10825. * Serializes the actions and its related information.
  10826. * @param parent defines the object to serialize in
  10827. * @returns the serialized object
  10828. */
  10829. serialize(parent: any): any;
  10830. }
  10831. /**
  10832. * This defines an action responsible to increment the target value
  10833. * to a desired value once triggered.
  10834. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10835. */
  10836. export class IncrementValueAction extends Action {
  10837. /**
  10838. * The path of the property to increment in the target.
  10839. */
  10840. propertyPath: string;
  10841. /**
  10842. * The value we should increment the property by.
  10843. */
  10844. value: any;
  10845. private _target;
  10846. private _effectiveTarget;
  10847. private _property;
  10848. /**
  10849. * Instantiate the action
  10850. * @param triggerOptions defines the trigger options
  10851. * @param target defines the object containing the property
  10852. * @param propertyPath defines the path of the property to increment in the target
  10853. * @param value defines the value value we should increment the property by
  10854. * @param condition defines the trigger related conditions
  10855. */
  10856. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10857. /** @hidden */
  10858. _prepare(): void;
  10859. /**
  10860. * Execute the action and increment the target of the value amount.
  10861. */
  10862. execute(): void;
  10863. /**
  10864. * Serializes the actions and its related information.
  10865. * @param parent defines the object to serialize in
  10866. * @returns the serialized object
  10867. */
  10868. serialize(parent: any): any;
  10869. }
  10870. /**
  10871. * This defines an action responsible to start an animation once triggered.
  10872. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10873. */
  10874. export class PlayAnimationAction extends Action {
  10875. /**
  10876. * Where the animation should start (animation frame)
  10877. */
  10878. from: number;
  10879. /**
  10880. * Where the animation should stop (animation frame)
  10881. */
  10882. to: number;
  10883. /**
  10884. * Define if the animation should loop or stop after the first play.
  10885. */
  10886. loop?: boolean;
  10887. private _target;
  10888. /**
  10889. * Instantiate the action
  10890. * @param triggerOptions defines the trigger options
  10891. * @param target defines the target animation or animation name
  10892. * @param from defines from where the animation should start (animation frame)
  10893. * @param end defines where the animation should stop (animation frame)
  10894. * @param loop defines if the animation should loop or stop after the first play
  10895. * @param condition defines the trigger related conditions
  10896. */
  10897. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10898. /** @hidden */
  10899. _prepare(): void;
  10900. /**
  10901. * Execute the action and play the animation.
  10902. */
  10903. execute(): void;
  10904. /**
  10905. * Serializes the actions and its related information.
  10906. * @param parent defines the object to serialize in
  10907. * @returns the serialized object
  10908. */
  10909. serialize(parent: any): any;
  10910. }
  10911. /**
  10912. * This defines an action responsible to stop an animation once triggered.
  10913. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10914. */
  10915. export class StopAnimationAction extends Action {
  10916. private _target;
  10917. /**
  10918. * Instantiate the action
  10919. * @param triggerOptions defines the trigger options
  10920. * @param target defines the target animation or animation name
  10921. * @param condition defines the trigger related conditions
  10922. */
  10923. constructor(triggerOptions: any, target: any, condition?: Condition);
  10924. /** @hidden */
  10925. _prepare(): void;
  10926. /**
  10927. * Execute the action and stop the animation.
  10928. */
  10929. execute(): void;
  10930. /**
  10931. * Serializes the actions and its related information.
  10932. * @param parent defines the object to serialize in
  10933. * @returns the serialized object
  10934. */
  10935. serialize(parent: any): any;
  10936. }
  10937. /**
  10938. * This defines an action responsible that does nothing once triggered.
  10939. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10940. */
  10941. export class DoNothingAction extends Action {
  10942. /**
  10943. * Instantiate the action
  10944. * @param triggerOptions defines the trigger options
  10945. * @param condition defines the trigger related conditions
  10946. */
  10947. constructor(triggerOptions?: any, condition?: Condition);
  10948. /**
  10949. * Execute the action and do nothing.
  10950. */
  10951. execute(): void;
  10952. /**
  10953. * Serializes the actions and its related information.
  10954. * @param parent defines the object to serialize in
  10955. * @returns the serialized object
  10956. */
  10957. serialize(parent: any): any;
  10958. }
  10959. /**
  10960. * This defines an action responsible to trigger several actions once triggered.
  10961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10962. */
  10963. export class CombineAction extends Action {
  10964. /**
  10965. * The list of aggregated animations to run.
  10966. */
  10967. children: Action[];
  10968. /**
  10969. * Instantiate the action
  10970. * @param triggerOptions defines the trigger options
  10971. * @param children defines the list of aggregated animations to run
  10972. * @param condition defines the trigger related conditions
  10973. */
  10974. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10975. /** @hidden */
  10976. _prepare(): void;
  10977. /**
  10978. * Execute the action and executes all the aggregated actions.
  10979. */
  10980. execute(evt: ActionEvent): void;
  10981. /**
  10982. * Serializes the actions and its related information.
  10983. * @param parent defines the object to serialize in
  10984. * @returns the serialized object
  10985. */
  10986. serialize(parent: any): any;
  10987. }
  10988. /**
  10989. * This defines an action responsible to run code (external event) once triggered.
  10990. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10991. */
  10992. export class ExecuteCodeAction extends Action {
  10993. /**
  10994. * The callback function to run.
  10995. */
  10996. func: (evt: ActionEvent) => void;
  10997. /**
  10998. * Instantiate the action
  10999. * @param triggerOptions defines the trigger options
  11000. * @param func defines the callback function to run
  11001. * @param condition defines the trigger related conditions
  11002. */
  11003. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11004. /**
  11005. * Execute the action and run the attached code.
  11006. */
  11007. execute(evt: ActionEvent): void;
  11008. }
  11009. /**
  11010. * This defines an action responsible to set the parent property of the target once triggered.
  11011. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11012. */
  11013. export class SetParentAction extends Action {
  11014. private _parent;
  11015. private _target;
  11016. /**
  11017. * Instantiate the action
  11018. * @param triggerOptions defines the trigger options
  11019. * @param target defines the target containing the parent property
  11020. * @param parent defines from where the animation should start (animation frame)
  11021. * @param condition defines the trigger related conditions
  11022. */
  11023. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11024. /** @hidden */
  11025. _prepare(): void;
  11026. /**
  11027. * Execute the action and set the parent property.
  11028. */
  11029. execute(): void;
  11030. /**
  11031. * Serializes the actions and its related information.
  11032. * @param parent defines the object to serialize in
  11033. * @returns the serialized object
  11034. */
  11035. serialize(parent: any): any;
  11036. }
  11037. }
  11038. declare module "babylonjs/Actions/actionManager" {
  11039. import { Nullable } from "babylonjs/types";
  11040. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11041. import { Scene } from "babylonjs/scene";
  11042. import { IAction } from "babylonjs/Actions/action";
  11043. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11044. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11045. /**
  11046. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11047. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11048. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11049. */
  11050. export class ActionManager extends AbstractActionManager {
  11051. /**
  11052. * Nothing
  11053. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11054. */
  11055. static readonly NothingTrigger: number;
  11056. /**
  11057. * On pick
  11058. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11059. */
  11060. static readonly OnPickTrigger: number;
  11061. /**
  11062. * On left pick
  11063. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11064. */
  11065. static readonly OnLeftPickTrigger: number;
  11066. /**
  11067. * On right pick
  11068. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11069. */
  11070. static readonly OnRightPickTrigger: number;
  11071. /**
  11072. * On center pick
  11073. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11074. */
  11075. static readonly OnCenterPickTrigger: number;
  11076. /**
  11077. * On pick down
  11078. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11079. */
  11080. static readonly OnPickDownTrigger: number;
  11081. /**
  11082. * On double pick
  11083. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11084. */
  11085. static readonly OnDoublePickTrigger: number;
  11086. /**
  11087. * On pick up
  11088. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11089. */
  11090. static readonly OnPickUpTrigger: number;
  11091. /**
  11092. * On pick out.
  11093. * This trigger will only be raised if you also declared a OnPickDown
  11094. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11095. */
  11096. static readonly OnPickOutTrigger: number;
  11097. /**
  11098. * On long press
  11099. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11100. */
  11101. static readonly OnLongPressTrigger: number;
  11102. /**
  11103. * On pointer over
  11104. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11105. */
  11106. static readonly OnPointerOverTrigger: number;
  11107. /**
  11108. * On pointer out
  11109. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11110. */
  11111. static readonly OnPointerOutTrigger: number;
  11112. /**
  11113. * On every frame
  11114. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11115. */
  11116. static readonly OnEveryFrameTrigger: number;
  11117. /**
  11118. * On intersection enter
  11119. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11120. */
  11121. static readonly OnIntersectionEnterTrigger: number;
  11122. /**
  11123. * On intersection exit
  11124. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11125. */
  11126. static readonly OnIntersectionExitTrigger: number;
  11127. /**
  11128. * On key down
  11129. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11130. */
  11131. static readonly OnKeyDownTrigger: number;
  11132. /**
  11133. * On key up
  11134. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11135. */
  11136. static readonly OnKeyUpTrigger: number;
  11137. private _scene;
  11138. /**
  11139. * Creates a new action manager
  11140. * @param scene defines the hosting scene
  11141. */
  11142. constructor(scene: Scene);
  11143. /**
  11144. * Releases all associated resources
  11145. */
  11146. dispose(): void;
  11147. /**
  11148. * Gets hosting scene
  11149. * @returns the hosting scene
  11150. */
  11151. getScene(): Scene;
  11152. /**
  11153. * Does this action manager handles actions of any of the given triggers
  11154. * @param triggers defines the triggers to be tested
  11155. * @return a boolean indicating whether one (or more) of the triggers is handled
  11156. */
  11157. hasSpecificTriggers(triggers: number[]): boolean;
  11158. /**
  11159. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11160. * speed.
  11161. * @param triggerA defines the trigger to be tested
  11162. * @param triggerB defines the trigger to be tested
  11163. * @return a boolean indicating whether one (or more) of the triggers is handled
  11164. */
  11165. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11166. /**
  11167. * Does this action manager handles actions of a given trigger
  11168. * @param trigger defines the trigger to be tested
  11169. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11170. * @return whether the trigger is handled
  11171. */
  11172. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11173. /**
  11174. * Does this action manager has pointer triggers
  11175. */
  11176. readonly hasPointerTriggers: boolean;
  11177. /**
  11178. * Does this action manager has pick triggers
  11179. */
  11180. readonly hasPickTriggers: boolean;
  11181. /**
  11182. * Registers an action to this action manager
  11183. * @param action defines the action to be registered
  11184. * @return the action amended (prepared) after registration
  11185. */
  11186. registerAction(action: IAction): Nullable<IAction>;
  11187. /**
  11188. * Unregisters an action to this action manager
  11189. * @param action defines the action to be unregistered
  11190. * @return a boolean indicating whether the action has been unregistered
  11191. */
  11192. unregisterAction(action: IAction): Boolean;
  11193. /**
  11194. * Process a specific trigger
  11195. * @param trigger defines the trigger to process
  11196. * @param evt defines the event details to be processed
  11197. */
  11198. processTrigger(trigger: number, evt?: IActionEvent): void;
  11199. /** @hidden */
  11200. _getEffectiveTarget(target: any, propertyPath: string): any;
  11201. /** @hidden */
  11202. _getProperty(propertyPath: string): string;
  11203. /**
  11204. * Serialize this manager to a JSON object
  11205. * @param name defines the property name to store this manager
  11206. * @returns a JSON representation of this manager
  11207. */
  11208. serialize(name: string): any;
  11209. /**
  11210. * Creates a new ActionManager from a JSON data
  11211. * @param parsedActions defines the JSON data to read from
  11212. * @param object defines the hosting mesh
  11213. * @param scene defines the hosting scene
  11214. */
  11215. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11216. /**
  11217. * Get a trigger name by index
  11218. * @param trigger defines the trigger index
  11219. * @returns a trigger name
  11220. */
  11221. static GetTriggerName(trigger: number): string;
  11222. }
  11223. }
  11224. declare module "babylonjs/Culling/ray" {
  11225. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11226. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  11227. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11228. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11229. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11230. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11231. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11232. import { Plane } from "babylonjs/Maths/math.plane";
  11233. /**
  11234. * Class representing a ray with position and direction
  11235. */
  11236. export class Ray {
  11237. /** origin point */
  11238. origin: Vector3;
  11239. /** direction */
  11240. direction: Vector3;
  11241. /** length of the ray */
  11242. length: number;
  11243. private static readonly TmpVector3;
  11244. private _tmpRay;
  11245. /**
  11246. * Creates a new ray
  11247. * @param origin origin point
  11248. * @param direction direction
  11249. * @param length length of the ray
  11250. */
  11251. constructor(
  11252. /** origin point */
  11253. origin: Vector3,
  11254. /** direction */
  11255. direction: Vector3,
  11256. /** length of the ray */
  11257. length?: number);
  11258. /**
  11259. * Checks if the ray intersects a box
  11260. * @param minimum bound of the box
  11261. * @param maximum bound of the box
  11262. * @param intersectionTreshold extra extend to be added to the box in all direction
  11263. * @returns if the box was hit
  11264. */
  11265. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11266. /**
  11267. * Checks if the ray intersects a box
  11268. * @param box the bounding box to check
  11269. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11270. * @returns if the box was hit
  11271. */
  11272. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11273. /**
  11274. * If the ray hits a sphere
  11275. * @param sphere the bounding sphere to check
  11276. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11277. * @returns true if it hits the sphere
  11278. */
  11279. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11280. /**
  11281. * If the ray hits a triange
  11282. * @param vertex0 triangle vertex
  11283. * @param vertex1 triangle vertex
  11284. * @param vertex2 triangle vertex
  11285. * @returns intersection information if hit
  11286. */
  11287. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11288. /**
  11289. * Checks if ray intersects a plane
  11290. * @param plane the plane to check
  11291. * @returns the distance away it was hit
  11292. */
  11293. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11294. /**
  11295. * Calculate the intercept of a ray on a given axis
  11296. * @param axis to check 'x' | 'y' | 'z'
  11297. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11298. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11299. */
  11300. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11301. /**
  11302. * Checks if ray intersects a mesh
  11303. * @param mesh the mesh to check
  11304. * @param fastCheck if only the bounding box should checked
  11305. * @returns picking info of the intersecton
  11306. */
  11307. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11308. /**
  11309. * Checks if ray intersects a mesh
  11310. * @param meshes the meshes to check
  11311. * @param fastCheck if only the bounding box should checked
  11312. * @param results array to store result in
  11313. * @returns Array of picking infos
  11314. */
  11315. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11316. private _comparePickingInfo;
  11317. private static smallnum;
  11318. private static rayl;
  11319. /**
  11320. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11321. * @param sega the first point of the segment to test the intersection against
  11322. * @param segb the second point of the segment to test the intersection against
  11323. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11324. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11325. */
  11326. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11327. /**
  11328. * Update the ray from viewport position
  11329. * @param x position
  11330. * @param y y position
  11331. * @param viewportWidth viewport width
  11332. * @param viewportHeight viewport height
  11333. * @param world world matrix
  11334. * @param view view matrix
  11335. * @param projection projection matrix
  11336. * @returns this ray updated
  11337. */
  11338. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11339. /**
  11340. * Creates a ray with origin and direction of 0,0,0
  11341. * @returns the new ray
  11342. */
  11343. static Zero(): Ray;
  11344. /**
  11345. * Creates a new ray from screen space and viewport
  11346. * @param x position
  11347. * @param y y position
  11348. * @param viewportWidth viewport width
  11349. * @param viewportHeight viewport height
  11350. * @param world world matrix
  11351. * @param view view matrix
  11352. * @param projection projection matrix
  11353. * @returns new ray
  11354. */
  11355. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11356. /**
  11357. * 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
  11358. * transformed to the given world matrix.
  11359. * @param origin The origin point
  11360. * @param end The end point
  11361. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11362. * @returns the new ray
  11363. */
  11364. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11365. /**
  11366. * Transforms a ray by a matrix
  11367. * @param ray ray to transform
  11368. * @param matrix matrix to apply
  11369. * @returns the resulting new ray
  11370. */
  11371. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11372. /**
  11373. * Transforms a ray by a matrix
  11374. * @param ray ray to transform
  11375. * @param matrix matrix to apply
  11376. * @param result ray to store result in
  11377. */
  11378. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11379. /**
  11380. * Unproject a ray from screen space to object space
  11381. * @param sourceX defines the screen space x coordinate to use
  11382. * @param sourceY defines the screen space y coordinate to use
  11383. * @param viewportWidth defines the current width of the viewport
  11384. * @param viewportHeight defines the current height of the viewport
  11385. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11386. * @param view defines the view matrix to use
  11387. * @param projection defines the projection matrix to use
  11388. */
  11389. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11390. }
  11391. /**
  11392. * Type used to define predicate used to select faces when a mesh intersection is detected
  11393. */
  11394. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11395. module "babylonjs/scene" {
  11396. interface Scene {
  11397. /** @hidden */
  11398. _tempPickingRay: Nullable<Ray>;
  11399. /** @hidden */
  11400. _cachedRayForTransform: Ray;
  11401. /** @hidden */
  11402. _pickWithRayInverseMatrix: Matrix;
  11403. /** @hidden */
  11404. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11405. /** @hidden */
  11406. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11407. }
  11408. }
  11409. }
  11410. declare module "babylonjs/sceneComponent" {
  11411. import { Scene } from "babylonjs/scene";
  11412. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11413. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11414. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11415. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11416. import { Nullable } from "babylonjs/types";
  11417. import { Camera } from "babylonjs/Cameras/camera";
  11418. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11419. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11420. import { AbstractScene } from "babylonjs/abstractScene";
  11421. import { Mesh } from "babylonjs/Meshes/mesh";
  11422. /**
  11423. * Groups all the scene component constants in one place to ease maintenance.
  11424. * @hidden
  11425. */
  11426. export class SceneComponentConstants {
  11427. static readonly NAME_EFFECTLAYER: string;
  11428. static readonly NAME_LAYER: string;
  11429. static readonly NAME_LENSFLARESYSTEM: string;
  11430. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11431. static readonly NAME_PARTICLESYSTEM: string;
  11432. static readonly NAME_GAMEPAD: string;
  11433. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11434. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11435. static readonly NAME_DEPTHRENDERER: string;
  11436. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11437. static readonly NAME_SPRITE: string;
  11438. static readonly NAME_OUTLINERENDERER: string;
  11439. static readonly NAME_PROCEDURALTEXTURE: string;
  11440. static readonly NAME_SHADOWGENERATOR: string;
  11441. static readonly NAME_OCTREE: string;
  11442. static readonly NAME_PHYSICSENGINE: string;
  11443. static readonly NAME_AUDIO: string;
  11444. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11445. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11446. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11447. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11448. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11449. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11450. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11451. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11452. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11453. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11454. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11455. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11456. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11457. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11458. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11459. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11460. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11461. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11462. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11463. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11464. static readonly STEP_AFTERRENDER_AUDIO: number;
  11465. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11466. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11467. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11468. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11469. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11470. static readonly STEP_POINTERMOVE_SPRITE: number;
  11471. static readonly STEP_POINTERDOWN_SPRITE: number;
  11472. static readonly STEP_POINTERUP_SPRITE: number;
  11473. }
  11474. /**
  11475. * This represents a scene component.
  11476. *
  11477. * This is used to decouple the dependency the scene is having on the different workloads like
  11478. * layers, post processes...
  11479. */
  11480. export interface ISceneComponent {
  11481. /**
  11482. * The name of the component. Each component must have a unique name.
  11483. */
  11484. name: string;
  11485. /**
  11486. * The scene the component belongs to.
  11487. */
  11488. scene: Scene;
  11489. /**
  11490. * Register the component to one instance of a scene.
  11491. */
  11492. register(): void;
  11493. /**
  11494. * Rebuilds the elements related to this component in case of
  11495. * context lost for instance.
  11496. */
  11497. rebuild(): void;
  11498. /**
  11499. * Disposes the component and the associated ressources.
  11500. */
  11501. dispose(): void;
  11502. }
  11503. /**
  11504. * This represents a SERIALIZABLE scene component.
  11505. *
  11506. * This extends Scene Component to add Serialization methods on top.
  11507. */
  11508. export interface ISceneSerializableComponent extends ISceneComponent {
  11509. /**
  11510. * Adds all the elements from the container to the scene
  11511. * @param container the container holding the elements
  11512. */
  11513. addFromContainer(container: AbstractScene): void;
  11514. /**
  11515. * Removes all the elements in the container from the scene
  11516. * @param container contains the elements to remove
  11517. * @param dispose if the removed element should be disposed (default: false)
  11518. */
  11519. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11520. /**
  11521. * Serializes the component data to the specified json object
  11522. * @param serializationObject The object to serialize to
  11523. */
  11524. serialize(serializationObject: any): void;
  11525. }
  11526. /**
  11527. * Strong typing of a Mesh related stage step action
  11528. */
  11529. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11530. /**
  11531. * Strong typing of a Evaluate Sub Mesh related stage step action
  11532. */
  11533. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11534. /**
  11535. * Strong typing of a Active Mesh related stage step action
  11536. */
  11537. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11538. /**
  11539. * Strong typing of a Camera related stage step action
  11540. */
  11541. export type CameraStageAction = (camera: Camera) => void;
  11542. /**
  11543. * Strong typing of a Camera Frame buffer related stage step action
  11544. */
  11545. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11546. /**
  11547. * Strong typing of a Render Target related stage step action
  11548. */
  11549. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11550. /**
  11551. * Strong typing of a RenderingGroup related stage step action
  11552. */
  11553. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11554. /**
  11555. * Strong typing of a Mesh Render related stage step action
  11556. */
  11557. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11558. /**
  11559. * Strong typing of a simple stage step action
  11560. */
  11561. export type SimpleStageAction = () => void;
  11562. /**
  11563. * Strong typing of a render target action.
  11564. */
  11565. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11566. /**
  11567. * Strong typing of a pointer move action.
  11568. */
  11569. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11570. /**
  11571. * Strong typing of a pointer up/down action.
  11572. */
  11573. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11574. /**
  11575. * Representation of a stage in the scene (Basically a list of ordered steps)
  11576. * @hidden
  11577. */
  11578. export class Stage<T extends Function> extends Array<{
  11579. index: number;
  11580. component: ISceneComponent;
  11581. action: T;
  11582. }> {
  11583. /**
  11584. * Hide ctor from the rest of the world.
  11585. * @param items The items to add.
  11586. */
  11587. private constructor();
  11588. /**
  11589. * Creates a new Stage.
  11590. * @returns A new instance of a Stage
  11591. */
  11592. static Create<T extends Function>(): Stage<T>;
  11593. /**
  11594. * Registers a step in an ordered way in the targeted stage.
  11595. * @param index Defines the position to register the step in
  11596. * @param component Defines the component attached to the step
  11597. * @param action Defines the action to launch during the step
  11598. */
  11599. registerStep(index: number, component: ISceneComponent, action: T): void;
  11600. /**
  11601. * Clears all the steps from the stage.
  11602. */
  11603. clear(): void;
  11604. }
  11605. }
  11606. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11607. import { Nullable } from "babylonjs/types";
  11608. import { Observable } from "babylonjs/Misc/observable";
  11609. import { Scene } from "babylonjs/scene";
  11610. import { Sprite } from "babylonjs/Sprites/sprite";
  11611. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11612. import { Ray } from "babylonjs/Culling/ray";
  11613. import { Camera } from "babylonjs/Cameras/camera";
  11614. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11615. import { ISceneComponent } from "babylonjs/sceneComponent";
  11616. module "babylonjs/scene" {
  11617. interface Scene {
  11618. /** @hidden */
  11619. _pointerOverSprite: Nullable<Sprite>;
  11620. /** @hidden */
  11621. _pickedDownSprite: Nullable<Sprite>;
  11622. /** @hidden */
  11623. _tempSpritePickingRay: Nullable<Ray>;
  11624. /**
  11625. * All of the sprite managers added to this scene
  11626. * @see http://doc.babylonjs.com/babylon101/sprites
  11627. */
  11628. spriteManagers: Array<ISpriteManager>;
  11629. /**
  11630. * An event triggered when sprites rendering is about to start
  11631. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11632. */
  11633. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11634. /**
  11635. * An event triggered when sprites rendering is done
  11636. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11637. */
  11638. onAfterSpritesRenderingObservable: Observable<Scene>;
  11639. /** @hidden */
  11640. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11641. /** Launch a ray to try to pick a sprite in the scene
  11642. * @param x position on screen
  11643. * @param y position on screen
  11644. * @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
  11645. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11646. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11647. * @returns a PickingInfo
  11648. */
  11649. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11650. /** Use the given ray to pick a sprite in the scene
  11651. * @param ray The ray (in world space) to use to pick meshes
  11652. * @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
  11653. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11654. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11655. * @returns a PickingInfo
  11656. */
  11657. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11658. /** @hidden */
  11659. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11660. /** Launch a ray to try to pick sprites in the scene
  11661. * @param x position on screen
  11662. * @param y position on screen
  11663. * @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
  11664. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11665. * @returns a PickingInfo array
  11666. */
  11667. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11668. /** Use the given ray to pick sprites in the scene
  11669. * @param ray The ray (in world space) to use to pick meshes
  11670. * @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
  11671. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11672. * @returns a PickingInfo array
  11673. */
  11674. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11675. /**
  11676. * Force the sprite under the pointer
  11677. * @param sprite defines the sprite to use
  11678. */
  11679. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11680. /**
  11681. * Gets the sprite under the pointer
  11682. * @returns a Sprite or null if no sprite is under the pointer
  11683. */
  11684. getPointerOverSprite(): Nullable<Sprite>;
  11685. }
  11686. }
  11687. /**
  11688. * Defines the sprite scene component responsible to manage sprites
  11689. * in a given scene.
  11690. */
  11691. export class SpriteSceneComponent implements ISceneComponent {
  11692. /**
  11693. * The component name helpfull to identify the component in the list of scene components.
  11694. */
  11695. readonly name: string;
  11696. /**
  11697. * The scene the component belongs to.
  11698. */
  11699. scene: Scene;
  11700. /** @hidden */
  11701. private _spritePredicate;
  11702. /**
  11703. * Creates a new instance of the component for the given scene
  11704. * @param scene Defines the scene to register the component in
  11705. */
  11706. constructor(scene: Scene);
  11707. /**
  11708. * Registers the component in a given scene
  11709. */
  11710. register(): void;
  11711. /**
  11712. * Rebuilds the elements related to this component in case of
  11713. * context lost for instance.
  11714. */
  11715. rebuild(): void;
  11716. /**
  11717. * Disposes the component and the associated ressources.
  11718. */
  11719. dispose(): void;
  11720. private _pickSpriteButKeepRay;
  11721. private _pointerMove;
  11722. private _pointerDown;
  11723. private _pointerUp;
  11724. }
  11725. }
  11726. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11727. /** @hidden */
  11728. export var fogFragmentDeclaration: {
  11729. name: string;
  11730. shader: string;
  11731. };
  11732. }
  11733. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11734. /** @hidden */
  11735. export var fogFragment: {
  11736. name: string;
  11737. shader: string;
  11738. };
  11739. }
  11740. declare module "babylonjs/Shaders/sprites.fragment" {
  11741. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11742. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11743. /** @hidden */
  11744. export var spritesPixelShader: {
  11745. name: string;
  11746. shader: string;
  11747. };
  11748. }
  11749. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11750. /** @hidden */
  11751. export var fogVertexDeclaration: {
  11752. name: string;
  11753. shader: string;
  11754. };
  11755. }
  11756. declare module "babylonjs/Shaders/sprites.vertex" {
  11757. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11758. /** @hidden */
  11759. export var spritesVertexShader: {
  11760. name: string;
  11761. shader: string;
  11762. };
  11763. }
  11764. declare module "babylonjs/Sprites/spriteManager" {
  11765. import { IDisposable, Scene } from "babylonjs/scene";
  11766. import { Nullable } from "babylonjs/types";
  11767. import { Observable } from "babylonjs/Misc/observable";
  11768. import { Sprite } from "babylonjs/Sprites/sprite";
  11769. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11770. import { Camera } from "babylonjs/Cameras/camera";
  11771. import { Texture } from "babylonjs/Materials/Textures/texture";
  11772. import "babylonjs/Shaders/sprites.fragment";
  11773. import "babylonjs/Shaders/sprites.vertex";
  11774. import { Ray } from "babylonjs/Culling/ray";
  11775. /**
  11776. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11777. */
  11778. export interface ISpriteManager extends IDisposable {
  11779. /**
  11780. * Restricts the camera to viewing objects with the same layerMask.
  11781. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11782. */
  11783. layerMask: number;
  11784. /**
  11785. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11786. */
  11787. isPickable: boolean;
  11788. /**
  11789. * Specifies the rendering group id for this mesh (0 by default)
  11790. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11791. */
  11792. renderingGroupId: number;
  11793. /**
  11794. * Defines the list of sprites managed by the manager.
  11795. */
  11796. sprites: Array<Sprite>;
  11797. /**
  11798. * Tests the intersection of a sprite with a specific ray.
  11799. * @param ray The ray we are sending to test the collision
  11800. * @param camera The camera space we are sending rays in
  11801. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11802. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11803. * @returns picking info or null.
  11804. */
  11805. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11806. /**
  11807. * Intersects the sprites with a ray
  11808. * @param ray defines the ray to intersect with
  11809. * @param camera defines the current active camera
  11810. * @param predicate defines a predicate used to select candidate sprites
  11811. * @returns null if no hit or a PickingInfo array
  11812. */
  11813. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11814. /**
  11815. * Renders the list of sprites on screen.
  11816. */
  11817. render(): void;
  11818. }
  11819. /**
  11820. * Class used to manage multiple sprites on the same spritesheet
  11821. * @see http://doc.babylonjs.com/babylon101/sprites
  11822. */
  11823. export class SpriteManager implements ISpriteManager {
  11824. /** defines the manager's name */
  11825. name: string;
  11826. /** Gets the list of sprites */
  11827. sprites: Sprite[];
  11828. /** Gets or sets the rendering group id (0 by default) */
  11829. renderingGroupId: number;
  11830. /** Gets or sets camera layer mask */
  11831. layerMask: number;
  11832. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11833. fogEnabled: boolean;
  11834. /** Gets or sets a boolean indicating if the sprites are pickable */
  11835. isPickable: boolean;
  11836. /** Defines the default width of a cell in the spritesheet */
  11837. cellWidth: number;
  11838. /** Defines the default height of a cell in the spritesheet */
  11839. cellHeight: number;
  11840. /** Associative array from JSON sprite data file */
  11841. private _cellData;
  11842. /** Array of sprite names from JSON sprite data file */
  11843. private _spriteMap;
  11844. /** True when packed cell data from JSON file is ready*/
  11845. private _packedAndReady;
  11846. /**
  11847. * An event triggered when the manager is disposed.
  11848. */
  11849. onDisposeObservable: Observable<SpriteManager>;
  11850. private _onDisposeObserver;
  11851. /**
  11852. * Callback called when the manager is disposed
  11853. */
  11854. onDispose: () => void;
  11855. private _capacity;
  11856. private _fromPacked;
  11857. private _spriteTexture;
  11858. private _epsilon;
  11859. private _scene;
  11860. private _vertexData;
  11861. private _buffer;
  11862. private _vertexBuffers;
  11863. private _indexBuffer;
  11864. private _effectBase;
  11865. private _effectFog;
  11866. /**
  11867. * Gets or sets the spritesheet texture
  11868. */
  11869. texture: Texture;
  11870. /**
  11871. * Creates a new sprite manager
  11872. * @param name defines the manager's name
  11873. * @param imgUrl defines the sprite sheet url
  11874. * @param capacity defines the maximum allowed number of sprites
  11875. * @param cellSize defines the size of a sprite cell
  11876. * @param scene defines the hosting scene
  11877. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11878. * @param samplingMode defines the smapling mode to use with spritesheet
  11879. * @param fromPacked set to false; do not alter
  11880. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11881. */
  11882. constructor(
  11883. /** defines the manager's name */
  11884. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11885. private _makePacked;
  11886. private _appendSpriteVertex;
  11887. /**
  11888. * Intersects the sprites with a ray
  11889. * @param ray defines the ray to intersect with
  11890. * @param camera defines the current active camera
  11891. * @param predicate defines a predicate used to select candidate sprites
  11892. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11893. * @returns null if no hit or a PickingInfo
  11894. */
  11895. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11896. /**
  11897. * Intersects the sprites with a ray
  11898. * @param ray defines the ray to intersect with
  11899. * @param camera defines the current active camera
  11900. * @param predicate defines a predicate used to select candidate sprites
  11901. * @returns null if no hit or a PickingInfo array
  11902. */
  11903. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11904. /**
  11905. * Render all child sprites
  11906. */
  11907. render(): void;
  11908. /**
  11909. * Release associated resources
  11910. */
  11911. dispose(): void;
  11912. }
  11913. }
  11914. declare module "babylonjs/Sprites/sprite" {
  11915. import { Vector3 } from "babylonjs/Maths/math.vector";
  11916. import { Nullable } from "babylonjs/types";
  11917. import { ActionManager } from "babylonjs/Actions/actionManager";
  11918. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11919. import { Color4 } from "babylonjs/Maths/math.color";
  11920. /**
  11921. * Class used to represent a sprite
  11922. * @see http://doc.babylonjs.com/babylon101/sprites
  11923. */
  11924. export class Sprite {
  11925. /** defines the name */
  11926. name: string;
  11927. /** Gets or sets the current world position */
  11928. position: Vector3;
  11929. /** Gets or sets the main color */
  11930. color: Color4;
  11931. /** Gets or sets the width */
  11932. width: number;
  11933. /** Gets or sets the height */
  11934. height: number;
  11935. /** Gets or sets rotation angle */
  11936. angle: number;
  11937. /** Gets or sets the cell index in the sprite sheet */
  11938. cellIndex: number;
  11939. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11940. cellRef: string;
  11941. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11942. invertU: number;
  11943. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11944. invertV: number;
  11945. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11946. disposeWhenFinishedAnimating: boolean;
  11947. /** Gets the list of attached animations */
  11948. animations: Animation[];
  11949. /** Gets or sets a boolean indicating if the sprite can be picked */
  11950. isPickable: boolean;
  11951. /**
  11952. * Gets or sets the associated action manager
  11953. */
  11954. actionManager: Nullable<ActionManager>;
  11955. private _animationStarted;
  11956. private _loopAnimation;
  11957. private _fromIndex;
  11958. private _toIndex;
  11959. private _delay;
  11960. private _direction;
  11961. private _manager;
  11962. private _time;
  11963. private _onAnimationEnd;
  11964. /**
  11965. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11966. */
  11967. isVisible: boolean;
  11968. /**
  11969. * Gets or sets the sprite size
  11970. */
  11971. size: number;
  11972. /**
  11973. * Creates a new Sprite
  11974. * @param name defines the name
  11975. * @param manager defines the manager
  11976. */
  11977. constructor(
  11978. /** defines the name */
  11979. name: string, manager: ISpriteManager);
  11980. /**
  11981. * Starts an animation
  11982. * @param from defines the initial key
  11983. * @param to defines the end key
  11984. * @param loop defines if the animation must loop
  11985. * @param delay defines the start delay (in ms)
  11986. * @param onAnimationEnd defines a callback to call when animation ends
  11987. */
  11988. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11989. /** Stops current animation (if any) */
  11990. stopAnimation(): void;
  11991. /** @hidden */
  11992. _animate(deltaTime: number): void;
  11993. /** Release associated resources */
  11994. dispose(): void;
  11995. }
  11996. }
  11997. declare module "babylonjs/Collisions/pickingInfo" {
  11998. import { Nullable } from "babylonjs/types";
  11999. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  12000. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12001. import { Sprite } from "babylonjs/Sprites/sprite";
  12002. import { Ray } from "babylonjs/Culling/ray";
  12003. /**
  12004. * Information about the result of picking within a scene
  12005. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  12006. */
  12007. export class PickingInfo {
  12008. /** @hidden */
  12009. _pickingUnavailable: boolean;
  12010. /**
  12011. * If the pick collided with an object
  12012. */
  12013. hit: boolean;
  12014. /**
  12015. * Distance away where the pick collided
  12016. */
  12017. distance: number;
  12018. /**
  12019. * The location of pick collision
  12020. */
  12021. pickedPoint: Nullable<Vector3>;
  12022. /**
  12023. * The mesh corresponding the the pick collision
  12024. */
  12025. pickedMesh: Nullable<AbstractMesh>;
  12026. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  12027. bu: number;
  12028. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  12029. bv: number;
  12030. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  12031. faceId: number;
  12032. /** Id of the the submesh that was picked */
  12033. subMeshId: number;
  12034. /** If a sprite was picked, this will be the sprite the pick collided with */
  12035. pickedSprite: Nullable<Sprite>;
  12036. /**
  12037. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12038. */
  12039. originMesh: Nullable<AbstractMesh>;
  12040. /**
  12041. * The ray that was used to perform the picking.
  12042. */
  12043. ray: Nullable<Ray>;
  12044. /**
  12045. * Gets the normal correspodning to the face the pick collided with
  12046. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12047. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12048. * @returns The normal correspodning to the face the pick collided with
  12049. */
  12050. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12051. /**
  12052. * Gets the texture coordinates of where the pick occured
  12053. * @returns the vector containing the coordnates of the texture
  12054. */
  12055. getTextureCoordinates(): Nullable<Vector2>;
  12056. }
  12057. }
  12058. declare module "babylonjs/Events/pointerEvents" {
  12059. import { Nullable } from "babylonjs/types";
  12060. import { Vector2 } from "babylonjs/Maths/math.vector";
  12061. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12062. import { Ray } from "babylonjs/Culling/ray";
  12063. /**
  12064. * Gather the list of pointer event types as constants.
  12065. */
  12066. export class PointerEventTypes {
  12067. /**
  12068. * 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.
  12069. */
  12070. static readonly POINTERDOWN: number;
  12071. /**
  12072. * The pointerup event is fired when a pointer is no longer active.
  12073. */
  12074. static readonly POINTERUP: number;
  12075. /**
  12076. * The pointermove event is fired when a pointer changes coordinates.
  12077. */
  12078. static readonly POINTERMOVE: number;
  12079. /**
  12080. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12081. */
  12082. static readonly POINTERWHEEL: number;
  12083. /**
  12084. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12085. */
  12086. static readonly POINTERPICK: number;
  12087. /**
  12088. * The pointertap event is fired when a the object has been touched and released without drag.
  12089. */
  12090. static readonly POINTERTAP: number;
  12091. /**
  12092. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12093. */
  12094. static readonly POINTERDOUBLETAP: number;
  12095. }
  12096. /**
  12097. * Base class of pointer info types.
  12098. */
  12099. export class PointerInfoBase {
  12100. /**
  12101. * Defines the type of event (PointerEventTypes)
  12102. */
  12103. type: number;
  12104. /**
  12105. * Defines the related dom event
  12106. */
  12107. event: PointerEvent | MouseWheelEvent;
  12108. /**
  12109. * Instantiates the base class of pointers info.
  12110. * @param type Defines the type of event (PointerEventTypes)
  12111. * @param event Defines the related dom event
  12112. */
  12113. constructor(
  12114. /**
  12115. * Defines the type of event (PointerEventTypes)
  12116. */
  12117. type: number,
  12118. /**
  12119. * Defines the related dom event
  12120. */
  12121. event: PointerEvent | MouseWheelEvent);
  12122. }
  12123. /**
  12124. * This class is used to store pointer related info for the onPrePointerObservable event.
  12125. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12126. */
  12127. export class PointerInfoPre extends PointerInfoBase {
  12128. /**
  12129. * Ray from a pointer if availible (eg. 6dof controller)
  12130. */
  12131. ray: Nullable<Ray>;
  12132. /**
  12133. * Defines the local position of the pointer on the canvas.
  12134. */
  12135. localPosition: Vector2;
  12136. /**
  12137. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12138. */
  12139. skipOnPointerObservable: boolean;
  12140. /**
  12141. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12142. * @param type Defines the type of event (PointerEventTypes)
  12143. * @param event Defines the related dom event
  12144. * @param localX Defines the local x coordinates of the pointer when the event occured
  12145. * @param localY Defines the local y coordinates of the pointer when the event occured
  12146. */
  12147. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12148. }
  12149. /**
  12150. * This type contains all the data related to a pointer event in Babylon.js.
  12151. * 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.
  12152. */
  12153. export class PointerInfo extends PointerInfoBase {
  12154. /**
  12155. * Defines the picking info associated to the info (if any)\
  12156. */
  12157. pickInfo: Nullable<PickingInfo>;
  12158. /**
  12159. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12160. * @param type Defines the type of event (PointerEventTypes)
  12161. * @param event Defines the related dom event
  12162. * @param pickInfo Defines the picking info associated to the info (if any)\
  12163. */
  12164. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12165. /**
  12166. * Defines the picking info associated to the info (if any)\
  12167. */
  12168. pickInfo: Nullable<PickingInfo>);
  12169. }
  12170. /**
  12171. * Data relating to a touch event on the screen.
  12172. */
  12173. export interface PointerTouch {
  12174. /**
  12175. * X coordinate of touch.
  12176. */
  12177. x: number;
  12178. /**
  12179. * Y coordinate of touch.
  12180. */
  12181. y: number;
  12182. /**
  12183. * Id of touch. Unique for each finger.
  12184. */
  12185. pointerId: number;
  12186. /**
  12187. * Event type passed from DOM.
  12188. */
  12189. type: any;
  12190. }
  12191. }
  12192. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12193. import { Observable } from "babylonjs/Misc/observable";
  12194. import { Nullable } from "babylonjs/types";
  12195. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12196. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12197. /**
  12198. * Manage the mouse inputs to control the movement of a free camera.
  12199. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12200. */
  12201. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12202. /**
  12203. * Define if touch is enabled in the mouse input
  12204. */
  12205. touchEnabled: boolean;
  12206. /**
  12207. * Defines the camera the input is attached to.
  12208. */
  12209. camera: FreeCamera;
  12210. /**
  12211. * Defines the buttons associated with the input to handle camera move.
  12212. */
  12213. buttons: number[];
  12214. /**
  12215. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12216. */
  12217. angularSensibility: number;
  12218. private _pointerInput;
  12219. private _onMouseMove;
  12220. private _observer;
  12221. private previousPosition;
  12222. /**
  12223. * Observable for when a pointer move event occurs containing the move offset
  12224. */
  12225. onPointerMovedObservable: Observable<{
  12226. offsetX: number;
  12227. offsetY: number;
  12228. }>;
  12229. /**
  12230. * @hidden
  12231. * If the camera should be rotated automatically based on pointer movement
  12232. */
  12233. _allowCameraRotation: boolean;
  12234. /**
  12235. * Manage the mouse inputs to control the movement of a free camera.
  12236. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12237. * @param touchEnabled Defines if touch is enabled or not
  12238. */
  12239. constructor(
  12240. /**
  12241. * Define if touch is enabled in the mouse input
  12242. */
  12243. touchEnabled?: boolean);
  12244. /**
  12245. * Attach the input controls to a specific dom element to get the input from.
  12246. * @param element Defines the element the controls should be listened from
  12247. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12248. */
  12249. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12250. /**
  12251. * Called on JS contextmenu event.
  12252. * Override this method to provide functionality.
  12253. */
  12254. protected onContextMenu(evt: PointerEvent): void;
  12255. /**
  12256. * Detach the current controls from the specified dom element.
  12257. * @param element Defines the element to stop listening the inputs from
  12258. */
  12259. detachControl(element: Nullable<HTMLElement>): void;
  12260. /**
  12261. * Gets the class name of the current intput.
  12262. * @returns the class name
  12263. */
  12264. getClassName(): string;
  12265. /**
  12266. * Get the friendly name associated with the input class.
  12267. * @returns the input friendly name
  12268. */
  12269. getSimpleName(): string;
  12270. }
  12271. }
  12272. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12273. import { Nullable } from "babylonjs/types";
  12274. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12275. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12276. /**
  12277. * Manage the touch inputs to control the movement of a free camera.
  12278. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12279. */
  12280. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12281. /**
  12282. * Defines the camera the input is attached to.
  12283. */
  12284. camera: FreeCamera;
  12285. /**
  12286. * Defines the touch sensibility for rotation.
  12287. * The higher the faster.
  12288. */
  12289. touchAngularSensibility: number;
  12290. /**
  12291. * Defines the touch sensibility for move.
  12292. * The higher the faster.
  12293. */
  12294. touchMoveSensibility: number;
  12295. private _offsetX;
  12296. private _offsetY;
  12297. private _pointerPressed;
  12298. private _pointerInput;
  12299. private _observer;
  12300. private _onLostFocus;
  12301. /**
  12302. * Attach the input controls to a specific dom element to get the input from.
  12303. * @param element Defines the element the controls should be listened from
  12304. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12305. */
  12306. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12307. /**
  12308. * Detach the current controls from the specified dom element.
  12309. * @param element Defines the element to stop listening the inputs from
  12310. */
  12311. detachControl(element: Nullable<HTMLElement>): void;
  12312. /**
  12313. * Update the current camera state depending on the inputs that have been used this frame.
  12314. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12315. */
  12316. checkInputs(): void;
  12317. /**
  12318. * Gets the class name of the current intput.
  12319. * @returns the class name
  12320. */
  12321. getClassName(): string;
  12322. /**
  12323. * Get the friendly name associated with the input class.
  12324. * @returns the input friendly name
  12325. */
  12326. getSimpleName(): string;
  12327. }
  12328. }
  12329. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12330. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12331. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12332. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12333. import { Nullable } from "babylonjs/types";
  12334. /**
  12335. * Default Inputs manager for the FreeCamera.
  12336. * It groups all the default supported inputs for ease of use.
  12337. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12338. */
  12339. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12340. /**
  12341. * @hidden
  12342. */
  12343. _mouseInput: Nullable<FreeCameraMouseInput>;
  12344. /**
  12345. * Instantiates a new FreeCameraInputsManager.
  12346. * @param camera Defines the camera the inputs belong to
  12347. */
  12348. constructor(camera: FreeCamera);
  12349. /**
  12350. * Add keyboard input support to the input manager.
  12351. * @returns the current input manager
  12352. */
  12353. addKeyboard(): FreeCameraInputsManager;
  12354. /**
  12355. * Add mouse input support to the input manager.
  12356. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12357. * @returns the current input manager
  12358. */
  12359. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12360. /**
  12361. * Removes the mouse input support from the manager
  12362. * @returns the current input manager
  12363. */
  12364. removeMouse(): FreeCameraInputsManager;
  12365. /**
  12366. * Add touch input support to the input manager.
  12367. * @returns the current input manager
  12368. */
  12369. addTouch(): FreeCameraInputsManager;
  12370. /**
  12371. * Remove all attached input methods from a camera
  12372. */
  12373. clear(): void;
  12374. }
  12375. }
  12376. declare module "babylonjs/Cameras/freeCamera" {
  12377. import { Vector3 } from "babylonjs/Maths/math.vector";
  12378. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12379. import { Scene } from "babylonjs/scene";
  12380. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12381. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12382. /**
  12383. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12384. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12385. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12386. */
  12387. export class FreeCamera extends TargetCamera {
  12388. /**
  12389. * Define the collision ellipsoid of the camera.
  12390. * This is helpful to simulate a camera body like the player body around the camera
  12391. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12392. */
  12393. ellipsoid: Vector3;
  12394. /**
  12395. * Define an offset for the position of the ellipsoid around the camera.
  12396. * This can be helpful to determine the center of the body near the gravity center of the body
  12397. * instead of its head.
  12398. */
  12399. ellipsoidOffset: Vector3;
  12400. /**
  12401. * Enable or disable collisions of the camera with the rest of the scene objects.
  12402. */
  12403. checkCollisions: boolean;
  12404. /**
  12405. * Enable or disable gravity on the camera.
  12406. */
  12407. applyGravity: boolean;
  12408. /**
  12409. * Define the input manager associated to the camera.
  12410. */
  12411. inputs: FreeCameraInputsManager;
  12412. /**
  12413. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12414. * Higher values reduce sensitivity.
  12415. */
  12416. /**
  12417. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12418. * Higher values reduce sensitivity.
  12419. */
  12420. angularSensibility: number;
  12421. /**
  12422. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12423. */
  12424. keysUp: number[];
  12425. /**
  12426. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12427. */
  12428. keysDown: number[];
  12429. /**
  12430. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12431. */
  12432. keysLeft: number[];
  12433. /**
  12434. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12435. */
  12436. keysRight: number[];
  12437. /**
  12438. * Event raised when the camera collide with a mesh in the scene.
  12439. */
  12440. onCollide: (collidedMesh: AbstractMesh) => void;
  12441. private _collider;
  12442. private _needMoveForGravity;
  12443. private _oldPosition;
  12444. private _diffPosition;
  12445. private _newPosition;
  12446. /** @hidden */
  12447. _localDirection: Vector3;
  12448. /** @hidden */
  12449. _transformedDirection: Vector3;
  12450. /**
  12451. * Instantiates a Free Camera.
  12452. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12453. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12454. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12455. * @param name Define the name of the camera in the scene
  12456. * @param position Define the start position of the camera in the scene
  12457. * @param scene Define the scene the camera belongs to
  12458. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12459. */
  12460. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12461. /**
  12462. * Attached controls to the current camera.
  12463. * @param element Defines the element the controls should be listened from
  12464. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12465. */
  12466. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12467. /**
  12468. * Detach the current controls from the camera.
  12469. * The camera will stop reacting to inputs.
  12470. * @param element Defines the element to stop listening the inputs from
  12471. */
  12472. detachControl(element: HTMLElement): void;
  12473. private _collisionMask;
  12474. /**
  12475. * Define a collision mask to limit the list of object the camera can collide with
  12476. */
  12477. collisionMask: number;
  12478. /** @hidden */
  12479. _collideWithWorld(displacement: Vector3): void;
  12480. private _onCollisionPositionChange;
  12481. /** @hidden */
  12482. _checkInputs(): void;
  12483. /** @hidden */
  12484. _decideIfNeedsToMove(): boolean;
  12485. /** @hidden */
  12486. _updatePosition(): void;
  12487. /**
  12488. * Destroy the camera and release the current resources hold by it.
  12489. */
  12490. dispose(): void;
  12491. /**
  12492. * Gets the current object class name.
  12493. * @return the class name
  12494. */
  12495. getClassName(): string;
  12496. }
  12497. }
  12498. declare module "babylonjs/Gamepads/gamepad" {
  12499. import { Observable } from "babylonjs/Misc/observable";
  12500. /**
  12501. * Represents a gamepad control stick position
  12502. */
  12503. export class StickValues {
  12504. /**
  12505. * The x component of the control stick
  12506. */
  12507. x: number;
  12508. /**
  12509. * The y component of the control stick
  12510. */
  12511. y: number;
  12512. /**
  12513. * Initializes the gamepad x and y control stick values
  12514. * @param x The x component of the gamepad control stick value
  12515. * @param y The y component of the gamepad control stick value
  12516. */
  12517. constructor(
  12518. /**
  12519. * The x component of the control stick
  12520. */
  12521. x: number,
  12522. /**
  12523. * The y component of the control stick
  12524. */
  12525. y: number);
  12526. }
  12527. /**
  12528. * An interface which manages callbacks for gamepad button changes
  12529. */
  12530. export interface GamepadButtonChanges {
  12531. /**
  12532. * Called when a gamepad has been changed
  12533. */
  12534. changed: boolean;
  12535. /**
  12536. * Called when a gamepad press event has been triggered
  12537. */
  12538. pressChanged: boolean;
  12539. /**
  12540. * Called when a touch event has been triggered
  12541. */
  12542. touchChanged: boolean;
  12543. /**
  12544. * Called when a value has changed
  12545. */
  12546. valueChanged: boolean;
  12547. }
  12548. /**
  12549. * Represents a gamepad
  12550. */
  12551. export class Gamepad {
  12552. /**
  12553. * The id of the gamepad
  12554. */
  12555. id: string;
  12556. /**
  12557. * The index of the gamepad
  12558. */
  12559. index: number;
  12560. /**
  12561. * The browser gamepad
  12562. */
  12563. browserGamepad: any;
  12564. /**
  12565. * Specifies what type of gamepad this represents
  12566. */
  12567. type: number;
  12568. private _leftStick;
  12569. private _rightStick;
  12570. /** @hidden */
  12571. _isConnected: boolean;
  12572. private _leftStickAxisX;
  12573. private _leftStickAxisY;
  12574. private _rightStickAxisX;
  12575. private _rightStickAxisY;
  12576. /**
  12577. * Triggered when the left control stick has been changed
  12578. */
  12579. private _onleftstickchanged;
  12580. /**
  12581. * Triggered when the right control stick has been changed
  12582. */
  12583. private _onrightstickchanged;
  12584. /**
  12585. * Represents a gamepad controller
  12586. */
  12587. static GAMEPAD: number;
  12588. /**
  12589. * Represents a generic controller
  12590. */
  12591. static GENERIC: number;
  12592. /**
  12593. * Represents an XBox controller
  12594. */
  12595. static XBOX: number;
  12596. /**
  12597. * Represents a pose-enabled controller
  12598. */
  12599. static POSE_ENABLED: number;
  12600. /**
  12601. * Represents an Dual Shock controller
  12602. */
  12603. static DUALSHOCK: number;
  12604. /**
  12605. * Specifies whether the left control stick should be Y-inverted
  12606. */
  12607. protected _invertLeftStickY: boolean;
  12608. /**
  12609. * Specifies if the gamepad has been connected
  12610. */
  12611. readonly isConnected: boolean;
  12612. /**
  12613. * Initializes the gamepad
  12614. * @param id The id of the gamepad
  12615. * @param index The index of the gamepad
  12616. * @param browserGamepad The browser gamepad
  12617. * @param leftStickX The x component of the left joystick
  12618. * @param leftStickY The y component of the left joystick
  12619. * @param rightStickX The x component of the right joystick
  12620. * @param rightStickY The y component of the right joystick
  12621. */
  12622. constructor(
  12623. /**
  12624. * The id of the gamepad
  12625. */
  12626. id: string,
  12627. /**
  12628. * The index of the gamepad
  12629. */
  12630. index: number,
  12631. /**
  12632. * The browser gamepad
  12633. */
  12634. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12635. /**
  12636. * Callback triggered when the left joystick has changed
  12637. * @param callback
  12638. */
  12639. onleftstickchanged(callback: (values: StickValues) => void): void;
  12640. /**
  12641. * Callback triggered when the right joystick has changed
  12642. * @param callback
  12643. */
  12644. onrightstickchanged(callback: (values: StickValues) => void): void;
  12645. /**
  12646. * Gets the left joystick
  12647. */
  12648. /**
  12649. * Sets the left joystick values
  12650. */
  12651. leftStick: StickValues;
  12652. /**
  12653. * Gets the right joystick
  12654. */
  12655. /**
  12656. * Sets the right joystick value
  12657. */
  12658. rightStick: StickValues;
  12659. /**
  12660. * Updates the gamepad joystick positions
  12661. */
  12662. update(): void;
  12663. /**
  12664. * Disposes the gamepad
  12665. */
  12666. dispose(): void;
  12667. }
  12668. /**
  12669. * Represents a generic gamepad
  12670. */
  12671. export class GenericPad extends Gamepad {
  12672. private _buttons;
  12673. private _onbuttondown;
  12674. private _onbuttonup;
  12675. /**
  12676. * Observable triggered when a button has been pressed
  12677. */
  12678. onButtonDownObservable: Observable<number>;
  12679. /**
  12680. * Observable triggered when a button has been released
  12681. */
  12682. onButtonUpObservable: Observable<number>;
  12683. /**
  12684. * Callback triggered when a button has been pressed
  12685. * @param callback Called when a button has been pressed
  12686. */
  12687. onbuttondown(callback: (buttonPressed: number) => void): void;
  12688. /**
  12689. * Callback triggered when a button has been released
  12690. * @param callback Called when a button has been released
  12691. */
  12692. onbuttonup(callback: (buttonReleased: number) => void): void;
  12693. /**
  12694. * Initializes the generic gamepad
  12695. * @param id The id of the generic gamepad
  12696. * @param index The index of the generic gamepad
  12697. * @param browserGamepad The browser gamepad
  12698. */
  12699. constructor(id: string, index: number, browserGamepad: any);
  12700. private _setButtonValue;
  12701. /**
  12702. * Updates the generic gamepad
  12703. */
  12704. update(): void;
  12705. /**
  12706. * Disposes the generic gamepad
  12707. */
  12708. dispose(): void;
  12709. }
  12710. }
  12711. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12712. import { Nullable } from "babylonjs/types";
  12713. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12714. import { Scene } from "babylonjs/scene";
  12715. module "babylonjs/Engines/engine" {
  12716. interface Engine {
  12717. /**
  12718. * Creates a raw texture
  12719. * @param data defines the data to store in the texture
  12720. * @param width defines the width of the texture
  12721. * @param height defines the height of the texture
  12722. * @param format defines the format of the data
  12723. * @param generateMipMaps defines if the engine should generate the mip levels
  12724. * @param invertY defines if data must be stored with Y axis inverted
  12725. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12726. * @param compression defines the compression used (null by default)
  12727. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12728. * @returns the raw texture inside an InternalTexture
  12729. */
  12730. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12731. /**
  12732. * Update a raw texture
  12733. * @param texture defines the texture to update
  12734. * @param data defines the data to store in the texture
  12735. * @param format defines the format of the data
  12736. * @param invertY defines if data must be stored with Y axis inverted
  12737. */
  12738. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12739. /**
  12740. * Update a raw texture
  12741. * @param texture defines the texture to update
  12742. * @param data defines the data to store in the texture
  12743. * @param format defines the format of the data
  12744. * @param invertY defines if data must be stored with Y axis inverted
  12745. * @param compression defines the compression used (null by default)
  12746. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12747. */
  12748. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12749. /**
  12750. * Creates a new raw cube texture
  12751. * @param data defines the array of data to use to create each face
  12752. * @param size defines the size of the textures
  12753. * @param format defines the format of the data
  12754. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12755. * @param generateMipMaps defines if the engine should generate the mip levels
  12756. * @param invertY defines if data must be stored with Y axis inverted
  12757. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12758. * @param compression defines the compression used (null by default)
  12759. * @returns the cube texture as an InternalTexture
  12760. */
  12761. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12762. /**
  12763. * Update a raw cube texture
  12764. * @param texture defines the texture to udpdate
  12765. * @param data defines the data to store
  12766. * @param format defines the data format
  12767. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12768. * @param invertY defines if data must be stored with Y axis inverted
  12769. */
  12770. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12771. /**
  12772. * Update a raw cube texture
  12773. * @param texture defines the texture to udpdate
  12774. * @param data defines the data to store
  12775. * @param format defines the data format
  12776. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12777. * @param invertY defines if data must be stored with Y axis inverted
  12778. * @param compression defines the compression used (null by default)
  12779. */
  12780. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12781. /**
  12782. * Update a raw cube texture
  12783. * @param texture defines the texture to udpdate
  12784. * @param data defines the data to store
  12785. * @param format defines the data format
  12786. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12787. * @param invertY defines if data must be stored with Y axis inverted
  12788. * @param compression defines the compression used (null by default)
  12789. * @param level defines which level of the texture to update
  12790. */
  12791. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12792. /**
  12793. * Creates a new raw cube texture from a specified url
  12794. * @param url defines the url where the data is located
  12795. * @param scene defines the current scene
  12796. * @param size defines the size of the textures
  12797. * @param format defines the format of the data
  12798. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12799. * @param noMipmap defines if the engine should avoid generating the mip levels
  12800. * @param callback defines a callback used to extract texture data from loaded data
  12801. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12802. * @param onLoad defines a callback called when texture is loaded
  12803. * @param onError defines a callback called if there is an error
  12804. * @returns the cube texture as an InternalTexture
  12805. */
  12806. 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;
  12807. /**
  12808. * Creates a new raw cube texture from a specified url
  12809. * @param url defines the url where the data is located
  12810. * @param scene defines the current scene
  12811. * @param size defines the size of the textures
  12812. * @param format defines the format of the data
  12813. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12814. * @param noMipmap defines if the engine should avoid generating the mip levels
  12815. * @param callback defines a callback used to extract texture data from loaded data
  12816. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12817. * @param onLoad defines a callback called when texture is loaded
  12818. * @param onError defines a callback called if there is an error
  12819. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12820. * @param invertY defines if data must be stored with Y axis inverted
  12821. * @returns the cube texture as an InternalTexture
  12822. */
  12823. 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;
  12824. /**
  12825. * Creates a new raw 3D texture
  12826. * @param data defines the data used to create the texture
  12827. * @param width defines the width of the texture
  12828. * @param height defines the height of the texture
  12829. * @param depth defines the depth of the texture
  12830. * @param format defines the format of the texture
  12831. * @param generateMipMaps defines if the engine must generate mip levels
  12832. * @param invertY defines if data must be stored with Y axis inverted
  12833. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12834. * @param compression defines the compressed used (can be null)
  12835. * @param textureType defines the compressed used (can be null)
  12836. * @returns a new raw 3D texture (stored in an InternalTexture)
  12837. */
  12838. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12839. /**
  12840. * Update a raw 3D texture
  12841. * @param texture defines the texture to update
  12842. * @param data defines the data to store
  12843. * @param format defines the data format
  12844. * @param invertY defines if data must be stored with Y axis inverted
  12845. */
  12846. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12847. /**
  12848. * Update a raw 3D texture
  12849. * @param texture defines the texture to update
  12850. * @param data defines the data to store
  12851. * @param format defines the data format
  12852. * @param invertY defines if data must be stored with Y axis inverted
  12853. * @param compression defines the used compression (can be null)
  12854. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12855. */
  12856. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12857. /**
  12858. * Creates a new raw 2D array texture
  12859. * @param data defines the data used to create the texture
  12860. * @param width defines the width of the texture
  12861. * @param height defines the height of the texture
  12862. * @param depth defines the number of layers of the texture
  12863. * @param format defines the format of the texture
  12864. * @param generateMipMaps defines if the engine must generate mip levels
  12865. * @param invertY defines if data must be stored with Y axis inverted
  12866. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12867. * @param compression defines the compressed used (can be null)
  12868. * @param textureType defines the compressed used (can be null)
  12869. * @returns a new raw 2D array texture (stored in an InternalTexture)
  12870. */
  12871. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12872. /**
  12873. * Update a raw 2D array texture
  12874. * @param texture defines the texture to update
  12875. * @param data defines the data to store
  12876. * @param format defines the data format
  12877. * @param invertY defines if data must be stored with Y axis inverted
  12878. */
  12879. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12880. /**
  12881. * Update a raw 2D array texture
  12882. * @param texture defines the texture to update
  12883. * @param data defines the data to store
  12884. * @param format defines the data format
  12885. * @param invertY defines if data must be stored with Y axis inverted
  12886. * @param compression defines the used compression (can be null)
  12887. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12888. */
  12889. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12890. }
  12891. }
  12892. }
  12893. declare module "babylonjs/Materials/Textures/rawTexture" {
  12894. import { Scene } from "babylonjs/scene";
  12895. import { Texture } from "babylonjs/Materials/Textures/texture";
  12896. import "babylonjs/Engines/Extensions/engine.rawTexture";
  12897. /**
  12898. * Raw texture can help creating a texture directly from an array of data.
  12899. * This can be super useful if you either get the data from an uncompressed source or
  12900. * if you wish to create your texture pixel by pixel.
  12901. */
  12902. export class RawTexture extends Texture {
  12903. /**
  12904. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12905. */
  12906. format: number;
  12907. private _engine;
  12908. /**
  12909. * Instantiates a new RawTexture.
  12910. * Raw texture can help creating a texture directly from an array of data.
  12911. * This can be super useful if you either get the data from an uncompressed source or
  12912. * if you wish to create your texture pixel by pixel.
  12913. * @param data define the array of data to use to create the texture
  12914. * @param width define the width of the texture
  12915. * @param height define the height of the texture
  12916. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12917. * @param scene define the scene the texture belongs to
  12918. * @param generateMipMaps define whether mip maps should be generated or not
  12919. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12920. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12921. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12922. */
  12923. constructor(data: ArrayBufferView, width: number, height: number,
  12924. /**
  12925. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12926. */
  12927. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12928. /**
  12929. * Updates the texture underlying data.
  12930. * @param data Define the new data of the texture
  12931. */
  12932. update(data: ArrayBufferView): void;
  12933. /**
  12934. * Creates a luminance texture from some data.
  12935. * @param data Define the texture data
  12936. * @param width Define the width of the texture
  12937. * @param height Define the height of the texture
  12938. * @param scene Define the scene the texture belongs to
  12939. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12940. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12941. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12942. * @returns the luminance texture
  12943. */
  12944. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12945. /**
  12946. * Creates a luminance alpha texture from some data.
  12947. * @param data Define the texture data
  12948. * @param width Define the width of the texture
  12949. * @param height Define the height of the texture
  12950. * @param scene Define the scene the texture belongs to
  12951. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12952. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12953. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12954. * @returns the luminance alpha texture
  12955. */
  12956. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12957. /**
  12958. * Creates an alpha texture from some data.
  12959. * @param data Define the texture data
  12960. * @param width Define the width of the texture
  12961. * @param height Define the height of the texture
  12962. * @param scene Define the scene the texture belongs to
  12963. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12964. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12965. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12966. * @returns the alpha texture
  12967. */
  12968. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12969. /**
  12970. * Creates a RGB texture from some data.
  12971. * @param data Define the texture data
  12972. * @param width Define the width of the texture
  12973. * @param height Define the height of the texture
  12974. * @param scene Define the scene the texture belongs to
  12975. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12976. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12977. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12978. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12979. * @returns the RGB alpha texture
  12980. */
  12981. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12982. /**
  12983. * Creates a RGBA texture from some data.
  12984. * @param data Define the texture data
  12985. * @param width Define the width of the texture
  12986. * @param height Define the height of the texture
  12987. * @param scene Define the scene the texture belongs to
  12988. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12989. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12990. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12991. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12992. * @returns the RGBA texture
  12993. */
  12994. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12995. /**
  12996. * Creates a R texture from some data.
  12997. * @param data Define the texture data
  12998. * @param width Define the width of the texture
  12999. * @param height Define the height of the texture
  13000. * @param scene Define the scene the texture belongs to
  13001. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13002. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13003. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13004. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13005. * @returns the R texture
  13006. */
  13007. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13008. }
  13009. }
  13010. declare module "babylonjs/Maths/math.size" {
  13011. /**
  13012. * Interface for the size containing width and height
  13013. */
  13014. export interface ISize {
  13015. /**
  13016. * Width
  13017. */
  13018. width: number;
  13019. /**
  13020. * Heighht
  13021. */
  13022. height: number;
  13023. }
  13024. /**
  13025. * Size containing widht and height
  13026. */
  13027. export class Size implements ISize {
  13028. /**
  13029. * Width
  13030. */
  13031. width: number;
  13032. /**
  13033. * Height
  13034. */
  13035. height: number;
  13036. /**
  13037. * Creates a Size object from the given width and height (floats).
  13038. * @param width width of the new size
  13039. * @param height height of the new size
  13040. */
  13041. constructor(width: number, height: number);
  13042. /**
  13043. * Returns a string with the Size width and height
  13044. * @returns a string with the Size width and height
  13045. */
  13046. toString(): string;
  13047. /**
  13048. * "Size"
  13049. * @returns the string "Size"
  13050. */
  13051. getClassName(): string;
  13052. /**
  13053. * Returns the Size hash code.
  13054. * @returns a hash code for a unique width and height
  13055. */
  13056. getHashCode(): number;
  13057. /**
  13058. * Updates the current size from the given one.
  13059. * @param src the given size
  13060. */
  13061. copyFrom(src: Size): void;
  13062. /**
  13063. * Updates in place the current Size from the given floats.
  13064. * @param width width of the new size
  13065. * @param height height of the new size
  13066. * @returns the updated Size.
  13067. */
  13068. copyFromFloats(width: number, height: number): Size;
  13069. /**
  13070. * Updates in place the current Size from the given floats.
  13071. * @param width width to set
  13072. * @param height height to set
  13073. * @returns the updated Size.
  13074. */
  13075. set(width: number, height: number): Size;
  13076. /**
  13077. * Multiplies the width and height by numbers
  13078. * @param w factor to multiple the width by
  13079. * @param h factor to multiple the height by
  13080. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  13081. */
  13082. multiplyByFloats(w: number, h: number): Size;
  13083. /**
  13084. * Clones the size
  13085. * @returns a new Size copied from the given one.
  13086. */
  13087. clone(): Size;
  13088. /**
  13089. * True if the current Size and the given one width and height are strictly equal.
  13090. * @param other the other size to compare against
  13091. * @returns True if the current Size and the given one width and height are strictly equal.
  13092. */
  13093. equals(other: Size): boolean;
  13094. /**
  13095. * The surface of the Size : width * height (float).
  13096. */
  13097. readonly surface: number;
  13098. /**
  13099. * Create a new size of zero
  13100. * @returns a new Size set to (0.0, 0.0)
  13101. */
  13102. static Zero(): Size;
  13103. /**
  13104. * Sums the width and height of two sizes
  13105. * @param otherSize size to add to this size
  13106. * @returns a new Size set as the addition result of the current Size and the given one.
  13107. */
  13108. add(otherSize: Size): Size;
  13109. /**
  13110. * Subtracts the width and height of two
  13111. * @param otherSize size to subtract to this size
  13112. * @returns a new Size set as the subtraction result of the given one from the current Size.
  13113. */
  13114. subtract(otherSize: Size): Size;
  13115. /**
  13116. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  13117. * @param start starting size to lerp between
  13118. * @param end end size to lerp between
  13119. * @param amount amount to lerp between the start and end values
  13120. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  13121. */
  13122. static Lerp(start: Size, end: Size, amount: number): Size;
  13123. }
  13124. }
  13125. declare module "babylonjs/Animations/runtimeAnimation" {
  13126. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  13127. import { Animatable } from "babylonjs/Animations/animatable";
  13128. import { Scene } from "babylonjs/scene";
  13129. /**
  13130. * Defines a runtime animation
  13131. */
  13132. export class RuntimeAnimation {
  13133. private _events;
  13134. /**
  13135. * The current frame of the runtime animation
  13136. */
  13137. private _currentFrame;
  13138. /**
  13139. * The animation used by the runtime animation
  13140. */
  13141. private _animation;
  13142. /**
  13143. * The target of the runtime animation
  13144. */
  13145. private _target;
  13146. /**
  13147. * The initiating animatable
  13148. */
  13149. private _host;
  13150. /**
  13151. * The original value of the runtime animation
  13152. */
  13153. private _originalValue;
  13154. /**
  13155. * The original blend value of the runtime animation
  13156. */
  13157. private _originalBlendValue;
  13158. /**
  13159. * The offsets cache of the runtime animation
  13160. */
  13161. private _offsetsCache;
  13162. /**
  13163. * The high limits cache of the runtime animation
  13164. */
  13165. private _highLimitsCache;
  13166. /**
  13167. * Specifies if the runtime animation has been stopped
  13168. */
  13169. private _stopped;
  13170. /**
  13171. * The blending factor of the runtime animation
  13172. */
  13173. private _blendingFactor;
  13174. /**
  13175. * The BabylonJS scene
  13176. */
  13177. private _scene;
  13178. /**
  13179. * The current value of the runtime animation
  13180. */
  13181. private _currentValue;
  13182. /** @hidden */
  13183. _animationState: _IAnimationState;
  13184. /**
  13185. * The active target of the runtime animation
  13186. */
  13187. private _activeTargets;
  13188. private _currentActiveTarget;
  13189. private _directTarget;
  13190. /**
  13191. * The target path of the runtime animation
  13192. */
  13193. private _targetPath;
  13194. /**
  13195. * The weight of the runtime animation
  13196. */
  13197. private _weight;
  13198. /**
  13199. * The ratio offset of the runtime animation
  13200. */
  13201. private _ratioOffset;
  13202. /**
  13203. * The previous delay of the runtime animation
  13204. */
  13205. private _previousDelay;
  13206. /**
  13207. * The previous ratio of the runtime animation
  13208. */
  13209. private _previousRatio;
  13210. private _enableBlending;
  13211. private _keys;
  13212. private _minFrame;
  13213. private _maxFrame;
  13214. private _minValue;
  13215. private _maxValue;
  13216. private _targetIsArray;
  13217. /**
  13218. * Gets the current frame of the runtime animation
  13219. */
  13220. readonly currentFrame: number;
  13221. /**
  13222. * Gets the weight of the runtime animation
  13223. */
  13224. readonly weight: number;
  13225. /**
  13226. * Gets the current value of the runtime animation
  13227. */
  13228. readonly currentValue: any;
  13229. /**
  13230. * Gets the target path of the runtime animation
  13231. */
  13232. readonly targetPath: string;
  13233. /**
  13234. * Gets the actual target of the runtime animation
  13235. */
  13236. readonly target: any;
  13237. /** @hidden */
  13238. _onLoop: () => void;
  13239. /**
  13240. * Create a new RuntimeAnimation object
  13241. * @param target defines the target of the animation
  13242. * @param animation defines the source animation object
  13243. * @param scene defines the hosting scene
  13244. * @param host defines the initiating Animatable
  13245. */
  13246. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  13247. private _preparePath;
  13248. /**
  13249. * Gets the animation from the runtime animation
  13250. */
  13251. readonly animation: Animation;
  13252. /**
  13253. * Resets the runtime animation to the beginning
  13254. * @param restoreOriginal defines whether to restore the target property to the original value
  13255. */
  13256. reset(restoreOriginal?: boolean): void;
  13257. /**
  13258. * Specifies if the runtime animation is stopped
  13259. * @returns Boolean specifying if the runtime animation is stopped
  13260. */
  13261. isStopped(): boolean;
  13262. /**
  13263. * Disposes of the runtime animation
  13264. */
  13265. dispose(): void;
  13266. /**
  13267. * Apply the interpolated value to the target
  13268. * @param currentValue defines the value computed by the animation
  13269. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13270. */
  13271. setValue(currentValue: any, weight: number): void;
  13272. private _getOriginalValues;
  13273. private _setValue;
  13274. /**
  13275. * Gets the loop pmode of the runtime animation
  13276. * @returns Loop Mode
  13277. */
  13278. private _getCorrectLoopMode;
  13279. /**
  13280. * Move the current animation to a given frame
  13281. * @param frame defines the frame to move to
  13282. */
  13283. goToFrame(frame: number): void;
  13284. /**
  13285. * @hidden Internal use only
  13286. */
  13287. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13288. /**
  13289. * Execute the current animation
  13290. * @param delay defines the delay to add to the current frame
  13291. * @param from defines the lower bound of the animation range
  13292. * @param to defines the upper bound of the animation range
  13293. * @param loop defines if the current animation must loop
  13294. * @param speedRatio defines the current speed ratio
  13295. * @param weight defines the weight of the animation (default is -1 so no weight)
  13296. * @param onLoop optional callback called when animation loops
  13297. * @returns a boolean indicating if the animation is running
  13298. */
  13299. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13300. }
  13301. }
  13302. declare module "babylonjs/Animations/animatable" {
  13303. import { Animation } from "babylonjs/Animations/animation";
  13304. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  13305. import { Nullable } from "babylonjs/types";
  13306. import { Observable } from "babylonjs/Misc/observable";
  13307. import { Scene } from "babylonjs/scene";
  13308. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  13309. import { Node } from "babylonjs/node";
  13310. /**
  13311. * Class used to store an actual running animation
  13312. */
  13313. export class Animatable {
  13314. /** defines the target object */
  13315. target: any;
  13316. /** defines the starting frame number (default is 0) */
  13317. fromFrame: number;
  13318. /** defines the ending frame number (default is 100) */
  13319. toFrame: number;
  13320. /** defines if the animation must loop (default is false) */
  13321. loopAnimation: boolean;
  13322. /** defines a callback to call when animation ends if it is not looping */
  13323. onAnimationEnd?: (() => void) | null | undefined;
  13324. /** defines a callback to call when animation loops */
  13325. onAnimationLoop?: (() => void) | null | undefined;
  13326. private _localDelayOffset;
  13327. private _pausedDelay;
  13328. private _runtimeAnimations;
  13329. private _paused;
  13330. private _scene;
  13331. private _speedRatio;
  13332. private _weight;
  13333. private _syncRoot;
  13334. /**
  13335. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13336. * This will only apply for non looping animation (default is true)
  13337. */
  13338. disposeOnEnd: boolean;
  13339. /**
  13340. * Gets a boolean indicating if the animation has started
  13341. */
  13342. animationStarted: boolean;
  13343. /**
  13344. * Observer raised when the animation ends
  13345. */
  13346. onAnimationEndObservable: Observable<Animatable>;
  13347. /**
  13348. * Observer raised when the animation loops
  13349. */
  13350. onAnimationLoopObservable: Observable<Animatable>;
  13351. /**
  13352. * Gets the root Animatable used to synchronize and normalize animations
  13353. */
  13354. readonly syncRoot: Nullable<Animatable>;
  13355. /**
  13356. * Gets the current frame of the first RuntimeAnimation
  13357. * Used to synchronize Animatables
  13358. */
  13359. readonly masterFrame: number;
  13360. /**
  13361. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13362. */
  13363. weight: number;
  13364. /**
  13365. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13366. */
  13367. speedRatio: number;
  13368. /**
  13369. * Creates a new Animatable
  13370. * @param scene defines the hosting scene
  13371. * @param target defines the target object
  13372. * @param fromFrame defines the starting frame number (default is 0)
  13373. * @param toFrame defines the ending frame number (default is 100)
  13374. * @param loopAnimation defines if the animation must loop (default is false)
  13375. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13376. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13377. * @param animations defines a group of animation to add to the new Animatable
  13378. * @param onAnimationLoop defines a callback to call when animation loops
  13379. */
  13380. constructor(scene: Scene,
  13381. /** defines the target object */
  13382. target: any,
  13383. /** defines the starting frame number (default is 0) */
  13384. fromFrame?: number,
  13385. /** defines the ending frame number (default is 100) */
  13386. toFrame?: number,
  13387. /** defines if the animation must loop (default is false) */
  13388. loopAnimation?: boolean, speedRatio?: number,
  13389. /** defines a callback to call when animation ends if it is not looping */
  13390. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13391. /** defines a callback to call when animation loops */
  13392. onAnimationLoop?: (() => void) | null | undefined);
  13393. /**
  13394. * Synchronize and normalize current Animatable with a source Animatable
  13395. * This is useful when using animation weights and when animations are not of the same length
  13396. * @param root defines the root Animatable to synchronize with
  13397. * @returns the current Animatable
  13398. */
  13399. syncWith(root: Animatable): Animatable;
  13400. /**
  13401. * Gets the list of runtime animations
  13402. * @returns an array of RuntimeAnimation
  13403. */
  13404. getAnimations(): RuntimeAnimation[];
  13405. /**
  13406. * Adds more animations to the current animatable
  13407. * @param target defines the target of the animations
  13408. * @param animations defines the new animations to add
  13409. */
  13410. appendAnimations(target: any, animations: Animation[]): void;
  13411. /**
  13412. * Gets the source animation for a specific property
  13413. * @param property defines the propertyu to look for
  13414. * @returns null or the source animation for the given property
  13415. */
  13416. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13417. /**
  13418. * Gets the runtime animation for a specific property
  13419. * @param property defines the propertyu to look for
  13420. * @returns null or the runtime animation for the given property
  13421. */
  13422. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13423. /**
  13424. * Resets the animatable to its original state
  13425. */
  13426. reset(): void;
  13427. /**
  13428. * Allows the animatable to blend with current running animations
  13429. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13430. * @param blendingSpeed defines the blending speed to use
  13431. */
  13432. enableBlending(blendingSpeed: number): void;
  13433. /**
  13434. * Disable animation blending
  13435. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13436. */
  13437. disableBlending(): void;
  13438. /**
  13439. * Jump directly to a given frame
  13440. * @param frame defines the frame to jump to
  13441. */
  13442. goToFrame(frame: number): void;
  13443. /**
  13444. * Pause the animation
  13445. */
  13446. pause(): void;
  13447. /**
  13448. * Restart the animation
  13449. */
  13450. restart(): void;
  13451. private _raiseOnAnimationEnd;
  13452. /**
  13453. * Stop and delete the current animation
  13454. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13455. * @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)
  13456. */
  13457. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13458. /**
  13459. * Wait asynchronously for the animation to end
  13460. * @returns a promise which will be fullfilled when the animation ends
  13461. */
  13462. waitAsync(): Promise<Animatable>;
  13463. /** @hidden */
  13464. _animate(delay: number): boolean;
  13465. }
  13466. module "babylonjs/scene" {
  13467. interface Scene {
  13468. /** @hidden */
  13469. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13470. /** @hidden */
  13471. _processLateAnimationBindingsForMatrices(holder: {
  13472. totalWeight: number;
  13473. animations: RuntimeAnimation[];
  13474. originalValue: Matrix;
  13475. }): any;
  13476. /** @hidden */
  13477. _processLateAnimationBindingsForQuaternions(holder: {
  13478. totalWeight: number;
  13479. animations: RuntimeAnimation[];
  13480. originalValue: Quaternion;
  13481. }, refQuaternion: Quaternion): Quaternion;
  13482. /** @hidden */
  13483. _processLateAnimationBindings(): void;
  13484. /**
  13485. * Will start the animation sequence of a given target
  13486. * @param target defines the target
  13487. * @param from defines from which frame should animation start
  13488. * @param to defines until which frame should animation run.
  13489. * @param weight defines the weight to apply to the animation (1.0 by default)
  13490. * @param loop defines if the animation loops
  13491. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13492. * @param onAnimationEnd defines the function to be executed when the animation ends
  13493. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13494. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13495. * @param onAnimationLoop defines the callback to call when an animation loops
  13496. * @returns the animatable object created for this animation
  13497. */
  13498. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13499. /**
  13500. * Will start the animation sequence of a given target
  13501. * @param target defines the target
  13502. * @param from defines from which frame should animation start
  13503. * @param to defines until which frame should animation run.
  13504. * @param loop defines if the animation loops
  13505. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13506. * @param onAnimationEnd defines the function to be executed when the animation ends
  13507. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13508. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13509. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13510. * @param onAnimationLoop defines the callback to call when an animation loops
  13511. * @returns the animatable object created for this animation
  13512. */
  13513. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13514. /**
  13515. * Will start the animation sequence of a given target and its hierarchy
  13516. * @param target defines the target
  13517. * @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.
  13518. * @param from defines from which frame should animation start
  13519. * @param to defines until which frame should animation run.
  13520. * @param loop defines if the animation loops
  13521. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13522. * @param onAnimationEnd defines the function to be executed when the animation ends
  13523. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13524. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13525. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13526. * @param onAnimationLoop defines the callback to call when an animation loops
  13527. * @returns the list of created animatables
  13528. */
  13529. 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[];
  13530. /**
  13531. * Begin a new animation on a given node
  13532. * @param target defines the target where the animation will take place
  13533. * @param animations defines the list of animations to start
  13534. * @param from defines the initial value
  13535. * @param to defines the final value
  13536. * @param loop defines if you want animation to loop (off by default)
  13537. * @param speedRatio defines the speed ratio to apply to all animations
  13538. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13539. * @param onAnimationLoop defines the callback to call when an animation loops
  13540. * @returns the list of created animatables
  13541. */
  13542. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13543. /**
  13544. * Begin a new animation on a given node and its hierarchy
  13545. * @param target defines the root node where the animation will take place
  13546. * @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.
  13547. * @param animations defines the list of animations to start
  13548. * @param from defines the initial value
  13549. * @param to defines the final value
  13550. * @param loop defines if you want animation to loop (off by default)
  13551. * @param speedRatio defines the speed ratio to apply to all animations
  13552. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13553. * @param onAnimationLoop defines the callback to call when an animation loops
  13554. * @returns the list of animatables created for all nodes
  13555. */
  13556. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13557. /**
  13558. * Gets the animatable associated with a specific target
  13559. * @param target defines the target of the animatable
  13560. * @returns the required animatable if found
  13561. */
  13562. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13563. /**
  13564. * Gets all animatables associated with a given target
  13565. * @param target defines the target to look animatables for
  13566. * @returns an array of Animatables
  13567. */
  13568. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13569. /**
  13570. * Stops and removes all animations that have been applied to the scene
  13571. */
  13572. stopAllAnimations(): void;
  13573. /**
  13574. * Gets the current delta time used by animation engine
  13575. */
  13576. deltaTime: number;
  13577. }
  13578. }
  13579. module "babylonjs/Bones/bone" {
  13580. interface Bone {
  13581. /**
  13582. * Copy an animation range from another bone
  13583. * @param source defines the source bone
  13584. * @param rangeName defines the range name to copy
  13585. * @param frameOffset defines the frame offset
  13586. * @param rescaleAsRequired defines if rescaling must be applied if required
  13587. * @param skelDimensionsRatio defines the scaling ratio
  13588. * @returns true if operation was successful
  13589. */
  13590. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13591. }
  13592. }
  13593. }
  13594. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13595. /**
  13596. * Class used to override all child animations of a given target
  13597. */
  13598. export class AnimationPropertiesOverride {
  13599. /**
  13600. * Gets or sets a value indicating if animation blending must be used
  13601. */
  13602. enableBlending: boolean;
  13603. /**
  13604. * Gets or sets the blending speed to use when enableBlending is true
  13605. */
  13606. blendingSpeed: number;
  13607. /**
  13608. * Gets or sets the default loop mode to use
  13609. */
  13610. loopMode: number;
  13611. }
  13612. }
  13613. declare module "babylonjs/Bones/skeleton" {
  13614. import { Bone } from "babylonjs/Bones/bone";
  13615. import { Observable } from "babylonjs/Misc/observable";
  13616. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13617. import { Scene } from "babylonjs/scene";
  13618. import { Nullable } from "babylonjs/types";
  13619. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13620. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13621. import { Animatable } from "babylonjs/Animations/animatable";
  13622. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13623. import { Animation } from "babylonjs/Animations/animation";
  13624. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13625. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13626. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13627. /**
  13628. * Class used to handle skinning animations
  13629. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13630. */
  13631. export class Skeleton implements IAnimatable {
  13632. /** defines the skeleton name */
  13633. name: string;
  13634. /** defines the skeleton Id */
  13635. id: string;
  13636. /**
  13637. * Defines the list of child bones
  13638. */
  13639. bones: Bone[];
  13640. /**
  13641. * Defines an estimate of the dimension of the skeleton at rest
  13642. */
  13643. dimensionsAtRest: Vector3;
  13644. /**
  13645. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13646. */
  13647. needInitialSkinMatrix: boolean;
  13648. /**
  13649. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13650. */
  13651. overrideMesh: Nullable<AbstractMesh>;
  13652. /**
  13653. * Gets the list of animations attached to this skeleton
  13654. */
  13655. animations: Array<Animation>;
  13656. private _scene;
  13657. private _isDirty;
  13658. private _transformMatrices;
  13659. private _transformMatrixTexture;
  13660. private _meshesWithPoseMatrix;
  13661. private _animatables;
  13662. private _identity;
  13663. private _synchronizedWithMesh;
  13664. private _ranges;
  13665. private _lastAbsoluteTransformsUpdateId;
  13666. private _canUseTextureForBones;
  13667. private _uniqueId;
  13668. /** @hidden */
  13669. _numBonesWithLinkedTransformNode: number;
  13670. /** @hidden */
  13671. _hasWaitingData: Nullable<boolean>;
  13672. /**
  13673. * Specifies if the skeleton should be serialized
  13674. */
  13675. doNotSerialize: boolean;
  13676. private _useTextureToStoreBoneMatrices;
  13677. /**
  13678. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13679. * Please note that this option is not available if the hardware does not support it
  13680. */
  13681. useTextureToStoreBoneMatrices: boolean;
  13682. private _animationPropertiesOverride;
  13683. /**
  13684. * Gets or sets the animation properties override
  13685. */
  13686. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13687. /**
  13688. * List of inspectable custom properties (used by the Inspector)
  13689. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13690. */
  13691. inspectableCustomProperties: IInspectable[];
  13692. /**
  13693. * An observable triggered before computing the skeleton's matrices
  13694. */
  13695. onBeforeComputeObservable: Observable<Skeleton>;
  13696. /**
  13697. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13698. */
  13699. readonly isUsingTextureForMatrices: boolean;
  13700. /**
  13701. * Gets the unique ID of this skeleton
  13702. */
  13703. readonly uniqueId: number;
  13704. /**
  13705. * Creates a new skeleton
  13706. * @param name defines the skeleton name
  13707. * @param id defines the skeleton Id
  13708. * @param scene defines the hosting scene
  13709. */
  13710. constructor(
  13711. /** defines the skeleton name */
  13712. name: string,
  13713. /** defines the skeleton Id */
  13714. id: string, scene: Scene);
  13715. /**
  13716. * Gets the current object class name.
  13717. * @return the class name
  13718. */
  13719. getClassName(): string;
  13720. /**
  13721. * Returns an array containing the root bones
  13722. * @returns an array containing the root bones
  13723. */
  13724. getChildren(): Array<Bone>;
  13725. /**
  13726. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13727. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13728. * @returns a Float32Array containing matrices data
  13729. */
  13730. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13731. /**
  13732. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13733. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13734. * @returns a raw texture containing the data
  13735. */
  13736. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13737. /**
  13738. * Gets the current hosting scene
  13739. * @returns a scene object
  13740. */
  13741. getScene(): Scene;
  13742. /**
  13743. * Gets a string representing the current skeleton data
  13744. * @param fullDetails defines a boolean indicating if we want a verbose version
  13745. * @returns a string representing the current skeleton data
  13746. */
  13747. toString(fullDetails?: boolean): string;
  13748. /**
  13749. * Get bone's index searching by name
  13750. * @param name defines bone's name to search for
  13751. * @return the indice of the bone. Returns -1 if not found
  13752. */
  13753. getBoneIndexByName(name: string): number;
  13754. /**
  13755. * Creater a new animation range
  13756. * @param name defines the name of the range
  13757. * @param from defines the start key
  13758. * @param to defines the end key
  13759. */
  13760. createAnimationRange(name: string, from: number, to: number): void;
  13761. /**
  13762. * Delete a specific animation range
  13763. * @param name defines the name of the range
  13764. * @param deleteFrames defines if frames must be removed as well
  13765. */
  13766. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13767. /**
  13768. * Gets a specific animation range
  13769. * @param name defines the name of the range to look for
  13770. * @returns the requested animation range or null if not found
  13771. */
  13772. getAnimationRange(name: string): Nullable<AnimationRange>;
  13773. /**
  13774. * Gets the list of all animation ranges defined on this skeleton
  13775. * @returns an array
  13776. */
  13777. getAnimationRanges(): Nullable<AnimationRange>[];
  13778. /**
  13779. * Copy animation range from a source skeleton.
  13780. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13781. * @param source defines the source skeleton
  13782. * @param name defines the name of the range to copy
  13783. * @param rescaleAsRequired defines if rescaling must be applied if required
  13784. * @returns true if operation was successful
  13785. */
  13786. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13787. /**
  13788. * Forces the skeleton to go to rest pose
  13789. */
  13790. returnToRest(): void;
  13791. private _getHighestAnimationFrame;
  13792. /**
  13793. * Begin a specific animation range
  13794. * @param name defines the name of the range to start
  13795. * @param loop defines if looping must be turned on (false by default)
  13796. * @param speedRatio defines the speed ratio to apply (1 by default)
  13797. * @param onAnimationEnd defines a callback which will be called when animation will end
  13798. * @returns a new animatable
  13799. */
  13800. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13801. /** @hidden */
  13802. _markAsDirty(): void;
  13803. /** @hidden */
  13804. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13805. /** @hidden */
  13806. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13807. private _computeTransformMatrices;
  13808. /**
  13809. * Build all resources required to render a skeleton
  13810. */
  13811. prepare(): void;
  13812. /**
  13813. * Gets the list of animatables currently running for this skeleton
  13814. * @returns an array of animatables
  13815. */
  13816. getAnimatables(): IAnimatable[];
  13817. /**
  13818. * Clone the current skeleton
  13819. * @param name defines the name of the new skeleton
  13820. * @param id defines the id of the new skeleton
  13821. * @returns the new skeleton
  13822. */
  13823. clone(name: string, id?: string): Skeleton;
  13824. /**
  13825. * Enable animation blending for this skeleton
  13826. * @param blendingSpeed defines the blending speed to apply
  13827. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13828. */
  13829. enableBlending(blendingSpeed?: number): void;
  13830. /**
  13831. * Releases all resources associated with the current skeleton
  13832. */
  13833. dispose(): void;
  13834. /**
  13835. * Serialize the skeleton in a JSON object
  13836. * @returns a JSON object
  13837. */
  13838. serialize(): any;
  13839. /**
  13840. * Creates a new skeleton from serialized data
  13841. * @param parsedSkeleton defines the serialized data
  13842. * @param scene defines the hosting scene
  13843. * @returns a new skeleton
  13844. */
  13845. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13846. /**
  13847. * Compute all node absolute transforms
  13848. * @param forceUpdate defines if computation must be done even if cache is up to date
  13849. */
  13850. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13851. /**
  13852. * Gets the root pose matrix
  13853. * @returns a matrix
  13854. */
  13855. getPoseMatrix(): Nullable<Matrix>;
  13856. /**
  13857. * Sorts bones per internal index
  13858. */
  13859. sortBones(): void;
  13860. private _sortBones;
  13861. }
  13862. }
  13863. declare module "babylonjs/Bones/bone" {
  13864. import { Skeleton } from "babylonjs/Bones/skeleton";
  13865. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13866. import { Nullable } from "babylonjs/types";
  13867. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13868. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13869. import { Node } from "babylonjs/node";
  13870. import { Space } from "babylonjs/Maths/math.axis";
  13871. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13872. /**
  13873. * Class used to store bone information
  13874. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13875. */
  13876. export class Bone extends Node {
  13877. /**
  13878. * defines the bone name
  13879. */
  13880. name: string;
  13881. private static _tmpVecs;
  13882. private static _tmpQuat;
  13883. private static _tmpMats;
  13884. /**
  13885. * Gets the list of child bones
  13886. */
  13887. children: Bone[];
  13888. /** Gets the animations associated with this bone */
  13889. animations: import("babylonjs/Animations/animation").Animation[];
  13890. /**
  13891. * Gets or sets bone length
  13892. */
  13893. length: number;
  13894. /**
  13895. * @hidden Internal only
  13896. * Set this value to map this bone to a different index in the transform matrices
  13897. * Set this value to -1 to exclude the bone from the transform matrices
  13898. */
  13899. _index: Nullable<number>;
  13900. private _skeleton;
  13901. private _localMatrix;
  13902. private _restPose;
  13903. private _baseMatrix;
  13904. private _absoluteTransform;
  13905. private _invertedAbsoluteTransform;
  13906. private _parent;
  13907. private _scalingDeterminant;
  13908. private _worldTransform;
  13909. private _localScaling;
  13910. private _localRotation;
  13911. private _localPosition;
  13912. private _needToDecompose;
  13913. private _needToCompose;
  13914. /** @hidden */
  13915. _linkedTransformNode: Nullable<TransformNode>;
  13916. /** @hidden */
  13917. _waitingTransformNodeId: Nullable<string>;
  13918. /** @hidden */
  13919. /** @hidden */
  13920. _matrix: Matrix;
  13921. /**
  13922. * Create a new bone
  13923. * @param name defines the bone name
  13924. * @param skeleton defines the parent skeleton
  13925. * @param parentBone defines the parent (can be null if the bone is the root)
  13926. * @param localMatrix defines the local matrix
  13927. * @param restPose defines the rest pose matrix
  13928. * @param baseMatrix defines the base matrix
  13929. * @param index defines index of the bone in the hiearchy
  13930. */
  13931. constructor(
  13932. /**
  13933. * defines the bone name
  13934. */
  13935. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13936. /**
  13937. * Gets the current object class name.
  13938. * @return the class name
  13939. */
  13940. getClassName(): string;
  13941. /**
  13942. * Gets the parent skeleton
  13943. * @returns a skeleton
  13944. */
  13945. getSkeleton(): Skeleton;
  13946. /**
  13947. * Gets parent bone
  13948. * @returns a bone or null if the bone is the root of the bone hierarchy
  13949. */
  13950. getParent(): Nullable<Bone>;
  13951. /**
  13952. * Returns an array containing the root bones
  13953. * @returns an array containing the root bones
  13954. */
  13955. getChildren(): Array<Bone>;
  13956. /**
  13957. * Gets the node index in matrix array generated for rendering
  13958. * @returns the node index
  13959. */
  13960. getIndex(): number;
  13961. /**
  13962. * Sets the parent bone
  13963. * @param parent defines the parent (can be null if the bone is the root)
  13964. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13965. */
  13966. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13967. /**
  13968. * Gets the local matrix
  13969. * @returns a matrix
  13970. */
  13971. getLocalMatrix(): Matrix;
  13972. /**
  13973. * Gets the base matrix (initial matrix which remains unchanged)
  13974. * @returns a matrix
  13975. */
  13976. getBaseMatrix(): Matrix;
  13977. /**
  13978. * Gets the rest pose matrix
  13979. * @returns a matrix
  13980. */
  13981. getRestPose(): Matrix;
  13982. /**
  13983. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13984. */
  13985. getWorldMatrix(): Matrix;
  13986. /**
  13987. * Sets the local matrix to rest pose matrix
  13988. */
  13989. returnToRest(): void;
  13990. /**
  13991. * Gets the inverse of the absolute transform matrix.
  13992. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13993. * @returns a matrix
  13994. */
  13995. getInvertedAbsoluteTransform(): Matrix;
  13996. /**
  13997. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13998. * @returns a matrix
  13999. */
  14000. getAbsoluteTransform(): Matrix;
  14001. /**
  14002. * Links with the given transform node.
  14003. * The local matrix of this bone is copied from the transform node every frame.
  14004. * @param transformNode defines the transform node to link to
  14005. */
  14006. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14007. /**
  14008. * Gets the node used to drive the bone's transformation
  14009. * @returns a transform node or null
  14010. */
  14011. getTransformNode(): Nullable<TransformNode>;
  14012. /** Gets or sets current position (in local space) */
  14013. position: Vector3;
  14014. /** Gets or sets current rotation (in local space) */
  14015. rotation: Vector3;
  14016. /** Gets or sets current rotation quaternion (in local space) */
  14017. rotationQuaternion: Quaternion;
  14018. /** Gets or sets current scaling (in local space) */
  14019. scaling: Vector3;
  14020. /**
  14021. * Gets the animation properties override
  14022. */
  14023. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  14024. private _decompose;
  14025. private _compose;
  14026. /**
  14027. * Update the base and local matrices
  14028. * @param matrix defines the new base or local matrix
  14029. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14030. * @param updateLocalMatrix defines if the local matrix should be updated
  14031. */
  14032. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14033. /** @hidden */
  14034. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14035. /**
  14036. * Flag the bone as dirty (Forcing it to update everything)
  14037. */
  14038. markAsDirty(): void;
  14039. /** @hidden */
  14040. _markAsDirtyAndCompose(): void;
  14041. private _markAsDirtyAndDecompose;
  14042. /**
  14043. * Translate the bone in local or world space
  14044. * @param vec The amount to translate the bone
  14045. * @param space The space that the translation is in
  14046. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14047. */
  14048. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14049. /**
  14050. * Set the postion of the bone in local or world space
  14051. * @param position The position to set the bone
  14052. * @param space The space that the position is in
  14053. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14054. */
  14055. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14056. /**
  14057. * Set the absolute position of the bone (world space)
  14058. * @param position The position to set the bone
  14059. * @param mesh The mesh that this bone is attached to
  14060. */
  14061. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14062. /**
  14063. * Scale the bone on the x, y and z axes (in local space)
  14064. * @param x The amount to scale the bone on the x axis
  14065. * @param y The amount to scale the bone on the y axis
  14066. * @param z The amount to scale the bone on the z axis
  14067. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14068. */
  14069. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14070. /**
  14071. * Set the bone scaling in local space
  14072. * @param scale defines the scaling vector
  14073. */
  14074. setScale(scale: Vector3): void;
  14075. /**
  14076. * Gets the current scaling in local space
  14077. * @returns the current scaling vector
  14078. */
  14079. getScale(): Vector3;
  14080. /**
  14081. * Gets the current scaling in local space and stores it in a target vector
  14082. * @param result defines the target vector
  14083. */
  14084. getScaleToRef(result: Vector3): void;
  14085. /**
  14086. * Set the yaw, pitch, and roll of the bone in local or world space
  14087. * @param yaw The rotation of the bone on the y axis
  14088. * @param pitch The rotation of the bone on the x axis
  14089. * @param roll The rotation of the bone on the z axis
  14090. * @param space The space that the axes of rotation are in
  14091. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14092. */
  14093. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14094. /**
  14095. * Add a rotation to the bone on an axis in local or world space
  14096. * @param axis The axis to rotate the bone on
  14097. * @param amount The amount to rotate the bone
  14098. * @param space The space that the axis is in
  14099. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14100. */
  14101. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14102. /**
  14103. * Set the rotation of the bone to a particular axis angle in local or world space
  14104. * @param axis The axis to rotate the bone on
  14105. * @param angle The angle that the bone should be rotated to
  14106. * @param space The space that the axis is in
  14107. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14108. */
  14109. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14110. /**
  14111. * Set the euler rotation of the bone in local of world space
  14112. * @param rotation The euler rotation that the bone should be set to
  14113. * @param space The space that the rotation is in
  14114. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14115. */
  14116. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14117. /**
  14118. * Set the quaternion rotation of the bone in local of world space
  14119. * @param quat The quaternion rotation that the bone should be set to
  14120. * @param space The space that the rotation is in
  14121. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14122. */
  14123. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14124. /**
  14125. * Set the rotation matrix of the bone in local of world space
  14126. * @param rotMat The rotation matrix that the bone should be set to
  14127. * @param space The space that the rotation is in
  14128. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14129. */
  14130. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14131. private _rotateWithMatrix;
  14132. private _getNegativeRotationToRef;
  14133. /**
  14134. * Get the position of the bone in local or world space
  14135. * @param space The space that the returned position is in
  14136. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14137. * @returns The position of the bone
  14138. */
  14139. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14140. /**
  14141. * Copy the position of the bone to a vector3 in local or world space
  14142. * @param space The space that the returned position is in
  14143. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14144. * @param result The vector3 to copy the position to
  14145. */
  14146. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14147. /**
  14148. * Get the absolute position of the bone (world space)
  14149. * @param mesh The mesh that this bone is attached to
  14150. * @returns The absolute position of the bone
  14151. */
  14152. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14153. /**
  14154. * Copy the absolute position of the bone (world space) to the result param
  14155. * @param mesh The mesh that this bone is attached to
  14156. * @param result The vector3 to copy the absolute position to
  14157. */
  14158. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14159. /**
  14160. * Compute the absolute transforms of this bone and its children
  14161. */
  14162. computeAbsoluteTransforms(): void;
  14163. /**
  14164. * Get the world direction from an axis that is in the local space of the bone
  14165. * @param localAxis The local direction that is used to compute the world direction
  14166. * @param mesh The mesh that this bone is attached to
  14167. * @returns The world direction
  14168. */
  14169. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14170. /**
  14171. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14172. * @param localAxis The local direction that is used to compute the world direction
  14173. * @param mesh The mesh that this bone is attached to
  14174. * @param result The vector3 that the world direction will be copied to
  14175. */
  14176. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14177. /**
  14178. * Get the euler rotation of the bone in local or world space
  14179. * @param space The space that the rotation should be in
  14180. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14181. * @returns The euler rotation
  14182. */
  14183. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14184. /**
  14185. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14186. * @param space The space that the rotation should be in
  14187. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14188. * @param result The vector3 that the rotation should be copied to
  14189. */
  14190. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14191. /**
  14192. * Get the quaternion rotation of the bone in either local or world space
  14193. * @param space The space that the rotation should be in
  14194. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14195. * @returns The quaternion rotation
  14196. */
  14197. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14198. /**
  14199. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14200. * @param space The space that the rotation should be in
  14201. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14202. * @param result The quaternion that the rotation should be copied to
  14203. */
  14204. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14205. /**
  14206. * Get the rotation matrix of the bone in local or world space
  14207. * @param space The space that the rotation should be in
  14208. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14209. * @returns The rotation matrix
  14210. */
  14211. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14212. /**
  14213. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14214. * @param space The space that the rotation should be in
  14215. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14216. * @param result The quaternion that the rotation should be copied to
  14217. */
  14218. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14219. /**
  14220. * Get the world position of a point that is in the local space of the bone
  14221. * @param position The local position
  14222. * @param mesh The mesh that this bone is attached to
  14223. * @returns The world position
  14224. */
  14225. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14226. /**
  14227. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14228. * @param position The local position
  14229. * @param mesh The mesh that this bone is attached to
  14230. * @param result The vector3 that the world position should be copied to
  14231. */
  14232. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14233. /**
  14234. * Get the local position of a point that is in world space
  14235. * @param position The world position
  14236. * @param mesh The mesh that this bone is attached to
  14237. * @returns The local position
  14238. */
  14239. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14240. /**
  14241. * Get the local position of a point that is in world space and copy it to the result param
  14242. * @param position The world position
  14243. * @param mesh The mesh that this bone is attached to
  14244. * @param result The vector3 that the local position should be copied to
  14245. */
  14246. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14247. }
  14248. }
  14249. declare module "babylonjs/Meshes/transformNode" {
  14250. import { DeepImmutable } from "babylonjs/types";
  14251. import { Observable } from "babylonjs/Misc/observable";
  14252. import { Nullable } from "babylonjs/types";
  14253. import { Camera } from "babylonjs/Cameras/camera";
  14254. import { Scene } from "babylonjs/scene";
  14255. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14256. import { Node } from "babylonjs/node";
  14257. import { Bone } from "babylonjs/Bones/bone";
  14258. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14259. import { Space } from "babylonjs/Maths/math.axis";
  14260. /**
  14261. * 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.
  14262. * @see https://doc.babylonjs.com/how_to/transformnode
  14263. */
  14264. export class TransformNode extends Node {
  14265. /**
  14266. * Object will not rotate to face the camera
  14267. */
  14268. static BILLBOARDMODE_NONE: number;
  14269. /**
  14270. * Object will rotate to face the camera but only on the x axis
  14271. */
  14272. static BILLBOARDMODE_X: number;
  14273. /**
  14274. * Object will rotate to face the camera but only on the y axis
  14275. */
  14276. static BILLBOARDMODE_Y: number;
  14277. /**
  14278. * Object will rotate to face the camera but only on the z axis
  14279. */
  14280. static BILLBOARDMODE_Z: number;
  14281. /**
  14282. * Object will rotate to face the camera
  14283. */
  14284. static BILLBOARDMODE_ALL: number;
  14285. /**
  14286. * Object will rotate to face the camera's position instead of orientation
  14287. */
  14288. static BILLBOARDMODE_USE_POSITION: number;
  14289. private _forward;
  14290. private _forwardInverted;
  14291. private _up;
  14292. private _right;
  14293. private _rightInverted;
  14294. private _position;
  14295. private _rotation;
  14296. private _rotationQuaternion;
  14297. protected _scaling: Vector3;
  14298. protected _isDirty: boolean;
  14299. private _transformToBoneReferal;
  14300. private _isAbsoluteSynced;
  14301. private _billboardMode;
  14302. /**
  14303. * Gets or sets the billboard mode. Default is 0.
  14304. *
  14305. * | Value | Type | Description |
  14306. * | --- | --- | --- |
  14307. * | 0 | BILLBOARDMODE_NONE | |
  14308. * | 1 | BILLBOARDMODE_X | |
  14309. * | 2 | BILLBOARDMODE_Y | |
  14310. * | 4 | BILLBOARDMODE_Z | |
  14311. * | 7 | BILLBOARDMODE_ALL | |
  14312. *
  14313. */
  14314. billboardMode: number;
  14315. private _preserveParentRotationForBillboard;
  14316. /**
  14317. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14318. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14319. */
  14320. preserveParentRotationForBillboard: boolean;
  14321. /**
  14322. * 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
  14323. */
  14324. scalingDeterminant: number;
  14325. private _infiniteDistance;
  14326. /**
  14327. * Gets or sets the distance of the object to max, often used by skybox
  14328. */
  14329. infiniteDistance: boolean;
  14330. /**
  14331. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14332. * By default the system will update normals to compensate
  14333. */
  14334. ignoreNonUniformScaling: boolean;
  14335. /**
  14336. * 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
  14337. */
  14338. reIntegrateRotationIntoRotationQuaternion: boolean;
  14339. /** @hidden */
  14340. _poseMatrix: Nullable<Matrix>;
  14341. /** @hidden */
  14342. _localMatrix: Matrix;
  14343. private _usePivotMatrix;
  14344. private _absolutePosition;
  14345. private _absoluteScaling;
  14346. private _absoluteRotationQuaternion;
  14347. private _pivotMatrix;
  14348. private _pivotMatrixInverse;
  14349. protected _postMultiplyPivotMatrix: boolean;
  14350. protected _isWorldMatrixFrozen: boolean;
  14351. /** @hidden */
  14352. _indexInSceneTransformNodesArray: number;
  14353. /**
  14354. * An event triggered after the world matrix is updated
  14355. */
  14356. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14357. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14358. /**
  14359. * Gets a string identifying the name of the class
  14360. * @returns "TransformNode" string
  14361. */
  14362. getClassName(): string;
  14363. /**
  14364. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14365. */
  14366. position: Vector3;
  14367. /**
  14368. * 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)).
  14369. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14370. */
  14371. rotation: Vector3;
  14372. /**
  14373. * 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)).
  14374. */
  14375. scaling: Vector3;
  14376. /**
  14377. * 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).
  14378. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14379. */
  14380. rotationQuaternion: Nullable<Quaternion>;
  14381. /**
  14382. * The forward direction of that transform in world space.
  14383. */
  14384. readonly forward: Vector3;
  14385. /**
  14386. * The up direction of that transform in world space.
  14387. */
  14388. readonly up: Vector3;
  14389. /**
  14390. * The right direction of that transform in world space.
  14391. */
  14392. readonly right: Vector3;
  14393. /**
  14394. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14395. * @param matrix the matrix to copy the pose from
  14396. * @returns this TransformNode.
  14397. */
  14398. updatePoseMatrix(matrix: Matrix): TransformNode;
  14399. /**
  14400. * Returns the mesh Pose matrix.
  14401. * @returns the pose matrix
  14402. */
  14403. getPoseMatrix(): Matrix;
  14404. /** @hidden */
  14405. _isSynchronized(): boolean;
  14406. /** @hidden */
  14407. _initCache(): void;
  14408. /**
  14409. * Flag the transform node as dirty (Forcing it to update everything)
  14410. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14411. * @returns this transform node
  14412. */
  14413. markAsDirty(property: string): TransformNode;
  14414. /**
  14415. * Returns the current mesh absolute position.
  14416. * Returns a Vector3.
  14417. */
  14418. readonly absolutePosition: Vector3;
  14419. /**
  14420. * Returns the current mesh absolute scaling.
  14421. * Returns a Vector3.
  14422. */
  14423. readonly absoluteScaling: Vector3;
  14424. /**
  14425. * Returns the current mesh absolute rotation.
  14426. * Returns a Quaternion.
  14427. */
  14428. readonly absoluteRotationQuaternion: Quaternion;
  14429. /**
  14430. * Sets a new matrix to apply before all other transformation
  14431. * @param matrix defines the transform matrix
  14432. * @returns the current TransformNode
  14433. */
  14434. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14435. /**
  14436. * Sets a new pivot matrix to the current node
  14437. * @param matrix defines the new pivot matrix to use
  14438. * @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
  14439. * @returns the current TransformNode
  14440. */
  14441. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14442. /**
  14443. * Returns the mesh pivot matrix.
  14444. * Default : Identity.
  14445. * @returns the matrix
  14446. */
  14447. getPivotMatrix(): Matrix;
  14448. /**
  14449. * Instantiate (when possible) or clone that node with its hierarchy
  14450. * @param newParent defines the new parent to use for the instance (or clone)
  14451. * @param options defines options to configure how copy is done
  14452. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14453. * @returns an instance (or a clone) of the current node with its hiearchy
  14454. */
  14455. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14456. doNotInstantiate: boolean;
  14457. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14458. /**
  14459. * Prevents the World matrix to be computed any longer
  14460. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14461. * @returns the TransformNode.
  14462. */
  14463. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14464. /**
  14465. * Allows back the World matrix computation.
  14466. * @returns the TransformNode.
  14467. */
  14468. unfreezeWorldMatrix(): this;
  14469. /**
  14470. * True if the World matrix has been frozen.
  14471. */
  14472. readonly isWorldMatrixFrozen: boolean;
  14473. /**
  14474. * Retuns the mesh absolute position in the World.
  14475. * @returns a Vector3.
  14476. */
  14477. getAbsolutePosition(): Vector3;
  14478. /**
  14479. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14480. * @param absolutePosition the absolute position to set
  14481. * @returns the TransformNode.
  14482. */
  14483. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14484. /**
  14485. * Sets the mesh position in its local space.
  14486. * @param vector3 the position to set in localspace
  14487. * @returns the TransformNode.
  14488. */
  14489. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14490. /**
  14491. * Returns the mesh position in the local space from the current World matrix values.
  14492. * @returns a new Vector3.
  14493. */
  14494. getPositionExpressedInLocalSpace(): Vector3;
  14495. /**
  14496. * Translates the mesh along the passed Vector3 in its local space.
  14497. * @param vector3 the distance to translate in localspace
  14498. * @returns the TransformNode.
  14499. */
  14500. locallyTranslate(vector3: Vector3): TransformNode;
  14501. private static _lookAtVectorCache;
  14502. /**
  14503. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14504. * @param targetPoint the position (must be in same space as current mesh) to look at
  14505. * @param yawCor optional yaw (y-axis) correction in radians
  14506. * @param pitchCor optional pitch (x-axis) correction in radians
  14507. * @param rollCor optional roll (z-axis) correction in radians
  14508. * @param space the choosen space of the target
  14509. * @returns the TransformNode.
  14510. */
  14511. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14512. /**
  14513. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14514. * This Vector3 is expressed in the World space.
  14515. * @param localAxis axis to rotate
  14516. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14517. */
  14518. getDirection(localAxis: Vector3): Vector3;
  14519. /**
  14520. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14521. * localAxis is expressed in the mesh local space.
  14522. * result is computed in the Wordl space from the mesh World matrix.
  14523. * @param localAxis axis to rotate
  14524. * @param result the resulting transformnode
  14525. * @returns this TransformNode.
  14526. */
  14527. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14528. /**
  14529. * Sets this transform node rotation to the given local axis.
  14530. * @param localAxis the axis in local space
  14531. * @param yawCor optional yaw (y-axis) correction in radians
  14532. * @param pitchCor optional pitch (x-axis) correction in radians
  14533. * @param rollCor optional roll (z-axis) correction in radians
  14534. * @returns this TransformNode
  14535. */
  14536. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14537. /**
  14538. * Sets a new pivot point to the current node
  14539. * @param point defines the new pivot point to use
  14540. * @param space defines if the point is in world or local space (local by default)
  14541. * @returns the current TransformNode
  14542. */
  14543. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14544. /**
  14545. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14546. * @returns the pivot point
  14547. */
  14548. getPivotPoint(): Vector3;
  14549. /**
  14550. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14551. * @param result the vector3 to store the result
  14552. * @returns this TransformNode.
  14553. */
  14554. getPivotPointToRef(result: Vector3): TransformNode;
  14555. /**
  14556. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14557. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14558. */
  14559. getAbsolutePivotPoint(): Vector3;
  14560. /**
  14561. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14562. * @param result vector3 to store the result
  14563. * @returns this TransformNode.
  14564. */
  14565. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14566. /**
  14567. * Defines the passed node as the parent of the current node.
  14568. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14569. * @see https://doc.babylonjs.com/how_to/parenting
  14570. * @param node the node ot set as the parent
  14571. * @returns this TransformNode.
  14572. */
  14573. setParent(node: Nullable<Node>): TransformNode;
  14574. private _nonUniformScaling;
  14575. /**
  14576. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14577. */
  14578. readonly nonUniformScaling: boolean;
  14579. /** @hidden */
  14580. _updateNonUniformScalingState(value: boolean): boolean;
  14581. /**
  14582. * Attach the current TransformNode to another TransformNode associated with a bone
  14583. * @param bone Bone affecting the TransformNode
  14584. * @param affectedTransformNode TransformNode associated with the bone
  14585. * @returns this object
  14586. */
  14587. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14588. /**
  14589. * Detach the transform node if its associated with a bone
  14590. * @returns this object
  14591. */
  14592. detachFromBone(): TransformNode;
  14593. private static _rotationAxisCache;
  14594. /**
  14595. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14596. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14597. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14598. * The passed axis is also normalized.
  14599. * @param axis the axis to rotate around
  14600. * @param amount the amount to rotate in radians
  14601. * @param space Space to rotate in (Default: local)
  14602. * @returns the TransformNode.
  14603. */
  14604. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14605. /**
  14606. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14607. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14608. * The passed axis is also normalized. .
  14609. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14610. * @param point the point to rotate around
  14611. * @param axis the axis to rotate around
  14612. * @param amount the amount to rotate in radians
  14613. * @returns the TransformNode
  14614. */
  14615. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14616. /**
  14617. * Translates the mesh along the axis vector for the passed distance in the given space.
  14618. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14619. * @param axis the axis to translate in
  14620. * @param distance the distance to translate
  14621. * @param space Space to rotate in (Default: local)
  14622. * @returns the TransformNode.
  14623. */
  14624. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14625. /**
  14626. * Adds a rotation step to the mesh current rotation.
  14627. * x, y, z are Euler angles expressed in radians.
  14628. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14629. * This means this rotation is made in the mesh local space only.
  14630. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14631. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14632. * ```javascript
  14633. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14634. * ```
  14635. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14636. * 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.
  14637. * @param x Rotation to add
  14638. * @param y Rotation to add
  14639. * @param z Rotation to add
  14640. * @returns the TransformNode.
  14641. */
  14642. addRotation(x: number, y: number, z: number): TransformNode;
  14643. /**
  14644. * @hidden
  14645. */
  14646. protected _getEffectiveParent(): Nullable<Node>;
  14647. /**
  14648. * Computes the world matrix of the node
  14649. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14650. * @returns the world matrix
  14651. */
  14652. computeWorldMatrix(force?: boolean): Matrix;
  14653. protected _afterComputeWorldMatrix(): void;
  14654. /**
  14655. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14656. * @param func callback function to add
  14657. *
  14658. * @returns the TransformNode.
  14659. */
  14660. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14661. /**
  14662. * Removes a registered callback function.
  14663. * @param func callback function to remove
  14664. * @returns the TransformNode.
  14665. */
  14666. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14667. /**
  14668. * Gets the position of the current mesh in camera space
  14669. * @param camera defines the camera to use
  14670. * @returns a position
  14671. */
  14672. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14673. /**
  14674. * Returns the distance from the mesh to the active camera
  14675. * @param camera defines the camera to use
  14676. * @returns the distance
  14677. */
  14678. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14679. /**
  14680. * Clone the current transform node
  14681. * @param name Name of the new clone
  14682. * @param newParent New parent for the clone
  14683. * @param doNotCloneChildren Do not clone children hierarchy
  14684. * @returns the new transform node
  14685. */
  14686. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14687. /**
  14688. * Serializes the objects information.
  14689. * @param currentSerializationObject defines the object to serialize in
  14690. * @returns the serialized object
  14691. */
  14692. serialize(currentSerializationObject?: any): any;
  14693. /**
  14694. * Returns a new TransformNode object parsed from the source provided.
  14695. * @param parsedTransformNode is the source.
  14696. * @param scene the scne the object belongs to
  14697. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14698. * @returns a new TransformNode object parsed from the source provided.
  14699. */
  14700. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14701. /**
  14702. * Get all child-transformNodes of this node
  14703. * @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
  14704. * @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
  14705. * @returns an array of TransformNode
  14706. */
  14707. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14708. /**
  14709. * Releases resources associated with this transform node.
  14710. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14711. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14712. */
  14713. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14714. /**
  14715. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14716. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14717. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14718. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14719. * @returns the current mesh
  14720. */
  14721. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14722. private _syncAbsoluteScalingAndRotation;
  14723. }
  14724. }
  14725. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14726. import { Observable } from "babylonjs/Misc/observable";
  14727. import { Nullable } from "babylonjs/types";
  14728. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14729. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14730. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14731. import { Ray } from "babylonjs/Culling/ray";
  14732. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14733. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14734. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14735. /**
  14736. * Defines the types of pose enabled controllers that are supported
  14737. */
  14738. export enum PoseEnabledControllerType {
  14739. /**
  14740. * HTC Vive
  14741. */
  14742. VIVE = 0,
  14743. /**
  14744. * Oculus Rift
  14745. */
  14746. OCULUS = 1,
  14747. /**
  14748. * Windows mixed reality
  14749. */
  14750. WINDOWS = 2,
  14751. /**
  14752. * Samsung gear VR
  14753. */
  14754. GEAR_VR = 3,
  14755. /**
  14756. * Google Daydream
  14757. */
  14758. DAYDREAM = 4,
  14759. /**
  14760. * Generic
  14761. */
  14762. GENERIC = 5
  14763. }
  14764. /**
  14765. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14766. */
  14767. export interface MutableGamepadButton {
  14768. /**
  14769. * Value of the button/trigger
  14770. */
  14771. value: number;
  14772. /**
  14773. * If the button/trigger is currently touched
  14774. */
  14775. touched: boolean;
  14776. /**
  14777. * If the button/trigger is currently pressed
  14778. */
  14779. pressed: boolean;
  14780. }
  14781. /**
  14782. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14783. * @hidden
  14784. */
  14785. export interface ExtendedGamepadButton extends GamepadButton {
  14786. /**
  14787. * If the button/trigger is currently pressed
  14788. */
  14789. readonly pressed: boolean;
  14790. /**
  14791. * If the button/trigger is currently touched
  14792. */
  14793. readonly touched: boolean;
  14794. /**
  14795. * Value of the button/trigger
  14796. */
  14797. readonly value: number;
  14798. }
  14799. /** @hidden */
  14800. export interface _GamePadFactory {
  14801. /**
  14802. * Returns wether or not the current gamepad can be created for this type of controller.
  14803. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14804. * @returns true if it can be created, otherwise false
  14805. */
  14806. canCreate(gamepadInfo: any): boolean;
  14807. /**
  14808. * Creates a new instance of the Gamepad.
  14809. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14810. * @returns the new gamepad instance
  14811. */
  14812. create(gamepadInfo: any): Gamepad;
  14813. }
  14814. /**
  14815. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14816. */
  14817. export class PoseEnabledControllerHelper {
  14818. /** @hidden */
  14819. static _ControllerFactories: _GamePadFactory[];
  14820. /** @hidden */
  14821. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14822. /**
  14823. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14824. * @param vrGamepad the gamepad to initialized
  14825. * @returns a vr controller of the type the gamepad identified as
  14826. */
  14827. static InitiateController(vrGamepad: any): Gamepad;
  14828. }
  14829. /**
  14830. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14831. */
  14832. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14833. /**
  14834. * If the controller is used in a webXR session
  14835. */
  14836. isXR: boolean;
  14837. private _deviceRoomPosition;
  14838. private _deviceRoomRotationQuaternion;
  14839. /**
  14840. * The device position in babylon space
  14841. */
  14842. devicePosition: Vector3;
  14843. /**
  14844. * The device rotation in babylon space
  14845. */
  14846. deviceRotationQuaternion: Quaternion;
  14847. /**
  14848. * The scale factor of the device in babylon space
  14849. */
  14850. deviceScaleFactor: number;
  14851. /**
  14852. * (Likely devicePosition should be used instead) The device position in its room space
  14853. */
  14854. position: Vector3;
  14855. /**
  14856. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14857. */
  14858. rotationQuaternion: Quaternion;
  14859. /**
  14860. * The type of controller (Eg. Windows mixed reality)
  14861. */
  14862. controllerType: PoseEnabledControllerType;
  14863. protected _calculatedPosition: Vector3;
  14864. private _calculatedRotation;
  14865. /**
  14866. * The raw pose from the device
  14867. */
  14868. rawPose: DevicePose;
  14869. private _trackPosition;
  14870. private _maxRotationDistFromHeadset;
  14871. private _draggedRoomRotation;
  14872. /**
  14873. * @hidden
  14874. */
  14875. _disableTrackPosition(fixedPosition: Vector3): void;
  14876. /**
  14877. * Internal, the mesh attached to the controller
  14878. * @hidden
  14879. */
  14880. _mesh: Nullable<AbstractMesh>;
  14881. private _poseControlledCamera;
  14882. private _leftHandSystemQuaternion;
  14883. /**
  14884. * Internal, matrix used to convert room space to babylon space
  14885. * @hidden
  14886. */
  14887. _deviceToWorld: Matrix;
  14888. /**
  14889. * Node to be used when casting a ray from the controller
  14890. * @hidden
  14891. */
  14892. _pointingPoseNode: Nullable<TransformNode>;
  14893. /**
  14894. * Name of the child mesh that can be used to cast a ray from the controller
  14895. */
  14896. static readonly POINTING_POSE: string;
  14897. /**
  14898. * Creates a new PoseEnabledController from a gamepad
  14899. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14900. */
  14901. constructor(browserGamepad: any);
  14902. private _workingMatrix;
  14903. /**
  14904. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14905. */
  14906. update(): void;
  14907. /**
  14908. * Updates only the pose device and mesh without doing any button event checking
  14909. */
  14910. protected _updatePoseAndMesh(): void;
  14911. /**
  14912. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14913. * @param poseData raw pose fromthe device
  14914. */
  14915. updateFromDevice(poseData: DevicePose): void;
  14916. /**
  14917. * @hidden
  14918. */
  14919. _meshAttachedObservable: Observable<AbstractMesh>;
  14920. /**
  14921. * Attaches a mesh to the controller
  14922. * @param mesh the mesh to be attached
  14923. */
  14924. attachToMesh(mesh: AbstractMesh): void;
  14925. /**
  14926. * Attaches the controllers mesh to a camera
  14927. * @param camera the camera the mesh should be attached to
  14928. */
  14929. attachToPoseControlledCamera(camera: TargetCamera): void;
  14930. /**
  14931. * Disposes of the controller
  14932. */
  14933. dispose(): void;
  14934. /**
  14935. * The mesh that is attached to the controller
  14936. */
  14937. readonly mesh: Nullable<AbstractMesh>;
  14938. /**
  14939. * Gets the ray of the controller in the direction the controller is pointing
  14940. * @param length the length the resulting ray should be
  14941. * @returns a ray in the direction the controller is pointing
  14942. */
  14943. getForwardRay(length?: number): Ray;
  14944. }
  14945. }
  14946. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  14947. import { Observable } from "babylonjs/Misc/observable";
  14948. import { Scene } from "babylonjs/scene";
  14949. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14950. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  14951. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  14952. import { Nullable } from "babylonjs/types";
  14953. /**
  14954. * Defines the WebVRController object that represents controllers tracked in 3D space
  14955. */
  14956. export abstract class WebVRController extends PoseEnabledController {
  14957. /**
  14958. * Internal, the default controller model for the controller
  14959. */
  14960. protected _defaultModel: Nullable<AbstractMesh>;
  14961. /**
  14962. * Fired when the trigger state has changed
  14963. */
  14964. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14965. /**
  14966. * Fired when the main button state has changed
  14967. */
  14968. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14969. /**
  14970. * Fired when the secondary button state has changed
  14971. */
  14972. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14973. /**
  14974. * Fired when the pad state has changed
  14975. */
  14976. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14977. /**
  14978. * Fired when controllers stick values have changed
  14979. */
  14980. onPadValuesChangedObservable: Observable<StickValues>;
  14981. /**
  14982. * Array of button availible on the controller
  14983. */
  14984. protected _buttons: Array<MutableGamepadButton>;
  14985. private _onButtonStateChange;
  14986. /**
  14987. * Fired when a controller button's state has changed
  14988. * @param callback the callback containing the button that was modified
  14989. */
  14990. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14991. /**
  14992. * X and Y axis corresponding to the controllers joystick
  14993. */
  14994. pad: StickValues;
  14995. /**
  14996. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14997. */
  14998. hand: string;
  14999. /**
  15000. * The default controller model for the controller
  15001. */
  15002. readonly defaultModel: Nullable<AbstractMesh>;
  15003. /**
  15004. * Creates a new WebVRController from a gamepad
  15005. * @param vrGamepad the gamepad that the WebVRController should be created from
  15006. */
  15007. constructor(vrGamepad: any);
  15008. /**
  15009. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  15010. */
  15011. update(): void;
  15012. /**
  15013. * Function to be called when a button is modified
  15014. */
  15015. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  15016. /**
  15017. * Loads a mesh and attaches it to the controller
  15018. * @param scene the scene the mesh should be added to
  15019. * @param meshLoaded callback for when the mesh has been loaded
  15020. */
  15021. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  15022. private _setButtonValue;
  15023. private _changes;
  15024. private _checkChanges;
  15025. /**
  15026. * Disposes of th webVRCOntroller
  15027. */
  15028. dispose(): void;
  15029. }
  15030. }
  15031. declare module "babylonjs/Lights/hemisphericLight" {
  15032. import { Nullable } from "babylonjs/types";
  15033. import { Scene } from "babylonjs/scene";
  15034. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15035. import { Color3 } from "babylonjs/Maths/math.color";
  15036. import { Effect } from "babylonjs/Materials/effect";
  15037. import { Light } from "babylonjs/Lights/light";
  15038. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  15039. /**
  15040. * The HemisphericLight simulates the ambient environment light,
  15041. * so the passed direction is the light reflection direction, not the incoming direction.
  15042. */
  15043. export class HemisphericLight extends Light {
  15044. /**
  15045. * The groundColor is the light in the opposite direction to the one specified during creation.
  15046. * 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.
  15047. */
  15048. groundColor: Color3;
  15049. /**
  15050. * The light reflection direction, not the incoming direction.
  15051. */
  15052. direction: Vector3;
  15053. /**
  15054. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  15055. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  15056. * The HemisphericLight can't cast shadows.
  15057. * Documentation : https://doc.babylonjs.com/babylon101/lights
  15058. * @param name The friendly name of the light
  15059. * @param direction The direction of the light reflection
  15060. * @param scene The scene the light belongs to
  15061. */
  15062. constructor(name: string, direction: Vector3, scene: Scene);
  15063. protected _buildUniformLayout(): void;
  15064. /**
  15065. * Returns the string "HemisphericLight".
  15066. * @return The class name
  15067. */
  15068. getClassName(): string;
  15069. /**
  15070. * Sets the HemisphericLight direction towards the passed target (Vector3).
  15071. * Returns the updated direction.
  15072. * @param target The target the direction should point to
  15073. * @return The computed direction
  15074. */
  15075. setDirectionToTarget(target: Vector3): Vector3;
  15076. /**
  15077. * Returns the shadow generator associated to the light.
  15078. * @returns Always null for hemispheric lights because it does not support shadows.
  15079. */
  15080. getShadowGenerator(): Nullable<IShadowGenerator>;
  15081. /**
  15082. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  15083. * @param effect The effect to update
  15084. * @param lightIndex The index of the light in the effect to update
  15085. * @returns The hemispheric light
  15086. */
  15087. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  15088. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  15089. /**
  15090. * Computes the world matrix of the node
  15091. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15092. * @param useWasUpdatedFlag defines a reserved property
  15093. * @returns the world matrix
  15094. */
  15095. computeWorldMatrix(): Matrix;
  15096. /**
  15097. * Returns the integer 3.
  15098. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15099. */
  15100. getTypeID(): number;
  15101. /**
  15102. * Prepares the list of defines specific to the light type.
  15103. * @param defines the list of defines
  15104. * @param lightIndex defines the index of the light for the effect
  15105. */
  15106. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15107. }
  15108. }
  15109. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  15110. /** @hidden */
  15111. export var vrMultiviewToSingleviewPixelShader: {
  15112. name: string;
  15113. shader: string;
  15114. };
  15115. }
  15116. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  15117. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15118. import { Scene } from "babylonjs/scene";
  15119. /**
  15120. * Renders to multiple views with a single draw call
  15121. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  15122. */
  15123. export class MultiviewRenderTarget extends RenderTargetTexture {
  15124. /**
  15125. * Creates a multiview render target
  15126. * @param scene scene used with the render target
  15127. * @param size the size of the render target (used for each view)
  15128. */
  15129. constructor(scene: Scene, size?: number | {
  15130. width: number;
  15131. height: number;
  15132. } | {
  15133. ratio: number;
  15134. });
  15135. /**
  15136. * @hidden
  15137. * @param faceIndex the face index, if its a cube texture
  15138. */
  15139. _bindFrameBuffer(faceIndex?: number): void;
  15140. /**
  15141. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  15142. * @returns the view count
  15143. */
  15144. getViewCount(): number;
  15145. }
  15146. }
  15147. declare module "babylonjs/Maths/math.frustum" {
  15148. import { Matrix } from "babylonjs/Maths/math.vector";
  15149. import { DeepImmutable } from "babylonjs/types";
  15150. import { Plane } from "babylonjs/Maths/math.plane";
  15151. /**
  15152. * Represents a camera frustum
  15153. */
  15154. export class Frustum {
  15155. /**
  15156. * Gets the planes representing the frustum
  15157. * @param transform matrix to be applied to the returned planes
  15158. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  15159. */
  15160. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  15161. /**
  15162. * Gets the near frustum plane transformed by the transform matrix
  15163. * @param transform transformation matrix to be applied to the resulting frustum plane
  15164. * @param frustumPlane the resuling frustum plane
  15165. */
  15166. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15167. /**
  15168. * Gets the far frustum plane transformed by the transform matrix
  15169. * @param transform transformation matrix to be applied to the resulting frustum plane
  15170. * @param frustumPlane the resuling frustum plane
  15171. */
  15172. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15173. /**
  15174. * Gets the left frustum plane transformed by the transform matrix
  15175. * @param transform transformation matrix to be applied to the resulting frustum plane
  15176. * @param frustumPlane the resuling frustum plane
  15177. */
  15178. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15179. /**
  15180. * Gets the right frustum plane transformed by the transform matrix
  15181. * @param transform transformation matrix to be applied to the resulting frustum plane
  15182. * @param frustumPlane the resuling frustum plane
  15183. */
  15184. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15185. /**
  15186. * Gets the top frustum plane transformed by the transform matrix
  15187. * @param transform transformation matrix to be applied to the resulting frustum plane
  15188. * @param frustumPlane the resuling frustum plane
  15189. */
  15190. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15191. /**
  15192. * Gets the bottom frustum plane transformed by the transform matrix
  15193. * @param transform transformation matrix to be applied to the resulting frustum plane
  15194. * @param frustumPlane the resuling frustum plane
  15195. */
  15196. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15197. /**
  15198. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  15199. * @param transform transformation matrix to be applied to the resulting frustum planes
  15200. * @param frustumPlanes the resuling frustum planes
  15201. */
  15202. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  15203. }
  15204. }
  15205. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  15206. import { Camera } from "babylonjs/Cameras/camera";
  15207. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15208. import { Nullable } from "babylonjs/types";
  15209. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15210. import { Matrix } from "babylonjs/Maths/math.vector";
  15211. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  15212. module "babylonjs/Engines/engine" {
  15213. interface Engine {
  15214. /**
  15215. * Creates a new multiview render target
  15216. * @param width defines the width of the texture
  15217. * @param height defines the height of the texture
  15218. * @returns the created multiview texture
  15219. */
  15220. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  15221. /**
  15222. * Binds a multiview framebuffer to be drawn to
  15223. * @param multiviewTexture texture to bind
  15224. */
  15225. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  15226. }
  15227. }
  15228. module "babylonjs/Cameras/camera" {
  15229. interface Camera {
  15230. /**
  15231. * @hidden
  15232. * 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)
  15233. */
  15234. _useMultiviewToSingleView: boolean;
  15235. /**
  15236. * @hidden
  15237. * 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)
  15238. */
  15239. _multiviewTexture: Nullable<RenderTargetTexture>;
  15240. /**
  15241. * @hidden
  15242. * ensures the multiview texture of the camera exists and has the specified width/height
  15243. * @param width height to set on the multiview texture
  15244. * @param height width to set on the multiview texture
  15245. */
  15246. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  15247. }
  15248. }
  15249. module "babylonjs/scene" {
  15250. interface Scene {
  15251. /** @hidden */
  15252. _transformMatrixR: Matrix;
  15253. /** @hidden */
  15254. _multiviewSceneUbo: Nullable<UniformBuffer>;
  15255. /** @hidden */
  15256. _createMultiviewUbo(): void;
  15257. /** @hidden */
  15258. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  15259. /** @hidden */
  15260. _renderMultiviewToSingleView(camera: Camera): void;
  15261. }
  15262. }
  15263. }
  15264. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  15265. import { Camera } from "babylonjs/Cameras/camera";
  15266. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  15267. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  15268. import "babylonjs/Engines/Extensions/engine.multiview";
  15269. /**
  15270. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  15271. * This will not be used for webXR as it supports displaying texture arrays directly
  15272. */
  15273. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  15274. /**
  15275. * Initializes a VRMultiviewToSingleview
  15276. * @param name name of the post process
  15277. * @param camera camera to be applied to
  15278. * @param scaleFactor scaling factor to the size of the output texture
  15279. */
  15280. constructor(name: string, camera: Camera, scaleFactor: number);
  15281. }
  15282. }
  15283. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  15284. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  15285. import { Nullable } from "babylonjs/types";
  15286. import { Size } from "babylonjs/Maths/math.size";
  15287. import { Observable } from "babylonjs/Misc/observable";
  15288. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  15289. /**
  15290. * Interface used to define additional presentation attributes
  15291. */
  15292. export interface IVRPresentationAttributes {
  15293. /**
  15294. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  15295. */
  15296. highRefreshRate: boolean;
  15297. /**
  15298. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  15299. */
  15300. foveationLevel: number;
  15301. }
  15302. module "babylonjs/Engines/engine" {
  15303. interface Engine {
  15304. /** @hidden */
  15305. _vrDisplay: any;
  15306. /** @hidden */
  15307. _vrSupported: boolean;
  15308. /** @hidden */
  15309. _oldSize: Size;
  15310. /** @hidden */
  15311. _oldHardwareScaleFactor: number;
  15312. /** @hidden */
  15313. _vrExclusivePointerMode: boolean;
  15314. /** @hidden */
  15315. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15316. /** @hidden */
  15317. _onVRDisplayPointerRestricted: () => void;
  15318. /** @hidden */
  15319. _onVRDisplayPointerUnrestricted: () => void;
  15320. /** @hidden */
  15321. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15322. /** @hidden */
  15323. _onVrDisplayDisconnect: Nullable<() => void>;
  15324. /** @hidden */
  15325. _onVrDisplayPresentChange: Nullable<() => void>;
  15326. /**
  15327. * Observable signaled when VR display mode changes
  15328. */
  15329. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15330. /**
  15331. * Observable signaled when VR request present is complete
  15332. */
  15333. onVRRequestPresentComplete: Observable<boolean>;
  15334. /**
  15335. * Observable signaled when VR request present starts
  15336. */
  15337. onVRRequestPresentStart: Observable<Engine>;
  15338. /**
  15339. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15340. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15341. */
  15342. isInVRExclusivePointerMode: boolean;
  15343. /**
  15344. * Gets a boolean indicating if a webVR device was detected
  15345. * @returns true if a webVR device was detected
  15346. */
  15347. isVRDevicePresent(): boolean;
  15348. /**
  15349. * Gets the current webVR device
  15350. * @returns the current webVR device (or null)
  15351. */
  15352. getVRDevice(): any;
  15353. /**
  15354. * Initializes a webVR display and starts listening to display change events
  15355. * The onVRDisplayChangedObservable will be notified upon these changes
  15356. * @returns A promise containing a VRDisplay and if vr is supported
  15357. */
  15358. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15359. /** @hidden */
  15360. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15361. /**
  15362. * Gets or sets the presentation attributes used to configure VR rendering
  15363. */
  15364. vrPresentationAttributes?: IVRPresentationAttributes;
  15365. /**
  15366. * Call this function to switch to webVR mode
  15367. * Will do nothing if webVR is not supported or if there is no webVR device
  15368. * @param options the webvr options provided to the camera. mainly used for multiview
  15369. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15370. */
  15371. enableVR(options: WebVROptions): void;
  15372. /** @hidden */
  15373. _onVRFullScreenTriggered(): void;
  15374. }
  15375. }
  15376. }
  15377. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15378. import { Nullable } from "babylonjs/types";
  15379. import { Observable } from "babylonjs/Misc/observable";
  15380. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15381. import { Scene } from "babylonjs/scene";
  15382. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15383. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15384. import { Node } from "babylonjs/node";
  15385. import { Ray } from "babylonjs/Culling/ray";
  15386. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15387. import "babylonjs/Engines/Extensions/engine.webVR";
  15388. /**
  15389. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15390. * IMPORTANT!! The data is right-hand data.
  15391. * @export
  15392. * @interface DevicePose
  15393. */
  15394. export interface DevicePose {
  15395. /**
  15396. * The position of the device, values in array are [x,y,z].
  15397. */
  15398. readonly position: Nullable<Float32Array>;
  15399. /**
  15400. * The linearVelocity of the device, values in array are [x,y,z].
  15401. */
  15402. readonly linearVelocity: Nullable<Float32Array>;
  15403. /**
  15404. * The linearAcceleration of the device, values in array are [x,y,z].
  15405. */
  15406. readonly linearAcceleration: Nullable<Float32Array>;
  15407. /**
  15408. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15409. */
  15410. readonly orientation: Nullable<Float32Array>;
  15411. /**
  15412. * The angularVelocity of the device, values in array are [x,y,z].
  15413. */
  15414. readonly angularVelocity: Nullable<Float32Array>;
  15415. /**
  15416. * The angularAcceleration of the device, values in array are [x,y,z].
  15417. */
  15418. readonly angularAcceleration: Nullable<Float32Array>;
  15419. }
  15420. /**
  15421. * Interface representing a pose controlled object in Babylon.
  15422. * A pose controlled object has both regular pose values as well as pose values
  15423. * from an external device such as a VR head mounted display
  15424. */
  15425. export interface PoseControlled {
  15426. /**
  15427. * The position of the object in babylon space.
  15428. */
  15429. position: Vector3;
  15430. /**
  15431. * The rotation quaternion of the object in babylon space.
  15432. */
  15433. rotationQuaternion: Quaternion;
  15434. /**
  15435. * The position of the device in babylon space.
  15436. */
  15437. devicePosition?: Vector3;
  15438. /**
  15439. * The rotation quaternion of the device in babylon space.
  15440. */
  15441. deviceRotationQuaternion: Quaternion;
  15442. /**
  15443. * The raw pose coming from the device.
  15444. */
  15445. rawPose: Nullable<DevicePose>;
  15446. /**
  15447. * The scale of the device to be used when translating from device space to babylon space.
  15448. */
  15449. deviceScaleFactor: number;
  15450. /**
  15451. * Updates the poseControlled values based on the input device pose.
  15452. * @param poseData the pose data to update the object with
  15453. */
  15454. updateFromDevice(poseData: DevicePose): void;
  15455. }
  15456. /**
  15457. * Set of options to customize the webVRCamera
  15458. */
  15459. export interface WebVROptions {
  15460. /**
  15461. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15462. */
  15463. trackPosition?: boolean;
  15464. /**
  15465. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15466. */
  15467. positionScale?: number;
  15468. /**
  15469. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15470. */
  15471. displayName?: string;
  15472. /**
  15473. * Should the native controller meshes be initialized. (default: true)
  15474. */
  15475. controllerMeshes?: boolean;
  15476. /**
  15477. * Creating a default HemiLight only on controllers. (default: true)
  15478. */
  15479. defaultLightingOnControllers?: boolean;
  15480. /**
  15481. * If you don't want to use the default VR button of the helper. (default: false)
  15482. */
  15483. useCustomVRButton?: boolean;
  15484. /**
  15485. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15486. */
  15487. customVRButton?: HTMLButtonElement;
  15488. /**
  15489. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15490. */
  15491. rayLength?: number;
  15492. /**
  15493. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15494. */
  15495. defaultHeight?: number;
  15496. /**
  15497. * If multiview should be used if availible (default: false)
  15498. */
  15499. useMultiview?: boolean;
  15500. }
  15501. /**
  15502. * This represents a WebVR camera.
  15503. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15504. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15505. */
  15506. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15507. private webVROptions;
  15508. /**
  15509. * @hidden
  15510. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15511. */
  15512. _vrDevice: any;
  15513. /**
  15514. * The rawPose of the vrDevice.
  15515. */
  15516. rawPose: Nullable<DevicePose>;
  15517. private _onVREnabled;
  15518. private _specsVersion;
  15519. private _attached;
  15520. private _frameData;
  15521. protected _descendants: Array<Node>;
  15522. private _deviceRoomPosition;
  15523. /** @hidden */
  15524. _deviceRoomRotationQuaternion: Quaternion;
  15525. private _standingMatrix;
  15526. /**
  15527. * Represents device position in babylon space.
  15528. */
  15529. devicePosition: Vector3;
  15530. /**
  15531. * Represents device rotation in babylon space.
  15532. */
  15533. deviceRotationQuaternion: Quaternion;
  15534. /**
  15535. * The scale of the device to be used when translating from device space to babylon space.
  15536. */
  15537. deviceScaleFactor: number;
  15538. private _deviceToWorld;
  15539. private _worldToDevice;
  15540. /**
  15541. * References to the webVR controllers for the vrDevice.
  15542. */
  15543. controllers: Array<WebVRController>;
  15544. /**
  15545. * Emits an event when a controller is attached.
  15546. */
  15547. onControllersAttachedObservable: Observable<WebVRController[]>;
  15548. /**
  15549. * Emits an event when a controller's mesh has been loaded;
  15550. */
  15551. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15552. /**
  15553. * Emits an event when the HMD's pose has been updated.
  15554. */
  15555. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15556. private _poseSet;
  15557. /**
  15558. * If the rig cameras be used as parent instead of this camera.
  15559. */
  15560. rigParenting: boolean;
  15561. private _lightOnControllers;
  15562. private _defaultHeight?;
  15563. /**
  15564. * Instantiates a WebVRFreeCamera.
  15565. * @param name The name of the WebVRFreeCamera
  15566. * @param position The starting anchor position for the camera
  15567. * @param scene The scene the camera belongs to
  15568. * @param webVROptions a set of customizable options for the webVRCamera
  15569. */
  15570. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15571. /**
  15572. * Gets the device distance from the ground in meters.
  15573. * @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.
  15574. */
  15575. deviceDistanceToRoomGround(): number;
  15576. /**
  15577. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15578. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15579. */
  15580. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15581. /**
  15582. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15583. * @returns A promise with a boolean set to if the standing matrix is supported.
  15584. */
  15585. useStandingMatrixAsync(): Promise<boolean>;
  15586. /**
  15587. * Disposes the camera
  15588. */
  15589. dispose(): void;
  15590. /**
  15591. * Gets a vrController by name.
  15592. * @param name The name of the controller to retreive
  15593. * @returns the controller matching the name specified or null if not found
  15594. */
  15595. getControllerByName(name: string): Nullable<WebVRController>;
  15596. private _leftController;
  15597. /**
  15598. * The controller corresponding to the users left hand.
  15599. */
  15600. readonly leftController: Nullable<WebVRController>;
  15601. private _rightController;
  15602. /**
  15603. * The controller corresponding to the users right hand.
  15604. */
  15605. readonly rightController: Nullable<WebVRController>;
  15606. /**
  15607. * Casts a ray forward from the vrCamera's gaze.
  15608. * @param length Length of the ray (default: 100)
  15609. * @returns the ray corresponding to the gaze
  15610. */
  15611. getForwardRay(length?: number): Ray;
  15612. /**
  15613. * @hidden
  15614. * Updates the camera based on device's frame data
  15615. */
  15616. _checkInputs(): void;
  15617. /**
  15618. * Updates the poseControlled values based on the input device pose.
  15619. * @param poseData Pose coming from the device
  15620. */
  15621. updateFromDevice(poseData: DevicePose): void;
  15622. private _htmlElementAttached;
  15623. private _detachIfAttached;
  15624. /**
  15625. * WebVR's attach control will start broadcasting frames to the device.
  15626. * Note that in certain browsers (chrome for example) this function must be called
  15627. * within a user-interaction callback. Example:
  15628. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15629. *
  15630. * @param element html element to attach the vrDevice to
  15631. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15632. */
  15633. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15634. /**
  15635. * Detaches the camera from the html element and disables VR
  15636. *
  15637. * @param element html element to detach from
  15638. */
  15639. detachControl(element: HTMLElement): void;
  15640. /**
  15641. * @returns the name of this class
  15642. */
  15643. getClassName(): string;
  15644. /**
  15645. * Calls resetPose on the vrDisplay
  15646. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15647. */
  15648. resetToCurrentRotation(): void;
  15649. /**
  15650. * @hidden
  15651. * Updates the rig cameras (left and right eye)
  15652. */
  15653. _updateRigCameras(): void;
  15654. private _workingVector;
  15655. private _oneVector;
  15656. private _workingMatrix;
  15657. private updateCacheCalled;
  15658. private _correctPositionIfNotTrackPosition;
  15659. /**
  15660. * @hidden
  15661. * Updates the cached values of the camera
  15662. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15663. */
  15664. _updateCache(ignoreParentClass?: boolean): void;
  15665. /**
  15666. * @hidden
  15667. * Get current device position in babylon world
  15668. */
  15669. _computeDevicePosition(): void;
  15670. /**
  15671. * Updates the current device position and rotation in the babylon world
  15672. */
  15673. update(): void;
  15674. /**
  15675. * @hidden
  15676. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15677. * @returns an identity matrix
  15678. */
  15679. _getViewMatrix(): Matrix;
  15680. private _tmpMatrix;
  15681. /**
  15682. * This function is called by the two RIG cameras.
  15683. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15684. * @hidden
  15685. */
  15686. _getWebVRViewMatrix(): Matrix;
  15687. /** @hidden */
  15688. _getWebVRProjectionMatrix(): Matrix;
  15689. private _onGamepadConnectedObserver;
  15690. private _onGamepadDisconnectedObserver;
  15691. private _updateCacheWhenTrackingDisabledObserver;
  15692. /**
  15693. * Initializes the controllers and their meshes
  15694. */
  15695. initControllers(): void;
  15696. }
  15697. }
  15698. declare module "babylonjs/PostProcesses/postProcess" {
  15699. import { Nullable } from "babylonjs/types";
  15700. import { SmartArray } from "babylonjs/Misc/smartArray";
  15701. import { Observable } from "babylonjs/Misc/observable";
  15702. import { Vector2 } from "babylonjs/Maths/math.vector";
  15703. import { Camera } from "babylonjs/Cameras/camera";
  15704. import { Effect } from "babylonjs/Materials/effect";
  15705. import "babylonjs/Shaders/postprocess.vertex";
  15706. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15707. import { Engine } from "babylonjs/Engines/engine";
  15708. import { Color4 } from "babylonjs/Maths/math.color";
  15709. import "babylonjs/Engines/Extensions/engine.renderTarget";
  15710. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15711. /**
  15712. * Size options for a post process
  15713. */
  15714. export type PostProcessOptions = {
  15715. width: number;
  15716. height: number;
  15717. };
  15718. /**
  15719. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15720. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15721. */
  15722. export class PostProcess {
  15723. /** Name of the PostProcess. */
  15724. name: string;
  15725. /**
  15726. * Gets or sets the unique id of the post process
  15727. */
  15728. uniqueId: number;
  15729. /**
  15730. * Width of the texture to apply the post process on
  15731. */
  15732. width: number;
  15733. /**
  15734. * Height of the texture to apply the post process on
  15735. */
  15736. height: number;
  15737. /**
  15738. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15739. * @hidden
  15740. */
  15741. _outputTexture: Nullable<InternalTexture>;
  15742. /**
  15743. * Sampling mode used by the shader
  15744. * See https://doc.babylonjs.com/classes/3.1/texture
  15745. */
  15746. renderTargetSamplingMode: number;
  15747. /**
  15748. * Clear color to use when screen clearing
  15749. */
  15750. clearColor: Color4;
  15751. /**
  15752. * If the buffer needs to be cleared before applying the post process. (default: true)
  15753. * Should be set to false if shader will overwrite all previous pixels.
  15754. */
  15755. autoClear: boolean;
  15756. /**
  15757. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15758. */
  15759. alphaMode: number;
  15760. /**
  15761. * Sets the setAlphaBlendConstants of the babylon engine
  15762. */
  15763. alphaConstants: Color4;
  15764. /**
  15765. * Animations to be used for the post processing
  15766. */
  15767. animations: import("babylonjs/Animations/animation").Animation[];
  15768. /**
  15769. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15770. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15771. */
  15772. enablePixelPerfectMode: boolean;
  15773. /**
  15774. * Force the postprocess to be applied without taking in account viewport
  15775. */
  15776. forceFullscreenViewport: boolean;
  15777. /**
  15778. * List of inspectable custom properties (used by the Inspector)
  15779. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15780. */
  15781. inspectableCustomProperties: IInspectable[];
  15782. /**
  15783. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15784. *
  15785. * | Value | Type | Description |
  15786. * | ----- | ----------------------------------- | ----------- |
  15787. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15788. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15789. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15790. *
  15791. */
  15792. scaleMode: number;
  15793. /**
  15794. * Force textures to be a power of two (default: false)
  15795. */
  15796. alwaysForcePOT: boolean;
  15797. private _samples;
  15798. /**
  15799. * Number of sample textures (default: 1)
  15800. */
  15801. samples: number;
  15802. /**
  15803. * Modify the scale of the post process to be the same as the viewport (default: false)
  15804. */
  15805. adaptScaleToCurrentViewport: boolean;
  15806. private _camera;
  15807. private _scene;
  15808. private _engine;
  15809. private _options;
  15810. private _reusable;
  15811. private _textureType;
  15812. /**
  15813. * Smart array of input and output textures for the post process.
  15814. * @hidden
  15815. */
  15816. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15817. /**
  15818. * The index in _textures that corresponds to the output texture.
  15819. * @hidden
  15820. */
  15821. _currentRenderTextureInd: number;
  15822. private _effect;
  15823. private _samplers;
  15824. private _fragmentUrl;
  15825. private _vertexUrl;
  15826. private _parameters;
  15827. private _scaleRatio;
  15828. protected _indexParameters: any;
  15829. private _shareOutputWithPostProcess;
  15830. private _texelSize;
  15831. private _forcedOutputTexture;
  15832. /**
  15833. * Returns the fragment url or shader name used in the post process.
  15834. * @returns the fragment url or name in the shader store.
  15835. */
  15836. getEffectName(): string;
  15837. /**
  15838. * An event triggered when the postprocess is activated.
  15839. */
  15840. onActivateObservable: Observable<Camera>;
  15841. private _onActivateObserver;
  15842. /**
  15843. * A function that is added to the onActivateObservable
  15844. */
  15845. onActivate: Nullable<(camera: Camera) => void>;
  15846. /**
  15847. * An event triggered when the postprocess changes its size.
  15848. */
  15849. onSizeChangedObservable: Observable<PostProcess>;
  15850. private _onSizeChangedObserver;
  15851. /**
  15852. * A function that is added to the onSizeChangedObservable
  15853. */
  15854. onSizeChanged: (postProcess: PostProcess) => void;
  15855. /**
  15856. * An event triggered when the postprocess applies its effect.
  15857. */
  15858. onApplyObservable: Observable<Effect>;
  15859. private _onApplyObserver;
  15860. /**
  15861. * A function that is added to the onApplyObservable
  15862. */
  15863. onApply: (effect: Effect) => void;
  15864. /**
  15865. * An event triggered before rendering the postprocess
  15866. */
  15867. onBeforeRenderObservable: Observable<Effect>;
  15868. private _onBeforeRenderObserver;
  15869. /**
  15870. * A function that is added to the onBeforeRenderObservable
  15871. */
  15872. onBeforeRender: (effect: Effect) => void;
  15873. /**
  15874. * An event triggered after rendering the postprocess
  15875. */
  15876. onAfterRenderObservable: Observable<Effect>;
  15877. private _onAfterRenderObserver;
  15878. /**
  15879. * A function that is added to the onAfterRenderObservable
  15880. */
  15881. onAfterRender: (efect: Effect) => void;
  15882. /**
  15883. * 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
  15884. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15885. */
  15886. inputTexture: InternalTexture;
  15887. /**
  15888. * Gets the camera which post process is applied to.
  15889. * @returns The camera the post process is applied to.
  15890. */
  15891. getCamera(): Camera;
  15892. /**
  15893. * Gets the texel size of the postprocess.
  15894. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15895. */
  15896. readonly texelSize: Vector2;
  15897. /**
  15898. * Creates a new instance PostProcess
  15899. * @param name The name of the PostProcess.
  15900. * @param fragmentUrl The url of the fragment shader to be used.
  15901. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15902. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15903. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15904. * @param camera The camera to apply the render pass to.
  15905. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15906. * @param engine The engine which the post process will be applied. (default: current engine)
  15907. * @param reusable If the post process can be reused on the same frame. (default: false)
  15908. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15909. * @param textureType Type of textures used when performing the post process. (default: 0)
  15910. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15911. * @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
  15912. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15913. */
  15914. constructor(
  15915. /** Name of the PostProcess. */
  15916. 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);
  15917. /**
  15918. * Gets a string idenfifying the name of the class
  15919. * @returns "PostProcess" string
  15920. */
  15921. getClassName(): string;
  15922. /**
  15923. * Gets the engine which this post process belongs to.
  15924. * @returns The engine the post process was enabled with.
  15925. */
  15926. getEngine(): Engine;
  15927. /**
  15928. * The effect that is created when initializing the post process.
  15929. * @returns The created effect corresponding the the postprocess.
  15930. */
  15931. getEffect(): Effect;
  15932. /**
  15933. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15934. * @param postProcess The post process to share the output with.
  15935. * @returns This post process.
  15936. */
  15937. shareOutputWith(postProcess: PostProcess): PostProcess;
  15938. /**
  15939. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15940. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15941. */
  15942. useOwnOutput(): void;
  15943. /**
  15944. * Updates the effect with the current post process compile time values and recompiles the shader.
  15945. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15946. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15947. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15948. * @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
  15949. * @param onCompiled Called when the shader has been compiled.
  15950. * @param onError Called if there is an error when compiling a shader.
  15951. */
  15952. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15953. /**
  15954. * The post process is reusable if it can be used multiple times within one frame.
  15955. * @returns If the post process is reusable
  15956. */
  15957. isReusable(): boolean;
  15958. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15959. markTextureDirty(): void;
  15960. /**
  15961. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15962. * 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.
  15963. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15964. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15965. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15966. * @returns The target texture that was bound to be written to.
  15967. */
  15968. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15969. /**
  15970. * If the post process is supported.
  15971. */
  15972. readonly isSupported: boolean;
  15973. /**
  15974. * The aspect ratio of the output texture.
  15975. */
  15976. readonly aspectRatio: number;
  15977. /**
  15978. * Get a value indicating if the post-process is ready to be used
  15979. * @returns true if the post-process is ready (shader is compiled)
  15980. */
  15981. isReady(): boolean;
  15982. /**
  15983. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15984. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15985. */
  15986. apply(): Nullable<Effect>;
  15987. private _disposeTextures;
  15988. /**
  15989. * Disposes the post process.
  15990. * @param camera The camera to dispose the post process on.
  15991. */
  15992. dispose(camera?: Camera): void;
  15993. }
  15994. }
  15995. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  15996. /** @hidden */
  15997. export var kernelBlurVaryingDeclaration: {
  15998. name: string;
  15999. shader: string;
  16000. };
  16001. }
  16002. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  16003. /** @hidden */
  16004. export var kernelBlurFragment: {
  16005. name: string;
  16006. shader: string;
  16007. };
  16008. }
  16009. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  16010. /** @hidden */
  16011. export var kernelBlurFragment2: {
  16012. name: string;
  16013. shader: string;
  16014. };
  16015. }
  16016. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  16017. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  16018. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  16019. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  16020. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  16021. /** @hidden */
  16022. export var kernelBlurPixelShader: {
  16023. name: string;
  16024. shader: string;
  16025. };
  16026. }
  16027. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  16028. /** @hidden */
  16029. export var kernelBlurVertex: {
  16030. name: string;
  16031. shader: string;
  16032. };
  16033. }
  16034. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  16035. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  16036. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  16037. /** @hidden */
  16038. export var kernelBlurVertexShader: {
  16039. name: string;
  16040. shader: string;
  16041. };
  16042. }
  16043. declare module "babylonjs/PostProcesses/blurPostProcess" {
  16044. import { Vector2 } from "babylonjs/Maths/math.vector";
  16045. import { Nullable } from "babylonjs/types";
  16046. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  16047. import { Camera } from "babylonjs/Cameras/camera";
  16048. import { Effect } from "babylonjs/Materials/effect";
  16049. import { Engine } from "babylonjs/Engines/engine";
  16050. import "babylonjs/Shaders/kernelBlur.fragment";
  16051. import "babylonjs/Shaders/kernelBlur.vertex";
  16052. /**
  16053. * The Blur Post Process which blurs an image based on a kernel and direction.
  16054. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  16055. */
  16056. export class BlurPostProcess extends PostProcess {
  16057. /** The direction in which to blur the image. */
  16058. direction: Vector2;
  16059. private blockCompilation;
  16060. protected _kernel: number;
  16061. protected _idealKernel: number;
  16062. protected _packedFloat: boolean;
  16063. private _staticDefines;
  16064. /**
  16065. * Sets the length in pixels of the blur sample region
  16066. */
  16067. /**
  16068. * Gets the length in pixels of the blur sample region
  16069. */
  16070. kernel: number;
  16071. /**
  16072. * Sets wether or not the blur needs to unpack/repack floats
  16073. */
  16074. /**
  16075. * Gets wether or not the blur is unpacking/repacking floats
  16076. */
  16077. packedFloat: boolean;
  16078. /**
  16079. * Creates a new instance BlurPostProcess
  16080. * @param name The name of the effect.
  16081. * @param direction The direction in which to blur the image.
  16082. * @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.
  16083. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  16084. * @param camera The camera to apply the render pass to.
  16085. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  16086. * @param engine The engine which the post process will be applied. (default: current engine)
  16087. * @param reusable If the post process can be reused on the same frame. (default: false)
  16088. * @param textureType Type of textures used when performing the post process. (default: 0)
  16089. * @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)
  16090. */
  16091. constructor(name: string,
  16092. /** The direction in which to blur the image. */
  16093. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  16094. /**
  16095. * Updates the effect with the current post process compile time values and recompiles the shader.
  16096. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  16097. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  16098. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  16099. * @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
  16100. * @param onCompiled Called when the shader has been compiled.
  16101. * @param onError Called if there is an error when compiling a shader.
  16102. */
  16103. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16104. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16105. /**
  16106. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  16107. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  16108. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  16109. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  16110. * The gaps between physical kernels are compensated for in the weighting of the samples
  16111. * @param idealKernel Ideal blur kernel.
  16112. * @return Nearest best kernel.
  16113. */
  16114. protected _nearestBestKernel(idealKernel: number): number;
  16115. /**
  16116. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  16117. * @param x The point on the Gaussian distribution to sample.
  16118. * @return the value of the Gaussian function at x.
  16119. */
  16120. protected _gaussianWeight(x: number): number;
  16121. /**
  16122. * Generates a string that can be used as a floating point number in GLSL.
  16123. * @param x Value to print.
  16124. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  16125. * @return GLSL float string.
  16126. */
  16127. protected _glslFloat(x: number, decimalFigures?: number): string;
  16128. }
  16129. }
  16130. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  16131. import { Scene } from "babylonjs/scene";
  16132. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  16133. import { Plane } from "babylonjs/Maths/math.plane";
  16134. /**
  16135. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16136. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16137. * You can then easily use it as a reflectionTexture on a flat surface.
  16138. * In case the surface is not a plane, please consider relying on reflection probes.
  16139. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16140. */
  16141. export class MirrorTexture extends RenderTargetTexture {
  16142. private scene;
  16143. /**
  16144. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  16145. * 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.
  16146. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16147. */
  16148. mirrorPlane: Plane;
  16149. /**
  16150. * Define the blur ratio used to blur the reflection if needed.
  16151. */
  16152. blurRatio: number;
  16153. /**
  16154. * Define the adaptive blur kernel used to blur the reflection if needed.
  16155. * This will autocompute the closest best match for the `blurKernel`
  16156. */
  16157. adaptiveBlurKernel: number;
  16158. /**
  16159. * Define the blur kernel used to blur the reflection if needed.
  16160. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16161. */
  16162. blurKernel: number;
  16163. /**
  16164. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  16165. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16166. */
  16167. blurKernelX: number;
  16168. /**
  16169. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  16170. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16171. */
  16172. blurKernelY: number;
  16173. private _autoComputeBlurKernel;
  16174. protected _onRatioRescale(): void;
  16175. private _updateGammaSpace;
  16176. private _imageProcessingConfigChangeObserver;
  16177. private _transformMatrix;
  16178. private _mirrorMatrix;
  16179. private _savedViewMatrix;
  16180. private _blurX;
  16181. private _blurY;
  16182. private _adaptiveBlurKernel;
  16183. private _blurKernelX;
  16184. private _blurKernelY;
  16185. private _blurRatio;
  16186. /**
  16187. * Instantiates a Mirror Texture.
  16188. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16189. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16190. * You can then easily use it as a reflectionTexture on a flat surface.
  16191. * In case the surface is not a plane, please consider relying on reflection probes.
  16192. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16193. * @param name
  16194. * @param size
  16195. * @param scene
  16196. * @param generateMipMaps
  16197. * @param type
  16198. * @param samplingMode
  16199. * @param generateDepthBuffer
  16200. */
  16201. constructor(name: string, size: number | {
  16202. width: number;
  16203. height: number;
  16204. } | {
  16205. ratio: number;
  16206. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  16207. private _preparePostProcesses;
  16208. /**
  16209. * Clone the mirror texture.
  16210. * @returns the cloned texture
  16211. */
  16212. clone(): MirrorTexture;
  16213. /**
  16214. * Serialize the texture to a JSON representation you could use in Parse later on
  16215. * @returns the serialized JSON representation
  16216. */
  16217. serialize(): any;
  16218. /**
  16219. * Dispose the texture and release its associated resources.
  16220. */
  16221. dispose(): void;
  16222. }
  16223. }
  16224. declare module "babylonjs/Materials/Textures/texture" {
  16225. import { Observable } from "babylonjs/Misc/observable";
  16226. import { Nullable } from "babylonjs/types";
  16227. import { Matrix } from "babylonjs/Maths/math.vector";
  16228. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16229. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16230. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  16231. import { Scene } from "babylonjs/scene";
  16232. /**
  16233. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16234. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16235. */
  16236. export class Texture extends BaseTexture {
  16237. /**
  16238. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  16239. */
  16240. static SerializeBuffers: boolean;
  16241. /** @hidden */
  16242. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  16243. /** @hidden */
  16244. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  16245. /** @hidden */
  16246. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  16247. /** nearest is mag = nearest and min = nearest and mip = linear */
  16248. static readonly NEAREST_SAMPLINGMODE: number;
  16249. /** nearest is mag = nearest and min = nearest and mip = linear */
  16250. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  16251. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16252. static readonly BILINEAR_SAMPLINGMODE: number;
  16253. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16254. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  16255. /** Trilinear is mag = linear and min = linear and mip = linear */
  16256. static readonly TRILINEAR_SAMPLINGMODE: number;
  16257. /** Trilinear is mag = linear and min = linear and mip = linear */
  16258. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  16259. /** mag = nearest and min = nearest and mip = nearest */
  16260. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  16261. /** mag = nearest and min = linear and mip = nearest */
  16262. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  16263. /** mag = nearest and min = linear and mip = linear */
  16264. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  16265. /** mag = nearest and min = linear and mip = none */
  16266. static readonly NEAREST_LINEAR: number;
  16267. /** mag = nearest and min = nearest and mip = none */
  16268. static readonly NEAREST_NEAREST: number;
  16269. /** mag = linear and min = nearest and mip = nearest */
  16270. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  16271. /** mag = linear and min = nearest and mip = linear */
  16272. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  16273. /** mag = linear and min = linear and mip = none */
  16274. static readonly LINEAR_LINEAR: number;
  16275. /** mag = linear and min = nearest and mip = none */
  16276. static readonly LINEAR_NEAREST: number;
  16277. /** Explicit coordinates mode */
  16278. static readonly EXPLICIT_MODE: number;
  16279. /** Spherical coordinates mode */
  16280. static readonly SPHERICAL_MODE: number;
  16281. /** Planar coordinates mode */
  16282. static readonly PLANAR_MODE: number;
  16283. /** Cubic coordinates mode */
  16284. static readonly CUBIC_MODE: number;
  16285. /** Projection coordinates mode */
  16286. static readonly PROJECTION_MODE: number;
  16287. /** Inverse Cubic coordinates mode */
  16288. static readonly SKYBOX_MODE: number;
  16289. /** Inverse Cubic coordinates mode */
  16290. static readonly INVCUBIC_MODE: number;
  16291. /** Equirectangular coordinates mode */
  16292. static readonly EQUIRECTANGULAR_MODE: number;
  16293. /** Equirectangular Fixed coordinates mode */
  16294. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  16295. /** Equirectangular Fixed Mirrored coordinates mode */
  16296. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  16297. /** Texture is not repeating outside of 0..1 UVs */
  16298. static readonly CLAMP_ADDRESSMODE: number;
  16299. /** Texture is repeating outside of 0..1 UVs */
  16300. static readonly WRAP_ADDRESSMODE: number;
  16301. /** Texture is repeating and mirrored */
  16302. static readonly MIRROR_ADDRESSMODE: number;
  16303. /**
  16304. * 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
  16305. */
  16306. static UseSerializedUrlIfAny: boolean;
  16307. /**
  16308. * Define the url of the texture.
  16309. */
  16310. url: Nullable<string>;
  16311. /**
  16312. * Define an offset on the texture to offset the u coordinates of the UVs
  16313. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16314. */
  16315. uOffset: number;
  16316. /**
  16317. * Define an offset on the texture to offset the v coordinates of the UVs
  16318. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16319. */
  16320. vOffset: number;
  16321. /**
  16322. * Define an offset on the texture to scale the u coordinates of the UVs
  16323. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16324. */
  16325. uScale: number;
  16326. /**
  16327. * Define an offset on the texture to scale the v coordinates of the UVs
  16328. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16329. */
  16330. vScale: number;
  16331. /**
  16332. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16333. * @see http://doc.babylonjs.com/how_to/more_materials
  16334. */
  16335. uAng: number;
  16336. /**
  16337. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16338. * @see http://doc.babylonjs.com/how_to/more_materials
  16339. */
  16340. vAng: number;
  16341. /**
  16342. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16343. * @see http://doc.babylonjs.com/how_to/more_materials
  16344. */
  16345. wAng: number;
  16346. /**
  16347. * Defines the center of rotation (U)
  16348. */
  16349. uRotationCenter: number;
  16350. /**
  16351. * Defines the center of rotation (V)
  16352. */
  16353. vRotationCenter: number;
  16354. /**
  16355. * Defines the center of rotation (W)
  16356. */
  16357. wRotationCenter: number;
  16358. /**
  16359. * Are mip maps generated for this texture or not.
  16360. */
  16361. readonly noMipmap: boolean;
  16362. /**
  16363. * List of inspectable custom properties (used by the Inspector)
  16364. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16365. */
  16366. inspectableCustomProperties: Nullable<IInspectable[]>;
  16367. private _noMipmap;
  16368. /** @hidden */
  16369. _invertY: boolean;
  16370. private _rowGenerationMatrix;
  16371. private _cachedTextureMatrix;
  16372. private _projectionModeMatrix;
  16373. private _t0;
  16374. private _t1;
  16375. private _t2;
  16376. private _cachedUOffset;
  16377. private _cachedVOffset;
  16378. private _cachedUScale;
  16379. private _cachedVScale;
  16380. private _cachedUAng;
  16381. private _cachedVAng;
  16382. private _cachedWAng;
  16383. private _cachedProjectionMatrixId;
  16384. private _cachedCoordinatesMode;
  16385. /** @hidden */
  16386. protected _initialSamplingMode: number;
  16387. /** @hidden */
  16388. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  16389. private _deleteBuffer;
  16390. protected _format: Nullable<number>;
  16391. private _delayedOnLoad;
  16392. private _delayedOnError;
  16393. private _mimeType?;
  16394. /**
  16395. * Observable triggered once the texture has been loaded.
  16396. */
  16397. onLoadObservable: Observable<Texture>;
  16398. protected _isBlocking: boolean;
  16399. /**
  16400. * Is the texture preventing material to render while loading.
  16401. * If false, a default texture will be used instead of the loading one during the preparation step.
  16402. */
  16403. isBlocking: boolean;
  16404. /**
  16405. * Get the current sampling mode associated with the texture.
  16406. */
  16407. readonly samplingMode: number;
  16408. /**
  16409. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16410. */
  16411. readonly invertY: boolean;
  16412. /**
  16413. * Instantiates a new texture.
  16414. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16415. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16416. * @param url defines the url of the picture to load as a texture
  16417. * @param scene defines the scene or engine the texture will belong to
  16418. * @param noMipmap defines if the texture will require mip maps or not
  16419. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  16420. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16421. * @param onLoad defines a callback triggered when the texture has been loaded
  16422. * @param onError defines a callback triggered when an error occurred during the loading session
  16423. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  16424. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  16425. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16426. * @param mimeType defines an optional mime type information
  16427. */
  16428. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string);
  16429. /**
  16430. * Update the url (and optional buffer) of this texture if url was null during construction.
  16431. * @param url the url of the texture
  16432. * @param buffer the buffer of the texture (defaults to null)
  16433. * @param onLoad callback called when the texture is loaded (defaults to null)
  16434. */
  16435. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16436. /**
  16437. * Finish the loading sequence of a texture flagged as delayed load.
  16438. * @hidden
  16439. */
  16440. delayLoad(): void;
  16441. private _prepareRowForTextureGeneration;
  16442. /**
  16443. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16444. * @returns the transform matrix of the texture.
  16445. */
  16446. getTextureMatrix(uBase?: number): Matrix;
  16447. /**
  16448. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16449. * @returns The reflection texture transform
  16450. */
  16451. getReflectionTextureMatrix(): Matrix;
  16452. /**
  16453. * Clones the texture.
  16454. * @returns the cloned texture
  16455. */
  16456. clone(): Texture;
  16457. /**
  16458. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16459. * @returns The JSON representation of the texture
  16460. */
  16461. serialize(): any;
  16462. /**
  16463. * Get the current class name of the texture useful for serialization or dynamic coding.
  16464. * @returns "Texture"
  16465. */
  16466. getClassName(): string;
  16467. /**
  16468. * Dispose the texture and release its associated resources.
  16469. */
  16470. dispose(): void;
  16471. /**
  16472. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16473. * @param parsedTexture Define the JSON representation of the texture
  16474. * @param scene Define the scene the parsed texture should be instantiated in
  16475. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16476. * @returns The parsed texture if successful
  16477. */
  16478. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16479. /**
  16480. * Creates a texture from its base 64 representation.
  16481. * @param data Define the base64 payload without the data: prefix
  16482. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16483. * @param scene Define the scene the texture should belong to
  16484. * @param noMipmap Forces the texture to not create mip map information if true
  16485. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16486. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16487. * @param onLoad define a callback triggered when the texture has been loaded
  16488. * @param onError define a callback triggered when an error occurred during the loading session
  16489. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16490. * @returns the created texture
  16491. */
  16492. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16493. /**
  16494. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16495. * @param data Define the base64 payload without the data: prefix
  16496. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16497. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16498. * @param scene Define the scene the texture should belong to
  16499. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16500. * @param noMipmap Forces the texture to not create mip map information if true
  16501. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16502. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16503. * @param onLoad define a callback triggered when the texture has been loaded
  16504. * @param onError define a callback triggered when an error occurred during the loading session
  16505. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16506. * @returns the created texture
  16507. */
  16508. 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;
  16509. }
  16510. }
  16511. declare module "babylonjs/PostProcesses/postProcessManager" {
  16512. import { Nullable } from "babylonjs/types";
  16513. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16514. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16515. import { Scene } from "babylonjs/scene";
  16516. /**
  16517. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16518. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16519. */
  16520. export class PostProcessManager {
  16521. private _scene;
  16522. private _indexBuffer;
  16523. private _vertexBuffers;
  16524. /**
  16525. * Creates a new instance PostProcess
  16526. * @param scene The scene that the post process is associated with.
  16527. */
  16528. constructor(scene: Scene);
  16529. private _prepareBuffers;
  16530. private _buildIndexBuffer;
  16531. /**
  16532. * Rebuilds the vertex buffers of the manager.
  16533. * @hidden
  16534. */
  16535. _rebuild(): void;
  16536. /**
  16537. * Prepares a frame to be run through a post process.
  16538. * @param sourceTexture The input texture to the post procesess. (default: null)
  16539. * @param postProcesses An array of post processes to be run. (default: null)
  16540. * @returns True if the post processes were able to be run.
  16541. * @hidden
  16542. */
  16543. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16544. /**
  16545. * Manually render a set of post processes to a texture.
  16546. * @param postProcesses An array of post processes to be run.
  16547. * @param targetTexture The target texture to render to.
  16548. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16549. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16550. * @param lodLevel defines which lod of the texture to render to
  16551. */
  16552. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16553. /**
  16554. * Finalize the result of the output of the postprocesses.
  16555. * @param doNotPresent If true the result will not be displayed to the screen.
  16556. * @param targetTexture The target texture to render to.
  16557. * @param faceIndex The index of the face to bind the target texture to.
  16558. * @param postProcesses The array of post processes to render.
  16559. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16560. * @hidden
  16561. */
  16562. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16563. /**
  16564. * Disposes of the post process manager.
  16565. */
  16566. dispose(): void;
  16567. }
  16568. }
  16569. declare module "babylonjs/Misc/gradients" {
  16570. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16571. /** Interface used by value gradients (color, factor, ...) */
  16572. export interface IValueGradient {
  16573. /**
  16574. * Gets or sets the gradient value (between 0 and 1)
  16575. */
  16576. gradient: number;
  16577. }
  16578. /** Class used to store color4 gradient */
  16579. export class ColorGradient implements IValueGradient {
  16580. /**
  16581. * Gets or sets the gradient value (between 0 and 1)
  16582. */
  16583. gradient: number;
  16584. /**
  16585. * Gets or sets first associated color
  16586. */
  16587. color1: Color4;
  16588. /**
  16589. * Gets or sets second associated color
  16590. */
  16591. color2?: Color4;
  16592. /**
  16593. * Will get a color picked randomly between color1 and color2.
  16594. * If color2 is undefined then color1 will be used
  16595. * @param result defines the target Color4 to store the result in
  16596. */
  16597. getColorToRef(result: Color4): void;
  16598. }
  16599. /** Class used to store color 3 gradient */
  16600. export class Color3Gradient implements IValueGradient {
  16601. /**
  16602. * Gets or sets the gradient value (between 0 and 1)
  16603. */
  16604. gradient: number;
  16605. /**
  16606. * Gets or sets the associated color
  16607. */
  16608. color: Color3;
  16609. }
  16610. /** Class used to store factor gradient */
  16611. export class FactorGradient implements IValueGradient {
  16612. /**
  16613. * Gets or sets the gradient value (between 0 and 1)
  16614. */
  16615. gradient: number;
  16616. /**
  16617. * Gets or sets first associated factor
  16618. */
  16619. factor1: number;
  16620. /**
  16621. * Gets or sets second associated factor
  16622. */
  16623. factor2?: number;
  16624. /**
  16625. * Will get a number picked randomly between factor1 and factor2.
  16626. * If factor2 is undefined then factor1 will be used
  16627. * @returns the picked number
  16628. */
  16629. getFactor(): number;
  16630. }
  16631. /**
  16632. * Helper used to simplify some generic gradient tasks
  16633. */
  16634. export class GradientHelper {
  16635. /**
  16636. * Gets the current gradient from an array of IValueGradient
  16637. * @param ratio defines the current ratio to get
  16638. * @param gradients defines the array of IValueGradient
  16639. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16640. */
  16641. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16642. }
  16643. }
  16644. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  16645. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16646. import { Nullable } from "babylonjs/types";
  16647. module "babylonjs/Engines/thinEngine" {
  16648. interface ThinEngine {
  16649. /**
  16650. * Creates a dynamic texture
  16651. * @param width defines the width of the texture
  16652. * @param height defines the height of the texture
  16653. * @param generateMipMaps defines if the engine should generate the mip levels
  16654. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16655. * @returns the dynamic texture inside an InternalTexture
  16656. */
  16657. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16658. /**
  16659. * Update the content of a dynamic texture
  16660. * @param texture defines the texture to update
  16661. * @param canvas defines the canvas containing the source
  16662. * @param invertY defines if data must be stored with Y axis inverted
  16663. * @param premulAlpha defines if alpha is stored as premultiplied
  16664. * @param format defines the format of the data
  16665. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16666. */
  16667. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16668. }
  16669. }
  16670. }
  16671. declare module "babylonjs/Misc/canvasGenerator" {
  16672. /**
  16673. * Helper class used to generate a canvas to manipulate images
  16674. */
  16675. export class CanvasGenerator {
  16676. /**
  16677. * Create a new canvas (or offscreen canvas depending on the context)
  16678. * @param width defines the expected width
  16679. * @param height defines the expected height
  16680. * @return a new canvas or offscreen canvas
  16681. */
  16682. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  16683. }
  16684. }
  16685. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  16686. import { Scene } from "babylonjs/scene";
  16687. import { Texture } from "babylonjs/Materials/Textures/texture";
  16688. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  16689. /**
  16690. * A class extending Texture allowing drawing on a texture
  16691. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16692. */
  16693. export class DynamicTexture extends Texture {
  16694. private _generateMipMaps;
  16695. private _canvas;
  16696. private _context;
  16697. private _engine;
  16698. /**
  16699. * Creates a DynamicTexture
  16700. * @param name defines the name of the texture
  16701. * @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
  16702. * @param scene defines the scene where you want the texture
  16703. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16704. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16705. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16706. */
  16707. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16708. /**
  16709. * Get the current class name of the texture useful for serialization or dynamic coding.
  16710. * @returns "DynamicTexture"
  16711. */
  16712. getClassName(): string;
  16713. /**
  16714. * Gets the current state of canRescale
  16715. */
  16716. readonly canRescale: boolean;
  16717. private _recreate;
  16718. /**
  16719. * Scales the texture
  16720. * @param ratio the scale factor to apply to both width and height
  16721. */
  16722. scale(ratio: number): void;
  16723. /**
  16724. * Resizes the texture
  16725. * @param width the new width
  16726. * @param height the new height
  16727. */
  16728. scaleTo(width: number, height: number): void;
  16729. /**
  16730. * Gets the context of the canvas used by the texture
  16731. * @returns the canvas context of the dynamic texture
  16732. */
  16733. getContext(): CanvasRenderingContext2D;
  16734. /**
  16735. * Clears the texture
  16736. */
  16737. clear(): void;
  16738. /**
  16739. * Updates the texture
  16740. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16741. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16742. */
  16743. update(invertY?: boolean, premulAlpha?: boolean): void;
  16744. /**
  16745. * Draws text onto the texture
  16746. * @param text defines the text to be drawn
  16747. * @param x defines the placement of the text from the left
  16748. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16749. * @param font defines the font to be used with font-style, font-size, font-name
  16750. * @param color defines the color used for the text
  16751. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16752. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16753. * @param update defines whether texture is immediately update (default is true)
  16754. */
  16755. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16756. /**
  16757. * Clones the texture
  16758. * @returns the clone of the texture.
  16759. */
  16760. clone(): DynamicTexture;
  16761. /**
  16762. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16763. * @returns a serialized dynamic texture object
  16764. */
  16765. serialize(): any;
  16766. /** @hidden */
  16767. _rebuild(): void;
  16768. }
  16769. }
  16770. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16771. import { Scene } from "babylonjs/scene";
  16772. import { ISceneComponent } from "babylonjs/sceneComponent";
  16773. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16774. module "babylonjs/abstractScene" {
  16775. interface AbstractScene {
  16776. /**
  16777. * The list of procedural textures added to the scene
  16778. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16779. */
  16780. proceduralTextures: Array<ProceduralTexture>;
  16781. }
  16782. }
  16783. /**
  16784. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16785. * in a given scene.
  16786. */
  16787. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16788. /**
  16789. * The component name helpfull to identify the component in the list of scene components.
  16790. */
  16791. readonly name: string;
  16792. /**
  16793. * The scene the component belongs to.
  16794. */
  16795. scene: Scene;
  16796. /**
  16797. * Creates a new instance of the component for the given scene
  16798. * @param scene Defines the scene to register the component in
  16799. */
  16800. constructor(scene: Scene);
  16801. /**
  16802. * Registers the component in a given scene
  16803. */
  16804. register(): void;
  16805. /**
  16806. * Rebuilds the elements related to this component in case of
  16807. * context lost for instance.
  16808. */
  16809. rebuild(): void;
  16810. /**
  16811. * Disposes the component and the associated ressources.
  16812. */
  16813. dispose(): void;
  16814. private _beforeClear;
  16815. }
  16816. }
  16817. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  16818. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16819. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16820. module "babylonjs/Engines/thinEngine" {
  16821. interface ThinEngine {
  16822. /**
  16823. * Creates a new render target cube texture
  16824. * @param size defines the size of the texture
  16825. * @param options defines the options used to create the texture
  16826. * @returns a new render target cube texture stored in an InternalTexture
  16827. */
  16828. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16829. }
  16830. }
  16831. }
  16832. declare module "babylonjs/Shaders/procedural.vertex" {
  16833. /** @hidden */
  16834. export var proceduralVertexShader: {
  16835. name: string;
  16836. shader: string;
  16837. };
  16838. }
  16839. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16840. import { Observable } from "babylonjs/Misc/observable";
  16841. import { Nullable } from "babylonjs/types";
  16842. import { Scene } from "babylonjs/scene";
  16843. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16844. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16845. import { Effect } from "babylonjs/Materials/effect";
  16846. import { Texture } from "babylonjs/Materials/Textures/texture";
  16847. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16848. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  16849. import "babylonjs/Shaders/procedural.vertex";
  16850. /**
  16851. * 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.
  16852. * This is the base class of any Procedural texture and contains most of the shareable code.
  16853. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16854. */
  16855. export class ProceduralTexture extends Texture {
  16856. isCube: boolean;
  16857. /**
  16858. * Define if the texture is enabled or not (disabled texture will not render)
  16859. */
  16860. isEnabled: boolean;
  16861. /**
  16862. * Define if the texture must be cleared before rendering (default is true)
  16863. */
  16864. autoClear: boolean;
  16865. /**
  16866. * Callback called when the texture is generated
  16867. */
  16868. onGenerated: () => void;
  16869. /**
  16870. * Event raised when the texture is generated
  16871. */
  16872. onGeneratedObservable: Observable<ProceduralTexture>;
  16873. /** @hidden */
  16874. _generateMipMaps: boolean;
  16875. /** @hidden **/
  16876. _effect: Effect;
  16877. /** @hidden */
  16878. _textures: {
  16879. [key: string]: Texture;
  16880. };
  16881. private _size;
  16882. private _currentRefreshId;
  16883. private _refreshRate;
  16884. private _vertexBuffers;
  16885. private _indexBuffer;
  16886. private _uniforms;
  16887. private _samplers;
  16888. private _fragment;
  16889. private _floats;
  16890. private _ints;
  16891. private _floatsArrays;
  16892. private _colors3;
  16893. private _colors4;
  16894. private _vectors2;
  16895. private _vectors3;
  16896. private _matrices;
  16897. private _fallbackTexture;
  16898. private _fallbackTextureUsed;
  16899. private _engine;
  16900. private _cachedDefines;
  16901. private _contentUpdateId;
  16902. private _contentData;
  16903. /**
  16904. * Instantiates a new procedural texture.
  16905. * 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.
  16906. * This is the base class of any Procedural texture and contains most of the shareable code.
  16907. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16908. * @param name Define the name of the texture
  16909. * @param size Define the size of the texture to create
  16910. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16911. * @param scene Define the scene the texture belongs to
  16912. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16913. * @param generateMipMaps Define if the texture should creates mip maps or not
  16914. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16915. */
  16916. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16917. /**
  16918. * The effect that is created when initializing the post process.
  16919. * @returns The created effect corresponding the the postprocess.
  16920. */
  16921. getEffect(): Effect;
  16922. /**
  16923. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16924. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16925. */
  16926. getContent(): Nullable<ArrayBufferView>;
  16927. private _createIndexBuffer;
  16928. /** @hidden */
  16929. _rebuild(): void;
  16930. /**
  16931. * Resets the texture in order to recreate its associated resources.
  16932. * This can be called in case of context loss
  16933. */
  16934. reset(): void;
  16935. protected _getDefines(): string;
  16936. /**
  16937. * Is the texture ready to be used ? (rendered at least once)
  16938. * @returns true if ready, otherwise, false.
  16939. */
  16940. isReady(): boolean;
  16941. /**
  16942. * Resets the refresh counter of the texture and start bak from scratch.
  16943. * Could be useful to regenerate the texture if it is setup to render only once.
  16944. */
  16945. resetRefreshCounter(): void;
  16946. /**
  16947. * Set the fragment shader to use in order to render the texture.
  16948. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16949. */
  16950. setFragment(fragment: any): void;
  16951. /**
  16952. * Define the refresh rate of the texture or the rendering frequency.
  16953. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16954. */
  16955. refreshRate: number;
  16956. /** @hidden */
  16957. _shouldRender(): boolean;
  16958. /**
  16959. * Get the size the texture is rendering at.
  16960. * @returns the size (texture is always squared)
  16961. */
  16962. getRenderSize(): number;
  16963. /**
  16964. * Resize the texture to new value.
  16965. * @param size Define the new size the texture should have
  16966. * @param generateMipMaps Define whether the new texture should create mip maps
  16967. */
  16968. resize(size: number, generateMipMaps: boolean): void;
  16969. private _checkUniform;
  16970. /**
  16971. * Set a texture in the shader program used to render.
  16972. * @param name Define the name of the uniform samplers as defined in the shader
  16973. * @param texture Define the texture to bind to this sampler
  16974. * @return the texture itself allowing "fluent" like uniform updates
  16975. */
  16976. setTexture(name: string, texture: Texture): ProceduralTexture;
  16977. /**
  16978. * Set a float in the shader.
  16979. * @param name Define the name of the uniform as defined in the shader
  16980. * @param value Define the value to give to the uniform
  16981. * @return the texture itself allowing "fluent" like uniform updates
  16982. */
  16983. setFloat(name: string, value: number): ProceduralTexture;
  16984. /**
  16985. * Set a int in the shader.
  16986. * @param name Define the name of the uniform as defined in the shader
  16987. * @param value Define the value to give to the uniform
  16988. * @return the texture itself allowing "fluent" like uniform updates
  16989. */
  16990. setInt(name: string, value: number): ProceduralTexture;
  16991. /**
  16992. * Set an array of floats in the shader.
  16993. * @param name Define the name of the uniform as defined in the shader
  16994. * @param value Define the value to give to the uniform
  16995. * @return the texture itself allowing "fluent" like uniform updates
  16996. */
  16997. setFloats(name: string, value: number[]): ProceduralTexture;
  16998. /**
  16999. * Set a vec3 in the shader from a Color3.
  17000. * @param name Define the name of the uniform as defined in the shader
  17001. * @param value Define the value to give to the uniform
  17002. * @return the texture itself allowing "fluent" like uniform updates
  17003. */
  17004. setColor3(name: string, value: Color3): ProceduralTexture;
  17005. /**
  17006. * Set a vec4 in the shader from a Color4.
  17007. * @param name Define the name of the uniform as defined in the shader
  17008. * @param value Define the value to give to the uniform
  17009. * @return the texture itself allowing "fluent" like uniform updates
  17010. */
  17011. setColor4(name: string, value: Color4): ProceduralTexture;
  17012. /**
  17013. * Set a vec2 in the shader from a Vector2.
  17014. * @param name Define the name of the uniform as defined in the shader
  17015. * @param value Define the value to give to the uniform
  17016. * @return the texture itself allowing "fluent" like uniform updates
  17017. */
  17018. setVector2(name: string, value: Vector2): ProceduralTexture;
  17019. /**
  17020. * Set a vec3 in the shader from a Vector3.
  17021. * @param name Define the name of the uniform as defined in the shader
  17022. * @param value Define the value to give to the uniform
  17023. * @return the texture itself allowing "fluent" like uniform updates
  17024. */
  17025. setVector3(name: string, value: Vector3): ProceduralTexture;
  17026. /**
  17027. * Set a mat4 in the shader from a MAtrix.
  17028. * @param name Define the name of the uniform as defined in the shader
  17029. * @param value Define the value to give to the uniform
  17030. * @return the texture itself allowing "fluent" like uniform updates
  17031. */
  17032. setMatrix(name: string, value: Matrix): ProceduralTexture;
  17033. /**
  17034. * Render the texture to its associated render target.
  17035. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  17036. */
  17037. render(useCameraPostProcess?: boolean): void;
  17038. /**
  17039. * Clone the texture.
  17040. * @returns the cloned texture
  17041. */
  17042. clone(): ProceduralTexture;
  17043. /**
  17044. * Dispose the texture and release its asoociated resources.
  17045. */
  17046. dispose(): void;
  17047. }
  17048. }
  17049. declare module "babylonjs/Particles/baseParticleSystem" {
  17050. import { Nullable } from "babylonjs/types";
  17051. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  17052. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17053. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  17054. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  17055. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  17056. import { Scene } from "babylonjs/scene";
  17057. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  17058. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  17059. import { Texture } from "babylonjs/Materials/Textures/texture";
  17060. import { Color4 } from "babylonjs/Maths/math.color";
  17061. import { Animation } from "babylonjs/Animations/animation";
  17062. /**
  17063. * This represents the base class for particle system in Babylon.
  17064. * 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.
  17065. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17066. * @example https://doc.babylonjs.com/babylon101/particles
  17067. */
  17068. export class BaseParticleSystem {
  17069. /**
  17070. * Source color is added to the destination color without alpha affecting the result
  17071. */
  17072. static BLENDMODE_ONEONE: number;
  17073. /**
  17074. * Blend current color and particle color using particle’s alpha
  17075. */
  17076. static BLENDMODE_STANDARD: number;
  17077. /**
  17078. * Add current color and particle color multiplied by particle’s alpha
  17079. */
  17080. static BLENDMODE_ADD: number;
  17081. /**
  17082. * Multiply current color with particle color
  17083. */
  17084. static BLENDMODE_MULTIPLY: number;
  17085. /**
  17086. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  17087. */
  17088. static BLENDMODE_MULTIPLYADD: number;
  17089. /**
  17090. * List of animations used by the particle system.
  17091. */
  17092. animations: Animation[];
  17093. /**
  17094. * The id of the Particle system.
  17095. */
  17096. id: string;
  17097. /**
  17098. * The friendly name of the Particle system.
  17099. */
  17100. name: string;
  17101. /**
  17102. * The rendering group used by the Particle system to chose when to render.
  17103. */
  17104. renderingGroupId: number;
  17105. /**
  17106. * The emitter represents the Mesh or position we are attaching the particle system to.
  17107. */
  17108. emitter: Nullable<AbstractMesh | Vector3>;
  17109. /**
  17110. * The maximum number of particles to emit per frame
  17111. */
  17112. emitRate: number;
  17113. /**
  17114. * If you want to launch only a few particles at once, that can be done, as well.
  17115. */
  17116. manualEmitCount: number;
  17117. /**
  17118. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17119. */
  17120. updateSpeed: number;
  17121. /**
  17122. * The amount of time the particle system is running (depends of the overall update speed).
  17123. */
  17124. targetStopDuration: number;
  17125. /**
  17126. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  17127. */
  17128. disposeOnStop: boolean;
  17129. /**
  17130. * Minimum power of emitting particles.
  17131. */
  17132. minEmitPower: number;
  17133. /**
  17134. * Maximum power of emitting particles.
  17135. */
  17136. maxEmitPower: number;
  17137. /**
  17138. * Minimum life time of emitting particles.
  17139. */
  17140. minLifeTime: number;
  17141. /**
  17142. * Maximum life time of emitting particles.
  17143. */
  17144. maxLifeTime: number;
  17145. /**
  17146. * Minimum Size of emitting particles.
  17147. */
  17148. minSize: number;
  17149. /**
  17150. * Maximum Size of emitting particles.
  17151. */
  17152. maxSize: number;
  17153. /**
  17154. * Minimum scale of emitting particles on X axis.
  17155. */
  17156. minScaleX: number;
  17157. /**
  17158. * Maximum scale of emitting particles on X axis.
  17159. */
  17160. maxScaleX: number;
  17161. /**
  17162. * Minimum scale of emitting particles on Y axis.
  17163. */
  17164. minScaleY: number;
  17165. /**
  17166. * Maximum scale of emitting particles on Y axis.
  17167. */
  17168. maxScaleY: number;
  17169. /**
  17170. * Gets or sets the minimal initial rotation in radians.
  17171. */
  17172. minInitialRotation: number;
  17173. /**
  17174. * Gets or sets the maximal initial rotation in radians.
  17175. */
  17176. maxInitialRotation: number;
  17177. /**
  17178. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17179. */
  17180. minAngularSpeed: number;
  17181. /**
  17182. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17183. */
  17184. maxAngularSpeed: number;
  17185. /**
  17186. * The texture used to render each particle. (this can be a spritesheet)
  17187. */
  17188. particleTexture: Nullable<Texture>;
  17189. /**
  17190. * The layer mask we are rendering the particles through.
  17191. */
  17192. layerMask: number;
  17193. /**
  17194. * This can help using your own shader to render the particle system.
  17195. * The according effect will be created
  17196. */
  17197. customShader: any;
  17198. /**
  17199. * By default particle system starts as soon as they are created. This prevents the
  17200. * automatic start to happen and let you decide when to start emitting particles.
  17201. */
  17202. preventAutoStart: boolean;
  17203. private _noiseTexture;
  17204. /**
  17205. * Gets or sets a texture used to add random noise to particle positions
  17206. */
  17207. noiseTexture: Nullable<ProceduralTexture>;
  17208. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17209. noiseStrength: Vector3;
  17210. /**
  17211. * Callback triggered when the particle animation is ending.
  17212. */
  17213. onAnimationEnd: Nullable<() => void>;
  17214. /**
  17215. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  17216. */
  17217. blendMode: number;
  17218. /**
  17219. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  17220. * to override the particles.
  17221. */
  17222. forceDepthWrite: boolean;
  17223. /** 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 */
  17224. preWarmCycles: number;
  17225. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  17226. preWarmStepOffset: number;
  17227. /**
  17228. * 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)
  17229. */
  17230. spriteCellChangeSpeed: number;
  17231. /**
  17232. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17233. */
  17234. startSpriteCellID: number;
  17235. /**
  17236. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17237. */
  17238. endSpriteCellID: number;
  17239. /**
  17240. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17241. */
  17242. spriteCellWidth: number;
  17243. /**
  17244. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17245. */
  17246. spriteCellHeight: number;
  17247. /**
  17248. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17249. */
  17250. spriteRandomStartCell: boolean;
  17251. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17252. translationPivot: Vector2;
  17253. /** @hidden */
  17254. protected _isAnimationSheetEnabled: boolean;
  17255. /**
  17256. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17257. */
  17258. beginAnimationOnStart: boolean;
  17259. /**
  17260. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17261. */
  17262. beginAnimationFrom: number;
  17263. /**
  17264. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17265. */
  17266. beginAnimationTo: number;
  17267. /**
  17268. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17269. */
  17270. beginAnimationLoop: boolean;
  17271. /**
  17272. * Gets or sets a world offset applied to all particles
  17273. */
  17274. worldOffset: Vector3;
  17275. /**
  17276. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  17277. */
  17278. isAnimationSheetEnabled: boolean;
  17279. /**
  17280. * Get hosting scene
  17281. * @returns the scene
  17282. */
  17283. getScene(): Scene;
  17284. /**
  17285. * You can use gravity if you want to give an orientation to your particles.
  17286. */
  17287. gravity: Vector3;
  17288. protected _colorGradients: Nullable<Array<ColorGradient>>;
  17289. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  17290. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  17291. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  17292. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  17293. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  17294. protected _dragGradients: Nullable<Array<FactorGradient>>;
  17295. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  17296. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  17297. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  17298. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  17299. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  17300. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  17301. /**
  17302. * Defines the delay in milliseconds before starting the system (0 by default)
  17303. */
  17304. startDelay: number;
  17305. /**
  17306. * Gets the current list of drag gradients.
  17307. * You must use addDragGradient and removeDragGradient to udpate this list
  17308. * @returns the list of drag gradients
  17309. */
  17310. getDragGradients(): Nullable<Array<FactorGradient>>;
  17311. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17312. limitVelocityDamping: number;
  17313. /**
  17314. * Gets the current list of limit velocity gradients.
  17315. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17316. * @returns the list of limit velocity gradients
  17317. */
  17318. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17319. /**
  17320. * Gets the current list of color gradients.
  17321. * You must use addColorGradient and removeColorGradient to udpate this list
  17322. * @returns the list of color gradients
  17323. */
  17324. getColorGradients(): Nullable<Array<ColorGradient>>;
  17325. /**
  17326. * Gets the current list of size gradients.
  17327. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17328. * @returns the list of size gradients
  17329. */
  17330. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17331. /**
  17332. * Gets the current list of color remap gradients.
  17333. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17334. * @returns the list of color remap gradients
  17335. */
  17336. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17337. /**
  17338. * Gets the current list of alpha remap gradients.
  17339. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17340. * @returns the list of alpha remap gradients
  17341. */
  17342. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17343. /**
  17344. * Gets the current list of life time gradients.
  17345. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17346. * @returns the list of life time gradients
  17347. */
  17348. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17349. /**
  17350. * Gets the current list of angular speed gradients.
  17351. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17352. * @returns the list of angular speed gradients
  17353. */
  17354. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17355. /**
  17356. * Gets the current list of velocity gradients.
  17357. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17358. * @returns the list of velocity gradients
  17359. */
  17360. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17361. /**
  17362. * Gets the current list of start size gradients.
  17363. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17364. * @returns the list of start size gradients
  17365. */
  17366. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17367. /**
  17368. * Gets the current list of emit rate gradients.
  17369. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17370. * @returns the list of emit rate gradients
  17371. */
  17372. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17373. /**
  17374. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17375. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17376. */
  17377. direction1: Vector3;
  17378. /**
  17379. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17380. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17381. */
  17382. direction2: Vector3;
  17383. /**
  17384. * 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.
  17385. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17386. */
  17387. minEmitBox: Vector3;
  17388. /**
  17389. * 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.
  17390. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17391. */
  17392. maxEmitBox: Vector3;
  17393. /**
  17394. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17395. */
  17396. color1: Color4;
  17397. /**
  17398. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17399. */
  17400. color2: Color4;
  17401. /**
  17402. * Color the particle will have at the end of its lifetime
  17403. */
  17404. colorDead: Color4;
  17405. /**
  17406. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17407. */
  17408. textureMask: Color4;
  17409. /**
  17410. * The particle emitter type defines the emitter used by the particle system.
  17411. * It can be for example box, sphere, or cone...
  17412. */
  17413. particleEmitterType: IParticleEmitterType;
  17414. /** @hidden */
  17415. _isSubEmitter: boolean;
  17416. /**
  17417. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17418. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17419. */
  17420. billboardMode: number;
  17421. protected _isBillboardBased: boolean;
  17422. /**
  17423. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17424. */
  17425. isBillboardBased: boolean;
  17426. /**
  17427. * The scene the particle system belongs to.
  17428. */
  17429. protected _scene: Scene;
  17430. /**
  17431. * Local cache of defines for image processing.
  17432. */
  17433. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17434. /**
  17435. * Default configuration related to image processing available in the standard Material.
  17436. */
  17437. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17438. /**
  17439. * Gets the image processing configuration used either in this material.
  17440. */
  17441. /**
  17442. * Sets the Default image processing configuration used either in the this material.
  17443. *
  17444. * If sets to null, the scene one is in use.
  17445. */
  17446. imageProcessingConfiguration: ImageProcessingConfiguration;
  17447. /**
  17448. * Attaches a new image processing configuration to the Standard Material.
  17449. * @param configuration
  17450. */
  17451. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17452. /** @hidden */
  17453. protected _reset(): void;
  17454. /** @hidden */
  17455. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17456. /**
  17457. * Instantiates a particle system.
  17458. * 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.
  17459. * @param name The name of the particle system
  17460. */
  17461. constructor(name: string);
  17462. /**
  17463. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17464. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17465. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17466. * @returns the emitter
  17467. */
  17468. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17469. /**
  17470. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17471. * @param radius The radius of the hemisphere to emit from
  17472. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17473. * @returns the emitter
  17474. */
  17475. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17476. /**
  17477. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17478. * @param radius The radius of the sphere to emit from
  17479. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17480. * @returns the emitter
  17481. */
  17482. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17483. /**
  17484. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17485. * @param radius The radius of the sphere to emit from
  17486. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17487. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17488. * @returns the emitter
  17489. */
  17490. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17491. /**
  17492. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17493. * @param radius The radius of the emission cylinder
  17494. * @param height The height of the emission cylinder
  17495. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17496. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17497. * @returns the emitter
  17498. */
  17499. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17500. /**
  17501. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17502. * @param radius The radius of the cylinder to emit from
  17503. * @param height The height of the emission cylinder
  17504. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17505. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17506. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17507. * @returns the emitter
  17508. */
  17509. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17510. /**
  17511. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17512. * @param radius The radius of the cone to emit from
  17513. * @param angle The base angle of the cone
  17514. * @returns the emitter
  17515. */
  17516. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17517. /**
  17518. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17519. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17520. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17521. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17522. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17523. * @returns the emitter
  17524. */
  17525. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17526. }
  17527. }
  17528. declare module "babylonjs/Particles/subEmitter" {
  17529. import { Scene } from "babylonjs/scene";
  17530. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17531. /**
  17532. * Type of sub emitter
  17533. */
  17534. export enum SubEmitterType {
  17535. /**
  17536. * Attached to the particle over it's lifetime
  17537. */
  17538. ATTACHED = 0,
  17539. /**
  17540. * Created when the particle dies
  17541. */
  17542. END = 1
  17543. }
  17544. /**
  17545. * Sub emitter class used to emit particles from an existing particle
  17546. */
  17547. export class SubEmitter {
  17548. /**
  17549. * the particle system to be used by the sub emitter
  17550. */
  17551. particleSystem: ParticleSystem;
  17552. /**
  17553. * Type of the submitter (Default: END)
  17554. */
  17555. type: SubEmitterType;
  17556. /**
  17557. * 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)
  17558. * Note: This only is supported when using an emitter of type Mesh
  17559. */
  17560. inheritDirection: boolean;
  17561. /**
  17562. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17563. */
  17564. inheritedVelocityAmount: number;
  17565. /**
  17566. * Creates a sub emitter
  17567. * @param particleSystem the particle system to be used by the sub emitter
  17568. */
  17569. constructor(
  17570. /**
  17571. * the particle system to be used by the sub emitter
  17572. */
  17573. particleSystem: ParticleSystem);
  17574. /**
  17575. * Clones the sub emitter
  17576. * @returns the cloned sub emitter
  17577. */
  17578. clone(): SubEmitter;
  17579. /**
  17580. * Serialize current object to a JSON object
  17581. * @returns the serialized object
  17582. */
  17583. serialize(): any;
  17584. /** @hidden */
  17585. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17586. /**
  17587. * Creates a new SubEmitter from a serialized JSON version
  17588. * @param serializationObject defines the JSON object to read from
  17589. * @param scene defines the hosting scene
  17590. * @param rootUrl defines the rootUrl for data loading
  17591. * @returns a new SubEmitter
  17592. */
  17593. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17594. /** Release associated resources */
  17595. dispose(): void;
  17596. }
  17597. }
  17598. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17599. /** @hidden */
  17600. export var clipPlaneFragmentDeclaration: {
  17601. name: string;
  17602. shader: string;
  17603. };
  17604. }
  17605. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17606. /** @hidden */
  17607. export var imageProcessingDeclaration: {
  17608. name: string;
  17609. shader: string;
  17610. };
  17611. }
  17612. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17613. /** @hidden */
  17614. export var imageProcessingFunctions: {
  17615. name: string;
  17616. shader: string;
  17617. };
  17618. }
  17619. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17620. /** @hidden */
  17621. export var clipPlaneFragment: {
  17622. name: string;
  17623. shader: string;
  17624. };
  17625. }
  17626. declare module "babylonjs/Shaders/particles.fragment" {
  17627. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17628. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17629. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17630. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17631. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17632. /** @hidden */
  17633. export var particlesPixelShader: {
  17634. name: string;
  17635. shader: string;
  17636. };
  17637. }
  17638. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17639. /** @hidden */
  17640. export var clipPlaneVertexDeclaration: {
  17641. name: string;
  17642. shader: string;
  17643. };
  17644. }
  17645. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17646. /** @hidden */
  17647. export var clipPlaneVertex: {
  17648. name: string;
  17649. shader: string;
  17650. };
  17651. }
  17652. declare module "babylonjs/Shaders/particles.vertex" {
  17653. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17654. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17655. /** @hidden */
  17656. export var particlesVertexShader: {
  17657. name: string;
  17658. shader: string;
  17659. };
  17660. }
  17661. declare module "babylonjs/Particles/particleSystem" {
  17662. import { Nullable } from "babylonjs/types";
  17663. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17664. import { Observable } from "babylonjs/Misc/observable";
  17665. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17666. import { Effect } from "babylonjs/Materials/effect";
  17667. import { Scene, IDisposable } from "babylonjs/scene";
  17668. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17669. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17670. import { Particle } from "babylonjs/Particles/particle";
  17671. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17672. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17673. import "babylonjs/Shaders/particles.fragment";
  17674. import "babylonjs/Shaders/particles.vertex";
  17675. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17676. /**
  17677. * This represents a particle system in Babylon.
  17678. * 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.
  17679. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17680. * @example https://doc.babylonjs.com/babylon101/particles
  17681. */
  17682. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17683. /**
  17684. * Billboard mode will only apply to Y axis
  17685. */
  17686. static readonly BILLBOARDMODE_Y: number;
  17687. /**
  17688. * Billboard mode will apply to all axes
  17689. */
  17690. static readonly BILLBOARDMODE_ALL: number;
  17691. /**
  17692. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17693. */
  17694. static readonly BILLBOARDMODE_STRETCHED: number;
  17695. /**
  17696. * This function can be defined to provide custom update for active particles.
  17697. * This function will be called instead of regular update (age, position, color, etc.).
  17698. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17699. */
  17700. updateFunction: (particles: Particle[]) => void;
  17701. private _emitterWorldMatrix;
  17702. /**
  17703. * This function can be defined to specify initial direction for every new particle.
  17704. * It by default use the emitterType defined function
  17705. */
  17706. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17707. /**
  17708. * This function can be defined to specify initial position for every new particle.
  17709. * It by default use the emitterType defined function
  17710. */
  17711. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17712. /**
  17713. * @hidden
  17714. */
  17715. _inheritedVelocityOffset: Vector3;
  17716. /**
  17717. * An event triggered when the system is disposed
  17718. */
  17719. onDisposeObservable: Observable<ParticleSystem>;
  17720. private _onDisposeObserver;
  17721. /**
  17722. * Sets a callback that will be triggered when the system is disposed
  17723. */
  17724. onDispose: () => void;
  17725. private _particles;
  17726. private _epsilon;
  17727. private _capacity;
  17728. private _stockParticles;
  17729. private _newPartsExcess;
  17730. private _vertexData;
  17731. private _vertexBuffer;
  17732. private _vertexBuffers;
  17733. private _spriteBuffer;
  17734. private _indexBuffer;
  17735. private _effect;
  17736. private _customEffect;
  17737. private _cachedDefines;
  17738. private _scaledColorStep;
  17739. private _colorDiff;
  17740. private _scaledDirection;
  17741. private _scaledGravity;
  17742. private _currentRenderId;
  17743. private _alive;
  17744. private _useInstancing;
  17745. private _started;
  17746. private _stopped;
  17747. private _actualFrame;
  17748. private _scaledUpdateSpeed;
  17749. private _vertexBufferSize;
  17750. /** @hidden */
  17751. _currentEmitRateGradient: Nullable<FactorGradient>;
  17752. /** @hidden */
  17753. _currentEmitRate1: number;
  17754. /** @hidden */
  17755. _currentEmitRate2: number;
  17756. /** @hidden */
  17757. _currentStartSizeGradient: Nullable<FactorGradient>;
  17758. /** @hidden */
  17759. _currentStartSize1: number;
  17760. /** @hidden */
  17761. _currentStartSize2: number;
  17762. private readonly _rawTextureWidth;
  17763. private _rampGradientsTexture;
  17764. private _useRampGradients;
  17765. /** Gets or sets a boolean indicating that ramp gradients must be used
  17766. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17767. */
  17768. useRampGradients: boolean;
  17769. /**
  17770. * 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.
  17771. * 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: [])
  17772. */
  17773. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17774. private _subEmitters;
  17775. /**
  17776. * @hidden
  17777. * If the particle systems emitter should be disposed when the particle system is disposed
  17778. */
  17779. _disposeEmitterOnDispose: boolean;
  17780. /**
  17781. * The current active Sub-systems, this property is used by the root particle system only.
  17782. */
  17783. activeSubSystems: Array<ParticleSystem>;
  17784. private _rootParticleSystem;
  17785. /**
  17786. * Gets the current list of active particles
  17787. */
  17788. readonly particles: Particle[];
  17789. /**
  17790. * Returns the string "ParticleSystem"
  17791. * @returns a string containing the class name
  17792. */
  17793. getClassName(): string;
  17794. /**
  17795. * Instantiates a particle system.
  17796. * 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.
  17797. * @param name The name of the particle system
  17798. * @param capacity The max number of particles alive at the same time
  17799. * @param scene The scene the particle system belongs to
  17800. * @param customEffect a custom effect used to change the way particles are rendered by default
  17801. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17802. * @param epsilon Offset used to render the particles
  17803. */
  17804. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17805. private _addFactorGradient;
  17806. private _removeFactorGradient;
  17807. /**
  17808. * Adds a new life time gradient
  17809. * @param gradient defines the gradient to use (between 0 and 1)
  17810. * @param factor defines the life time factor to affect to the specified gradient
  17811. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17812. * @returns the current particle system
  17813. */
  17814. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17815. /**
  17816. * Remove a specific life time gradient
  17817. * @param gradient defines the gradient to remove
  17818. * @returns the current particle system
  17819. */
  17820. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17821. /**
  17822. * Adds a new size gradient
  17823. * @param gradient defines the gradient to use (between 0 and 1)
  17824. * @param factor defines the size factor to affect to the specified gradient
  17825. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17826. * @returns the current particle system
  17827. */
  17828. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17829. /**
  17830. * Remove a specific size gradient
  17831. * @param gradient defines the gradient to remove
  17832. * @returns the current particle system
  17833. */
  17834. removeSizeGradient(gradient: number): IParticleSystem;
  17835. /**
  17836. * Adds a new color remap gradient
  17837. * @param gradient defines the gradient to use (between 0 and 1)
  17838. * @param min defines the color remap minimal range
  17839. * @param max defines the color remap maximal range
  17840. * @returns the current particle system
  17841. */
  17842. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17843. /**
  17844. * Remove a specific color remap gradient
  17845. * @param gradient defines the gradient to remove
  17846. * @returns the current particle system
  17847. */
  17848. removeColorRemapGradient(gradient: number): IParticleSystem;
  17849. /**
  17850. * Adds a new alpha remap gradient
  17851. * @param gradient defines the gradient to use (between 0 and 1)
  17852. * @param min defines the alpha remap minimal range
  17853. * @param max defines the alpha remap maximal range
  17854. * @returns the current particle system
  17855. */
  17856. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17857. /**
  17858. * Remove a specific alpha remap gradient
  17859. * @param gradient defines the gradient to remove
  17860. * @returns the current particle system
  17861. */
  17862. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17863. /**
  17864. * Adds a new angular speed gradient
  17865. * @param gradient defines the gradient to use (between 0 and 1)
  17866. * @param factor defines the angular speed to affect to the specified gradient
  17867. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17868. * @returns the current particle system
  17869. */
  17870. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17871. /**
  17872. * Remove a specific angular speed gradient
  17873. * @param gradient defines the gradient to remove
  17874. * @returns the current particle system
  17875. */
  17876. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17877. /**
  17878. * Adds a new velocity gradient
  17879. * @param gradient defines the gradient to use (between 0 and 1)
  17880. * @param factor defines the velocity to affect to the specified gradient
  17881. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17882. * @returns the current particle system
  17883. */
  17884. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17885. /**
  17886. * Remove a specific velocity gradient
  17887. * @param gradient defines the gradient to remove
  17888. * @returns the current particle system
  17889. */
  17890. removeVelocityGradient(gradient: number): IParticleSystem;
  17891. /**
  17892. * Adds a new limit velocity gradient
  17893. * @param gradient defines the gradient to use (between 0 and 1)
  17894. * @param factor defines the limit velocity value to affect to the specified gradient
  17895. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17896. * @returns the current particle system
  17897. */
  17898. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17899. /**
  17900. * Remove a specific limit velocity gradient
  17901. * @param gradient defines the gradient to remove
  17902. * @returns the current particle system
  17903. */
  17904. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17905. /**
  17906. * Adds a new drag gradient
  17907. * @param gradient defines the gradient to use (between 0 and 1)
  17908. * @param factor defines the drag value to affect to the specified gradient
  17909. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17910. * @returns the current particle system
  17911. */
  17912. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17913. /**
  17914. * Remove a specific drag gradient
  17915. * @param gradient defines the gradient to remove
  17916. * @returns the current particle system
  17917. */
  17918. removeDragGradient(gradient: number): IParticleSystem;
  17919. /**
  17920. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17921. * @param gradient defines the gradient to use (between 0 and 1)
  17922. * @param factor defines the emit rate value to affect to the specified gradient
  17923. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17924. * @returns the current particle system
  17925. */
  17926. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17927. /**
  17928. * Remove a specific emit rate gradient
  17929. * @param gradient defines the gradient to remove
  17930. * @returns the current particle system
  17931. */
  17932. removeEmitRateGradient(gradient: number): IParticleSystem;
  17933. /**
  17934. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17935. * @param gradient defines the gradient to use (between 0 and 1)
  17936. * @param factor defines the start size value to affect to the specified gradient
  17937. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17938. * @returns the current particle system
  17939. */
  17940. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17941. /**
  17942. * Remove a specific start size gradient
  17943. * @param gradient defines the gradient to remove
  17944. * @returns the current particle system
  17945. */
  17946. removeStartSizeGradient(gradient: number): IParticleSystem;
  17947. private _createRampGradientTexture;
  17948. /**
  17949. * Gets the current list of ramp gradients.
  17950. * You must use addRampGradient and removeRampGradient to udpate this list
  17951. * @returns the list of ramp gradients
  17952. */
  17953. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17954. /**
  17955. * Adds a new ramp gradient used to remap particle colors
  17956. * @param gradient defines the gradient to use (between 0 and 1)
  17957. * @param color defines the color to affect to the specified gradient
  17958. * @returns the current particle system
  17959. */
  17960. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17961. /**
  17962. * Remove a specific ramp gradient
  17963. * @param gradient defines the gradient to remove
  17964. * @returns the current particle system
  17965. */
  17966. removeRampGradient(gradient: number): ParticleSystem;
  17967. /**
  17968. * Adds a new color gradient
  17969. * @param gradient defines the gradient to use (between 0 and 1)
  17970. * @param color1 defines the color to affect to the specified gradient
  17971. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17972. * @returns this particle system
  17973. */
  17974. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17975. /**
  17976. * Remove a specific color gradient
  17977. * @param gradient defines the gradient to remove
  17978. * @returns this particle system
  17979. */
  17980. removeColorGradient(gradient: number): IParticleSystem;
  17981. private _fetchR;
  17982. protected _reset(): void;
  17983. private _resetEffect;
  17984. private _createVertexBuffers;
  17985. private _createIndexBuffer;
  17986. /**
  17987. * Gets the maximum number of particles active at the same time.
  17988. * @returns The max number of active particles.
  17989. */
  17990. getCapacity(): number;
  17991. /**
  17992. * Gets whether there are still active particles in the system.
  17993. * @returns True if it is alive, otherwise false.
  17994. */
  17995. isAlive(): boolean;
  17996. /**
  17997. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17998. * @returns True if it has been started, otherwise false.
  17999. */
  18000. isStarted(): boolean;
  18001. private _prepareSubEmitterInternalArray;
  18002. /**
  18003. * Starts the particle system and begins to emit
  18004. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  18005. */
  18006. start(delay?: number): void;
  18007. /**
  18008. * Stops the particle system.
  18009. * @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.
  18010. */
  18011. stop(stopSubEmitters?: boolean): void;
  18012. /**
  18013. * Remove all active particles
  18014. */
  18015. reset(): void;
  18016. /**
  18017. * @hidden (for internal use only)
  18018. */
  18019. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  18020. /**
  18021. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  18022. * Its lifetime will start back at 0.
  18023. */
  18024. recycleParticle: (particle: Particle) => void;
  18025. private _stopSubEmitters;
  18026. private _createParticle;
  18027. private _removeFromRoot;
  18028. private _emitFromParticle;
  18029. private _update;
  18030. /** @hidden */
  18031. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  18032. /** @hidden */
  18033. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  18034. /** @hidden */
  18035. private _getEffect;
  18036. /**
  18037. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  18038. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  18039. */
  18040. animate(preWarmOnly?: boolean): void;
  18041. private _appendParticleVertices;
  18042. /**
  18043. * Rebuilds the particle system.
  18044. */
  18045. rebuild(): void;
  18046. /**
  18047. * Is this system ready to be used/rendered
  18048. * @return true if the system is ready
  18049. */
  18050. isReady(): boolean;
  18051. private _render;
  18052. /**
  18053. * Renders the particle system in its current state.
  18054. * @returns the current number of particles
  18055. */
  18056. render(): number;
  18057. /**
  18058. * Disposes the particle system and free the associated resources
  18059. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18060. */
  18061. dispose(disposeTexture?: boolean): void;
  18062. /**
  18063. * Clones the particle system.
  18064. * @param name The name of the cloned object
  18065. * @param newEmitter The new emitter to use
  18066. * @returns the cloned particle system
  18067. */
  18068. clone(name: string, newEmitter: any): ParticleSystem;
  18069. /**
  18070. * Serializes the particle system to a JSON object.
  18071. * @returns the JSON object
  18072. */
  18073. serialize(): any;
  18074. /** @hidden */
  18075. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  18076. /** @hidden */
  18077. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  18078. /**
  18079. * Parses a JSON object to create a particle system.
  18080. * @param parsedParticleSystem The JSON object to parse
  18081. * @param scene The scene to create the particle system in
  18082. * @param rootUrl The root url to use to load external dependencies like texture
  18083. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  18084. * @returns the Parsed particle system
  18085. */
  18086. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  18087. }
  18088. }
  18089. declare module "babylonjs/Particles/particle" {
  18090. import { Nullable } from "babylonjs/types";
  18091. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  18092. import { Color4 } from "babylonjs/Maths/math.color";
  18093. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  18094. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  18095. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  18096. /**
  18097. * A particle represents one of the element emitted by a particle system.
  18098. * This is mainly define by its coordinates, direction, velocity and age.
  18099. */
  18100. export class Particle {
  18101. /**
  18102. * The particle system the particle belongs to.
  18103. */
  18104. particleSystem: ParticleSystem;
  18105. private static _Count;
  18106. /**
  18107. * Unique ID of the particle
  18108. */
  18109. id: number;
  18110. /**
  18111. * The world position of the particle in the scene.
  18112. */
  18113. position: Vector3;
  18114. /**
  18115. * The world direction of the particle in the scene.
  18116. */
  18117. direction: Vector3;
  18118. /**
  18119. * The color of the particle.
  18120. */
  18121. color: Color4;
  18122. /**
  18123. * The color change of the particle per step.
  18124. */
  18125. colorStep: Color4;
  18126. /**
  18127. * Defines how long will the life of the particle be.
  18128. */
  18129. lifeTime: number;
  18130. /**
  18131. * The current age of the particle.
  18132. */
  18133. age: number;
  18134. /**
  18135. * The current size of the particle.
  18136. */
  18137. size: number;
  18138. /**
  18139. * The current scale of the particle.
  18140. */
  18141. scale: Vector2;
  18142. /**
  18143. * The current angle of the particle.
  18144. */
  18145. angle: number;
  18146. /**
  18147. * Defines how fast is the angle changing.
  18148. */
  18149. angularSpeed: number;
  18150. /**
  18151. * Defines the cell index used by the particle to be rendered from a sprite.
  18152. */
  18153. cellIndex: number;
  18154. /**
  18155. * The information required to support color remapping
  18156. */
  18157. remapData: Vector4;
  18158. /** @hidden */
  18159. _randomCellOffset?: number;
  18160. /** @hidden */
  18161. _initialDirection: Nullable<Vector3>;
  18162. /** @hidden */
  18163. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  18164. /** @hidden */
  18165. _initialStartSpriteCellID: number;
  18166. /** @hidden */
  18167. _initialEndSpriteCellID: number;
  18168. /** @hidden */
  18169. _currentColorGradient: Nullable<ColorGradient>;
  18170. /** @hidden */
  18171. _currentColor1: Color4;
  18172. /** @hidden */
  18173. _currentColor2: Color4;
  18174. /** @hidden */
  18175. _currentSizeGradient: Nullable<FactorGradient>;
  18176. /** @hidden */
  18177. _currentSize1: number;
  18178. /** @hidden */
  18179. _currentSize2: number;
  18180. /** @hidden */
  18181. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  18182. /** @hidden */
  18183. _currentAngularSpeed1: number;
  18184. /** @hidden */
  18185. _currentAngularSpeed2: number;
  18186. /** @hidden */
  18187. _currentVelocityGradient: Nullable<FactorGradient>;
  18188. /** @hidden */
  18189. _currentVelocity1: number;
  18190. /** @hidden */
  18191. _currentVelocity2: number;
  18192. /** @hidden */
  18193. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  18194. /** @hidden */
  18195. _currentLimitVelocity1: number;
  18196. /** @hidden */
  18197. _currentLimitVelocity2: number;
  18198. /** @hidden */
  18199. _currentDragGradient: Nullable<FactorGradient>;
  18200. /** @hidden */
  18201. _currentDrag1: number;
  18202. /** @hidden */
  18203. _currentDrag2: number;
  18204. /** @hidden */
  18205. _randomNoiseCoordinates1: Vector3;
  18206. /** @hidden */
  18207. _randomNoiseCoordinates2: Vector3;
  18208. /**
  18209. * Creates a new instance Particle
  18210. * @param particleSystem the particle system the particle belongs to
  18211. */
  18212. constructor(
  18213. /**
  18214. * The particle system the particle belongs to.
  18215. */
  18216. particleSystem: ParticleSystem);
  18217. private updateCellInfoFromSystem;
  18218. /**
  18219. * Defines how the sprite cell index is updated for the particle
  18220. */
  18221. updateCellIndex(): void;
  18222. /** @hidden */
  18223. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  18224. /** @hidden */
  18225. _inheritParticleInfoToSubEmitters(): void;
  18226. /** @hidden */
  18227. _reset(): void;
  18228. /**
  18229. * Copy the properties of particle to another one.
  18230. * @param other the particle to copy the information to.
  18231. */
  18232. copyTo(other: Particle): void;
  18233. }
  18234. }
  18235. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  18236. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18237. import { Effect } from "babylonjs/Materials/effect";
  18238. import { Particle } from "babylonjs/Particles/particle";
  18239. /**
  18240. * Particle emitter represents a volume emitting particles.
  18241. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  18242. */
  18243. export interface IParticleEmitterType {
  18244. /**
  18245. * Called by the particle System when the direction is computed for the created particle.
  18246. * @param worldMatrix is the world matrix of the particle system
  18247. * @param directionToUpdate is the direction vector to update with the result
  18248. * @param particle is the particle we are computed the direction for
  18249. */
  18250. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18251. /**
  18252. * Called by the particle System when the position is computed for the created particle.
  18253. * @param worldMatrix is the world matrix of the particle system
  18254. * @param positionToUpdate is the position vector to update with the result
  18255. * @param particle is the particle we are computed the position for
  18256. */
  18257. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18258. /**
  18259. * Clones the current emitter and returns a copy of it
  18260. * @returns the new emitter
  18261. */
  18262. clone(): IParticleEmitterType;
  18263. /**
  18264. * Called by the GPUParticleSystem to setup the update shader
  18265. * @param effect defines the update shader
  18266. */
  18267. applyToShader(effect: Effect): void;
  18268. /**
  18269. * Returns a string to use to update the GPU particles update shader
  18270. * @returns the effect defines string
  18271. */
  18272. getEffectDefines(): string;
  18273. /**
  18274. * Returns a string representing the class name
  18275. * @returns a string containing the class name
  18276. */
  18277. getClassName(): string;
  18278. /**
  18279. * Serializes the particle system to a JSON object.
  18280. * @returns the JSON object
  18281. */
  18282. serialize(): any;
  18283. /**
  18284. * Parse properties from a JSON object
  18285. * @param serializationObject defines the JSON object
  18286. */
  18287. parse(serializationObject: any): void;
  18288. }
  18289. }
  18290. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  18291. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18292. import { Effect } from "babylonjs/Materials/effect";
  18293. import { Particle } from "babylonjs/Particles/particle";
  18294. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18295. /**
  18296. * Particle emitter emitting particles from the inside of a box.
  18297. * It emits the particles randomly between 2 given directions.
  18298. */
  18299. export class BoxParticleEmitter implements IParticleEmitterType {
  18300. /**
  18301. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18302. */
  18303. direction1: Vector3;
  18304. /**
  18305. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18306. */
  18307. direction2: Vector3;
  18308. /**
  18309. * 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.
  18310. */
  18311. minEmitBox: Vector3;
  18312. /**
  18313. * 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.
  18314. */
  18315. maxEmitBox: Vector3;
  18316. /**
  18317. * Creates a new instance BoxParticleEmitter
  18318. */
  18319. constructor();
  18320. /**
  18321. * Called by the particle System when the direction is computed for the created particle.
  18322. * @param worldMatrix is the world matrix of the particle system
  18323. * @param directionToUpdate is the direction vector to update with the result
  18324. * @param particle is the particle we are computed the direction for
  18325. */
  18326. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18327. /**
  18328. * Called by the particle System when the position is computed for the created particle.
  18329. * @param worldMatrix is the world matrix of the particle system
  18330. * @param positionToUpdate is the position vector to update with the result
  18331. * @param particle is the particle we are computed the position for
  18332. */
  18333. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18334. /**
  18335. * Clones the current emitter and returns a copy of it
  18336. * @returns the new emitter
  18337. */
  18338. clone(): BoxParticleEmitter;
  18339. /**
  18340. * Called by the GPUParticleSystem to setup the update shader
  18341. * @param effect defines the update shader
  18342. */
  18343. applyToShader(effect: Effect): void;
  18344. /**
  18345. * Returns a string to use to update the GPU particles update shader
  18346. * @returns a string containng the defines string
  18347. */
  18348. getEffectDefines(): string;
  18349. /**
  18350. * Returns the string "BoxParticleEmitter"
  18351. * @returns a string containing the class name
  18352. */
  18353. getClassName(): string;
  18354. /**
  18355. * Serializes the particle system to a JSON object.
  18356. * @returns the JSON object
  18357. */
  18358. serialize(): any;
  18359. /**
  18360. * Parse properties from a JSON object
  18361. * @param serializationObject defines the JSON object
  18362. */
  18363. parse(serializationObject: any): void;
  18364. }
  18365. }
  18366. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  18367. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18368. import { Effect } from "babylonjs/Materials/effect";
  18369. import { Particle } from "babylonjs/Particles/particle";
  18370. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18371. /**
  18372. * Particle emitter emitting particles from the inside of a cone.
  18373. * It emits the particles alongside the cone volume from the base to the particle.
  18374. * The emission direction might be randomized.
  18375. */
  18376. export class ConeParticleEmitter implements IParticleEmitterType {
  18377. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18378. directionRandomizer: number;
  18379. private _radius;
  18380. private _angle;
  18381. private _height;
  18382. /**
  18383. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18384. */
  18385. radiusRange: number;
  18386. /**
  18387. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18388. */
  18389. heightRange: number;
  18390. /**
  18391. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18392. */
  18393. emitFromSpawnPointOnly: boolean;
  18394. /**
  18395. * Gets or sets the radius of the emission cone
  18396. */
  18397. radius: number;
  18398. /**
  18399. * Gets or sets the angle of the emission cone
  18400. */
  18401. angle: number;
  18402. private _buildHeight;
  18403. /**
  18404. * Creates a new instance ConeParticleEmitter
  18405. * @param radius the radius of the emission cone (1 by default)
  18406. * @param angle the cone base angle (PI by default)
  18407. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18408. */
  18409. constructor(radius?: number, angle?: number,
  18410. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18411. directionRandomizer?: number);
  18412. /**
  18413. * Called by the particle System when the direction is computed for the created particle.
  18414. * @param worldMatrix is the world matrix of the particle system
  18415. * @param directionToUpdate is the direction vector to update with the result
  18416. * @param particle is the particle we are computed the direction for
  18417. */
  18418. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18419. /**
  18420. * Called by the particle System when the position is computed for the created particle.
  18421. * @param worldMatrix is the world matrix of the particle system
  18422. * @param positionToUpdate is the position vector to update with the result
  18423. * @param particle is the particle we are computed the position for
  18424. */
  18425. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18426. /**
  18427. * Clones the current emitter and returns a copy of it
  18428. * @returns the new emitter
  18429. */
  18430. clone(): ConeParticleEmitter;
  18431. /**
  18432. * Called by the GPUParticleSystem to setup the update shader
  18433. * @param effect defines the update shader
  18434. */
  18435. applyToShader(effect: Effect): void;
  18436. /**
  18437. * Returns a string to use to update the GPU particles update shader
  18438. * @returns a string containng the defines string
  18439. */
  18440. getEffectDefines(): string;
  18441. /**
  18442. * Returns the string "ConeParticleEmitter"
  18443. * @returns a string containing the class name
  18444. */
  18445. getClassName(): string;
  18446. /**
  18447. * Serializes the particle system to a JSON object.
  18448. * @returns the JSON object
  18449. */
  18450. serialize(): any;
  18451. /**
  18452. * Parse properties from a JSON object
  18453. * @param serializationObject defines the JSON object
  18454. */
  18455. parse(serializationObject: any): void;
  18456. }
  18457. }
  18458. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  18459. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18460. import { Effect } from "babylonjs/Materials/effect";
  18461. import { Particle } from "babylonjs/Particles/particle";
  18462. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18463. /**
  18464. * Particle emitter emitting particles from the inside of a cylinder.
  18465. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18466. */
  18467. export class CylinderParticleEmitter implements IParticleEmitterType {
  18468. /**
  18469. * The radius of the emission cylinder.
  18470. */
  18471. radius: number;
  18472. /**
  18473. * The height of the emission cylinder.
  18474. */
  18475. height: number;
  18476. /**
  18477. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18478. */
  18479. radiusRange: number;
  18480. /**
  18481. * How much to randomize the particle direction [0-1].
  18482. */
  18483. directionRandomizer: number;
  18484. /**
  18485. * Creates a new instance CylinderParticleEmitter
  18486. * @param radius the radius of the emission cylinder (1 by default)
  18487. * @param height the height of the emission cylinder (1 by default)
  18488. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18489. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18490. */
  18491. constructor(
  18492. /**
  18493. * The radius of the emission cylinder.
  18494. */
  18495. radius?: number,
  18496. /**
  18497. * The height of the emission cylinder.
  18498. */
  18499. height?: number,
  18500. /**
  18501. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18502. */
  18503. radiusRange?: number,
  18504. /**
  18505. * How much to randomize the particle direction [0-1].
  18506. */
  18507. directionRandomizer?: number);
  18508. /**
  18509. * Called by the particle System when the direction is computed for the created particle.
  18510. * @param worldMatrix is the world matrix of the particle system
  18511. * @param directionToUpdate is the direction vector to update with the result
  18512. * @param particle is the particle we are computed the direction for
  18513. */
  18514. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18515. /**
  18516. * Called by the particle System when the position is computed for the created particle.
  18517. * @param worldMatrix is the world matrix of the particle system
  18518. * @param positionToUpdate is the position vector to update with the result
  18519. * @param particle is the particle we are computed the position for
  18520. */
  18521. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18522. /**
  18523. * Clones the current emitter and returns a copy of it
  18524. * @returns the new emitter
  18525. */
  18526. clone(): CylinderParticleEmitter;
  18527. /**
  18528. * Called by the GPUParticleSystem to setup the update shader
  18529. * @param effect defines the update shader
  18530. */
  18531. applyToShader(effect: Effect): void;
  18532. /**
  18533. * Returns a string to use to update the GPU particles update shader
  18534. * @returns a string containng the defines string
  18535. */
  18536. getEffectDefines(): string;
  18537. /**
  18538. * Returns the string "CylinderParticleEmitter"
  18539. * @returns a string containing the class name
  18540. */
  18541. getClassName(): string;
  18542. /**
  18543. * Serializes the particle system to a JSON object.
  18544. * @returns the JSON object
  18545. */
  18546. serialize(): any;
  18547. /**
  18548. * Parse properties from a JSON object
  18549. * @param serializationObject defines the JSON object
  18550. */
  18551. parse(serializationObject: any): void;
  18552. }
  18553. /**
  18554. * Particle emitter emitting particles from the inside of a cylinder.
  18555. * It emits the particles randomly between two vectors.
  18556. */
  18557. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18558. /**
  18559. * The min limit of the emission direction.
  18560. */
  18561. direction1: Vector3;
  18562. /**
  18563. * The max limit of the emission direction.
  18564. */
  18565. direction2: Vector3;
  18566. /**
  18567. * Creates a new instance CylinderDirectedParticleEmitter
  18568. * @param radius the radius of the emission cylinder (1 by default)
  18569. * @param height the height of the emission cylinder (1 by default)
  18570. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18571. * @param direction1 the min limit of the emission direction (up vector by default)
  18572. * @param direction2 the max limit of the emission direction (up vector by default)
  18573. */
  18574. constructor(radius?: number, height?: number, radiusRange?: number,
  18575. /**
  18576. * The min limit of the emission direction.
  18577. */
  18578. direction1?: Vector3,
  18579. /**
  18580. * The max limit of the emission direction.
  18581. */
  18582. direction2?: Vector3);
  18583. /**
  18584. * Called by the particle System when the direction is computed for the created particle.
  18585. * @param worldMatrix is the world matrix of the particle system
  18586. * @param directionToUpdate is the direction vector to update with the result
  18587. * @param particle is the particle we are computed the direction for
  18588. */
  18589. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18590. /**
  18591. * Clones the current emitter and returns a copy of it
  18592. * @returns the new emitter
  18593. */
  18594. clone(): CylinderDirectedParticleEmitter;
  18595. /**
  18596. * Called by the GPUParticleSystem to setup the update shader
  18597. * @param effect defines the update shader
  18598. */
  18599. applyToShader(effect: Effect): void;
  18600. /**
  18601. * Returns a string to use to update the GPU particles update shader
  18602. * @returns a string containng the defines string
  18603. */
  18604. getEffectDefines(): string;
  18605. /**
  18606. * Returns the string "CylinderDirectedParticleEmitter"
  18607. * @returns a string containing the class name
  18608. */
  18609. getClassName(): string;
  18610. /**
  18611. * Serializes the particle system to a JSON object.
  18612. * @returns the JSON object
  18613. */
  18614. serialize(): any;
  18615. /**
  18616. * Parse properties from a JSON object
  18617. * @param serializationObject defines the JSON object
  18618. */
  18619. parse(serializationObject: any): void;
  18620. }
  18621. }
  18622. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18623. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18624. import { Effect } from "babylonjs/Materials/effect";
  18625. import { Particle } from "babylonjs/Particles/particle";
  18626. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18627. /**
  18628. * Particle emitter emitting particles from the inside of a hemisphere.
  18629. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18630. */
  18631. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18632. /**
  18633. * The radius of the emission hemisphere.
  18634. */
  18635. radius: number;
  18636. /**
  18637. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18638. */
  18639. radiusRange: number;
  18640. /**
  18641. * How much to randomize the particle direction [0-1].
  18642. */
  18643. directionRandomizer: number;
  18644. /**
  18645. * Creates a new instance HemisphericParticleEmitter
  18646. * @param radius the radius of the emission hemisphere (1 by default)
  18647. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18648. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18649. */
  18650. constructor(
  18651. /**
  18652. * The radius of the emission hemisphere.
  18653. */
  18654. radius?: number,
  18655. /**
  18656. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18657. */
  18658. radiusRange?: number,
  18659. /**
  18660. * How much to randomize the particle direction [0-1].
  18661. */
  18662. directionRandomizer?: number);
  18663. /**
  18664. * Called by the particle System when the direction is computed for the created particle.
  18665. * @param worldMatrix is the world matrix of the particle system
  18666. * @param directionToUpdate is the direction vector to update with the result
  18667. * @param particle is the particle we are computed the direction for
  18668. */
  18669. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18670. /**
  18671. * Called by the particle System when the position is computed for the created particle.
  18672. * @param worldMatrix is the world matrix of the particle system
  18673. * @param positionToUpdate is the position vector to update with the result
  18674. * @param particle is the particle we are computed the position for
  18675. */
  18676. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18677. /**
  18678. * Clones the current emitter and returns a copy of it
  18679. * @returns the new emitter
  18680. */
  18681. clone(): HemisphericParticleEmitter;
  18682. /**
  18683. * Called by the GPUParticleSystem to setup the update shader
  18684. * @param effect defines the update shader
  18685. */
  18686. applyToShader(effect: Effect): void;
  18687. /**
  18688. * Returns a string to use to update the GPU particles update shader
  18689. * @returns a string containng the defines string
  18690. */
  18691. getEffectDefines(): string;
  18692. /**
  18693. * Returns the string "HemisphericParticleEmitter"
  18694. * @returns a string containing the class name
  18695. */
  18696. getClassName(): string;
  18697. /**
  18698. * Serializes the particle system to a JSON object.
  18699. * @returns the JSON object
  18700. */
  18701. serialize(): any;
  18702. /**
  18703. * Parse properties from a JSON object
  18704. * @param serializationObject defines the JSON object
  18705. */
  18706. parse(serializationObject: any): void;
  18707. }
  18708. }
  18709. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18710. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18711. import { Effect } from "babylonjs/Materials/effect";
  18712. import { Particle } from "babylonjs/Particles/particle";
  18713. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18714. /**
  18715. * Particle emitter emitting particles from a point.
  18716. * It emits the particles randomly between 2 given directions.
  18717. */
  18718. export class PointParticleEmitter implements IParticleEmitterType {
  18719. /**
  18720. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18721. */
  18722. direction1: Vector3;
  18723. /**
  18724. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18725. */
  18726. direction2: Vector3;
  18727. /**
  18728. * Creates a new instance PointParticleEmitter
  18729. */
  18730. constructor();
  18731. /**
  18732. * Called by the particle System when the direction is computed for the created particle.
  18733. * @param worldMatrix is the world matrix of the particle system
  18734. * @param directionToUpdate is the direction vector to update with the result
  18735. * @param particle is the particle we are computed the direction for
  18736. */
  18737. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18738. /**
  18739. * Called by the particle System when the position is computed for the created particle.
  18740. * @param worldMatrix is the world matrix of the particle system
  18741. * @param positionToUpdate is the position vector to update with the result
  18742. * @param particle is the particle we are computed the position for
  18743. */
  18744. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18745. /**
  18746. * Clones the current emitter and returns a copy of it
  18747. * @returns the new emitter
  18748. */
  18749. clone(): PointParticleEmitter;
  18750. /**
  18751. * Called by the GPUParticleSystem to setup the update shader
  18752. * @param effect defines the update shader
  18753. */
  18754. applyToShader(effect: Effect): void;
  18755. /**
  18756. * Returns a string to use to update the GPU particles update shader
  18757. * @returns a string containng the defines string
  18758. */
  18759. getEffectDefines(): string;
  18760. /**
  18761. * Returns the string "PointParticleEmitter"
  18762. * @returns a string containing the class name
  18763. */
  18764. getClassName(): string;
  18765. /**
  18766. * Serializes the particle system to a JSON object.
  18767. * @returns the JSON object
  18768. */
  18769. serialize(): any;
  18770. /**
  18771. * Parse properties from a JSON object
  18772. * @param serializationObject defines the JSON object
  18773. */
  18774. parse(serializationObject: any): void;
  18775. }
  18776. }
  18777. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18778. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18779. import { Effect } from "babylonjs/Materials/effect";
  18780. import { Particle } from "babylonjs/Particles/particle";
  18781. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18782. /**
  18783. * Particle emitter emitting particles from the inside of a sphere.
  18784. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18785. */
  18786. export class SphereParticleEmitter implements IParticleEmitterType {
  18787. /**
  18788. * The radius of the emission sphere.
  18789. */
  18790. radius: number;
  18791. /**
  18792. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18793. */
  18794. radiusRange: number;
  18795. /**
  18796. * How much to randomize the particle direction [0-1].
  18797. */
  18798. directionRandomizer: number;
  18799. /**
  18800. * Creates a new instance SphereParticleEmitter
  18801. * @param radius the radius of the emission sphere (1 by default)
  18802. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18803. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18804. */
  18805. constructor(
  18806. /**
  18807. * The radius of the emission sphere.
  18808. */
  18809. radius?: number,
  18810. /**
  18811. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18812. */
  18813. radiusRange?: number,
  18814. /**
  18815. * How much to randomize the particle direction [0-1].
  18816. */
  18817. directionRandomizer?: number);
  18818. /**
  18819. * Called by the particle System when the direction is computed for the created particle.
  18820. * @param worldMatrix is the world matrix of the particle system
  18821. * @param directionToUpdate is the direction vector to update with the result
  18822. * @param particle is the particle we are computed the direction for
  18823. */
  18824. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18825. /**
  18826. * Called by the particle System when the position is computed for the created particle.
  18827. * @param worldMatrix is the world matrix of the particle system
  18828. * @param positionToUpdate is the position vector to update with the result
  18829. * @param particle is the particle we are computed the position for
  18830. */
  18831. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18832. /**
  18833. * Clones the current emitter and returns a copy of it
  18834. * @returns the new emitter
  18835. */
  18836. clone(): SphereParticleEmitter;
  18837. /**
  18838. * Called by the GPUParticleSystem to setup the update shader
  18839. * @param effect defines the update shader
  18840. */
  18841. applyToShader(effect: Effect): void;
  18842. /**
  18843. * Returns a string to use to update the GPU particles update shader
  18844. * @returns a string containng the defines string
  18845. */
  18846. getEffectDefines(): string;
  18847. /**
  18848. * Returns the string "SphereParticleEmitter"
  18849. * @returns a string containing the class name
  18850. */
  18851. getClassName(): string;
  18852. /**
  18853. * Serializes the particle system to a JSON object.
  18854. * @returns the JSON object
  18855. */
  18856. serialize(): any;
  18857. /**
  18858. * Parse properties from a JSON object
  18859. * @param serializationObject defines the JSON object
  18860. */
  18861. parse(serializationObject: any): void;
  18862. }
  18863. /**
  18864. * Particle emitter emitting particles from the inside of a sphere.
  18865. * It emits the particles randomly between two vectors.
  18866. */
  18867. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18868. /**
  18869. * The min limit of the emission direction.
  18870. */
  18871. direction1: Vector3;
  18872. /**
  18873. * The max limit of the emission direction.
  18874. */
  18875. direction2: Vector3;
  18876. /**
  18877. * Creates a new instance SphereDirectedParticleEmitter
  18878. * @param radius the radius of the emission sphere (1 by default)
  18879. * @param direction1 the min limit of the emission direction (up vector by default)
  18880. * @param direction2 the max limit of the emission direction (up vector by default)
  18881. */
  18882. constructor(radius?: number,
  18883. /**
  18884. * The min limit of the emission direction.
  18885. */
  18886. direction1?: Vector3,
  18887. /**
  18888. * The max limit of the emission direction.
  18889. */
  18890. direction2?: Vector3);
  18891. /**
  18892. * Called by the particle System when the direction is computed for the created particle.
  18893. * @param worldMatrix is the world matrix of the particle system
  18894. * @param directionToUpdate is the direction vector to update with the result
  18895. * @param particle is the particle we are computed the direction for
  18896. */
  18897. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18898. /**
  18899. * Clones the current emitter and returns a copy of it
  18900. * @returns the new emitter
  18901. */
  18902. clone(): SphereDirectedParticleEmitter;
  18903. /**
  18904. * Called by the GPUParticleSystem to setup the update shader
  18905. * @param effect defines the update shader
  18906. */
  18907. applyToShader(effect: Effect): void;
  18908. /**
  18909. * Returns a string to use to update the GPU particles update shader
  18910. * @returns a string containng the defines string
  18911. */
  18912. getEffectDefines(): string;
  18913. /**
  18914. * Returns the string "SphereDirectedParticleEmitter"
  18915. * @returns a string containing the class name
  18916. */
  18917. getClassName(): string;
  18918. /**
  18919. * Serializes the particle system to a JSON object.
  18920. * @returns the JSON object
  18921. */
  18922. serialize(): any;
  18923. /**
  18924. * Parse properties from a JSON object
  18925. * @param serializationObject defines the JSON object
  18926. */
  18927. parse(serializationObject: any): void;
  18928. }
  18929. }
  18930. declare module "babylonjs/Particles/EmitterTypes/index" {
  18931. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  18932. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  18933. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  18934. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  18935. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18936. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  18937. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  18938. }
  18939. declare module "babylonjs/Particles/IParticleSystem" {
  18940. import { Nullable } from "babylonjs/types";
  18941. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  18942. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  18943. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18944. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18945. import { Texture } from "babylonjs/Materials/Textures/texture";
  18946. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  18947. import { Scene } from "babylonjs/scene";
  18948. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  18949. import { Animation } from "babylonjs/Animations/animation";
  18950. /**
  18951. * Interface representing a particle system in Babylon.js.
  18952. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18953. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18954. */
  18955. export interface IParticleSystem {
  18956. /**
  18957. * List of animations used by the particle system.
  18958. */
  18959. animations: Animation[];
  18960. /**
  18961. * The id of the Particle system.
  18962. */
  18963. id: string;
  18964. /**
  18965. * The name of the Particle system.
  18966. */
  18967. name: string;
  18968. /**
  18969. * The emitter represents the Mesh or position we are attaching the particle system to.
  18970. */
  18971. emitter: Nullable<AbstractMesh | Vector3>;
  18972. /**
  18973. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18974. */
  18975. isBillboardBased: boolean;
  18976. /**
  18977. * The rendering group used by the Particle system to chose when to render.
  18978. */
  18979. renderingGroupId: number;
  18980. /**
  18981. * The layer mask we are rendering the particles through.
  18982. */
  18983. layerMask: number;
  18984. /**
  18985. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18986. */
  18987. updateSpeed: number;
  18988. /**
  18989. * The amount of time the particle system is running (depends of the overall update speed).
  18990. */
  18991. targetStopDuration: number;
  18992. /**
  18993. * The texture used to render each particle. (this can be a spritesheet)
  18994. */
  18995. particleTexture: Nullable<Texture>;
  18996. /**
  18997. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18998. */
  18999. blendMode: number;
  19000. /**
  19001. * Minimum life time of emitting particles.
  19002. */
  19003. minLifeTime: number;
  19004. /**
  19005. * Maximum life time of emitting particles.
  19006. */
  19007. maxLifeTime: number;
  19008. /**
  19009. * Minimum Size of emitting particles.
  19010. */
  19011. minSize: number;
  19012. /**
  19013. * Maximum Size of emitting particles.
  19014. */
  19015. maxSize: number;
  19016. /**
  19017. * Minimum scale of emitting particles on X axis.
  19018. */
  19019. minScaleX: number;
  19020. /**
  19021. * Maximum scale of emitting particles on X axis.
  19022. */
  19023. maxScaleX: number;
  19024. /**
  19025. * Minimum scale of emitting particles on Y axis.
  19026. */
  19027. minScaleY: number;
  19028. /**
  19029. * Maximum scale of emitting particles on Y axis.
  19030. */
  19031. maxScaleY: number;
  19032. /**
  19033. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  19034. */
  19035. color1: Color4;
  19036. /**
  19037. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  19038. */
  19039. color2: Color4;
  19040. /**
  19041. * Color the particle will have at the end of its lifetime.
  19042. */
  19043. colorDead: Color4;
  19044. /**
  19045. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  19046. */
  19047. emitRate: number;
  19048. /**
  19049. * You can use gravity if you want to give an orientation to your particles.
  19050. */
  19051. gravity: Vector3;
  19052. /**
  19053. * Minimum power of emitting particles.
  19054. */
  19055. minEmitPower: number;
  19056. /**
  19057. * Maximum power of emitting particles.
  19058. */
  19059. maxEmitPower: number;
  19060. /**
  19061. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  19062. */
  19063. minAngularSpeed: number;
  19064. /**
  19065. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  19066. */
  19067. maxAngularSpeed: number;
  19068. /**
  19069. * Gets or sets the minimal initial rotation in radians.
  19070. */
  19071. minInitialRotation: number;
  19072. /**
  19073. * Gets or sets the maximal initial rotation in radians.
  19074. */
  19075. maxInitialRotation: number;
  19076. /**
  19077. * The particle emitter type defines the emitter used by the particle system.
  19078. * It can be for example box, sphere, or cone...
  19079. */
  19080. particleEmitterType: Nullable<IParticleEmitterType>;
  19081. /**
  19082. * Defines the delay in milliseconds before starting the system (0 by default)
  19083. */
  19084. startDelay: number;
  19085. /**
  19086. * 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
  19087. */
  19088. preWarmCycles: number;
  19089. /**
  19090. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  19091. */
  19092. preWarmStepOffset: number;
  19093. /**
  19094. * 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)
  19095. */
  19096. spriteCellChangeSpeed: number;
  19097. /**
  19098. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  19099. */
  19100. startSpriteCellID: number;
  19101. /**
  19102. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  19103. */
  19104. endSpriteCellID: number;
  19105. /**
  19106. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  19107. */
  19108. spriteCellWidth: number;
  19109. /**
  19110. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  19111. */
  19112. spriteCellHeight: number;
  19113. /**
  19114. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  19115. */
  19116. spriteRandomStartCell: boolean;
  19117. /**
  19118. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  19119. */
  19120. isAnimationSheetEnabled: boolean;
  19121. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  19122. translationPivot: Vector2;
  19123. /**
  19124. * Gets or sets a texture used to add random noise to particle positions
  19125. */
  19126. noiseTexture: Nullable<BaseTexture>;
  19127. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  19128. noiseStrength: Vector3;
  19129. /**
  19130. * Gets or sets the billboard mode to use when isBillboardBased = true.
  19131. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  19132. */
  19133. billboardMode: number;
  19134. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  19135. limitVelocityDamping: number;
  19136. /**
  19137. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  19138. */
  19139. beginAnimationOnStart: boolean;
  19140. /**
  19141. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  19142. */
  19143. beginAnimationFrom: number;
  19144. /**
  19145. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  19146. */
  19147. beginAnimationTo: number;
  19148. /**
  19149. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  19150. */
  19151. beginAnimationLoop: boolean;
  19152. /**
  19153. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  19154. */
  19155. disposeOnStop: boolean;
  19156. /**
  19157. * Gets the maximum number of particles active at the same time.
  19158. * @returns The max number of active particles.
  19159. */
  19160. getCapacity(): number;
  19161. /**
  19162. * Gets if the system has been started. (Note: this will still be true after stop is called)
  19163. * @returns True if it has been started, otherwise false.
  19164. */
  19165. isStarted(): boolean;
  19166. /**
  19167. * Animates the particle system for this frame.
  19168. */
  19169. animate(): void;
  19170. /**
  19171. * Renders the particle system in its current state.
  19172. * @returns the current number of particles
  19173. */
  19174. render(): number;
  19175. /**
  19176. * Dispose the particle system and frees its associated resources.
  19177. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  19178. */
  19179. dispose(disposeTexture?: boolean): void;
  19180. /**
  19181. * Clones the particle system.
  19182. * @param name The name of the cloned object
  19183. * @param newEmitter The new emitter to use
  19184. * @returns the cloned particle system
  19185. */
  19186. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  19187. /**
  19188. * Serializes the particle system to a JSON object.
  19189. * @returns the JSON object
  19190. */
  19191. serialize(): any;
  19192. /**
  19193. * Rebuild the particle system
  19194. */
  19195. rebuild(): void;
  19196. /**
  19197. * Starts the particle system and begins to emit
  19198. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  19199. */
  19200. start(delay?: number): void;
  19201. /**
  19202. * Stops the particle system.
  19203. */
  19204. stop(): void;
  19205. /**
  19206. * Remove all active particles
  19207. */
  19208. reset(): void;
  19209. /**
  19210. * Is this system ready to be used/rendered
  19211. * @return true if the system is ready
  19212. */
  19213. isReady(): boolean;
  19214. /**
  19215. * Adds a new color gradient
  19216. * @param gradient defines the gradient to use (between 0 and 1)
  19217. * @param color1 defines the color to affect to the specified gradient
  19218. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  19219. * @returns the current particle system
  19220. */
  19221. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  19222. /**
  19223. * Remove a specific color gradient
  19224. * @param gradient defines the gradient to remove
  19225. * @returns the current particle system
  19226. */
  19227. removeColorGradient(gradient: number): IParticleSystem;
  19228. /**
  19229. * Adds a new size gradient
  19230. * @param gradient defines the gradient to use (between 0 and 1)
  19231. * @param factor defines the size factor to affect to the specified gradient
  19232. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19233. * @returns the current particle system
  19234. */
  19235. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19236. /**
  19237. * Remove a specific size gradient
  19238. * @param gradient defines the gradient to remove
  19239. * @returns the current particle system
  19240. */
  19241. removeSizeGradient(gradient: number): IParticleSystem;
  19242. /**
  19243. * Gets the current list of color gradients.
  19244. * You must use addColorGradient and removeColorGradient to udpate this list
  19245. * @returns the list of color gradients
  19246. */
  19247. getColorGradients(): Nullable<Array<ColorGradient>>;
  19248. /**
  19249. * Gets the current list of size gradients.
  19250. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19251. * @returns the list of size gradients
  19252. */
  19253. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19254. /**
  19255. * Gets the current list of angular speed gradients.
  19256. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19257. * @returns the list of angular speed gradients
  19258. */
  19259. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19260. /**
  19261. * Adds a new angular speed gradient
  19262. * @param gradient defines the gradient to use (between 0 and 1)
  19263. * @param factor defines the angular speed to affect to the specified gradient
  19264. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19265. * @returns the current particle system
  19266. */
  19267. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19268. /**
  19269. * Remove a specific angular speed gradient
  19270. * @param gradient defines the gradient to remove
  19271. * @returns the current particle system
  19272. */
  19273. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  19274. /**
  19275. * Gets the current list of velocity gradients.
  19276. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19277. * @returns the list of velocity gradients
  19278. */
  19279. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19280. /**
  19281. * Adds a new velocity gradient
  19282. * @param gradient defines the gradient to use (between 0 and 1)
  19283. * @param factor defines the velocity to affect to the specified gradient
  19284. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19285. * @returns the current particle system
  19286. */
  19287. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19288. /**
  19289. * Remove a specific velocity gradient
  19290. * @param gradient defines the gradient to remove
  19291. * @returns the current particle system
  19292. */
  19293. removeVelocityGradient(gradient: number): IParticleSystem;
  19294. /**
  19295. * Gets the current list of limit velocity gradients.
  19296. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19297. * @returns the list of limit velocity gradients
  19298. */
  19299. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19300. /**
  19301. * Adds a new limit velocity gradient
  19302. * @param gradient defines the gradient to use (between 0 and 1)
  19303. * @param factor defines the limit velocity to affect to the specified gradient
  19304. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19305. * @returns the current particle system
  19306. */
  19307. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19308. /**
  19309. * Remove a specific limit velocity gradient
  19310. * @param gradient defines the gradient to remove
  19311. * @returns the current particle system
  19312. */
  19313. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  19314. /**
  19315. * Adds a new drag gradient
  19316. * @param gradient defines the gradient to use (between 0 and 1)
  19317. * @param factor defines the drag to affect to the specified gradient
  19318. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19319. * @returns the current particle system
  19320. */
  19321. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19322. /**
  19323. * Remove a specific drag gradient
  19324. * @param gradient defines the gradient to remove
  19325. * @returns the current particle system
  19326. */
  19327. removeDragGradient(gradient: number): IParticleSystem;
  19328. /**
  19329. * Gets the current list of drag gradients.
  19330. * You must use addDragGradient and removeDragGradient to udpate this list
  19331. * @returns the list of drag gradients
  19332. */
  19333. getDragGradients(): Nullable<Array<FactorGradient>>;
  19334. /**
  19335. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  19336. * @param gradient defines the gradient to use (between 0 and 1)
  19337. * @param factor defines the emit rate to affect to the specified gradient
  19338. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19339. * @returns the current particle system
  19340. */
  19341. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19342. /**
  19343. * Remove a specific emit rate gradient
  19344. * @param gradient defines the gradient to remove
  19345. * @returns the current particle system
  19346. */
  19347. removeEmitRateGradient(gradient: number): IParticleSystem;
  19348. /**
  19349. * Gets the current list of emit rate gradients.
  19350. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19351. * @returns the list of emit rate gradients
  19352. */
  19353. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19354. /**
  19355. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19356. * @param gradient defines the gradient to use (between 0 and 1)
  19357. * @param factor defines the start size to affect to the specified gradient
  19358. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19359. * @returns the current particle system
  19360. */
  19361. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19362. /**
  19363. * Remove a specific start size gradient
  19364. * @param gradient defines the gradient to remove
  19365. * @returns the current particle system
  19366. */
  19367. removeStartSizeGradient(gradient: number): IParticleSystem;
  19368. /**
  19369. * Gets the current list of start size gradients.
  19370. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19371. * @returns the list of start size gradients
  19372. */
  19373. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19374. /**
  19375. * Adds a new life time gradient
  19376. * @param gradient defines the gradient to use (between 0 and 1)
  19377. * @param factor defines the life time factor to affect to the specified gradient
  19378. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19379. * @returns the current particle system
  19380. */
  19381. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19382. /**
  19383. * Remove a specific life time gradient
  19384. * @param gradient defines the gradient to remove
  19385. * @returns the current particle system
  19386. */
  19387. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19388. /**
  19389. * Gets the current list of life time gradients.
  19390. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19391. * @returns the list of life time gradients
  19392. */
  19393. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19394. /**
  19395. * Gets the current list of color gradients.
  19396. * You must use addColorGradient and removeColorGradient to udpate this list
  19397. * @returns the list of color gradients
  19398. */
  19399. getColorGradients(): Nullable<Array<ColorGradient>>;
  19400. /**
  19401. * Adds a new ramp gradient used to remap particle colors
  19402. * @param gradient defines the gradient to use (between 0 and 1)
  19403. * @param color defines the color to affect to the specified gradient
  19404. * @returns the current particle system
  19405. */
  19406. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19407. /**
  19408. * Gets the current list of ramp gradients.
  19409. * You must use addRampGradient and removeRampGradient to udpate this list
  19410. * @returns the list of ramp gradients
  19411. */
  19412. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19413. /** Gets or sets a boolean indicating that ramp gradients must be used
  19414. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19415. */
  19416. useRampGradients: boolean;
  19417. /**
  19418. * Adds a new color remap gradient
  19419. * @param gradient defines the gradient to use (between 0 and 1)
  19420. * @param min defines the color remap minimal range
  19421. * @param max defines the color remap maximal range
  19422. * @returns the current particle system
  19423. */
  19424. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19425. /**
  19426. * Gets the current list of color remap gradients.
  19427. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19428. * @returns the list of color remap gradients
  19429. */
  19430. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19431. /**
  19432. * Adds a new alpha remap gradient
  19433. * @param gradient defines the gradient to use (between 0 and 1)
  19434. * @param min defines the alpha remap minimal range
  19435. * @param max defines the alpha remap maximal range
  19436. * @returns the current particle system
  19437. */
  19438. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19439. /**
  19440. * Gets the current list of alpha remap gradients.
  19441. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19442. * @returns the list of alpha remap gradients
  19443. */
  19444. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19445. /**
  19446. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19447. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19448. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19449. * @returns the emitter
  19450. */
  19451. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19452. /**
  19453. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19454. * @param radius The radius of the hemisphere to emit from
  19455. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19456. * @returns the emitter
  19457. */
  19458. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19459. /**
  19460. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19461. * @param radius The radius of the sphere to emit from
  19462. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19463. * @returns the emitter
  19464. */
  19465. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19466. /**
  19467. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19468. * @param radius The radius of the sphere to emit from
  19469. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19470. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19471. * @returns the emitter
  19472. */
  19473. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19474. /**
  19475. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19476. * @param radius The radius of the emission cylinder
  19477. * @param height The height of the emission cylinder
  19478. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19479. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19480. * @returns the emitter
  19481. */
  19482. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19483. /**
  19484. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19485. * @param radius The radius of the cylinder to emit from
  19486. * @param height The height of the emission cylinder
  19487. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19488. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19489. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19490. * @returns the emitter
  19491. */
  19492. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19493. /**
  19494. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19495. * @param radius The radius of the cone to emit from
  19496. * @param angle The base angle of the cone
  19497. * @returns the emitter
  19498. */
  19499. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19500. /**
  19501. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19502. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19503. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19504. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19505. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19506. * @returns the emitter
  19507. */
  19508. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19509. /**
  19510. * Get hosting scene
  19511. * @returns the scene
  19512. */
  19513. getScene(): Scene;
  19514. }
  19515. }
  19516. declare module "babylonjs/Meshes/instancedMesh" {
  19517. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19518. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19519. import { Camera } from "babylonjs/Cameras/camera";
  19520. import { Node } from "babylonjs/node";
  19521. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19522. import { Mesh } from "babylonjs/Meshes/mesh";
  19523. import { Material } from "babylonjs/Materials/material";
  19524. import { Skeleton } from "babylonjs/Bones/skeleton";
  19525. import { Light } from "babylonjs/Lights/light";
  19526. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19527. /**
  19528. * Creates an instance based on a source mesh.
  19529. */
  19530. export class InstancedMesh extends AbstractMesh {
  19531. private _sourceMesh;
  19532. private _currentLOD;
  19533. /** @hidden */
  19534. _indexInSourceMeshInstanceArray: number;
  19535. constructor(name: string, source: Mesh);
  19536. /**
  19537. * Returns the string "InstancedMesh".
  19538. */
  19539. getClassName(): string;
  19540. /** Gets the list of lights affecting that mesh */
  19541. readonly lightSources: Light[];
  19542. _resyncLightSources(): void;
  19543. _resyncLightSource(light: Light): void;
  19544. _removeLightSource(light: Light, dispose: boolean): void;
  19545. /**
  19546. * If the source mesh receives shadows
  19547. */
  19548. readonly receiveShadows: boolean;
  19549. /**
  19550. * The material of the source mesh
  19551. */
  19552. readonly material: Nullable<Material>;
  19553. /**
  19554. * Visibility of the source mesh
  19555. */
  19556. readonly visibility: number;
  19557. /**
  19558. * Skeleton of the source mesh
  19559. */
  19560. readonly skeleton: Nullable<Skeleton>;
  19561. /**
  19562. * Rendering ground id of the source mesh
  19563. */
  19564. renderingGroupId: number;
  19565. /**
  19566. * Returns the total number of vertices (integer).
  19567. */
  19568. getTotalVertices(): number;
  19569. /**
  19570. * Returns a positive integer : the total number of indices in this mesh geometry.
  19571. * @returns the numner of indices or zero if the mesh has no geometry.
  19572. */
  19573. getTotalIndices(): number;
  19574. /**
  19575. * The source mesh of the instance
  19576. */
  19577. readonly sourceMesh: Mesh;
  19578. /**
  19579. * Is this node ready to be used/rendered
  19580. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19581. * @return {boolean} is it ready
  19582. */
  19583. isReady(completeCheck?: boolean): boolean;
  19584. /**
  19585. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19586. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19587. * @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.
  19588. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19589. */
  19590. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19591. /**
  19592. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19593. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19594. * The `data` are either a numeric array either a Float32Array.
  19595. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19596. * 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).
  19597. * Note that a new underlying VertexBuffer object is created each call.
  19598. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19599. *
  19600. * Possible `kind` values :
  19601. * - VertexBuffer.PositionKind
  19602. * - VertexBuffer.UVKind
  19603. * - VertexBuffer.UV2Kind
  19604. * - VertexBuffer.UV3Kind
  19605. * - VertexBuffer.UV4Kind
  19606. * - VertexBuffer.UV5Kind
  19607. * - VertexBuffer.UV6Kind
  19608. * - VertexBuffer.ColorKind
  19609. * - VertexBuffer.MatricesIndicesKind
  19610. * - VertexBuffer.MatricesIndicesExtraKind
  19611. * - VertexBuffer.MatricesWeightsKind
  19612. * - VertexBuffer.MatricesWeightsExtraKind
  19613. *
  19614. * Returns the Mesh.
  19615. */
  19616. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19617. /**
  19618. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19619. * If the mesh has no geometry, it is simply returned as it is.
  19620. * The `data` are either a numeric array either a Float32Array.
  19621. * No new underlying VertexBuffer object is created.
  19622. * 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.
  19623. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19624. *
  19625. * Possible `kind` values :
  19626. * - VertexBuffer.PositionKind
  19627. * - VertexBuffer.UVKind
  19628. * - VertexBuffer.UV2Kind
  19629. * - VertexBuffer.UV3Kind
  19630. * - VertexBuffer.UV4Kind
  19631. * - VertexBuffer.UV5Kind
  19632. * - VertexBuffer.UV6Kind
  19633. * - VertexBuffer.ColorKind
  19634. * - VertexBuffer.MatricesIndicesKind
  19635. * - VertexBuffer.MatricesIndicesExtraKind
  19636. * - VertexBuffer.MatricesWeightsKind
  19637. * - VertexBuffer.MatricesWeightsExtraKind
  19638. *
  19639. * Returns the Mesh.
  19640. */
  19641. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19642. /**
  19643. * Sets the mesh indices.
  19644. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19645. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19646. * This method creates a new index buffer each call.
  19647. * Returns the Mesh.
  19648. */
  19649. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19650. /**
  19651. * Boolean : True if the mesh owns the requested kind of data.
  19652. */
  19653. isVerticesDataPresent(kind: string): boolean;
  19654. /**
  19655. * Returns an array of indices (IndicesArray).
  19656. */
  19657. getIndices(): Nullable<IndicesArray>;
  19658. readonly _positions: Nullable<Vector3[]>;
  19659. /**
  19660. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19661. * This means the mesh underlying bounding box and sphere are recomputed.
  19662. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19663. * @returns the current mesh
  19664. */
  19665. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19666. /** @hidden */
  19667. _preActivate(): InstancedMesh;
  19668. /** @hidden */
  19669. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19670. /** @hidden */
  19671. _postActivate(): void;
  19672. getWorldMatrix(): Matrix;
  19673. readonly isAnInstance: boolean;
  19674. /**
  19675. * Returns the current associated LOD AbstractMesh.
  19676. */
  19677. getLOD(camera: Camera): AbstractMesh;
  19678. /** @hidden */
  19679. _syncSubMeshes(): InstancedMesh;
  19680. /** @hidden */
  19681. _generatePointsArray(): boolean;
  19682. /**
  19683. * Creates a new InstancedMesh from the current mesh.
  19684. * - name (string) : the cloned mesh name
  19685. * - newParent (optional Node) : the optional Node to parent the clone to.
  19686. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19687. *
  19688. * Returns the clone.
  19689. */
  19690. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19691. /**
  19692. * Disposes the InstancedMesh.
  19693. * Returns nothing.
  19694. */
  19695. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19696. }
  19697. module "babylonjs/Meshes/mesh" {
  19698. interface Mesh {
  19699. /**
  19700. * Register a custom buffer that will be instanced
  19701. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19702. * @param kind defines the buffer kind
  19703. * @param stride defines the stride in floats
  19704. */
  19705. registerInstancedBuffer(kind: string, stride: number): void;
  19706. /** @hidden */
  19707. _userInstancedBuffersStorage: {
  19708. data: {
  19709. [key: string]: Float32Array;
  19710. };
  19711. sizes: {
  19712. [key: string]: number;
  19713. };
  19714. vertexBuffers: {
  19715. [key: string]: Nullable<VertexBuffer>;
  19716. };
  19717. strides: {
  19718. [key: string]: number;
  19719. };
  19720. };
  19721. }
  19722. }
  19723. module "babylonjs/Meshes/abstractMesh" {
  19724. interface AbstractMesh {
  19725. /**
  19726. * Object used to store instanced buffers defined by user
  19727. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19728. */
  19729. instancedBuffers: {
  19730. [key: string]: any;
  19731. };
  19732. }
  19733. }
  19734. }
  19735. declare module "babylonjs/Materials/shaderMaterial" {
  19736. import { Scene } from "babylonjs/scene";
  19737. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19738. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19739. import { Mesh } from "babylonjs/Meshes/mesh";
  19740. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19741. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19742. import { Texture } from "babylonjs/Materials/Textures/texture";
  19743. import { Material } from "babylonjs/Materials/material";
  19744. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19745. /**
  19746. * Defines the options associated with the creation of a shader material.
  19747. */
  19748. export interface IShaderMaterialOptions {
  19749. /**
  19750. * Does the material work in alpha blend mode
  19751. */
  19752. needAlphaBlending: boolean;
  19753. /**
  19754. * Does the material work in alpha test mode
  19755. */
  19756. needAlphaTesting: boolean;
  19757. /**
  19758. * The list of attribute names used in the shader
  19759. */
  19760. attributes: string[];
  19761. /**
  19762. * The list of unifrom names used in the shader
  19763. */
  19764. uniforms: string[];
  19765. /**
  19766. * The list of UBO names used in the shader
  19767. */
  19768. uniformBuffers: string[];
  19769. /**
  19770. * The list of sampler names used in the shader
  19771. */
  19772. samplers: string[];
  19773. /**
  19774. * The list of defines used in the shader
  19775. */
  19776. defines: string[];
  19777. }
  19778. /**
  19779. * 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.
  19780. *
  19781. * This returned material effects how the mesh will look based on the code in the shaders.
  19782. *
  19783. * @see http://doc.babylonjs.com/how_to/shader_material
  19784. */
  19785. export class ShaderMaterial extends Material {
  19786. private _shaderPath;
  19787. private _options;
  19788. private _textures;
  19789. private _textureArrays;
  19790. private _floats;
  19791. private _ints;
  19792. private _floatsArrays;
  19793. private _colors3;
  19794. private _colors3Arrays;
  19795. private _colors4;
  19796. private _colors4Arrays;
  19797. private _vectors2;
  19798. private _vectors3;
  19799. private _vectors4;
  19800. private _matrices;
  19801. private _matrixArrays;
  19802. private _matrices3x3;
  19803. private _matrices2x2;
  19804. private _vectors2Arrays;
  19805. private _vectors3Arrays;
  19806. private _vectors4Arrays;
  19807. private _cachedWorldViewMatrix;
  19808. private _cachedWorldViewProjectionMatrix;
  19809. private _renderId;
  19810. private _multiview;
  19811. /**
  19812. * Instantiate a new shader material.
  19813. * 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.
  19814. * This returned material effects how the mesh will look based on the code in the shaders.
  19815. * @see http://doc.babylonjs.com/how_to/shader_material
  19816. * @param name Define the name of the material in the scene
  19817. * @param scene Define the scene the material belongs to
  19818. * @param shaderPath Defines the route to the shader code in one of three ways:
  19819. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19820. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19821. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19822. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19823. * @param options Define the options used to create the shader
  19824. */
  19825. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19826. /**
  19827. * Gets the shader path used to define the shader code
  19828. * It can be modified to trigger a new compilation
  19829. */
  19830. /**
  19831. * Sets the shader path used to define the shader code
  19832. * It can be modified to trigger a new compilation
  19833. */
  19834. shaderPath: any;
  19835. /**
  19836. * Gets the options used to compile the shader.
  19837. * They can be modified to trigger a new compilation
  19838. */
  19839. readonly options: IShaderMaterialOptions;
  19840. /**
  19841. * Gets the current class name of the material e.g. "ShaderMaterial"
  19842. * Mainly use in serialization.
  19843. * @returns the class name
  19844. */
  19845. getClassName(): string;
  19846. /**
  19847. * Specifies if the material will require alpha blending
  19848. * @returns a boolean specifying if alpha blending is needed
  19849. */
  19850. needAlphaBlending(): boolean;
  19851. /**
  19852. * Specifies if this material should be rendered in alpha test mode
  19853. * @returns a boolean specifying if an alpha test is needed.
  19854. */
  19855. needAlphaTesting(): boolean;
  19856. private _checkUniform;
  19857. /**
  19858. * Set a texture in the shader.
  19859. * @param name Define the name of the uniform samplers as defined in the shader
  19860. * @param texture Define the texture to bind to this sampler
  19861. * @return the material itself allowing "fluent" like uniform updates
  19862. */
  19863. setTexture(name: string, texture: Texture): ShaderMaterial;
  19864. /**
  19865. * Set a texture array in the shader.
  19866. * @param name Define the name of the uniform sampler array as defined in the shader
  19867. * @param textures Define the list of textures to bind to this sampler
  19868. * @return the material itself allowing "fluent" like uniform updates
  19869. */
  19870. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19871. /**
  19872. * Set a float in the shader.
  19873. * @param name Define the name of the uniform as defined in the shader
  19874. * @param value Define the value to give to the uniform
  19875. * @return the material itself allowing "fluent" like uniform updates
  19876. */
  19877. setFloat(name: string, value: number): ShaderMaterial;
  19878. /**
  19879. * Set a int in the shader.
  19880. * @param name Define the name of the uniform as defined in the shader
  19881. * @param value Define the value to give to the uniform
  19882. * @return the material itself allowing "fluent" like uniform updates
  19883. */
  19884. setInt(name: string, value: number): ShaderMaterial;
  19885. /**
  19886. * Set an array of floats in the shader.
  19887. * @param name Define the name of the uniform as defined in the shader
  19888. * @param value Define the value to give to the uniform
  19889. * @return the material itself allowing "fluent" like uniform updates
  19890. */
  19891. setFloats(name: string, value: number[]): ShaderMaterial;
  19892. /**
  19893. * Set a vec3 in the shader from a Color3.
  19894. * @param name Define the name of the uniform as defined in the shader
  19895. * @param value Define the value to give to the uniform
  19896. * @return the material itself allowing "fluent" like uniform updates
  19897. */
  19898. setColor3(name: string, value: Color3): ShaderMaterial;
  19899. /**
  19900. * Set a vec3 array in the shader from a Color3 array.
  19901. * @param name Define the name of the uniform as defined in the shader
  19902. * @param value Define the value to give to the uniform
  19903. * @return the material itself allowing "fluent" like uniform updates
  19904. */
  19905. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19906. /**
  19907. * Set a vec4 in the shader from a Color4.
  19908. * @param name Define the name of the uniform as defined in the shader
  19909. * @param value Define the value to give to the uniform
  19910. * @return the material itself allowing "fluent" like uniform updates
  19911. */
  19912. setColor4(name: string, value: Color4): ShaderMaterial;
  19913. /**
  19914. * Set a vec4 array in the shader from a Color4 array.
  19915. * @param name Define the name of the uniform as defined in the shader
  19916. * @param value Define the value to give to the uniform
  19917. * @return the material itself allowing "fluent" like uniform updates
  19918. */
  19919. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19920. /**
  19921. * Set a vec2 in the shader from a Vector2.
  19922. * @param name Define the name of the uniform as defined in the shader
  19923. * @param value Define the value to give to the uniform
  19924. * @return the material itself allowing "fluent" like uniform updates
  19925. */
  19926. setVector2(name: string, value: Vector2): ShaderMaterial;
  19927. /**
  19928. * Set a vec3 in the shader from a Vector3.
  19929. * @param name Define the name of the uniform as defined in the shader
  19930. * @param value Define the value to give to the uniform
  19931. * @return the material itself allowing "fluent" like uniform updates
  19932. */
  19933. setVector3(name: string, value: Vector3): ShaderMaterial;
  19934. /**
  19935. * Set a vec4 in the shader from a Vector4.
  19936. * @param name Define the name of the uniform as defined in the shader
  19937. * @param value Define the value to give to the uniform
  19938. * @return the material itself allowing "fluent" like uniform updates
  19939. */
  19940. setVector4(name: string, value: Vector4): ShaderMaterial;
  19941. /**
  19942. * Set a mat4 in the shader from a Matrix.
  19943. * @param name Define the name of the uniform as defined in the shader
  19944. * @param value Define the value to give to the uniform
  19945. * @return the material itself allowing "fluent" like uniform updates
  19946. */
  19947. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19948. /**
  19949. * Set a float32Array in the shader from a matrix array.
  19950. * @param name Define the name of the uniform as defined in the shader
  19951. * @param value Define the value to give to the uniform
  19952. * @return the material itself allowing "fluent" like uniform updates
  19953. */
  19954. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  19955. /**
  19956. * Set a mat3 in the shader from a Float32Array.
  19957. * @param name Define the name of the uniform as defined in the shader
  19958. * @param value Define the value to give to the uniform
  19959. * @return the material itself allowing "fluent" like uniform updates
  19960. */
  19961. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19962. /**
  19963. * Set a mat2 in the shader from a Float32Array.
  19964. * @param name Define the name of the uniform as defined in the shader
  19965. * @param value Define the value to give to the uniform
  19966. * @return the material itself allowing "fluent" like uniform updates
  19967. */
  19968. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19969. /**
  19970. * Set a vec2 array in the shader from a number array.
  19971. * @param name Define the name of the uniform as defined in the shader
  19972. * @param value Define the value to give to the uniform
  19973. * @return the material itself allowing "fluent" like uniform updates
  19974. */
  19975. setArray2(name: string, value: number[]): ShaderMaterial;
  19976. /**
  19977. * Set a vec3 array in the shader from a number array.
  19978. * @param name Define the name of the uniform as defined in the shader
  19979. * @param value Define the value to give to the uniform
  19980. * @return the material itself allowing "fluent" like uniform updates
  19981. */
  19982. setArray3(name: string, value: number[]): ShaderMaterial;
  19983. /**
  19984. * Set a vec4 array in the shader from a number array.
  19985. * @param name Define the name of the uniform as defined in the shader
  19986. * @param value Define the value to give to the uniform
  19987. * @return the material itself allowing "fluent" like uniform updates
  19988. */
  19989. setArray4(name: string, value: number[]): ShaderMaterial;
  19990. private _checkCache;
  19991. /**
  19992. * Specifies that the submesh is ready to be used
  19993. * @param mesh defines the mesh to check
  19994. * @param subMesh defines which submesh to check
  19995. * @param useInstances specifies that instances should be used
  19996. * @returns a boolean indicating that the submesh is ready or not
  19997. */
  19998. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19999. /**
  20000. * Checks if the material is ready to render the requested mesh
  20001. * @param mesh Define the mesh to render
  20002. * @param useInstances Define whether or not the material is used with instances
  20003. * @returns true if ready, otherwise false
  20004. */
  20005. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20006. /**
  20007. * Binds the world matrix to the material
  20008. * @param world defines the world transformation matrix
  20009. */
  20010. bindOnlyWorldMatrix(world: Matrix): void;
  20011. /**
  20012. * Binds the material to the mesh
  20013. * @param world defines the world transformation matrix
  20014. * @param mesh defines the mesh to bind the material to
  20015. */
  20016. bind(world: Matrix, mesh?: Mesh): void;
  20017. /**
  20018. * Gets the active textures from the material
  20019. * @returns an array of textures
  20020. */
  20021. getActiveTextures(): BaseTexture[];
  20022. /**
  20023. * Specifies if the material uses a texture
  20024. * @param texture defines the texture to check against the material
  20025. * @returns a boolean specifying if the material uses the texture
  20026. */
  20027. hasTexture(texture: BaseTexture): boolean;
  20028. /**
  20029. * Makes a duplicate of the material, and gives it a new name
  20030. * @param name defines the new name for the duplicated material
  20031. * @returns the cloned material
  20032. */
  20033. clone(name: string): ShaderMaterial;
  20034. /**
  20035. * Disposes the material
  20036. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20037. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20038. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20039. */
  20040. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20041. /**
  20042. * Serializes this material in a JSON representation
  20043. * @returns the serialized material object
  20044. */
  20045. serialize(): any;
  20046. /**
  20047. * Creates a shader material from parsed shader material data
  20048. * @param source defines the JSON represnetation of the material
  20049. * @param scene defines the hosting scene
  20050. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  20051. * @returns a new material
  20052. */
  20053. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  20054. }
  20055. }
  20056. declare module "babylonjs/Shaders/color.fragment" {
  20057. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  20058. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  20059. /** @hidden */
  20060. export var colorPixelShader: {
  20061. name: string;
  20062. shader: string;
  20063. };
  20064. }
  20065. declare module "babylonjs/Shaders/color.vertex" {
  20066. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  20067. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  20068. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  20069. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  20070. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  20071. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  20072. /** @hidden */
  20073. export var colorVertexShader: {
  20074. name: string;
  20075. shader: string;
  20076. };
  20077. }
  20078. declare module "babylonjs/Meshes/linesMesh" {
  20079. import { Nullable } from "babylonjs/types";
  20080. import { Scene } from "babylonjs/scene";
  20081. import { Color3 } from "babylonjs/Maths/math.color";
  20082. import { Node } from "babylonjs/node";
  20083. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20084. import { Mesh } from "babylonjs/Meshes/mesh";
  20085. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  20086. import { Effect } from "babylonjs/Materials/effect";
  20087. import { Material } from "babylonjs/Materials/material";
  20088. import "babylonjs/Shaders/color.fragment";
  20089. import "babylonjs/Shaders/color.vertex";
  20090. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20091. /**
  20092. * Line mesh
  20093. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  20094. */
  20095. export class LinesMesh extends Mesh {
  20096. /**
  20097. * If vertex color should be applied to the mesh
  20098. */
  20099. readonly useVertexColor?: boolean | undefined;
  20100. /**
  20101. * If vertex alpha should be applied to the mesh
  20102. */
  20103. readonly useVertexAlpha?: boolean | undefined;
  20104. /**
  20105. * Color of the line (Default: White)
  20106. */
  20107. color: Color3;
  20108. /**
  20109. * Alpha of the line (Default: 1)
  20110. */
  20111. alpha: number;
  20112. /**
  20113. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20114. * This margin is expressed in world space coordinates, so its value may vary.
  20115. * Default value is 0.1
  20116. */
  20117. intersectionThreshold: number;
  20118. private _colorShader;
  20119. private color4;
  20120. /**
  20121. * Creates a new LinesMesh
  20122. * @param name defines the name
  20123. * @param scene defines the hosting scene
  20124. * @param parent defines the parent mesh if any
  20125. * @param source defines the optional source LinesMesh used to clone data from
  20126. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20127. * When false, achieved by calling a clone(), also passing False.
  20128. * This will make creation of children, recursive.
  20129. * @param useVertexColor defines if this LinesMesh supports vertex color
  20130. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  20131. */
  20132. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  20133. /**
  20134. * If vertex color should be applied to the mesh
  20135. */
  20136. useVertexColor?: boolean | undefined,
  20137. /**
  20138. * If vertex alpha should be applied to the mesh
  20139. */
  20140. useVertexAlpha?: boolean | undefined);
  20141. private _addClipPlaneDefine;
  20142. private _removeClipPlaneDefine;
  20143. isReady(): boolean;
  20144. /**
  20145. * Returns the string "LineMesh"
  20146. */
  20147. getClassName(): string;
  20148. /**
  20149. * @hidden
  20150. */
  20151. /**
  20152. * @hidden
  20153. */
  20154. material: Material;
  20155. /**
  20156. * @hidden
  20157. */
  20158. readonly checkCollisions: boolean;
  20159. /** @hidden */
  20160. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20161. /** @hidden */
  20162. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  20163. /**
  20164. * Disposes of the line mesh
  20165. * @param doNotRecurse If children should be disposed
  20166. */
  20167. dispose(doNotRecurse?: boolean): void;
  20168. /**
  20169. * Returns a new LineMesh object cloned from the current one.
  20170. */
  20171. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  20172. /**
  20173. * Creates a new InstancedLinesMesh object from the mesh model.
  20174. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20175. * @param name defines the name of the new instance
  20176. * @returns a new InstancedLinesMesh
  20177. */
  20178. createInstance(name: string): InstancedLinesMesh;
  20179. }
  20180. /**
  20181. * Creates an instance based on a source LinesMesh
  20182. */
  20183. export class InstancedLinesMesh extends InstancedMesh {
  20184. /**
  20185. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20186. * This margin is expressed in world space coordinates, so its value may vary.
  20187. * Initilized with the intersectionThreshold value of the source LinesMesh
  20188. */
  20189. intersectionThreshold: number;
  20190. constructor(name: string, source: LinesMesh);
  20191. /**
  20192. * Returns the string "InstancedLinesMesh".
  20193. */
  20194. getClassName(): string;
  20195. }
  20196. }
  20197. declare module "babylonjs/Shaders/line.fragment" {
  20198. /** @hidden */
  20199. export var linePixelShader: {
  20200. name: string;
  20201. shader: string;
  20202. };
  20203. }
  20204. declare module "babylonjs/Shaders/line.vertex" {
  20205. /** @hidden */
  20206. export var lineVertexShader: {
  20207. name: string;
  20208. shader: string;
  20209. };
  20210. }
  20211. declare module "babylonjs/Rendering/edgesRenderer" {
  20212. import { Nullable } from "babylonjs/types";
  20213. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20214. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20215. import { Vector3 } from "babylonjs/Maths/math.vector";
  20216. import { IDisposable } from "babylonjs/scene";
  20217. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  20218. import "babylonjs/Shaders/line.fragment";
  20219. import "babylonjs/Shaders/line.vertex";
  20220. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  20221. module "babylonjs/Meshes/abstractMesh" {
  20222. interface AbstractMesh {
  20223. /**
  20224. * Gets the edgesRenderer associated with the mesh
  20225. */
  20226. edgesRenderer: Nullable<EdgesRenderer>;
  20227. }
  20228. }
  20229. module "babylonjs/Meshes/linesMesh" {
  20230. interface LinesMesh {
  20231. /**
  20232. * Enables the edge rendering mode on the mesh.
  20233. * This mode makes the mesh edges visible
  20234. * @param epsilon defines the maximal distance between two angles to detect a face
  20235. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20236. * @returns the currentAbstractMesh
  20237. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20238. */
  20239. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  20240. }
  20241. }
  20242. module "babylonjs/Meshes/linesMesh" {
  20243. interface InstancedLinesMesh {
  20244. /**
  20245. * Enables the edge rendering mode on the mesh.
  20246. * This mode makes the mesh edges visible
  20247. * @param epsilon defines the maximal distance between two angles to detect a face
  20248. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20249. * @returns the current InstancedLinesMesh
  20250. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20251. */
  20252. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  20253. }
  20254. }
  20255. /**
  20256. * Defines the minimum contract an Edges renderer should follow.
  20257. */
  20258. export interface IEdgesRenderer extends IDisposable {
  20259. /**
  20260. * Gets or sets a boolean indicating if the edgesRenderer is active
  20261. */
  20262. isEnabled: boolean;
  20263. /**
  20264. * Renders the edges of the attached mesh,
  20265. */
  20266. render(): void;
  20267. /**
  20268. * Checks wether or not the edges renderer is ready to render.
  20269. * @return true if ready, otherwise false.
  20270. */
  20271. isReady(): boolean;
  20272. }
  20273. /**
  20274. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  20275. */
  20276. export class EdgesRenderer implements IEdgesRenderer {
  20277. /**
  20278. * Define the size of the edges with an orthographic camera
  20279. */
  20280. edgesWidthScalerForOrthographic: number;
  20281. /**
  20282. * Define the size of the edges with a perspective camera
  20283. */
  20284. edgesWidthScalerForPerspective: number;
  20285. protected _source: AbstractMesh;
  20286. protected _linesPositions: number[];
  20287. protected _linesNormals: number[];
  20288. protected _linesIndices: number[];
  20289. protected _epsilon: number;
  20290. protected _indicesCount: number;
  20291. protected _lineShader: ShaderMaterial;
  20292. protected _ib: DataBuffer;
  20293. protected _buffers: {
  20294. [key: string]: Nullable<VertexBuffer>;
  20295. };
  20296. protected _checkVerticesInsteadOfIndices: boolean;
  20297. private _meshRebuildObserver;
  20298. private _meshDisposeObserver;
  20299. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  20300. isEnabled: boolean;
  20301. /**
  20302. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  20303. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  20304. * @param source Mesh used to create edges
  20305. * @param epsilon sum of angles in adjacency to check for edge
  20306. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  20307. * @param generateEdgesLines - should generate Lines or only prepare resources.
  20308. */
  20309. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  20310. protected _prepareRessources(): void;
  20311. /** @hidden */
  20312. _rebuild(): void;
  20313. /**
  20314. * Releases the required resources for the edges renderer
  20315. */
  20316. dispose(): void;
  20317. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  20318. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  20319. /**
  20320. * Checks if the pair of p0 and p1 is en edge
  20321. * @param faceIndex
  20322. * @param edge
  20323. * @param faceNormals
  20324. * @param p0
  20325. * @param p1
  20326. * @private
  20327. */
  20328. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  20329. /**
  20330. * push line into the position, normal and index buffer
  20331. * @protected
  20332. */
  20333. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  20334. /**
  20335. * Generates lines edges from adjacencjes
  20336. * @private
  20337. */
  20338. _generateEdgesLines(): void;
  20339. /**
  20340. * Checks wether or not the edges renderer is ready to render.
  20341. * @return true if ready, otherwise false.
  20342. */
  20343. isReady(): boolean;
  20344. /**
  20345. * Renders the edges of the attached mesh,
  20346. */
  20347. render(): void;
  20348. }
  20349. /**
  20350. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  20351. */
  20352. export class LineEdgesRenderer extends EdgesRenderer {
  20353. /**
  20354. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  20355. * @param source LineMesh used to generate edges
  20356. * @param epsilon not important (specified angle for edge detection)
  20357. * @param checkVerticesInsteadOfIndices not important for LineMesh
  20358. */
  20359. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  20360. /**
  20361. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  20362. */
  20363. _generateEdgesLines(): void;
  20364. }
  20365. }
  20366. declare module "babylonjs/Rendering/renderingGroup" {
  20367. import { SmartArray } from "babylonjs/Misc/smartArray";
  20368. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20369. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20370. import { Nullable } from "babylonjs/types";
  20371. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20372. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  20373. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20374. import { Material } from "babylonjs/Materials/material";
  20375. import { Scene } from "babylonjs/scene";
  20376. /**
  20377. * This represents the object necessary to create a rendering group.
  20378. * This is exclusively used and created by the rendering manager.
  20379. * To modify the behavior, you use the available helpers in your scene or meshes.
  20380. * @hidden
  20381. */
  20382. export class RenderingGroup {
  20383. index: number;
  20384. private static _zeroVector;
  20385. private _scene;
  20386. private _opaqueSubMeshes;
  20387. private _transparentSubMeshes;
  20388. private _alphaTestSubMeshes;
  20389. private _depthOnlySubMeshes;
  20390. private _particleSystems;
  20391. private _spriteManagers;
  20392. private _opaqueSortCompareFn;
  20393. private _alphaTestSortCompareFn;
  20394. private _transparentSortCompareFn;
  20395. private _renderOpaque;
  20396. private _renderAlphaTest;
  20397. private _renderTransparent;
  20398. /** @hidden */
  20399. _edgesRenderers: SmartArray<IEdgesRenderer>;
  20400. onBeforeTransparentRendering: () => void;
  20401. /**
  20402. * Set the opaque sort comparison function.
  20403. * If null the sub meshes will be render in the order they were created
  20404. */
  20405. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20406. /**
  20407. * Set the alpha test sort comparison function.
  20408. * If null the sub meshes will be render in the order they were created
  20409. */
  20410. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20411. /**
  20412. * Set the transparent sort comparison function.
  20413. * If null the sub meshes will be render in the order they were created
  20414. */
  20415. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20416. /**
  20417. * Creates a new rendering group.
  20418. * @param index The rendering group index
  20419. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  20420. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  20421. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  20422. */
  20423. 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>);
  20424. /**
  20425. * Render all the sub meshes contained in the group.
  20426. * @param customRenderFunction Used to override the default render behaviour of the group.
  20427. * @returns true if rendered some submeshes.
  20428. */
  20429. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  20430. /**
  20431. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  20432. * @param subMeshes The submeshes to render
  20433. */
  20434. private renderOpaqueSorted;
  20435. /**
  20436. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20437. * @param subMeshes The submeshes to render
  20438. */
  20439. private renderAlphaTestSorted;
  20440. /**
  20441. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20442. * @param subMeshes The submeshes to render
  20443. */
  20444. private renderTransparentSorted;
  20445. /**
  20446. * Renders the submeshes in a specified order.
  20447. * @param subMeshes The submeshes to sort before render
  20448. * @param sortCompareFn The comparison function use to sort
  20449. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20450. * @param transparent Specifies to activate blending if true
  20451. */
  20452. private static renderSorted;
  20453. /**
  20454. * Renders the submeshes in the order they were dispatched (no sort applied).
  20455. * @param subMeshes The submeshes to render
  20456. */
  20457. private static renderUnsorted;
  20458. /**
  20459. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20460. * are rendered back to front if in the same alpha index.
  20461. *
  20462. * @param a The first submesh
  20463. * @param b The second submesh
  20464. * @returns The result of the comparison
  20465. */
  20466. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20467. /**
  20468. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20469. * are rendered back to front.
  20470. *
  20471. * @param a The first submesh
  20472. * @param b The second submesh
  20473. * @returns The result of the comparison
  20474. */
  20475. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20476. /**
  20477. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20478. * are rendered front to back (prevent overdraw).
  20479. *
  20480. * @param a The first submesh
  20481. * @param b The second submesh
  20482. * @returns The result of the comparison
  20483. */
  20484. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20485. /**
  20486. * Resets the different lists of submeshes to prepare a new frame.
  20487. */
  20488. prepare(): void;
  20489. dispose(): void;
  20490. /**
  20491. * Inserts the submesh in its correct queue depending on its material.
  20492. * @param subMesh The submesh to dispatch
  20493. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20494. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20495. */
  20496. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20497. dispatchSprites(spriteManager: ISpriteManager): void;
  20498. dispatchParticles(particleSystem: IParticleSystem): void;
  20499. private _renderParticles;
  20500. private _renderSprites;
  20501. }
  20502. }
  20503. declare module "babylonjs/Rendering/renderingManager" {
  20504. import { Nullable } from "babylonjs/types";
  20505. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20506. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20507. import { SmartArray } from "babylonjs/Misc/smartArray";
  20508. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20509. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20510. import { Material } from "babylonjs/Materials/material";
  20511. import { Scene } from "babylonjs/scene";
  20512. import { Camera } from "babylonjs/Cameras/camera";
  20513. /**
  20514. * Interface describing the different options available in the rendering manager
  20515. * regarding Auto Clear between groups.
  20516. */
  20517. export interface IRenderingManagerAutoClearSetup {
  20518. /**
  20519. * Defines whether or not autoclear is enable.
  20520. */
  20521. autoClear: boolean;
  20522. /**
  20523. * Defines whether or not to autoclear the depth buffer.
  20524. */
  20525. depth: boolean;
  20526. /**
  20527. * Defines whether or not to autoclear the stencil buffer.
  20528. */
  20529. stencil: boolean;
  20530. }
  20531. /**
  20532. * This class is used by the onRenderingGroupObservable
  20533. */
  20534. export class RenderingGroupInfo {
  20535. /**
  20536. * The Scene that being rendered
  20537. */
  20538. scene: Scene;
  20539. /**
  20540. * The camera currently used for the rendering pass
  20541. */
  20542. camera: Nullable<Camera>;
  20543. /**
  20544. * The ID of the renderingGroup being processed
  20545. */
  20546. renderingGroupId: number;
  20547. }
  20548. /**
  20549. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20550. * It is enable to manage the different groups as well as the different necessary sort functions.
  20551. * This should not be used directly aside of the few static configurations
  20552. */
  20553. export class RenderingManager {
  20554. /**
  20555. * The max id used for rendering groups (not included)
  20556. */
  20557. static MAX_RENDERINGGROUPS: number;
  20558. /**
  20559. * The min id used for rendering groups (included)
  20560. */
  20561. static MIN_RENDERINGGROUPS: number;
  20562. /**
  20563. * Used to globally prevent autoclearing scenes.
  20564. */
  20565. static AUTOCLEAR: boolean;
  20566. /**
  20567. * @hidden
  20568. */
  20569. _useSceneAutoClearSetup: boolean;
  20570. private _scene;
  20571. private _renderingGroups;
  20572. private _depthStencilBufferAlreadyCleaned;
  20573. private _autoClearDepthStencil;
  20574. private _customOpaqueSortCompareFn;
  20575. private _customAlphaTestSortCompareFn;
  20576. private _customTransparentSortCompareFn;
  20577. private _renderingGroupInfo;
  20578. /**
  20579. * Instantiates a new rendering group for a particular scene
  20580. * @param scene Defines the scene the groups belongs to
  20581. */
  20582. constructor(scene: Scene);
  20583. private _clearDepthStencilBuffer;
  20584. /**
  20585. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20586. * @hidden
  20587. */
  20588. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20589. /**
  20590. * Resets the different information of the group to prepare a new frame
  20591. * @hidden
  20592. */
  20593. reset(): void;
  20594. /**
  20595. * Dispose and release the group and its associated resources.
  20596. * @hidden
  20597. */
  20598. dispose(): void;
  20599. /**
  20600. * Clear the info related to rendering groups preventing retention points during dispose.
  20601. */
  20602. freeRenderingGroups(): void;
  20603. private _prepareRenderingGroup;
  20604. /**
  20605. * Add a sprite manager to the rendering manager in order to render it this frame.
  20606. * @param spriteManager Define the sprite manager to render
  20607. */
  20608. dispatchSprites(spriteManager: ISpriteManager): void;
  20609. /**
  20610. * Add a particle system to the rendering manager in order to render it this frame.
  20611. * @param particleSystem Define the particle system to render
  20612. */
  20613. dispatchParticles(particleSystem: IParticleSystem): void;
  20614. /**
  20615. * Add a submesh to the manager in order to render it this frame
  20616. * @param subMesh The submesh to dispatch
  20617. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20618. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20619. */
  20620. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20621. /**
  20622. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20623. * This allowed control for front to back rendering or reversly depending of the special needs.
  20624. *
  20625. * @param renderingGroupId The rendering group id corresponding to its index
  20626. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20627. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20628. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20629. */
  20630. 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;
  20631. /**
  20632. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20633. *
  20634. * @param renderingGroupId The rendering group id corresponding to its index
  20635. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20636. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20637. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20638. */
  20639. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20640. /**
  20641. * Gets the current auto clear configuration for one rendering group of the rendering
  20642. * manager.
  20643. * @param index the rendering group index to get the information for
  20644. * @returns The auto clear setup for the requested rendering group
  20645. */
  20646. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20647. }
  20648. }
  20649. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20650. import { Observable } from "babylonjs/Misc/observable";
  20651. import { SmartArray } from "babylonjs/Misc/smartArray";
  20652. import { Nullable } from "babylonjs/types";
  20653. import { Camera } from "babylonjs/Cameras/camera";
  20654. import { Scene } from "babylonjs/scene";
  20655. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20656. import { Color4 } from "babylonjs/Maths/math.color";
  20657. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20658. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20659. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20660. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20661. import { Texture } from "babylonjs/Materials/Textures/texture";
  20662. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20663. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20664. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20665. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  20666. import { Engine } from "babylonjs/Engines/engine";
  20667. /**
  20668. * This Helps creating a texture that will be created from a camera in your scene.
  20669. * It is basically a dynamic texture that could be used to create special effects for instance.
  20670. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20671. */
  20672. export class RenderTargetTexture extends Texture {
  20673. isCube: boolean;
  20674. /**
  20675. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20676. */
  20677. static readonly REFRESHRATE_RENDER_ONCE: number;
  20678. /**
  20679. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20680. */
  20681. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20682. /**
  20683. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20684. * the central point of your effect and can save a lot of performances.
  20685. */
  20686. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20687. /**
  20688. * Use this predicate to dynamically define the list of mesh you want to render.
  20689. * If set, the renderList property will be overwritten.
  20690. */
  20691. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20692. private _renderList;
  20693. /**
  20694. * Use this list to define the list of mesh you want to render.
  20695. */
  20696. renderList: Nullable<Array<AbstractMesh>>;
  20697. private _hookArray;
  20698. /**
  20699. * Define if particles should be rendered in your texture.
  20700. */
  20701. renderParticles: boolean;
  20702. /**
  20703. * Define if sprites should be rendered in your texture.
  20704. */
  20705. renderSprites: boolean;
  20706. /**
  20707. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20708. */
  20709. coordinatesMode: number;
  20710. /**
  20711. * Define the camera used to render the texture.
  20712. */
  20713. activeCamera: Nullable<Camera>;
  20714. /**
  20715. * Override the render function of the texture with your own one.
  20716. */
  20717. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20718. /**
  20719. * Define if camera post processes should be use while rendering the texture.
  20720. */
  20721. useCameraPostProcesses: boolean;
  20722. /**
  20723. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20724. */
  20725. ignoreCameraViewport: boolean;
  20726. private _postProcessManager;
  20727. private _postProcesses;
  20728. private _resizeObserver;
  20729. /**
  20730. * An event triggered when the texture is unbind.
  20731. */
  20732. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20733. /**
  20734. * An event triggered when the texture is unbind.
  20735. */
  20736. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20737. private _onAfterUnbindObserver;
  20738. /**
  20739. * Set a after unbind callback in the texture.
  20740. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20741. */
  20742. onAfterUnbind: () => void;
  20743. /**
  20744. * An event triggered before rendering the texture
  20745. */
  20746. onBeforeRenderObservable: Observable<number>;
  20747. private _onBeforeRenderObserver;
  20748. /**
  20749. * Set a before render callback in the texture.
  20750. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20751. */
  20752. onBeforeRender: (faceIndex: number) => void;
  20753. /**
  20754. * An event triggered after rendering the texture
  20755. */
  20756. onAfterRenderObservable: Observable<number>;
  20757. private _onAfterRenderObserver;
  20758. /**
  20759. * Set a after render callback in the texture.
  20760. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20761. */
  20762. onAfterRender: (faceIndex: number) => void;
  20763. /**
  20764. * An event triggered after the texture clear
  20765. */
  20766. onClearObservable: Observable<Engine>;
  20767. private _onClearObserver;
  20768. /**
  20769. * Set a clear callback in the texture.
  20770. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20771. */
  20772. onClear: (Engine: Engine) => void;
  20773. /**
  20774. * An event triggered when the texture is resized.
  20775. */
  20776. onResizeObservable: Observable<RenderTargetTexture>;
  20777. /**
  20778. * Define the clear color of the Render Target if it should be different from the scene.
  20779. */
  20780. clearColor: Color4;
  20781. protected _size: number | {
  20782. width: number;
  20783. height: number;
  20784. };
  20785. protected _initialSizeParameter: number | {
  20786. width: number;
  20787. height: number;
  20788. } | {
  20789. ratio: number;
  20790. };
  20791. protected _sizeRatio: Nullable<number>;
  20792. /** @hidden */
  20793. _generateMipMaps: boolean;
  20794. protected _renderingManager: RenderingManager;
  20795. /** @hidden */
  20796. _waitingRenderList: string[];
  20797. protected _doNotChangeAspectRatio: boolean;
  20798. protected _currentRefreshId: number;
  20799. protected _refreshRate: number;
  20800. protected _textureMatrix: Matrix;
  20801. protected _samples: number;
  20802. protected _renderTargetOptions: RenderTargetCreationOptions;
  20803. /**
  20804. * Gets render target creation options that were used.
  20805. */
  20806. readonly renderTargetOptions: RenderTargetCreationOptions;
  20807. protected _engine: Engine;
  20808. protected _onRatioRescale(): void;
  20809. /**
  20810. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20811. * It must define where the camera used to render the texture is set
  20812. */
  20813. boundingBoxPosition: Vector3;
  20814. private _boundingBoxSize;
  20815. /**
  20816. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20817. * When defined, the cubemap will switch to local mode
  20818. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20819. * @example https://www.babylonjs-playground.com/#RNASML
  20820. */
  20821. boundingBoxSize: Vector3;
  20822. /**
  20823. * In case the RTT has been created with a depth texture, get the associated
  20824. * depth texture.
  20825. * Otherwise, return null.
  20826. */
  20827. depthStencilTexture: Nullable<InternalTexture>;
  20828. /**
  20829. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20830. * or used a shadow, depth texture...
  20831. * @param name The friendly name of the texture
  20832. * @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)
  20833. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20834. * @param generateMipMaps True if mip maps need to be generated after render.
  20835. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20836. * @param type The type of the buffer in the RTT (int, half float, float...)
  20837. * @param isCube True if a cube texture needs to be created
  20838. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20839. * @param generateDepthBuffer True to generate a depth buffer
  20840. * @param generateStencilBuffer True to generate a stencil buffer
  20841. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20842. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20843. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20844. */
  20845. constructor(name: string, size: number | {
  20846. width: number;
  20847. height: number;
  20848. } | {
  20849. ratio: number;
  20850. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20851. /**
  20852. * Creates a depth stencil texture.
  20853. * This is only available in WebGL 2 or with the depth texture extension available.
  20854. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20855. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20856. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20857. */
  20858. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20859. private _processSizeParameter;
  20860. /**
  20861. * Define the number of samples to use in case of MSAA.
  20862. * It defaults to one meaning no MSAA has been enabled.
  20863. */
  20864. samples: number;
  20865. /**
  20866. * Resets the refresh counter of the texture and start bak from scratch.
  20867. * Could be useful to regenerate the texture if it is setup to render only once.
  20868. */
  20869. resetRefreshCounter(): void;
  20870. /**
  20871. * Define the refresh rate of the texture or the rendering frequency.
  20872. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20873. */
  20874. refreshRate: number;
  20875. /**
  20876. * Adds a post process to the render target rendering passes.
  20877. * @param postProcess define the post process to add
  20878. */
  20879. addPostProcess(postProcess: PostProcess): void;
  20880. /**
  20881. * Clear all the post processes attached to the render target
  20882. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20883. */
  20884. clearPostProcesses(dispose?: boolean): void;
  20885. /**
  20886. * Remove one of the post process from the list of attached post processes to the texture
  20887. * @param postProcess define the post process to remove from the list
  20888. */
  20889. removePostProcess(postProcess: PostProcess): void;
  20890. /** @hidden */
  20891. _shouldRender(): boolean;
  20892. /**
  20893. * Gets the actual render size of the texture.
  20894. * @returns the width of the render size
  20895. */
  20896. getRenderSize(): number;
  20897. /**
  20898. * Gets the actual render width of the texture.
  20899. * @returns the width of the render size
  20900. */
  20901. getRenderWidth(): number;
  20902. /**
  20903. * Gets the actual render height of the texture.
  20904. * @returns the height of the render size
  20905. */
  20906. getRenderHeight(): number;
  20907. /**
  20908. * Get if the texture can be rescaled or not.
  20909. */
  20910. readonly canRescale: boolean;
  20911. /**
  20912. * Resize the texture using a ratio.
  20913. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20914. */
  20915. scale(ratio: number): void;
  20916. /**
  20917. * Get the texture reflection matrix used to rotate/transform the reflection.
  20918. * @returns the reflection matrix
  20919. */
  20920. getReflectionTextureMatrix(): Matrix;
  20921. /**
  20922. * Resize the texture to a new desired size.
  20923. * Be carrefull as it will recreate all the data in the new texture.
  20924. * @param size Define the new size. It can be:
  20925. * - a number for squared texture,
  20926. * - an object containing { width: number, height: number }
  20927. * - or an object containing a ratio { ratio: number }
  20928. */
  20929. resize(size: number | {
  20930. width: number;
  20931. height: number;
  20932. } | {
  20933. ratio: number;
  20934. }): void;
  20935. /**
  20936. * Renders all the objects from the render list into the texture.
  20937. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20938. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20939. */
  20940. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20941. private _bestReflectionRenderTargetDimension;
  20942. /**
  20943. * @hidden
  20944. * @param faceIndex face index to bind to if this is a cubetexture
  20945. */
  20946. _bindFrameBuffer(faceIndex?: number): void;
  20947. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20948. private renderToTarget;
  20949. /**
  20950. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20951. * This allowed control for front to back rendering or reversly depending of the special needs.
  20952. *
  20953. * @param renderingGroupId The rendering group id corresponding to its index
  20954. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20955. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20956. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20957. */
  20958. 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;
  20959. /**
  20960. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20961. *
  20962. * @param renderingGroupId The rendering group id corresponding to its index
  20963. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20964. */
  20965. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20966. /**
  20967. * Clones the texture.
  20968. * @returns the cloned texture
  20969. */
  20970. clone(): RenderTargetTexture;
  20971. /**
  20972. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20973. * @returns The JSON representation of the texture
  20974. */
  20975. serialize(): any;
  20976. /**
  20977. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20978. */
  20979. disposeFramebufferObjects(): void;
  20980. /**
  20981. * Dispose the texture and release its associated resources.
  20982. */
  20983. dispose(): void;
  20984. /** @hidden */
  20985. _rebuild(): void;
  20986. /**
  20987. * Clear the info related to rendering groups preventing retention point in material dispose.
  20988. */
  20989. freeRenderingGroups(): void;
  20990. /**
  20991. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20992. * @returns the view count
  20993. */
  20994. getViewCount(): number;
  20995. }
  20996. }
  20997. declare module "babylonjs/Materials/material" {
  20998. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20999. import { SmartArray } from "babylonjs/Misc/smartArray";
  21000. import { Observable } from "babylonjs/Misc/observable";
  21001. import { Nullable } from "babylonjs/types";
  21002. import { Scene } from "babylonjs/scene";
  21003. import { Matrix } from "babylonjs/Maths/math.vector";
  21004. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  21005. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21006. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21007. import { Effect } from "babylonjs/Materials/effect";
  21008. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21009. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21010. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21011. import { IInspectable } from "babylonjs/Misc/iInspectable";
  21012. import { Mesh } from "babylonjs/Meshes/mesh";
  21013. import { Animation } from "babylonjs/Animations/animation";
  21014. /**
  21015. * Options for compiling materials.
  21016. */
  21017. export interface IMaterialCompilationOptions {
  21018. /**
  21019. * Defines whether clip planes are enabled.
  21020. */
  21021. clipPlane: boolean;
  21022. /**
  21023. * Defines whether instances are enabled.
  21024. */
  21025. useInstances: boolean;
  21026. }
  21027. /**
  21028. * Base class for the main features of a material in Babylon.js
  21029. */
  21030. export class Material implements IAnimatable {
  21031. /**
  21032. * Returns the triangle fill mode
  21033. */
  21034. static readonly TriangleFillMode: number;
  21035. /**
  21036. * Returns the wireframe mode
  21037. */
  21038. static readonly WireFrameFillMode: number;
  21039. /**
  21040. * Returns the point fill mode
  21041. */
  21042. static readonly PointFillMode: number;
  21043. /**
  21044. * Returns the point list draw mode
  21045. */
  21046. static readonly PointListDrawMode: number;
  21047. /**
  21048. * Returns the line list draw mode
  21049. */
  21050. static readonly LineListDrawMode: number;
  21051. /**
  21052. * Returns the line loop draw mode
  21053. */
  21054. static readonly LineLoopDrawMode: number;
  21055. /**
  21056. * Returns the line strip draw mode
  21057. */
  21058. static readonly LineStripDrawMode: number;
  21059. /**
  21060. * Returns the triangle strip draw mode
  21061. */
  21062. static readonly TriangleStripDrawMode: number;
  21063. /**
  21064. * Returns the triangle fan draw mode
  21065. */
  21066. static readonly TriangleFanDrawMode: number;
  21067. /**
  21068. * Stores the clock-wise side orientation
  21069. */
  21070. static readonly ClockWiseSideOrientation: number;
  21071. /**
  21072. * Stores the counter clock-wise side orientation
  21073. */
  21074. static readonly CounterClockWiseSideOrientation: number;
  21075. /**
  21076. * The dirty texture flag value
  21077. */
  21078. static readonly TextureDirtyFlag: number;
  21079. /**
  21080. * The dirty light flag value
  21081. */
  21082. static readonly LightDirtyFlag: number;
  21083. /**
  21084. * The dirty fresnel flag value
  21085. */
  21086. static readonly FresnelDirtyFlag: number;
  21087. /**
  21088. * The dirty attribute flag value
  21089. */
  21090. static readonly AttributesDirtyFlag: number;
  21091. /**
  21092. * The dirty misc flag value
  21093. */
  21094. static readonly MiscDirtyFlag: number;
  21095. /**
  21096. * The all dirty flag value
  21097. */
  21098. static readonly AllDirtyFlag: number;
  21099. /**
  21100. * The ID of the material
  21101. */
  21102. id: string;
  21103. /**
  21104. * Gets or sets the unique id of the material
  21105. */
  21106. uniqueId: number;
  21107. /**
  21108. * The name of the material
  21109. */
  21110. name: string;
  21111. /**
  21112. * Gets or sets user defined metadata
  21113. */
  21114. metadata: any;
  21115. /**
  21116. * For internal use only. Please do not use.
  21117. */
  21118. reservedDataStore: any;
  21119. /**
  21120. * Specifies if the ready state should be checked on each call
  21121. */
  21122. checkReadyOnEveryCall: boolean;
  21123. /**
  21124. * Specifies if the ready state should be checked once
  21125. */
  21126. checkReadyOnlyOnce: boolean;
  21127. /**
  21128. * The state of the material
  21129. */
  21130. state: string;
  21131. /**
  21132. * The alpha value of the material
  21133. */
  21134. protected _alpha: number;
  21135. /**
  21136. * List of inspectable custom properties (used by the Inspector)
  21137. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21138. */
  21139. inspectableCustomProperties: IInspectable[];
  21140. /**
  21141. * Sets the alpha value of the material
  21142. */
  21143. /**
  21144. * Gets the alpha value of the material
  21145. */
  21146. alpha: number;
  21147. /**
  21148. * Specifies if back face culling is enabled
  21149. */
  21150. protected _backFaceCulling: boolean;
  21151. /**
  21152. * Sets the back-face culling state
  21153. */
  21154. /**
  21155. * Gets the back-face culling state
  21156. */
  21157. backFaceCulling: boolean;
  21158. /**
  21159. * Stores the value for side orientation
  21160. */
  21161. sideOrientation: number;
  21162. /**
  21163. * Callback triggered when the material is compiled
  21164. */
  21165. onCompiled: Nullable<(effect: Effect) => void>;
  21166. /**
  21167. * Callback triggered when an error occurs
  21168. */
  21169. onError: Nullable<(effect: Effect, errors: string) => void>;
  21170. /**
  21171. * Callback triggered to get the render target textures
  21172. */
  21173. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21174. /**
  21175. * Gets a boolean indicating that current material needs to register RTT
  21176. */
  21177. readonly hasRenderTargetTextures: boolean;
  21178. /**
  21179. * Specifies if the material should be serialized
  21180. */
  21181. doNotSerialize: boolean;
  21182. /**
  21183. * @hidden
  21184. */
  21185. _storeEffectOnSubMeshes: boolean;
  21186. /**
  21187. * Stores the animations for the material
  21188. */
  21189. animations: Nullable<Array<Animation>>;
  21190. /**
  21191. * An event triggered when the material is disposed
  21192. */
  21193. onDisposeObservable: Observable<Material>;
  21194. /**
  21195. * An observer which watches for dispose events
  21196. */
  21197. private _onDisposeObserver;
  21198. private _onUnBindObservable;
  21199. /**
  21200. * Called during a dispose event
  21201. */
  21202. onDispose: () => void;
  21203. private _onBindObservable;
  21204. /**
  21205. * An event triggered when the material is bound
  21206. */
  21207. readonly onBindObservable: Observable<AbstractMesh>;
  21208. /**
  21209. * An observer which watches for bind events
  21210. */
  21211. private _onBindObserver;
  21212. /**
  21213. * Called during a bind event
  21214. */
  21215. onBind: (Mesh: AbstractMesh) => void;
  21216. /**
  21217. * An event triggered when the material is unbound
  21218. */
  21219. readonly onUnBindObservable: Observable<Material>;
  21220. /**
  21221. * Stores the value of the alpha mode
  21222. */
  21223. private _alphaMode;
  21224. /**
  21225. * Sets the value of the alpha mode.
  21226. *
  21227. * | Value | Type | Description |
  21228. * | --- | --- | --- |
  21229. * | 0 | ALPHA_DISABLE | |
  21230. * | 1 | ALPHA_ADD | |
  21231. * | 2 | ALPHA_COMBINE | |
  21232. * | 3 | ALPHA_SUBTRACT | |
  21233. * | 4 | ALPHA_MULTIPLY | |
  21234. * | 5 | ALPHA_MAXIMIZED | |
  21235. * | 6 | ALPHA_ONEONE | |
  21236. * | 7 | ALPHA_PREMULTIPLIED | |
  21237. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21238. * | 9 | ALPHA_INTERPOLATE | |
  21239. * | 10 | ALPHA_SCREENMODE | |
  21240. *
  21241. */
  21242. /**
  21243. * Gets the value of the alpha mode
  21244. */
  21245. alphaMode: number;
  21246. /**
  21247. * Stores the state of the need depth pre-pass value
  21248. */
  21249. private _needDepthPrePass;
  21250. /**
  21251. * Sets the need depth pre-pass value
  21252. */
  21253. /**
  21254. * Gets the depth pre-pass value
  21255. */
  21256. needDepthPrePass: boolean;
  21257. /**
  21258. * Specifies if depth writing should be disabled
  21259. */
  21260. disableDepthWrite: boolean;
  21261. /**
  21262. * Specifies if depth writing should be forced
  21263. */
  21264. forceDepthWrite: boolean;
  21265. /**
  21266. * Specifies the depth function that should be used. 0 means the default engine function
  21267. */
  21268. depthFunction: number;
  21269. /**
  21270. * Specifies if there should be a separate pass for culling
  21271. */
  21272. separateCullingPass: boolean;
  21273. /**
  21274. * Stores the state specifing if fog should be enabled
  21275. */
  21276. private _fogEnabled;
  21277. /**
  21278. * Sets the state for enabling fog
  21279. */
  21280. /**
  21281. * Gets the value of the fog enabled state
  21282. */
  21283. fogEnabled: boolean;
  21284. /**
  21285. * Stores the size of points
  21286. */
  21287. pointSize: number;
  21288. /**
  21289. * Stores the z offset value
  21290. */
  21291. zOffset: number;
  21292. /**
  21293. * Gets a value specifying if wireframe mode is enabled
  21294. */
  21295. /**
  21296. * Sets the state of wireframe mode
  21297. */
  21298. wireframe: boolean;
  21299. /**
  21300. * Gets the value specifying if point clouds are enabled
  21301. */
  21302. /**
  21303. * Sets the state of point cloud mode
  21304. */
  21305. pointsCloud: boolean;
  21306. /**
  21307. * Gets the material fill mode
  21308. */
  21309. /**
  21310. * Sets the material fill mode
  21311. */
  21312. fillMode: number;
  21313. /**
  21314. * @hidden
  21315. * Stores the effects for the material
  21316. */
  21317. _effect: Nullable<Effect>;
  21318. /**
  21319. * @hidden
  21320. * Specifies if the material was previously ready
  21321. */
  21322. _wasPreviouslyReady: boolean;
  21323. /**
  21324. * Specifies if uniform buffers should be used
  21325. */
  21326. private _useUBO;
  21327. /**
  21328. * Stores a reference to the scene
  21329. */
  21330. private _scene;
  21331. /**
  21332. * Stores the fill mode state
  21333. */
  21334. private _fillMode;
  21335. /**
  21336. * Specifies if the depth write state should be cached
  21337. */
  21338. private _cachedDepthWriteState;
  21339. /**
  21340. * Specifies if the depth function state should be cached
  21341. */
  21342. private _cachedDepthFunctionState;
  21343. /**
  21344. * Stores the uniform buffer
  21345. */
  21346. protected _uniformBuffer: UniformBuffer;
  21347. /** @hidden */
  21348. _indexInSceneMaterialArray: number;
  21349. /** @hidden */
  21350. meshMap: Nullable<{
  21351. [id: string]: AbstractMesh | undefined;
  21352. }>;
  21353. /**
  21354. * Creates a material instance
  21355. * @param name defines the name of the material
  21356. * @param scene defines the scene to reference
  21357. * @param doNotAdd specifies if the material should be added to the scene
  21358. */
  21359. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21360. /**
  21361. * Returns a string representation of the current material
  21362. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21363. * @returns a string with material information
  21364. */
  21365. toString(fullDetails?: boolean): string;
  21366. /**
  21367. * Gets the class name of the material
  21368. * @returns a string with the class name of the material
  21369. */
  21370. getClassName(): string;
  21371. /**
  21372. * Specifies if updates for the material been locked
  21373. */
  21374. readonly isFrozen: boolean;
  21375. /**
  21376. * Locks updates for the material
  21377. */
  21378. freeze(): void;
  21379. /**
  21380. * Unlocks updates for the material
  21381. */
  21382. unfreeze(): void;
  21383. /**
  21384. * Specifies if the material is ready to be used
  21385. * @param mesh defines the mesh to check
  21386. * @param useInstances specifies if instances should be used
  21387. * @returns a boolean indicating if the material is ready to be used
  21388. */
  21389. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21390. /**
  21391. * Specifies that the submesh is ready to be used
  21392. * @param mesh defines the mesh to check
  21393. * @param subMesh defines which submesh to check
  21394. * @param useInstances specifies that instances should be used
  21395. * @returns a boolean indicating that the submesh is ready or not
  21396. */
  21397. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21398. /**
  21399. * Returns the material effect
  21400. * @returns the effect associated with the material
  21401. */
  21402. getEffect(): Nullable<Effect>;
  21403. /**
  21404. * Returns the current scene
  21405. * @returns a Scene
  21406. */
  21407. getScene(): Scene;
  21408. /**
  21409. * Specifies if the material will require alpha blending
  21410. * @returns a boolean specifying if alpha blending is needed
  21411. */
  21412. needAlphaBlending(): boolean;
  21413. /**
  21414. * Specifies if the mesh will require alpha blending
  21415. * @param mesh defines the mesh to check
  21416. * @returns a boolean specifying if alpha blending is needed for the mesh
  21417. */
  21418. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21419. /**
  21420. * Specifies if this material should be rendered in alpha test mode
  21421. * @returns a boolean specifying if an alpha test is needed.
  21422. */
  21423. needAlphaTesting(): boolean;
  21424. /**
  21425. * Gets the texture used for the alpha test
  21426. * @returns the texture to use for alpha testing
  21427. */
  21428. getAlphaTestTexture(): Nullable<BaseTexture>;
  21429. /**
  21430. * Marks the material to indicate that it needs to be re-calculated
  21431. */
  21432. markDirty(): void;
  21433. /** @hidden */
  21434. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21435. /**
  21436. * Binds the material to the mesh
  21437. * @param world defines the world transformation matrix
  21438. * @param mesh defines the mesh to bind the material to
  21439. */
  21440. bind(world: Matrix, mesh?: Mesh): void;
  21441. /**
  21442. * Binds the submesh to the material
  21443. * @param world defines the world transformation matrix
  21444. * @param mesh defines the mesh containing the submesh
  21445. * @param subMesh defines the submesh to bind the material to
  21446. */
  21447. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21448. /**
  21449. * Binds the world matrix to the material
  21450. * @param world defines the world transformation matrix
  21451. */
  21452. bindOnlyWorldMatrix(world: Matrix): void;
  21453. /**
  21454. * Binds the scene's uniform buffer to the effect.
  21455. * @param effect defines the effect to bind to the scene uniform buffer
  21456. * @param sceneUbo defines the uniform buffer storing scene data
  21457. */
  21458. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21459. /**
  21460. * Binds the view matrix to the effect
  21461. * @param effect defines the effect to bind the view matrix to
  21462. */
  21463. bindView(effect: Effect): void;
  21464. /**
  21465. * Binds the view projection matrix to the effect
  21466. * @param effect defines the effect to bind the view projection matrix to
  21467. */
  21468. bindViewProjection(effect: Effect): void;
  21469. /**
  21470. * Specifies if material alpha testing should be turned on for the mesh
  21471. * @param mesh defines the mesh to check
  21472. */
  21473. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21474. /**
  21475. * Processes to execute after binding the material to a mesh
  21476. * @param mesh defines the rendered mesh
  21477. */
  21478. protected _afterBind(mesh?: Mesh): void;
  21479. /**
  21480. * Unbinds the material from the mesh
  21481. */
  21482. unbind(): void;
  21483. /**
  21484. * Gets the active textures from the material
  21485. * @returns an array of textures
  21486. */
  21487. getActiveTextures(): BaseTexture[];
  21488. /**
  21489. * Specifies if the material uses a texture
  21490. * @param texture defines the texture to check against the material
  21491. * @returns a boolean specifying if the material uses the texture
  21492. */
  21493. hasTexture(texture: BaseTexture): boolean;
  21494. /**
  21495. * Makes a duplicate of the material, and gives it a new name
  21496. * @param name defines the new name for the duplicated material
  21497. * @returns the cloned material
  21498. */
  21499. clone(name: string): Nullable<Material>;
  21500. /**
  21501. * Gets the meshes bound to the material
  21502. * @returns an array of meshes bound to the material
  21503. */
  21504. getBindedMeshes(): AbstractMesh[];
  21505. /**
  21506. * Force shader compilation
  21507. * @param mesh defines the mesh associated with this material
  21508. * @param onCompiled defines a function to execute once the material is compiled
  21509. * @param options defines the options to configure the compilation
  21510. * @param onError defines a function to execute if the material fails compiling
  21511. */
  21512. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21513. /**
  21514. * Force shader compilation
  21515. * @param mesh defines the mesh that will use this material
  21516. * @param options defines additional options for compiling the shaders
  21517. * @returns a promise that resolves when the compilation completes
  21518. */
  21519. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21520. private static readonly _AllDirtyCallBack;
  21521. private static readonly _ImageProcessingDirtyCallBack;
  21522. private static readonly _TextureDirtyCallBack;
  21523. private static readonly _FresnelDirtyCallBack;
  21524. private static readonly _MiscDirtyCallBack;
  21525. private static readonly _LightsDirtyCallBack;
  21526. private static readonly _AttributeDirtyCallBack;
  21527. private static _FresnelAndMiscDirtyCallBack;
  21528. private static _TextureAndMiscDirtyCallBack;
  21529. private static readonly _DirtyCallbackArray;
  21530. private static readonly _RunDirtyCallBacks;
  21531. /**
  21532. * Marks a define in the material to indicate that it needs to be re-computed
  21533. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21534. */
  21535. markAsDirty(flag: number): void;
  21536. /**
  21537. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21538. * @param func defines a function which checks material defines against the submeshes
  21539. */
  21540. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21541. /**
  21542. * Indicates that we need to re-calculated for all submeshes
  21543. */
  21544. protected _markAllSubMeshesAsAllDirty(): void;
  21545. /**
  21546. * Indicates that image processing needs to be re-calculated for all submeshes
  21547. */
  21548. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21549. /**
  21550. * Indicates that textures need to be re-calculated for all submeshes
  21551. */
  21552. protected _markAllSubMeshesAsTexturesDirty(): void;
  21553. /**
  21554. * Indicates that fresnel needs to be re-calculated for all submeshes
  21555. */
  21556. protected _markAllSubMeshesAsFresnelDirty(): void;
  21557. /**
  21558. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21559. */
  21560. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21561. /**
  21562. * Indicates that lights need to be re-calculated for all submeshes
  21563. */
  21564. protected _markAllSubMeshesAsLightsDirty(): void;
  21565. /**
  21566. * Indicates that attributes need to be re-calculated for all submeshes
  21567. */
  21568. protected _markAllSubMeshesAsAttributesDirty(): void;
  21569. /**
  21570. * Indicates that misc needs to be re-calculated for all submeshes
  21571. */
  21572. protected _markAllSubMeshesAsMiscDirty(): void;
  21573. /**
  21574. * Indicates that textures and misc need to be re-calculated for all submeshes
  21575. */
  21576. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21577. /**
  21578. * Disposes the material
  21579. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21580. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21581. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21582. */
  21583. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21584. /** @hidden */
  21585. private releaseVertexArrayObject;
  21586. /**
  21587. * Serializes this material
  21588. * @returns the serialized material object
  21589. */
  21590. serialize(): any;
  21591. /**
  21592. * Creates a material from parsed material data
  21593. * @param parsedMaterial defines parsed material data
  21594. * @param scene defines the hosting scene
  21595. * @param rootUrl defines the root URL to use to load textures
  21596. * @returns a new material
  21597. */
  21598. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21599. }
  21600. }
  21601. declare module "babylonjs/Materials/multiMaterial" {
  21602. import { Nullable } from "babylonjs/types";
  21603. import { Scene } from "babylonjs/scene";
  21604. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21605. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21606. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21607. import { Material } from "babylonjs/Materials/material";
  21608. /**
  21609. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21610. * separate meshes. This can be use to improve performances.
  21611. * @see http://doc.babylonjs.com/how_to/multi_materials
  21612. */
  21613. export class MultiMaterial extends Material {
  21614. private _subMaterials;
  21615. /**
  21616. * Gets or Sets the list of Materials used within the multi material.
  21617. * They need to be ordered according to the submeshes order in the associated mesh
  21618. */
  21619. subMaterials: Nullable<Material>[];
  21620. /**
  21621. * Function used to align with Node.getChildren()
  21622. * @returns the list of Materials used within the multi material
  21623. */
  21624. getChildren(): Nullable<Material>[];
  21625. /**
  21626. * Instantiates a new Multi Material
  21627. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21628. * separate meshes. This can be use to improve performances.
  21629. * @see http://doc.babylonjs.com/how_to/multi_materials
  21630. * @param name Define the name in the scene
  21631. * @param scene Define the scene the material belongs to
  21632. */
  21633. constructor(name: string, scene: Scene);
  21634. private _hookArray;
  21635. /**
  21636. * Get one of the submaterial by its index in the submaterials array
  21637. * @param index The index to look the sub material at
  21638. * @returns The Material if the index has been defined
  21639. */
  21640. getSubMaterial(index: number): Nullable<Material>;
  21641. /**
  21642. * Get the list of active textures for the whole sub materials list.
  21643. * @returns All the textures that will be used during the rendering
  21644. */
  21645. getActiveTextures(): BaseTexture[];
  21646. /**
  21647. * Gets the current class name of the material e.g. "MultiMaterial"
  21648. * Mainly use in serialization.
  21649. * @returns the class name
  21650. */
  21651. getClassName(): string;
  21652. /**
  21653. * Checks if the material is ready to render the requested sub mesh
  21654. * @param mesh Define the mesh the submesh belongs to
  21655. * @param subMesh Define the sub mesh to look readyness for
  21656. * @param useInstances Define whether or not the material is used with instances
  21657. * @returns true if ready, otherwise false
  21658. */
  21659. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21660. /**
  21661. * Clones the current material and its related sub materials
  21662. * @param name Define the name of the newly cloned material
  21663. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21664. * @returns the cloned material
  21665. */
  21666. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21667. /**
  21668. * Serializes the materials into a JSON representation.
  21669. * @returns the JSON representation
  21670. */
  21671. serialize(): any;
  21672. /**
  21673. * Dispose the material and release its associated resources
  21674. * @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)
  21675. * @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)
  21676. * @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)
  21677. */
  21678. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21679. /**
  21680. * Creates a MultiMaterial from parsed MultiMaterial data.
  21681. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21682. * @param scene defines the hosting scene
  21683. * @returns a new MultiMaterial
  21684. */
  21685. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21686. }
  21687. }
  21688. declare module "babylonjs/Meshes/subMesh" {
  21689. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21690. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21691. import { Engine } from "babylonjs/Engines/engine";
  21692. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21693. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21694. import { Effect } from "babylonjs/Materials/effect";
  21695. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21696. import { Plane } from "babylonjs/Maths/math.plane";
  21697. import { Collider } from "babylonjs/Collisions/collider";
  21698. import { Material } from "babylonjs/Materials/material";
  21699. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21700. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21701. import { Mesh } from "babylonjs/Meshes/mesh";
  21702. import { Ray } from "babylonjs/Culling/ray";
  21703. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21704. /**
  21705. * Base class for submeshes
  21706. */
  21707. export class BaseSubMesh {
  21708. /** @hidden */
  21709. _materialDefines: Nullable<MaterialDefines>;
  21710. /** @hidden */
  21711. _materialEffect: Nullable<Effect>;
  21712. /**
  21713. * Gets material defines used by the effect associated to the sub mesh
  21714. */
  21715. /**
  21716. * Sets material defines used by the effect associated to the sub mesh
  21717. */
  21718. materialDefines: Nullable<MaterialDefines>;
  21719. /**
  21720. * Gets associated effect
  21721. */
  21722. readonly effect: Nullable<Effect>;
  21723. /**
  21724. * Sets associated effect (effect used to render this submesh)
  21725. * @param effect defines the effect to associate with
  21726. * @param defines defines the set of defines used to compile this effect
  21727. */
  21728. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21729. }
  21730. /**
  21731. * Defines a subdivision inside a mesh
  21732. */
  21733. export class SubMesh extends BaseSubMesh implements ICullable {
  21734. /** the material index to use */
  21735. materialIndex: number;
  21736. /** vertex index start */
  21737. verticesStart: number;
  21738. /** vertices count */
  21739. verticesCount: number;
  21740. /** index start */
  21741. indexStart: number;
  21742. /** indices count */
  21743. indexCount: number;
  21744. /** @hidden */
  21745. _linesIndexCount: number;
  21746. private _mesh;
  21747. private _renderingMesh;
  21748. private _boundingInfo;
  21749. private _linesIndexBuffer;
  21750. /** @hidden */
  21751. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21752. /** @hidden */
  21753. _trianglePlanes: Plane[];
  21754. /** @hidden */
  21755. _lastColliderTransformMatrix: Nullable<Matrix>;
  21756. /** @hidden */
  21757. _renderId: number;
  21758. /** @hidden */
  21759. _alphaIndex: number;
  21760. /** @hidden */
  21761. _distanceToCamera: number;
  21762. /** @hidden */
  21763. _id: number;
  21764. private _currentMaterial;
  21765. /**
  21766. * Add a new submesh to a mesh
  21767. * @param materialIndex defines the material index to use
  21768. * @param verticesStart defines vertex index start
  21769. * @param verticesCount defines vertices count
  21770. * @param indexStart defines index start
  21771. * @param indexCount defines indices count
  21772. * @param mesh defines the parent mesh
  21773. * @param renderingMesh defines an optional rendering mesh
  21774. * @param createBoundingBox defines if bounding box should be created for this submesh
  21775. * @returns the new submesh
  21776. */
  21777. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21778. /**
  21779. * Creates a new submesh
  21780. * @param materialIndex defines the material index to use
  21781. * @param verticesStart defines vertex index start
  21782. * @param verticesCount defines vertices count
  21783. * @param indexStart defines index start
  21784. * @param indexCount defines indices count
  21785. * @param mesh defines the parent mesh
  21786. * @param renderingMesh defines an optional rendering mesh
  21787. * @param createBoundingBox defines if bounding box should be created for this submesh
  21788. */
  21789. constructor(
  21790. /** the material index to use */
  21791. materialIndex: number,
  21792. /** vertex index start */
  21793. verticesStart: number,
  21794. /** vertices count */
  21795. verticesCount: number,
  21796. /** index start */
  21797. indexStart: number,
  21798. /** indices count */
  21799. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21800. /**
  21801. * Returns true if this submesh covers the entire parent mesh
  21802. * @ignorenaming
  21803. */
  21804. readonly IsGlobal: boolean;
  21805. /**
  21806. * Returns the submesh BoudingInfo object
  21807. * @returns current bounding info (or mesh's one if the submesh is global)
  21808. */
  21809. getBoundingInfo(): BoundingInfo;
  21810. /**
  21811. * Sets the submesh BoundingInfo
  21812. * @param boundingInfo defines the new bounding info to use
  21813. * @returns the SubMesh
  21814. */
  21815. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21816. /**
  21817. * Returns the mesh of the current submesh
  21818. * @return the parent mesh
  21819. */
  21820. getMesh(): AbstractMesh;
  21821. /**
  21822. * Returns the rendering mesh of the submesh
  21823. * @returns the rendering mesh (could be different from parent mesh)
  21824. */
  21825. getRenderingMesh(): Mesh;
  21826. /**
  21827. * Returns the submesh material
  21828. * @returns null or the current material
  21829. */
  21830. getMaterial(): Nullable<Material>;
  21831. /**
  21832. * Sets a new updated BoundingInfo object to the submesh
  21833. * @param data defines an optional position array to use to determine the bounding info
  21834. * @returns the SubMesh
  21835. */
  21836. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21837. /** @hidden */
  21838. _checkCollision(collider: Collider): boolean;
  21839. /**
  21840. * Updates the submesh BoundingInfo
  21841. * @param world defines the world matrix to use to update the bounding info
  21842. * @returns the submesh
  21843. */
  21844. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21845. /**
  21846. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21847. * @param frustumPlanes defines the frustum planes
  21848. * @returns true if the submesh is intersecting with the frustum
  21849. */
  21850. isInFrustum(frustumPlanes: Plane[]): boolean;
  21851. /**
  21852. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21853. * @param frustumPlanes defines the frustum planes
  21854. * @returns true if the submesh is inside the frustum
  21855. */
  21856. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21857. /**
  21858. * Renders the submesh
  21859. * @param enableAlphaMode defines if alpha needs to be used
  21860. * @returns the submesh
  21861. */
  21862. render(enableAlphaMode: boolean): SubMesh;
  21863. /**
  21864. * @hidden
  21865. */
  21866. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21867. /**
  21868. * Checks if the submesh intersects with a ray
  21869. * @param ray defines the ray to test
  21870. * @returns true is the passed ray intersects the submesh bounding box
  21871. */
  21872. canIntersects(ray: Ray): boolean;
  21873. /**
  21874. * Intersects current submesh with a ray
  21875. * @param ray defines the ray to test
  21876. * @param positions defines mesh's positions array
  21877. * @param indices defines mesh's indices array
  21878. * @param fastCheck defines if only bounding info should be used
  21879. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21880. * @returns intersection info or null if no intersection
  21881. */
  21882. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21883. /** @hidden */
  21884. private _intersectLines;
  21885. /** @hidden */
  21886. private _intersectUnIndexedLines;
  21887. /** @hidden */
  21888. private _intersectTriangles;
  21889. /** @hidden */
  21890. private _intersectUnIndexedTriangles;
  21891. /** @hidden */
  21892. _rebuild(): void;
  21893. /**
  21894. * Creates a new submesh from the passed mesh
  21895. * @param newMesh defines the new hosting mesh
  21896. * @param newRenderingMesh defines an optional rendering mesh
  21897. * @returns the new submesh
  21898. */
  21899. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21900. /**
  21901. * Release associated resources
  21902. */
  21903. dispose(): void;
  21904. /**
  21905. * Gets the class name
  21906. * @returns the string "SubMesh".
  21907. */
  21908. getClassName(): string;
  21909. /**
  21910. * Creates a new submesh from indices data
  21911. * @param materialIndex the index of the main mesh material
  21912. * @param startIndex the index where to start the copy in the mesh indices array
  21913. * @param indexCount the number of indices to copy then from the startIndex
  21914. * @param mesh the main mesh to create the submesh from
  21915. * @param renderingMesh the optional rendering mesh
  21916. * @returns a new submesh
  21917. */
  21918. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21919. }
  21920. }
  21921. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21922. /**
  21923. * Class used to represent data loading progression
  21924. */
  21925. export class SceneLoaderFlags {
  21926. private static _ForceFullSceneLoadingForIncremental;
  21927. private static _ShowLoadingScreen;
  21928. private static _CleanBoneMatrixWeights;
  21929. private static _loggingLevel;
  21930. /**
  21931. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21932. */
  21933. static ForceFullSceneLoadingForIncremental: boolean;
  21934. /**
  21935. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21936. */
  21937. static ShowLoadingScreen: boolean;
  21938. /**
  21939. * Defines the current logging level (while loading the scene)
  21940. * @ignorenaming
  21941. */
  21942. static loggingLevel: number;
  21943. /**
  21944. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21945. */
  21946. static CleanBoneMatrixWeights: boolean;
  21947. }
  21948. }
  21949. declare module "babylonjs/Meshes/geometry" {
  21950. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21951. import { Scene } from "babylonjs/scene";
  21952. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21953. import { Engine } from "babylonjs/Engines/engine";
  21954. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21955. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21956. import { Effect } from "babylonjs/Materials/effect";
  21957. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21958. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21959. import { Mesh } from "babylonjs/Meshes/mesh";
  21960. /**
  21961. * Class used to store geometry data (vertex buffers + index buffer)
  21962. */
  21963. export class Geometry implements IGetSetVerticesData {
  21964. /**
  21965. * Gets or sets the ID of the geometry
  21966. */
  21967. id: string;
  21968. /**
  21969. * Gets or sets the unique ID of the geometry
  21970. */
  21971. uniqueId: number;
  21972. /**
  21973. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21974. */
  21975. delayLoadState: number;
  21976. /**
  21977. * Gets the file containing the data to load when running in delay load state
  21978. */
  21979. delayLoadingFile: Nullable<string>;
  21980. /**
  21981. * Callback called when the geometry is updated
  21982. */
  21983. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21984. private _scene;
  21985. private _engine;
  21986. private _meshes;
  21987. private _totalVertices;
  21988. /** @hidden */
  21989. _indices: IndicesArray;
  21990. /** @hidden */
  21991. _vertexBuffers: {
  21992. [key: string]: VertexBuffer;
  21993. };
  21994. private _isDisposed;
  21995. private _extend;
  21996. private _boundingBias;
  21997. /** @hidden */
  21998. _delayInfo: Array<string>;
  21999. private _indexBuffer;
  22000. private _indexBufferIsUpdatable;
  22001. /** @hidden */
  22002. _boundingInfo: Nullable<BoundingInfo>;
  22003. /** @hidden */
  22004. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22005. /** @hidden */
  22006. _softwareSkinningFrameId: number;
  22007. private _vertexArrayObjects;
  22008. private _updatable;
  22009. /** @hidden */
  22010. _positions: Nullable<Vector3[]>;
  22011. /**
  22012. * 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
  22013. */
  22014. /**
  22015. * 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
  22016. */
  22017. boundingBias: Vector2;
  22018. /**
  22019. * Static function used to attach a new empty geometry to a mesh
  22020. * @param mesh defines the mesh to attach the geometry to
  22021. * @returns the new Geometry
  22022. */
  22023. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22024. /**
  22025. * Creates a new geometry
  22026. * @param id defines the unique ID
  22027. * @param scene defines the hosting scene
  22028. * @param vertexData defines the VertexData used to get geometry data
  22029. * @param updatable defines if geometry must be updatable (false by default)
  22030. * @param mesh defines the mesh that will be associated with the geometry
  22031. */
  22032. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22033. /**
  22034. * Gets the current extend of the geometry
  22035. */
  22036. readonly extend: {
  22037. minimum: Vector3;
  22038. maximum: Vector3;
  22039. };
  22040. /**
  22041. * Gets the hosting scene
  22042. * @returns the hosting Scene
  22043. */
  22044. getScene(): Scene;
  22045. /**
  22046. * Gets the hosting engine
  22047. * @returns the hosting Engine
  22048. */
  22049. getEngine(): Engine;
  22050. /**
  22051. * Defines if the geometry is ready to use
  22052. * @returns true if the geometry is ready to be used
  22053. */
  22054. isReady(): boolean;
  22055. /**
  22056. * Gets a value indicating that the geometry should not be serialized
  22057. */
  22058. readonly doNotSerialize: boolean;
  22059. /** @hidden */
  22060. _rebuild(): void;
  22061. /**
  22062. * Affects all geometry data in one call
  22063. * @param vertexData defines the geometry data
  22064. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22065. */
  22066. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22067. /**
  22068. * Set specific vertex data
  22069. * @param kind defines the data kind (Position, normal, etc...)
  22070. * @param data defines the vertex data to use
  22071. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22072. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22073. */
  22074. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22075. /**
  22076. * Removes a specific vertex data
  22077. * @param kind defines the data kind (Position, normal, etc...)
  22078. */
  22079. removeVerticesData(kind: string): void;
  22080. /**
  22081. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22082. * @param buffer defines the vertex buffer to use
  22083. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22084. */
  22085. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22086. /**
  22087. * Update a specific vertex buffer
  22088. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22089. * It will do nothing if the buffer is not updatable
  22090. * @param kind defines the data kind (Position, normal, etc...)
  22091. * @param data defines the data to use
  22092. * @param offset defines the offset in the target buffer where to store the data
  22093. * @param useBytes set to true if the offset is in bytes
  22094. */
  22095. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22096. /**
  22097. * Update a specific vertex buffer
  22098. * This function will create a new buffer if the current one is not updatable
  22099. * @param kind defines the data kind (Position, normal, etc...)
  22100. * @param data defines the data to use
  22101. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22102. */
  22103. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22104. private _updateBoundingInfo;
  22105. /** @hidden */
  22106. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22107. /**
  22108. * Gets total number of vertices
  22109. * @returns the total number of vertices
  22110. */
  22111. getTotalVertices(): number;
  22112. /**
  22113. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22114. * @param kind defines the data kind (Position, normal, etc...)
  22115. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22116. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22117. * @returns a float array containing vertex data
  22118. */
  22119. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22120. /**
  22121. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22122. * @param kind defines the data kind (Position, normal, etc...)
  22123. * @returns true if the vertex buffer with the specified kind is updatable
  22124. */
  22125. isVertexBufferUpdatable(kind: string): boolean;
  22126. /**
  22127. * Gets a specific vertex buffer
  22128. * @param kind defines the data kind (Position, normal, etc...)
  22129. * @returns a VertexBuffer
  22130. */
  22131. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22132. /**
  22133. * Returns all vertex buffers
  22134. * @return an object holding all vertex buffers indexed by kind
  22135. */
  22136. getVertexBuffers(): Nullable<{
  22137. [key: string]: VertexBuffer;
  22138. }>;
  22139. /**
  22140. * Gets a boolean indicating if specific vertex buffer is present
  22141. * @param kind defines the data kind (Position, normal, etc...)
  22142. * @returns true if data is present
  22143. */
  22144. isVerticesDataPresent(kind: string): boolean;
  22145. /**
  22146. * Gets a list of all attached data kinds (Position, normal, etc...)
  22147. * @returns a list of string containing all kinds
  22148. */
  22149. getVerticesDataKinds(): string[];
  22150. /**
  22151. * Update index buffer
  22152. * @param indices defines the indices to store in the index buffer
  22153. * @param offset defines the offset in the target buffer where to store the data
  22154. * @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)
  22155. */
  22156. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22157. /**
  22158. * Creates a new index buffer
  22159. * @param indices defines the indices to store in the index buffer
  22160. * @param totalVertices defines the total number of vertices (could be null)
  22161. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22162. */
  22163. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22164. /**
  22165. * Return the total number of indices
  22166. * @returns the total number of indices
  22167. */
  22168. getTotalIndices(): number;
  22169. /**
  22170. * Gets the index buffer array
  22171. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22172. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22173. * @returns the index buffer array
  22174. */
  22175. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22176. /**
  22177. * Gets the index buffer
  22178. * @return the index buffer
  22179. */
  22180. getIndexBuffer(): Nullable<DataBuffer>;
  22181. /** @hidden */
  22182. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22183. /**
  22184. * Release the associated resources for a specific mesh
  22185. * @param mesh defines the source mesh
  22186. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22187. */
  22188. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22189. /**
  22190. * Apply current geometry to a given mesh
  22191. * @param mesh defines the mesh to apply geometry to
  22192. */
  22193. applyToMesh(mesh: Mesh): void;
  22194. private _updateExtend;
  22195. private _applyToMesh;
  22196. private notifyUpdate;
  22197. /**
  22198. * Load the geometry if it was flagged as delay loaded
  22199. * @param scene defines the hosting scene
  22200. * @param onLoaded defines a callback called when the geometry is loaded
  22201. */
  22202. load(scene: Scene, onLoaded?: () => void): void;
  22203. private _queueLoad;
  22204. /**
  22205. * Invert the geometry to move from a right handed system to a left handed one.
  22206. */
  22207. toLeftHanded(): void;
  22208. /** @hidden */
  22209. _resetPointsArrayCache(): void;
  22210. /** @hidden */
  22211. _generatePointsArray(): boolean;
  22212. /**
  22213. * Gets a value indicating if the geometry is disposed
  22214. * @returns true if the geometry was disposed
  22215. */
  22216. isDisposed(): boolean;
  22217. private _disposeVertexArrayObjects;
  22218. /**
  22219. * Free all associated resources
  22220. */
  22221. dispose(): void;
  22222. /**
  22223. * Clone the current geometry into a new geometry
  22224. * @param id defines the unique ID of the new geometry
  22225. * @returns a new geometry object
  22226. */
  22227. copy(id: string): Geometry;
  22228. /**
  22229. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22230. * @return a JSON representation of the current geometry data (without the vertices data)
  22231. */
  22232. serialize(): any;
  22233. private toNumberArray;
  22234. /**
  22235. * Serialize all vertices data into a JSON oject
  22236. * @returns a JSON representation of the current geometry data
  22237. */
  22238. serializeVerticeData(): any;
  22239. /**
  22240. * Extracts a clone of a mesh geometry
  22241. * @param mesh defines the source mesh
  22242. * @param id defines the unique ID of the new geometry object
  22243. * @returns the new geometry object
  22244. */
  22245. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22246. /**
  22247. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22248. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22249. * Be aware Math.random() could cause collisions, but:
  22250. * "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"
  22251. * @returns a string containing a new GUID
  22252. */
  22253. static RandomId(): string;
  22254. /** @hidden */
  22255. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22256. private static _CleanMatricesWeights;
  22257. /**
  22258. * Create a new geometry from persisted data (Using .babylon file format)
  22259. * @param parsedVertexData defines the persisted data
  22260. * @param scene defines the hosting scene
  22261. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22262. * @returns the new geometry object
  22263. */
  22264. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22265. }
  22266. }
  22267. declare module "babylonjs/Meshes/mesh.vertexData" {
  22268. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22269. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  22270. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  22271. import { Geometry } from "babylonjs/Meshes/geometry";
  22272. import { Mesh } from "babylonjs/Meshes/mesh";
  22273. /**
  22274. * Define an interface for all classes that will get and set the data on vertices
  22275. */
  22276. export interface IGetSetVerticesData {
  22277. /**
  22278. * Gets a boolean indicating if specific vertex data is present
  22279. * @param kind defines the vertex data kind to use
  22280. * @returns true is data kind is present
  22281. */
  22282. isVerticesDataPresent(kind: string): boolean;
  22283. /**
  22284. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22285. * @param kind defines the data kind (Position, normal, etc...)
  22286. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22287. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22288. * @returns a float array containing vertex data
  22289. */
  22290. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22291. /**
  22292. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22293. * @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.
  22294. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22295. * @returns the indices array or an empty array if the mesh has no geometry
  22296. */
  22297. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22298. /**
  22299. * Set specific vertex data
  22300. * @param kind defines the data kind (Position, normal, etc...)
  22301. * @param data defines the vertex data to use
  22302. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22303. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22304. */
  22305. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22306. /**
  22307. * Update a specific associated vertex buffer
  22308. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22309. * - VertexBuffer.PositionKind
  22310. * - VertexBuffer.UVKind
  22311. * - VertexBuffer.UV2Kind
  22312. * - VertexBuffer.UV3Kind
  22313. * - VertexBuffer.UV4Kind
  22314. * - VertexBuffer.UV5Kind
  22315. * - VertexBuffer.UV6Kind
  22316. * - VertexBuffer.ColorKind
  22317. * - VertexBuffer.MatricesIndicesKind
  22318. * - VertexBuffer.MatricesIndicesExtraKind
  22319. * - VertexBuffer.MatricesWeightsKind
  22320. * - VertexBuffer.MatricesWeightsExtraKind
  22321. * @param data defines the data source
  22322. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22323. * @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)
  22324. */
  22325. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22326. /**
  22327. * Creates a new index buffer
  22328. * @param indices defines the indices to store in the index buffer
  22329. * @param totalVertices defines the total number of vertices (could be null)
  22330. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22331. */
  22332. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22333. }
  22334. /**
  22335. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22336. */
  22337. export class VertexData {
  22338. /**
  22339. * Mesh side orientation : usually the external or front surface
  22340. */
  22341. static readonly FRONTSIDE: number;
  22342. /**
  22343. * Mesh side orientation : usually the internal or back surface
  22344. */
  22345. static readonly BACKSIDE: number;
  22346. /**
  22347. * Mesh side orientation : both internal and external or front and back surfaces
  22348. */
  22349. static readonly DOUBLESIDE: number;
  22350. /**
  22351. * Mesh side orientation : by default, `FRONTSIDE`
  22352. */
  22353. static readonly DEFAULTSIDE: number;
  22354. /**
  22355. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22356. */
  22357. positions: Nullable<FloatArray>;
  22358. /**
  22359. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22360. */
  22361. normals: Nullable<FloatArray>;
  22362. /**
  22363. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22364. */
  22365. tangents: Nullable<FloatArray>;
  22366. /**
  22367. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22368. */
  22369. uvs: Nullable<FloatArray>;
  22370. /**
  22371. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22372. */
  22373. uvs2: Nullable<FloatArray>;
  22374. /**
  22375. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22376. */
  22377. uvs3: Nullable<FloatArray>;
  22378. /**
  22379. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22380. */
  22381. uvs4: Nullable<FloatArray>;
  22382. /**
  22383. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22384. */
  22385. uvs5: Nullable<FloatArray>;
  22386. /**
  22387. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22388. */
  22389. uvs6: Nullable<FloatArray>;
  22390. /**
  22391. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22392. */
  22393. colors: Nullable<FloatArray>;
  22394. /**
  22395. * 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).
  22396. */
  22397. matricesIndices: Nullable<FloatArray>;
  22398. /**
  22399. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22400. */
  22401. matricesWeights: Nullable<FloatArray>;
  22402. /**
  22403. * An array extending the number of possible indices
  22404. */
  22405. matricesIndicesExtra: Nullable<FloatArray>;
  22406. /**
  22407. * An array extending the number of possible weights when the number of indices is extended
  22408. */
  22409. matricesWeightsExtra: Nullable<FloatArray>;
  22410. /**
  22411. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22412. */
  22413. indices: Nullable<IndicesArray>;
  22414. /**
  22415. * Uses the passed data array to set the set the values for the specified kind of data
  22416. * @param data a linear array of floating numbers
  22417. * @param kind the type of data that is being set, eg positions, colors etc
  22418. */
  22419. set(data: FloatArray, kind: string): void;
  22420. /**
  22421. * Associates the vertexData to the passed Mesh.
  22422. * Sets it as updatable or not (default `false`)
  22423. * @param mesh the mesh the vertexData is applied to
  22424. * @param updatable when used and having the value true allows new data to update the vertexData
  22425. * @returns the VertexData
  22426. */
  22427. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22428. /**
  22429. * Associates the vertexData to the passed Geometry.
  22430. * Sets it as updatable or not (default `false`)
  22431. * @param geometry the geometry the vertexData is applied to
  22432. * @param updatable when used and having the value true allows new data to update the vertexData
  22433. * @returns VertexData
  22434. */
  22435. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22436. /**
  22437. * Updates the associated mesh
  22438. * @param mesh the mesh to be updated
  22439. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22440. * @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
  22441. * @returns VertexData
  22442. */
  22443. updateMesh(mesh: Mesh): VertexData;
  22444. /**
  22445. * Updates the associated geometry
  22446. * @param geometry the geometry to be updated
  22447. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22448. * @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
  22449. * @returns VertexData.
  22450. */
  22451. updateGeometry(geometry: Geometry): VertexData;
  22452. private _applyTo;
  22453. private _update;
  22454. /**
  22455. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22456. * @param matrix the transforming matrix
  22457. * @returns the VertexData
  22458. */
  22459. transform(matrix: Matrix): VertexData;
  22460. /**
  22461. * Merges the passed VertexData into the current one
  22462. * @param other the VertexData to be merged into the current one
  22463. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22464. * @returns the modified VertexData
  22465. */
  22466. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22467. private _mergeElement;
  22468. private _validate;
  22469. /**
  22470. * Serializes the VertexData
  22471. * @returns a serialized object
  22472. */
  22473. serialize(): any;
  22474. /**
  22475. * Extracts the vertexData from a mesh
  22476. * @param mesh the mesh from which to extract the VertexData
  22477. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22478. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22479. * @returns the object VertexData associated to the passed mesh
  22480. */
  22481. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22482. /**
  22483. * Extracts the vertexData from the geometry
  22484. * @param geometry the geometry from which to extract the VertexData
  22485. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22486. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22487. * @returns the object VertexData associated to the passed mesh
  22488. */
  22489. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22490. private static _ExtractFrom;
  22491. /**
  22492. * Creates the VertexData for a Ribbon
  22493. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22494. * * pathArray array of paths, each of which an array of successive Vector3
  22495. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22496. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22497. * * 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
  22498. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22499. * * 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)
  22500. * * 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)
  22501. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22502. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22503. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22504. * @returns the VertexData of the ribbon
  22505. */
  22506. static CreateRibbon(options: {
  22507. pathArray: Vector3[][];
  22508. closeArray?: boolean;
  22509. closePath?: boolean;
  22510. offset?: number;
  22511. sideOrientation?: number;
  22512. frontUVs?: Vector4;
  22513. backUVs?: Vector4;
  22514. invertUV?: boolean;
  22515. uvs?: Vector2[];
  22516. colors?: Color4[];
  22517. }): VertexData;
  22518. /**
  22519. * Creates the VertexData for a box
  22520. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22521. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22522. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22523. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22524. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22525. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22526. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22527. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22528. * * 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)
  22529. * * 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)
  22530. * @returns the VertexData of the box
  22531. */
  22532. static CreateBox(options: {
  22533. size?: number;
  22534. width?: number;
  22535. height?: number;
  22536. depth?: number;
  22537. faceUV?: Vector4[];
  22538. faceColors?: Color4[];
  22539. sideOrientation?: number;
  22540. frontUVs?: Vector4;
  22541. backUVs?: Vector4;
  22542. }): VertexData;
  22543. /**
  22544. * Creates the VertexData for a tiled box
  22545. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22546. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22547. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22548. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22549. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22550. * @returns the VertexData of the box
  22551. */
  22552. static CreateTiledBox(options: {
  22553. pattern?: number;
  22554. width?: number;
  22555. height?: number;
  22556. depth?: number;
  22557. tileSize?: number;
  22558. tileWidth?: number;
  22559. tileHeight?: number;
  22560. alignHorizontal?: number;
  22561. alignVertical?: number;
  22562. faceUV?: Vector4[];
  22563. faceColors?: Color4[];
  22564. sideOrientation?: number;
  22565. }): VertexData;
  22566. /**
  22567. * Creates the VertexData for a tiled plane
  22568. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22569. * * pattern a limited pattern arrangement depending on the number
  22570. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22571. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22572. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22573. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22574. * * 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)
  22575. * * 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)
  22576. * @returns the VertexData of the tiled plane
  22577. */
  22578. static CreateTiledPlane(options: {
  22579. pattern?: number;
  22580. tileSize?: number;
  22581. tileWidth?: number;
  22582. tileHeight?: number;
  22583. size?: number;
  22584. width?: number;
  22585. height?: number;
  22586. alignHorizontal?: number;
  22587. alignVertical?: number;
  22588. sideOrientation?: number;
  22589. frontUVs?: Vector4;
  22590. backUVs?: Vector4;
  22591. }): VertexData;
  22592. /**
  22593. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22594. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22595. * * segments sets the number of horizontal strips optional, default 32
  22596. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22597. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22598. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22599. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22600. * * 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
  22601. * * 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
  22602. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22603. * * 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)
  22604. * * 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)
  22605. * @returns the VertexData of the ellipsoid
  22606. */
  22607. static CreateSphere(options: {
  22608. segments?: number;
  22609. diameter?: number;
  22610. diameterX?: number;
  22611. diameterY?: number;
  22612. diameterZ?: number;
  22613. arc?: number;
  22614. slice?: number;
  22615. sideOrientation?: number;
  22616. frontUVs?: Vector4;
  22617. backUVs?: Vector4;
  22618. }): VertexData;
  22619. /**
  22620. * Creates the VertexData for a cylinder, cone or prism
  22621. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22622. * * height sets the height (y direction) of the cylinder, optional, default 2
  22623. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22624. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22625. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22626. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22627. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22628. * * 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
  22629. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22630. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22631. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22632. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22633. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22634. * * 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)
  22635. * * 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)
  22636. * @returns the VertexData of the cylinder, cone or prism
  22637. */
  22638. static CreateCylinder(options: {
  22639. height?: number;
  22640. diameterTop?: number;
  22641. diameterBottom?: number;
  22642. diameter?: number;
  22643. tessellation?: number;
  22644. subdivisions?: number;
  22645. arc?: number;
  22646. faceColors?: Color4[];
  22647. faceUV?: Vector4[];
  22648. hasRings?: boolean;
  22649. enclose?: boolean;
  22650. sideOrientation?: number;
  22651. frontUVs?: Vector4;
  22652. backUVs?: Vector4;
  22653. }): VertexData;
  22654. /**
  22655. * Creates the VertexData for a torus
  22656. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22657. * * diameter the diameter of the torus, optional default 1
  22658. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22659. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22660. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22661. * * 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)
  22662. * * 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)
  22663. * @returns the VertexData of the torus
  22664. */
  22665. static CreateTorus(options: {
  22666. diameter?: number;
  22667. thickness?: number;
  22668. tessellation?: number;
  22669. sideOrientation?: number;
  22670. frontUVs?: Vector4;
  22671. backUVs?: Vector4;
  22672. }): VertexData;
  22673. /**
  22674. * Creates the VertexData of the LineSystem
  22675. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22676. * - lines an array of lines, each line being an array of successive Vector3
  22677. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22678. * @returns the VertexData of the LineSystem
  22679. */
  22680. static CreateLineSystem(options: {
  22681. lines: Vector3[][];
  22682. colors?: Nullable<Color4[][]>;
  22683. }): VertexData;
  22684. /**
  22685. * Create the VertexData for a DashedLines
  22686. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22687. * - points an array successive Vector3
  22688. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22689. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22690. * - dashNb the intended total number of dashes, optional, default 200
  22691. * @returns the VertexData for the DashedLines
  22692. */
  22693. static CreateDashedLines(options: {
  22694. points: Vector3[];
  22695. dashSize?: number;
  22696. gapSize?: number;
  22697. dashNb?: number;
  22698. }): VertexData;
  22699. /**
  22700. * Creates the VertexData for a Ground
  22701. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22702. * - width the width (x direction) of the ground, optional, default 1
  22703. * - height the height (z direction) of the ground, optional, default 1
  22704. * - subdivisions the number of subdivisions per side, optional, default 1
  22705. * @returns the VertexData of the Ground
  22706. */
  22707. static CreateGround(options: {
  22708. width?: number;
  22709. height?: number;
  22710. subdivisions?: number;
  22711. subdivisionsX?: number;
  22712. subdivisionsY?: number;
  22713. }): VertexData;
  22714. /**
  22715. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22716. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22717. * * xmin the ground minimum X coordinate, optional, default -1
  22718. * * zmin the ground minimum Z coordinate, optional, default -1
  22719. * * xmax the ground maximum X coordinate, optional, default 1
  22720. * * zmax the ground maximum Z coordinate, optional, default 1
  22721. * * 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}
  22722. * * 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}
  22723. * @returns the VertexData of the TiledGround
  22724. */
  22725. static CreateTiledGround(options: {
  22726. xmin: number;
  22727. zmin: number;
  22728. xmax: number;
  22729. zmax: number;
  22730. subdivisions?: {
  22731. w: number;
  22732. h: number;
  22733. };
  22734. precision?: {
  22735. w: number;
  22736. h: number;
  22737. };
  22738. }): VertexData;
  22739. /**
  22740. * Creates the VertexData of the Ground designed from a heightmap
  22741. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22742. * * width the width (x direction) of the ground
  22743. * * height the height (z direction) of the ground
  22744. * * subdivisions the number of subdivisions per side
  22745. * * minHeight the minimum altitude on the ground, optional, default 0
  22746. * * maxHeight the maximum altitude on the ground, optional default 1
  22747. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22748. * * buffer the array holding the image color data
  22749. * * bufferWidth the width of image
  22750. * * bufferHeight the height of image
  22751. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22752. * @returns the VertexData of the Ground designed from a heightmap
  22753. */
  22754. static CreateGroundFromHeightMap(options: {
  22755. width: number;
  22756. height: number;
  22757. subdivisions: number;
  22758. minHeight: number;
  22759. maxHeight: number;
  22760. colorFilter: Color3;
  22761. buffer: Uint8Array;
  22762. bufferWidth: number;
  22763. bufferHeight: number;
  22764. alphaFilter: number;
  22765. }): VertexData;
  22766. /**
  22767. * Creates the VertexData for a Plane
  22768. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22769. * * size sets the width and height of the plane to the value of size, optional default 1
  22770. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22771. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22772. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22773. * * 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)
  22774. * * 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)
  22775. * @returns the VertexData of the box
  22776. */
  22777. static CreatePlane(options: {
  22778. size?: number;
  22779. width?: number;
  22780. height?: number;
  22781. sideOrientation?: number;
  22782. frontUVs?: Vector4;
  22783. backUVs?: Vector4;
  22784. }): VertexData;
  22785. /**
  22786. * Creates the VertexData of the Disc or regular Polygon
  22787. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22788. * * radius the radius of the disc, optional default 0.5
  22789. * * tessellation the number of polygon sides, optional, default 64
  22790. * * 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
  22791. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22792. * * 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)
  22793. * * 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)
  22794. * @returns the VertexData of the box
  22795. */
  22796. static CreateDisc(options: {
  22797. radius?: number;
  22798. tessellation?: number;
  22799. arc?: number;
  22800. sideOrientation?: number;
  22801. frontUVs?: Vector4;
  22802. backUVs?: Vector4;
  22803. }): VertexData;
  22804. /**
  22805. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22806. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22807. * @param polygon a mesh built from polygonTriangulation.build()
  22808. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22809. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22810. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22811. * @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)
  22812. * @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)
  22813. * @returns the VertexData of the Polygon
  22814. */
  22815. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22816. /**
  22817. * Creates the VertexData of the IcoSphere
  22818. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22819. * * radius the radius of the IcoSphere, optional default 1
  22820. * * radiusX allows stretching in the x direction, optional, default radius
  22821. * * radiusY allows stretching in the y direction, optional, default radius
  22822. * * radiusZ allows stretching in the z direction, optional, default radius
  22823. * * flat when true creates a flat shaded mesh, optional, default true
  22824. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22825. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22826. * * 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)
  22827. * * 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)
  22828. * @returns the VertexData of the IcoSphere
  22829. */
  22830. static CreateIcoSphere(options: {
  22831. radius?: number;
  22832. radiusX?: number;
  22833. radiusY?: number;
  22834. radiusZ?: number;
  22835. flat?: boolean;
  22836. subdivisions?: number;
  22837. sideOrientation?: number;
  22838. frontUVs?: Vector4;
  22839. backUVs?: Vector4;
  22840. }): VertexData;
  22841. /**
  22842. * Creates the VertexData for a Polyhedron
  22843. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22844. * * type provided types are:
  22845. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22846. * * 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)
  22847. * * size the size of the IcoSphere, optional default 1
  22848. * * sizeX allows stretching in the x direction, optional, default size
  22849. * * sizeY allows stretching in the y direction, optional, default size
  22850. * * sizeZ allows stretching in the z direction, optional, default size
  22851. * * 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
  22852. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22853. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22854. * * flat when true creates a flat shaded mesh, optional, default true
  22855. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22856. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22857. * * 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)
  22858. * * 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)
  22859. * @returns the VertexData of the Polyhedron
  22860. */
  22861. static CreatePolyhedron(options: {
  22862. type?: number;
  22863. size?: number;
  22864. sizeX?: number;
  22865. sizeY?: number;
  22866. sizeZ?: number;
  22867. custom?: any;
  22868. faceUV?: Vector4[];
  22869. faceColors?: Color4[];
  22870. flat?: boolean;
  22871. sideOrientation?: number;
  22872. frontUVs?: Vector4;
  22873. backUVs?: Vector4;
  22874. }): VertexData;
  22875. /**
  22876. * Creates the VertexData for a TorusKnot
  22877. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22878. * * radius the radius of the torus knot, optional, default 2
  22879. * * tube the thickness of the tube, optional, default 0.5
  22880. * * radialSegments the number of sides on each tube segments, optional, default 32
  22881. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22882. * * p the number of windings around the z axis, optional, default 2
  22883. * * q the number of windings around the x axis, optional, default 3
  22884. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22885. * * 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)
  22886. * * 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)
  22887. * @returns the VertexData of the Torus Knot
  22888. */
  22889. static CreateTorusKnot(options: {
  22890. radius?: number;
  22891. tube?: number;
  22892. radialSegments?: number;
  22893. tubularSegments?: number;
  22894. p?: number;
  22895. q?: number;
  22896. sideOrientation?: number;
  22897. frontUVs?: Vector4;
  22898. backUVs?: Vector4;
  22899. }): VertexData;
  22900. /**
  22901. * Compute normals for given positions and indices
  22902. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22903. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22904. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22905. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22906. * * facetNormals : optional array of facet normals (vector3)
  22907. * * facetPositions : optional array of facet positions (vector3)
  22908. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22909. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22910. * * bInfo : optional bounding info, required for facetPartitioning computation
  22911. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22912. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22913. * * useRightHandedSystem: optional boolean to for right handed system computation
  22914. * * depthSort : optional boolean to enable the facet depth sort computation
  22915. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22916. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22917. */
  22918. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22919. facetNormals?: any;
  22920. facetPositions?: any;
  22921. facetPartitioning?: any;
  22922. ratio?: number;
  22923. bInfo?: any;
  22924. bbSize?: Vector3;
  22925. subDiv?: any;
  22926. useRightHandedSystem?: boolean;
  22927. depthSort?: boolean;
  22928. distanceTo?: Vector3;
  22929. depthSortedFacets?: any;
  22930. }): void;
  22931. /** @hidden */
  22932. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22933. /**
  22934. * Applies VertexData created from the imported parameters to the geometry
  22935. * @param parsedVertexData the parsed data from an imported file
  22936. * @param geometry the geometry to apply the VertexData to
  22937. */
  22938. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22939. }
  22940. }
  22941. declare module "babylonjs/Morph/morphTarget" {
  22942. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22943. import { Observable } from "babylonjs/Misc/observable";
  22944. import { Nullable, FloatArray } from "babylonjs/types";
  22945. import { Scene } from "babylonjs/scene";
  22946. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22947. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22948. /**
  22949. * Defines a target to use with MorphTargetManager
  22950. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22951. */
  22952. export class MorphTarget implements IAnimatable {
  22953. /** defines the name of the target */
  22954. name: string;
  22955. /**
  22956. * Gets or sets the list of animations
  22957. */
  22958. animations: import("babylonjs/Animations/animation").Animation[];
  22959. private _scene;
  22960. private _positions;
  22961. private _normals;
  22962. private _tangents;
  22963. private _uvs;
  22964. private _influence;
  22965. private _uniqueId;
  22966. /**
  22967. * Observable raised when the influence changes
  22968. */
  22969. onInfluenceChanged: Observable<boolean>;
  22970. /** @hidden */
  22971. _onDataLayoutChanged: Observable<void>;
  22972. /**
  22973. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22974. */
  22975. influence: number;
  22976. /**
  22977. * Gets or sets the id of the morph Target
  22978. */
  22979. id: string;
  22980. private _animationPropertiesOverride;
  22981. /**
  22982. * Gets or sets the animation properties override
  22983. */
  22984. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22985. /**
  22986. * Creates a new MorphTarget
  22987. * @param name defines the name of the target
  22988. * @param influence defines the influence to use
  22989. * @param scene defines the scene the morphtarget belongs to
  22990. */
  22991. constructor(
  22992. /** defines the name of the target */
  22993. name: string, influence?: number, scene?: Nullable<Scene>);
  22994. /**
  22995. * Gets the unique ID of this manager
  22996. */
  22997. readonly uniqueId: number;
  22998. /**
  22999. * Gets a boolean defining if the target contains position data
  23000. */
  23001. readonly hasPositions: boolean;
  23002. /**
  23003. * Gets a boolean defining if the target contains normal data
  23004. */
  23005. readonly hasNormals: boolean;
  23006. /**
  23007. * Gets a boolean defining if the target contains tangent data
  23008. */
  23009. readonly hasTangents: boolean;
  23010. /**
  23011. * Gets a boolean defining if the target contains texture coordinates data
  23012. */
  23013. readonly hasUVs: boolean;
  23014. /**
  23015. * Affects position data to this target
  23016. * @param data defines the position data to use
  23017. */
  23018. setPositions(data: Nullable<FloatArray>): void;
  23019. /**
  23020. * Gets the position data stored in this target
  23021. * @returns a FloatArray containing the position data (or null if not present)
  23022. */
  23023. getPositions(): Nullable<FloatArray>;
  23024. /**
  23025. * Affects normal data to this target
  23026. * @param data defines the normal data to use
  23027. */
  23028. setNormals(data: Nullable<FloatArray>): void;
  23029. /**
  23030. * Gets the normal data stored in this target
  23031. * @returns a FloatArray containing the normal data (or null if not present)
  23032. */
  23033. getNormals(): Nullable<FloatArray>;
  23034. /**
  23035. * Affects tangent data to this target
  23036. * @param data defines the tangent data to use
  23037. */
  23038. setTangents(data: Nullable<FloatArray>): void;
  23039. /**
  23040. * Gets the tangent data stored in this target
  23041. * @returns a FloatArray containing the tangent data (or null if not present)
  23042. */
  23043. getTangents(): Nullable<FloatArray>;
  23044. /**
  23045. * Affects texture coordinates data to this target
  23046. * @param data defines the texture coordinates data to use
  23047. */
  23048. setUVs(data: Nullable<FloatArray>): void;
  23049. /**
  23050. * Gets the texture coordinates data stored in this target
  23051. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  23052. */
  23053. getUVs(): Nullable<FloatArray>;
  23054. /**
  23055. * Clone the current target
  23056. * @returns a new MorphTarget
  23057. */
  23058. clone(): MorphTarget;
  23059. /**
  23060. * Serializes the current target into a Serialization object
  23061. * @returns the serialized object
  23062. */
  23063. serialize(): any;
  23064. /**
  23065. * Returns the string "MorphTarget"
  23066. * @returns "MorphTarget"
  23067. */
  23068. getClassName(): string;
  23069. /**
  23070. * Creates a new target from serialized data
  23071. * @param serializationObject defines the serialized data to use
  23072. * @returns a new MorphTarget
  23073. */
  23074. static Parse(serializationObject: any): MorphTarget;
  23075. /**
  23076. * Creates a MorphTarget from mesh data
  23077. * @param mesh defines the source mesh
  23078. * @param name defines the name to use for the new target
  23079. * @param influence defines the influence to attach to the target
  23080. * @returns a new MorphTarget
  23081. */
  23082. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23083. }
  23084. }
  23085. declare module "babylonjs/Morph/morphTargetManager" {
  23086. import { Nullable } from "babylonjs/types";
  23087. import { Scene } from "babylonjs/scene";
  23088. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  23089. /**
  23090. * This class is used to deform meshes using morphing between different targets
  23091. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23092. */
  23093. export class MorphTargetManager {
  23094. private _targets;
  23095. private _targetInfluenceChangedObservers;
  23096. private _targetDataLayoutChangedObservers;
  23097. private _activeTargets;
  23098. private _scene;
  23099. private _influences;
  23100. private _supportsNormals;
  23101. private _supportsTangents;
  23102. private _supportsUVs;
  23103. private _vertexCount;
  23104. private _uniqueId;
  23105. private _tempInfluences;
  23106. /**
  23107. * Gets or sets a boolean indicating if normals must be morphed
  23108. */
  23109. enableNormalMorphing: boolean;
  23110. /**
  23111. * Gets or sets a boolean indicating if tangents must be morphed
  23112. */
  23113. enableTangentMorphing: boolean;
  23114. /**
  23115. * Gets or sets a boolean indicating if UV must be morphed
  23116. */
  23117. enableUVMorphing: boolean;
  23118. /**
  23119. * Creates a new MorphTargetManager
  23120. * @param scene defines the current scene
  23121. */
  23122. constructor(scene?: Nullable<Scene>);
  23123. /**
  23124. * Gets the unique ID of this manager
  23125. */
  23126. readonly uniqueId: number;
  23127. /**
  23128. * Gets the number of vertices handled by this manager
  23129. */
  23130. readonly vertexCount: number;
  23131. /**
  23132. * Gets a boolean indicating if this manager supports morphing of normals
  23133. */
  23134. readonly supportsNormals: boolean;
  23135. /**
  23136. * Gets a boolean indicating if this manager supports morphing of tangents
  23137. */
  23138. readonly supportsTangents: boolean;
  23139. /**
  23140. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23141. */
  23142. readonly supportsUVs: boolean;
  23143. /**
  23144. * Gets the number of targets stored in this manager
  23145. */
  23146. readonly numTargets: number;
  23147. /**
  23148. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23149. */
  23150. readonly numInfluencers: number;
  23151. /**
  23152. * Gets the list of influences (one per target)
  23153. */
  23154. readonly influences: Float32Array;
  23155. /**
  23156. * Gets the active target at specified index. An active target is a target with an influence > 0
  23157. * @param index defines the index to check
  23158. * @returns the requested target
  23159. */
  23160. getActiveTarget(index: number): MorphTarget;
  23161. /**
  23162. * Gets the target at specified index
  23163. * @param index defines the index to check
  23164. * @returns the requested target
  23165. */
  23166. getTarget(index: number): MorphTarget;
  23167. /**
  23168. * Add a new target to this manager
  23169. * @param target defines the target to add
  23170. */
  23171. addTarget(target: MorphTarget): void;
  23172. /**
  23173. * Removes a target from the manager
  23174. * @param target defines the target to remove
  23175. */
  23176. removeTarget(target: MorphTarget): void;
  23177. /**
  23178. * Clone the current manager
  23179. * @returns a new MorphTargetManager
  23180. */
  23181. clone(): MorphTargetManager;
  23182. /**
  23183. * Serializes the current manager into a Serialization object
  23184. * @returns the serialized object
  23185. */
  23186. serialize(): any;
  23187. private _syncActiveTargets;
  23188. /**
  23189. * Syncrhonize the targets with all the meshes using this morph target manager
  23190. */
  23191. synchronize(): void;
  23192. /**
  23193. * Creates a new MorphTargetManager from serialized data
  23194. * @param serializationObject defines the serialized data
  23195. * @param scene defines the hosting scene
  23196. * @returns the new MorphTargetManager
  23197. */
  23198. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23199. }
  23200. }
  23201. declare module "babylonjs/Meshes/meshLODLevel" {
  23202. import { Mesh } from "babylonjs/Meshes/mesh";
  23203. import { Nullable } from "babylonjs/types";
  23204. /**
  23205. * Class used to represent a specific level of detail of a mesh
  23206. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23207. */
  23208. export class MeshLODLevel {
  23209. /** Defines the distance where this level should start being displayed */
  23210. distance: number;
  23211. /** Defines the mesh to use to render this level */
  23212. mesh: Nullable<Mesh>;
  23213. /**
  23214. * Creates a new LOD level
  23215. * @param distance defines the distance where this level should star being displayed
  23216. * @param mesh defines the mesh to use to render this level
  23217. */
  23218. constructor(
  23219. /** Defines the distance where this level should start being displayed */
  23220. distance: number,
  23221. /** Defines the mesh to use to render this level */
  23222. mesh: Nullable<Mesh>);
  23223. }
  23224. }
  23225. declare module "babylonjs/Meshes/groundMesh" {
  23226. import { Scene } from "babylonjs/scene";
  23227. import { Vector3 } from "babylonjs/Maths/math.vector";
  23228. import { Mesh } from "babylonjs/Meshes/mesh";
  23229. /**
  23230. * Mesh representing the gorund
  23231. */
  23232. export class GroundMesh extends Mesh {
  23233. /** If octree should be generated */
  23234. generateOctree: boolean;
  23235. private _heightQuads;
  23236. /** @hidden */
  23237. _subdivisionsX: number;
  23238. /** @hidden */
  23239. _subdivisionsY: number;
  23240. /** @hidden */
  23241. _width: number;
  23242. /** @hidden */
  23243. _height: number;
  23244. /** @hidden */
  23245. _minX: number;
  23246. /** @hidden */
  23247. _maxX: number;
  23248. /** @hidden */
  23249. _minZ: number;
  23250. /** @hidden */
  23251. _maxZ: number;
  23252. constructor(name: string, scene: Scene);
  23253. /**
  23254. * "GroundMesh"
  23255. * @returns "GroundMesh"
  23256. */
  23257. getClassName(): string;
  23258. /**
  23259. * The minimum of x and y subdivisions
  23260. */
  23261. readonly subdivisions: number;
  23262. /**
  23263. * X subdivisions
  23264. */
  23265. readonly subdivisionsX: number;
  23266. /**
  23267. * Y subdivisions
  23268. */
  23269. readonly subdivisionsY: number;
  23270. /**
  23271. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23272. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23273. * @param chunksCount the number of subdivisions for x and y
  23274. * @param octreeBlocksSize (Default: 32)
  23275. */
  23276. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23277. /**
  23278. * Returns a height (y) value in the Worl system :
  23279. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23280. * @param x x coordinate
  23281. * @param z z coordinate
  23282. * @returns the ground y position if (x, z) are outside the ground surface.
  23283. */
  23284. getHeightAtCoordinates(x: number, z: number): number;
  23285. /**
  23286. * Returns a normalized vector (Vector3) orthogonal to the ground
  23287. * at the ground coordinates (x, z) expressed in the World system.
  23288. * @param x x coordinate
  23289. * @param z z coordinate
  23290. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23291. */
  23292. getNormalAtCoordinates(x: number, z: number): Vector3;
  23293. /**
  23294. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23295. * at the ground coordinates (x, z) expressed in the World system.
  23296. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23297. * @param x x coordinate
  23298. * @param z z coordinate
  23299. * @param ref vector to store the result
  23300. * @returns the GroundMesh.
  23301. */
  23302. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23303. /**
  23304. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23305. * if the ground has been updated.
  23306. * This can be used in the render loop.
  23307. * @returns the GroundMesh.
  23308. */
  23309. updateCoordinateHeights(): GroundMesh;
  23310. private _getFacetAt;
  23311. private _initHeightQuads;
  23312. private _computeHeightQuads;
  23313. /**
  23314. * Serializes this ground mesh
  23315. * @param serializationObject object to write serialization to
  23316. */
  23317. serialize(serializationObject: any): void;
  23318. /**
  23319. * Parses a serialized ground mesh
  23320. * @param parsedMesh the serialized mesh
  23321. * @param scene the scene to create the ground mesh in
  23322. * @returns the created ground mesh
  23323. */
  23324. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23325. }
  23326. }
  23327. declare module "babylonjs/Physics/physicsJoint" {
  23328. import { Vector3 } from "babylonjs/Maths/math.vector";
  23329. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23330. /**
  23331. * Interface for Physics-Joint data
  23332. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23333. */
  23334. export interface PhysicsJointData {
  23335. /**
  23336. * The main pivot of the joint
  23337. */
  23338. mainPivot?: Vector3;
  23339. /**
  23340. * The connected pivot of the joint
  23341. */
  23342. connectedPivot?: Vector3;
  23343. /**
  23344. * The main axis of the joint
  23345. */
  23346. mainAxis?: Vector3;
  23347. /**
  23348. * The connected axis of the joint
  23349. */
  23350. connectedAxis?: Vector3;
  23351. /**
  23352. * The collision of the joint
  23353. */
  23354. collision?: boolean;
  23355. /**
  23356. * Native Oimo/Cannon/Energy data
  23357. */
  23358. nativeParams?: any;
  23359. }
  23360. /**
  23361. * This is a holder class for the physics joint created by the physics plugin
  23362. * It holds a set of functions to control the underlying joint
  23363. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23364. */
  23365. export class PhysicsJoint {
  23366. /**
  23367. * The type of the physics joint
  23368. */
  23369. type: number;
  23370. /**
  23371. * The data for the physics joint
  23372. */
  23373. jointData: PhysicsJointData;
  23374. private _physicsJoint;
  23375. protected _physicsPlugin: IPhysicsEnginePlugin;
  23376. /**
  23377. * Initializes the physics joint
  23378. * @param type The type of the physics joint
  23379. * @param jointData The data for the physics joint
  23380. */
  23381. constructor(
  23382. /**
  23383. * The type of the physics joint
  23384. */
  23385. type: number,
  23386. /**
  23387. * The data for the physics joint
  23388. */
  23389. jointData: PhysicsJointData);
  23390. /**
  23391. * Gets the physics joint
  23392. */
  23393. /**
  23394. * Sets the physics joint
  23395. */
  23396. physicsJoint: any;
  23397. /**
  23398. * Sets the physics plugin
  23399. */
  23400. physicsPlugin: IPhysicsEnginePlugin;
  23401. /**
  23402. * Execute a function that is physics-plugin specific.
  23403. * @param {Function} func the function that will be executed.
  23404. * It accepts two parameters: the physics world and the physics joint
  23405. */
  23406. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23407. /**
  23408. * Distance-Joint type
  23409. */
  23410. static DistanceJoint: number;
  23411. /**
  23412. * Hinge-Joint type
  23413. */
  23414. static HingeJoint: number;
  23415. /**
  23416. * Ball-and-Socket joint type
  23417. */
  23418. static BallAndSocketJoint: number;
  23419. /**
  23420. * Wheel-Joint type
  23421. */
  23422. static WheelJoint: number;
  23423. /**
  23424. * Slider-Joint type
  23425. */
  23426. static SliderJoint: number;
  23427. /**
  23428. * Prismatic-Joint type
  23429. */
  23430. static PrismaticJoint: number;
  23431. /**
  23432. * Universal-Joint type
  23433. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23434. */
  23435. static UniversalJoint: number;
  23436. /**
  23437. * Hinge-Joint 2 type
  23438. */
  23439. static Hinge2Joint: number;
  23440. /**
  23441. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23442. */
  23443. static PointToPointJoint: number;
  23444. /**
  23445. * Spring-Joint type
  23446. */
  23447. static SpringJoint: number;
  23448. /**
  23449. * Lock-Joint type
  23450. */
  23451. static LockJoint: number;
  23452. }
  23453. /**
  23454. * A class representing a physics distance joint
  23455. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23456. */
  23457. export class DistanceJoint extends PhysicsJoint {
  23458. /**
  23459. *
  23460. * @param jointData The data for the Distance-Joint
  23461. */
  23462. constructor(jointData: DistanceJointData);
  23463. /**
  23464. * Update the predefined distance.
  23465. * @param maxDistance The maximum preferred distance
  23466. * @param minDistance The minimum preferred distance
  23467. */
  23468. updateDistance(maxDistance: number, minDistance?: number): void;
  23469. }
  23470. /**
  23471. * Represents a Motor-Enabled Joint
  23472. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23473. */
  23474. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23475. /**
  23476. * Initializes the Motor-Enabled Joint
  23477. * @param type The type of the joint
  23478. * @param jointData The physica joint data for the joint
  23479. */
  23480. constructor(type: number, jointData: PhysicsJointData);
  23481. /**
  23482. * Set the motor values.
  23483. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23484. * @param force the force to apply
  23485. * @param maxForce max force for this motor.
  23486. */
  23487. setMotor(force?: number, maxForce?: number): void;
  23488. /**
  23489. * Set the motor's limits.
  23490. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23491. * @param upperLimit The upper limit of the motor
  23492. * @param lowerLimit The lower limit of the motor
  23493. */
  23494. setLimit(upperLimit: number, lowerLimit?: number): void;
  23495. }
  23496. /**
  23497. * This class represents a single physics Hinge-Joint
  23498. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23499. */
  23500. export class HingeJoint extends MotorEnabledJoint {
  23501. /**
  23502. * Initializes the Hinge-Joint
  23503. * @param jointData The joint data for the Hinge-Joint
  23504. */
  23505. constructor(jointData: PhysicsJointData);
  23506. /**
  23507. * Set the motor values.
  23508. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23509. * @param {number} force the force to apply
  23510. * @param {number} maxForce max force for this motor.
  23511. */
  23512. setMotor(force?: number, maxForce?: number): void;
  23513. /**
  23514. * Set the motor's limits.
  23515. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23516. * @param upperLimit The upper limit of the motor
  23517. * @param lowerLimit The lower limit of the motor
  23518. */
  23519. setLimit(upperLimit: number, lowerLimit?: number): void;
  23520. }
  23521. /**
  23522. * This class represents a dual hinge physics joint (same as wheel joint)
  23523. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23524. */
  23525. export class Hinge2Joint extends MotorEnabledJoint {
  23526. /**
  23527. * Initializes the Hinge2-Joint
  23528. * @param jointData The joint data for the Hinge2-Joint
  23529. */
  23530. constructor(jointData: PhysicsJointData);
  23531. /**
  23532. * Set the motor values.
  23533. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23534. * @param {number} targetSpeed the speed the motor is to reach
  23535. * @param {number} maxForce max force for this motor.
  23536. * @param {motorIndex} the motor's index, 0 or 1.
  23537. */
  23538. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23539. /**
  23540. * Set the motor limits.
  23541. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23542. * @param {number} upperLimit the upper limit
  23543. * @param {number} lowerLimit lower limit
  23544. * @param {motorIndex} the motor's index, 0 or 1.
  23545. */
  23546. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23547. }
  23548. /**
  23549. * Interface for a motor enabled joint
  23550. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23551. */
  23552. export interface IMotorEnabledJoint {
  23553. /**
  23554. * Physics joint
  23555. */
  23556. physicsJoint: any;
  23557. /**
  23558. * Sets the motor of the motor-enabled joint
  23559. * @param force The force of the motor
  23560. * @param maxForce The maximum force of the motor
  23561. * @param motorIndex The index of the motor
  23562. */
  23563. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23564. /**
  23565. * Sets the limit of the motor
  23566. * @param upperLimit The upper limit of the motor
  23567. * @param lowerLimit The lower limit of the motor
  23568. * @param motorIndex The index of the motor
  23569. */
  23570. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23571. }
  23572. /**
  23573. * Joint data for a Distance-Joint
  23574. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23575. */
  23576. export interface DistanceJointData extends PhysicsJointData {
  23577. /**
  23578. * Max distance the 2 joint objects can be apart
  23579. */
  23580. maxDistance: number;
  23581. }
  23582. /**
  23583. * Joint data from a spring joint
  23584. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23585. */
  23586. export interface SpringJointData extends PhysicsJointData {
  23587. /**
  23588. * Length of the spring
  23589. */
  23590. length: number;
  23591. /**
  23592. * Stiffness of the spring
  23593. */
  23594. stiffness: number;
  23595. /**
  23596. * Damping of the spring
  23597. */
  23598. damping: number;
  23599. /** this callback will be called when applying the force to the impostors. */
  23600. forceApplicationCallback: () => void;
  23601. }
  23602. }
  23603. declare module "babylonjs/Physics/physicsRaycastResult" {
  23604. import { Vector3 } from "babylonjs/Maths/math.vector";
  23605. /**
  23606. * Holds the data for the raycast result
  23607. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23608. */
  23609. export class PhysicsRaycastResult {
  23610. private _hasHit;
  23611. private _hitDistance;
  23612. private _hitNormalWorld;
  23613. private _hitPointWorld;
  23614. private _rayFromWorld;
  23615. private _rayToWorld;
  23616. /**
  23617. * Gets if there was a hit
  23618. */
  23619. readonly hasHit: boolean;
  23620. /**
  23621. * Gets the distance from the hit
  23622. */
  23623. readonly hitDistance: number;
  23624. /**
  23625. * Gets the hit normal/direction in the world
  23626. */
  23627. readonly hitNormalWorld: Vector3;
  23628. /**
  23629. * Gets the hit point in the world
  23630. */
  23631. readonly hitPointWorld: Vector3;
  23632. /**
  23633. * Gets the ray "start point" of the ray in the world
  23634. */
  23635. readonly rayFromWorld: Vector3;
  23636. /**
  23637. * Gets the ray "end point" of the ray in the world
  23638. */
  23639. readonly rayToWorld: Vector3;
  23640. /**
  23641. * Sets the hit data (normal & point in world space)
  23642. * @param hitNormalWorld defines the normal in world space
  23643. * @param hitPointWorld defines the point in world space
  23644. */
  23645. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23646. /**
  23647. * Sets the distance from the start point to the hit point
  23648. * @param distance
  23649. */
  23650. setHitDistance(distance: number): void;
  23651. /**
  23652. * Calculates the distance manually
  23653. */
  23654. calculateHitDistance(): void;
  23655. /**
  23656. * Resets all the values to default
  23657. * @param from The from point on world space
  23658. * @param to The to point on world space
  23659. */
  23660. reset(from?: Vector3, to?: Vector3): void;
  23661. }
  23662. /**
  23663. * Interface for the size containing width and height
  23664. */
  23665. interface IXYZ {
  23666. /**
  23667. * X
  23668. */
  23669. x: number;
  23670. /**
  23671. * Y
  23672. */
  23673. y: number;
  23674. /**
  23675. * Z
  23676. */
  23677. z: number;
  23678. }
  23679. }
  23680. declare module "babylonjs/Physics/IPhysicsEngine" {
  23681. import { Nullable } from "babylonjs/types";
  23682. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23683. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23684. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23685. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23686. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23687. /**
  23688. * Interface used to describe a physics joint
  23689. */
  23690. export interface PhysicsImpostorJoint {
  23691. /** Defines the main impostor to which the joint is linked */
  23692. mainImpostor: PhysicsImpostor;
  23693. /** Defines the impostor that is connected to the main impostor using this joint */
  23694. connectedImpostor: PhysicsImpostor;
  23695. /** Defines the joint itself */
  23696. joint: PhysicsJoint;
  23697. }
  23698. /** @hidden */
  23699. export interface IPhysicsEnginePlugin {
  23700. world: any;
  23701. name: string;
  23702. setGravity(gravity: Vector3): void;
  23703. setTimeStep(timeStep: number): void;
  23704. getTimeStep(): number;
  23705. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23706. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23707. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23708. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23709. removePhysicsBody(impostor: PhysicsImpostor): void;
  23710. generateJoint(joint: PhysicsImpostorJoint): void;
  23711. removeJoint(joint: PhysicsImpostorJoint): void;
  23712. isSupported(): boolean;
  23713. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23714. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23715. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23716. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23717. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23718. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23719. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23720. getBodyMass(impostor: PhysicsImpostor): number;
  23721. getBodyFriction(impostor: PhysicsImpostor): number;
  23722. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23723. getBodyRestitution(impostor: PhysicsImpostor): number;
  23724. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23725. getBodyPressure?(impostor: PhysicsImpostor): number;
  23726. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23727. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23728. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23729. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23730. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23731. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23732. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23733. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23734. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23735. sleepBody(impostor: PhysicsImpostor): void;
  23736. wakeUpBody(impostor: PhysicsImpostor): void;
  23737. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23738. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23739. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23740. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23741. getRadius(impostor: PhysicsImpostor): number;
  23742. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23743. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23744. dispose(): void;
  23745. }
  23746. /**
  23747. * Interface used to define a physics engine
  23748. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23749. */
  23750. export interface IPhysicsEngine {
  23751. /**
  23752. * Gets the gravity vector used by the simulation
  23753. */
  23754. gravity: Vector3;
  23755. /**
  23756. * Sets the gravity vector used by the simulation
  23757. * @param gravity defines the gravity vector to use
  23758. */
  23759. setGravity(gravity: Vector3): void;
  23760. /**
  23761. * Set the time step of the physics engine.
  23762. * Default is 1/60.
  23763. * To slow it down, enter 1/600 for example.
  23764. * To speed it up, 1/30
  23765. * @param newTimeStep the new timestep to apply to this world.
  23766. */
  23767. setTimeStep(newTimeStep: number): void;
  23768. /**
  23769. * Get the time step of the physics engine.
  23770. * @returns the current time step
  23771. */
  23772. getTimeStep(): number;
  23773. /**
  23774. * Set the sub time step of the physics engine.
  23775. * Default is 0 meaning there is no sub steps
  23776. * To increase physics resolution precision, set a small value (like 1 ms)
  23777. * @param subTimeStep defines the new sub timestep used for physics resolution.
  23778. */
  23779. setSubTimeStep(subTimeStep: number): void;
  23780. /**
  23781. * Get the sub time step of the physics engine.
  23782. * @returns the current sub time step
  23783. */
  23784. getSubTimeStep(): number;
  23785. /**
  23786. * Release all resources
  23787. */
  23788. dispose(): void;
  23789. /**
  23790. * Gets the name of the current physics plugin
  23791. * @returns the name of the plugin
  23792. */
  23793. getPhysicsPluginName(): string;
  23794. /**
  23795. * Adding a new impostor for the impostor tracking.
  23796. * This will be done by the impostor itself.
  23797. * @param impostor the impostor to add
  23798. */
  23799. addImpostor(impostor: PhysicsImpostor): void;
  23800. /**
  23801. * Remove an impostor from the engine.
  23802. * This impostor and its mesh will not longer be updated by the physics engine.
  23803. * @param impostor the impostor to remove
  23804. */
  23805. removeImpostor(impostor: PhysicsImpostor): void;
  23806. /**
  23807. * Add a joint to the physics engine
  23808. * @param mainImpostor defines the main impostor to which the joint is added.
  23809. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23810. * @param joint defines the joint that will connect both impostors.
  23811. */
  23812. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23813. /**
  23814. * Removes a joint from the simulation
  23815. * @param mainImpostor defines the impostor used with the joint
  23816. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23817. * @param joint defines the joint to remove
  23818. */
  23819. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23820. /**
  23821. * Gets the current plugin used to run the simulation
  23822. * @returns current plugin
  23823. */
  23824. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23825. /**
  23826. * Gets the list of physic impostors
  23827. * @returns an array of PhysicsImpostor
  23828. */
  23829. getImpostors(): Array<PhysicsImpostor>;
  23830. /**
  23831. * Gets the impostor for a physics enabled object
  23832. * @param object defines the object impersonated by the impostor
  23833. * @returns the PhysicsImpostor or null if not found
  23834. */
  23835. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23836. /**
  23837. * Gets the impostor for a physics body object
  23838. * @param body defines physics body used by the impostor
  23839. * @returns the PhysicsImpostor or null if not found
  23840. */
  23841. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23842. /**
  23843. * Does a raycast in the physics world
  23844. * @param from when should the ray start?
  23845. * @param to when should the ray end?
  23846. * @returns PhysicsRaycastResult
  23847. */
  23848. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23849. /**
  23850. * Called by the scene. No need to call it.
  23851. * @param delta defines the timespam between frames
  23852. */
  23853. _step(delta: number): void;
  23854. }
  23855. }
  23856. declare module "babylonjs/Physics/physicsImpostor" {
  23857. import { Nullable, IndicesArray } from "babylonjs/types";
  23858. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23859. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23860. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23861. import { Scene } from "babylonjs/scene";
  23862. import { Bone } from "babylonjs/Bones/bone";
  23863. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23864. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23865. import { Space } from "babylonjs/Maths/math.axis";
  23866. /**
  23867. * The interface for the physics imposter parameters
  23868. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23869. */
  23870. export interface PhysicsImpostorParameters {
  23871. /**
  23872. * The mass of the physics imposter
  23873. */
  23874. mass: number;
  23875. /**
  23876. * The friction of the physics imposter
  23877. */
  23878. friction?: number;
  23879. /**
  23880. * The coefficient of restitution of the physics imposter
  23881. */
  23882. restitution?: number;
  23883. /**
  23884. * The native options of the physics imposter
  23885. */
  23886. nativeOptions?: any;
  23887. /**
  23888. * Specifies if the parent should be ignored
  23889. */
  23890. ignoreParent?: boolean;
  23891. /**
  23892. * Specifies if bi-directional transformations should be disabled
  23893. */
  23894. disableBidirectionalTransformation?: boolean;
  23895. /**
  23896. * The pressure inside the physics imposter, soft object only
  23897. */
  23898. pressure?: number;
  23899. /**
  23900. * The stiffness the physics imposter, soft object only
  23901. */
  23902. stiffness?: number;
  23903. /**
  23904. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23905. */
  23906. velocityIterations?: number;
  23907. /**
  23908. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23909. */
  23910. positionIterations?: number;
  23911. /**
  23912. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23913. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23914. * Add to fix multiple points
  23915. */
  23916. fixedPoints?: number;
  23917. /**
  23918. * The collision margin around a soft object
  23919. */
  23920. margin?: number;
  23921. /**
  23922. * The collision margin around a soft object
  23923. */
  23924. damping?: number;
  23925. /**
  23926. * The path for a rope based on an extrusion
  23927. */
  23928. path?: any;
  23929. /**
  23930. * The shape of an extrusion used for a rope based on an extrusion
  23931. */
  23932. shape?: any;
  23933. }
  23934. /**
  23935. * Interface for a physics-enabled object
  23936. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23937. */
  23938. export interface IPhysicsEnabledObject {
  23939. /**
  23940. * The position of the physics-enabled object
  23941. */
  23942. position: Vector3;
  23943. /**
  23944. * The rotation of the physics-enabled object
  23945. */
  23946. rotationQuaternion: Nullable<Quaternion>;
  23947. /**
  23948. * The scale of the physics-enabled object
  23949. */
  23950. scaling: Vector3;
  23951. /**
  23952. * The rotation of the physics-enabled object
  23953. */
  23954. rotation?: Vector3;
  23955. /**
  23956. * The parent of the physics-enabled object
  23957. */
  23958. parent?: any;
  23959. /**
  23960. * The bounding info of the physics-enabled object
  23961. * @returns The bounding info of the physics-enabled object
  23962. */
  23963. getBoundingInfo(): BoundingInfo;
  23964. /**
  23965. * Computes the world matrix
  23966. * @param force Specifies if the world matrix should be computed by force
  23967. * @returns A world matrix
  23968. */
  23969. computeWorldMatrix(force: boolean): Matrix;
  23970. /**
  23971. * Gets the world matrix
  23972. * @returns A world matrix
  23973. */
  23974. getWorldMatrix?(): Matrix;
  23975. /**
  23976. * Gets the child meshes
  23977. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23978. * @returns An array of abstract meshes
  23979. */
  23980. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23981. /**
  23982. * Gets the vertex data
  23983. * @param kind The type of vertex data
  23984. * @returns A nullable array of numbers, or a float32 array
  23985. */
  23986. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23987. /**
  23988. * Gets the indices from the mesh
  23989. * @returns A nullable array of index arrays
  23990. */
  23991. getIndices?(): Nullable<IndicesArray>;
  23992. /**
  23993. * Gets the scene from the mesh
  23994. * @returns the indices array or null
  23995. */
  23996. getScene?(): Scene;
  23997. /**
  23998. * Gets the absolute position from the mesh
  23999. * @returns the absolute position
  24000. */
  24001. getAbsolutePosition(): Vector3;
  24002. /**
  24003. * Gets the absolute pivot point from the mesh
  24004. * @returns the absolute pivot point
  24005. */
  24006. getAbsolutePivotPoint(): Vector3;
  24007. /**
  24008. * Rotates the mesh
  24009. * @param axis The axis of rotation
  24010. * @param amount The amount of rotation
  24011. * @param space The space of the rotation
  24012. * @returns The rotation transform node
  24013. */
  24014. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24015. /**
  24016. * Translates the mesh
  24017. * @param axis The axis of translation
  24018. * @param distance The distance of translation
  24019. * @param space The space of the translation
  24020. * @returns The transform node
  24021. */
  24022. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24023. /**
  24024. * Sets the absolute position of the mesh
  24025. * @param absolutePosition The absolute position of the mesh
  24026. * @returns The transform node
  24027. */
  24028. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24029. /**
  24030. * Gets the class name of the mesh
  24031. * @returns The class name
  24032. */
  24033. getClassName(): string;
  24034. }
  24035. /**
  24036. * Represents a physics imposter
  24037. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24038. */
  24039. export class PhysicsImpostor {
  24040. /**
  24041. * The physics-enabled object used as the physics imposter
  24042. */
  24043. object: IPhysicsEnabledObject;
  24044. /**
  24045. * The type of the physics imposter
  24046. */
  24047. type: number;
  24048. private _options;
  24049. private _scene?;
  24050. /**
  24051. * The default object size of the imposter
  24052. */
  24053. static DEFAULT_OBJECT_SIZE: Vector3;
  24054. /**
  24055. * The identity quaternion of the imposter
  24056. */
  24057. static IDENTITY_QUATERNION: Quaternion;
  24058. /** @hidden */
  24059. _pluginData: any;
  24060. private _physicsEngine;
  24061. private _physicsBody;
  24062. private _bodyUpdateRequired;
  24063. private _onBeforePhysicsStepCallbacks;
  24064. private _onAfterPhysicsStepCallbacks;
  24065. /** @hidden */
  24066. _onPhysicsCollideCallbacks: Array<{
  24067. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  24068. otherImpostors: Array<PhysicsImpostor>;
  24069. }>;
  24070. private _deltaPosition;
  24071. private _deltaRotation;
  24072. private _deltaRotationConjugated;
  24073. /** @hidden */
  24074. _isFromLine: boolean;
  24075. private _parent;
  24076. private _isDisposed;
  24077. private static _tmpVecs;
  24078. private static _tmpQuat;
  24079. /**
  24080. * Specifies if the physics imposter is disposed
  24081. */
  24082. readonly isDisposed: boolean;
  24083. /**
  24084. * Gets the mass of the physics imposter
  24085. */
  24086. mass: number;
  24087. /**
  24088. * Gets the coefficient of friction
  24089. */
  24090. /**
  24091. * Sets the coefficient of friction
  24092. */
  24093. friction: number;
  24094. /**
  24095. * Gets the coefficient of restitution
  24096. */
  24097. /**
  24098. * Sets the coefficient of restitution
  24099. */
  24100. restitution: number;
  24101. /**
  24102. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24103. */
  24104. /**
  24105. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24106. */
  24107. pressure: number;
  24108. /**
  24109. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24110. */
  24111. /**
  24112. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24113. */
  24114. stiffness: number;
  24115. /**
  24116. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24117. */
  24118. /**
  24119. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24120. */
  24121. velocityIterations: number;
  24122. /**
  24123. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24124. */
  24125. /**
  24126. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24127. */
  24128. positionIterations: number;
  24129. /**
  24130. * The unique id of the physics imposter
  24131. * set by the physics engine when adding this impostor to the array
  24132. */
  24133. uniqueId: number;
  24134. /**
  24135. * @hidden
  24136. */
  24137. soft: boolean;
  24138. /**
  24139. * @hidden
  24140. */
  24141. segments: number;
  24142. private _joints;
  24143. /**
  24144. * Initializes the physics imposter
  24145. * @param object The physics-enabled object used as the physics imposter
  24146. * @param type The type of the physics imposter
  24147. * @param _options The options for the physics imposter
  24148. * @param _scene The Babylon scene
  24149. */
  24150. constructor(
  24151. /**
  24152. * The physics-enabled object used as the physics imposter
  24153. */
  24154. object: IPhysicsEnabledObject,
  24155. /**
  24156. * The type of the physics imposter
  24157. */
  24158. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24159. /**
  24160. * This function will completly initialize this impostor.
  24161. * It will create a new body - but only if this mesh has no parent.
  24162. * If it has, this impostor will not be used other than to define the impostor
  24163. * of the child mesh.
  24164. * @hidden
  24165. */
  24166. _init(): void;
  24167. private _getPhysicsParent;
  24168. /**
  24169. * Should a new body be generated.
  24170. * @returns boolean specifying if body initialization is required
  24171. */
  24172. isBodyInitRequired(): boolean;
  24173. /**
  24174. * Sets the updated scaling
  24175. * @param updated Specifies if the scaling is updated
  24176. */
  24177. setScalingUpdated(): void;
  24178. /**
  24179. * Force a regeneration of this or the parent's impostor's body.
  24180. * Use under cautious - This will remove all joints already implemented.
  24181. */
  24182. forceUpdate(): void;
  24183. /**
  24184. * Gets the body that holds this impostor. Either its own, or its parent.
  24185. */
  24186. /**
  24187. * Set the physics body. Used mainly by the physics engine/plugin
  24188. */
  24189. physicsBody: any;
  24190. /**
  24191. * Get the parent of the physics imposter
  24192. * @returns Physics imposter or null
  24193. */
  24194. /**
  24195. * Sets the parent of the physics imposter
  24196. */
  24197. parent: Nullable<PhysicsImpostor>;
  24198. /**
  24199. * Resets the update flags
  24200. */
  24201. resetUpdateFlags(): void;
  24202. /**
  24203. * Gets the object extend size
  24204. * @returns the object extend size
  24205. */
  24206. getObjectExtendSize(): Vector3;
  24207. /**
  24208. * Gets the object center
  24209. * @returns The object center
  24210. */
  24211. getObjectCenter(): Vector3;
  24212. /**
  24213. * Get a specific parametes from the options parameter
  24214. * @param paramName The object parameter name
  24215. * @returns The object parameter
  24216. */
  24217. getParam(paramName: string): any;
  24218. /**
  24219. * Sets a specific parameter in the options given to the physics plugin
  24220. * @param paramName The parameter name
  24221. * @param value The value of the parameter
  24222. */
  24223. setParam(paramName: string, value: number): void;
  24224. /**
  24225. * Specifically change the body's mass option. Won't recreate the physics body object
  24226. * @param mass The mass of the physics imposter
  24227. */
  24228. setMass(mass: number): void;
  24229. /**
  24230. * Gets the linear velocity
  24231. * @returns linear velocity or null
  24232. */
  24233. getLinearVelocity(): Nullable<Vector3>;
  24234. /**
  24235. * Sets the linear velocity
  24236. * @param velocity linear velocity or null
  24237. */
  24238. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24239. /**
  24240. * Gets the angular velocity
  24241. * @returns angular velocity or null
  24242. */
  24243. getAngularVelocity(): Nullable<Vector3>;
  24244. /**
  24245. * Sets the angular velocity
  24246. * @param velocity The velocity or null
  24247. */
  24248. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24249. /**
  24250. * Execute a function with the physics plugin native code
  24251. * Provide a function the will have two variables - the world object and the physics body object
  24252. * @param func The function to execute with the physics plugin native code
  24253. */
  24254. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24255. /**
  24256. * Register a function that will be executed before the physics world is stepping forward
  24257. * @param func The function to execute before the physics world is stepped forward
  24258. */
  24259. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24260. /**
  24261. * Unregister a function that will be executed before the physics world is stepping forward
  24262. * @param func The function to execute before the physics world is stepped forward
  24263. */
  24264. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24265. /**
  24266. * Register a function that will be executed after the physics step
  24267. * @param func The function to execute after physics step
  24268. */
  24269. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24270. /**
  24271. * Unregisters a function that will be executed after the physics step
  24272. * @param func The function to execute after physics step
  24273. */
  24274. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24275. /**
  24276. * register a function that will be executed when this impostor collides against a different body
  24277. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24278. * @param func Callback that is executed on collision
  24279. */
  24280. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24281. /**
  24282. * Unregisters the physics imposter on contact
  24283. * @param collideAgainst The physics object to collide against
  24284. * @param func Callback to execute on collision
  24285. */
  24286. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24287. private _tmpQuat;
  24288. private _tmpQuat2;
  24289. /**
  24290. * Get the parent rotation
  24291. * @returns The parent rotation
  24292. */
  24293. getParentsRotation(): Quaternion;
  24294. /**
  24295. * this function is executed by the physics engine.
  24296. */
  24297. beforeStep: () => void;
  24298. /**
  24299. * this function is executed by the physics engine
  24300. */
  24301. afterStep: () => void;
  24302. /**
  24303. * Legacy collision detection event support
  24304. */
  24305. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24306. /**
  24307. * event and body object due to cannon's event-based architecture.
  24308. */
  24309. onCollide: (e: {
  24310. body: any;
  24311. }) => void;
  24312. /**
  24313. * Apply a force
  24314. * @param force The force to apply
  24315. * @param contactPoint The contact point for the force
  24316. * @returns The physics imposter
  24317. */
  24318. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24319. /**
  24320. * Apply an impulse
  24321. * @param force The impulse force
  24322. * @param contactPoint The contact point for the impulse force
  24323. * @returns The physics imposter
  24324. */
  24325. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24326. /**
  24327. * A help function to create a joint
  24328. * @param otherImpostor A physics imposter used to create a joint
  24329. * @param jointType The type of joint
  24330. * @param jointData The data for the joint
  24331. * @returns The physics imposter
  24332. */
  24333. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24334. /**
  24335. * Add a joint to this impostor with a different impostor
  24336. * @param otherImpostor A physics imposter used to add a joint
  24337. * @param joint The joint to add
  24338. * @returns The physics imposter
  24339. */
  24340. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24341. /**
  24342. * Add an anchor to a cloth impostor
  24343. * @param otherImpostor rigid impostor to anchor to
  24344. * @param width ratio across width from 0 to 1
  24345. * @param height ratio up height from 0 to 1
  24346. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24347. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24348. * @returns impostor the soft imposter
  24349. */
  24350. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24351. /**
  24352. * Add a hook to a rope impostor
  24353. * @param otherImpostor rigid impostor to anchor to
  24354. * @param length ratio across rope from 0 to 1
  24355. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24356. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24357. * @returns impostor the rope imposter
  24358. */
  24359. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24360. /**
  24361. * Will keep this body still, in a sleep mode.
  24362. * @returns the physics imposter
  24363. */
  24364. sleep(): PhysicsImpostor;
  24365. /**
  24366. * Wake the body up.
  24367. * @returns The physics imposter
  24368. */
  24369. wakeUp(): PhysicsImpostor;
  24370. /**
  24371. * Clones the physics imposter
  24372. * @param newObject The physics imposter clones to this physics-enabled object
  24373. * @returns A nullable physics imposter
  24374. */
  24375. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24376. /**
  24377. * Disposes the physics imposter
  24378. */
  24379. dispose(): void;
  24380. /**
  24381. * Sets the delta position
  24382. * @param position The delta position amount
  24383. */
  24384. setDeltaPosition(position: Vector3): void;
  24385. /**
  24386. * Sets the delta rotation
  24387. * @param rotation The delta rotation amount
  24388. */
  24389. setDeltaRotation(rotation: Quaternion): void;
  24390. /**
  24391. * Gets the box size of the physics imposter and stores the result in the input parameter
  24392. * @param result Stores the box size
  24393. * @returns The physics imposter
  24394. */
  24395. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24396. /**
  24397. * Gets the radius of the physics imposter
  24398. * @returns Radius of the physics imposter
  24399. */
  24400. getRadius(): number;
  24401. /**
  24402. * Sync a bone with this impostor
  24403. * @param bone The bone to sync to the impostor.
  24404. * @param boneMesh The mesh that the bone is influencing.
  24405. * @param jointPivot The pivot of the joint / bone in local space.
  24406. * @param distToJoint Optional distance from the impostor to the joint.
  24407. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24408. */
  24409. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24410. /**
  24411. * Sync impostor to a bone
  24412. * @param bone The bone that the impostor will be synced to.
  24413. * @param boneMesh The mesh that the bone is influencing.
  24414. * @param jointPivot The pivot of the joint / bone in local space.
  24415. * @param distToJoint Optional distance from the impostor to the joint.
  24416. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24417. * @param boneAxis Optional vector3 axis the bone is aligned with
  24418. */
  24419. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24420. /**
  24421. * No-Imposter type
  24422. */
  24423. static NoImpostor: number;
  24424. /**
  24425. * Sphere-Imposter type
  24426. */
  24427. static SphereImpostor: number;
  24428. /**
  24429. * Box-Imposter type
  24430. */
  24431. static BoxImpostor: number;
  24432. /**
  24433. * Plane-Imposter type
  24434. */
  24435. static PlaneImpostor: number;
  24436. /**
  24437. * Mesh-imposter type
  24438. */
  24439. static MeshImpostor: number;
  24440. /**
  24441. * Capsule-Impostor type (Ammo.js plugin only)
  24442. */
  24443. static CapsuleImpostor: number;
  24444. /**
  24445. * Cylinder-Imposter type
  24446. */
  24447. static CylinderImpostor: number;
  24448. /**
  24449. * Particle-Imposter type
  24450. */
  24451. static ParticleImpostor: number;
  24452. /**
  24453. * Heightmap-Imposter type
  24454. */
  24455. static HeightmapImpostor: number;
  24456. /**
  24457. * ConvexHull-Impostor type (Ammo.js plugin only)
  24458. */
  24459. static ConvexHullImpostor: number;
  24460. /**
  24461. * Custom-Imposter type (Ammo.js plugin only)
  24462. */
  24463. static CustomImpostor: number;
  24464. /**
  24465. * Rope-Imposter type
  24466. */
  24467. static RopeImpostor: number;
  24468. /**
  24469. * Cloth-Imposter type
  24470. */
  24471. static ClothImpostor: number;
  24472. /**
  24473. * Softbody-Imposter type
  24474. */
  24475. static SoftbodyImpostor: number;
  24476. }
  24477. }
  24478. declare module "babylonjs/Meshes/mesh" {
  24479. import { Observable } from "babylonjs/Misc/observable";
  24480. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24481. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24482. import { Camera } from "babylonjs/Cameras/camera";
  24483. import { Scene } from "babylonjs/scene";
  24484. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24485. import { Color4 } from "babylonjs/Maths/math.color";
  24486. import { Engine } from "babylonjs/Engines/engine";
  24487. import { Node } from "babylonjs/node";
  24488. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24489. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24490. import { Buffer } from "babylonjs/Meshes/buffer";
  24491. import { Geometry } from "babylonjs/Meshes/geometry";
  24492. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24493. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24494. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24495. import { Effect } from "babylonjs/Materials/effect";
  24496. import { Material } from "babylonjs/Materials/material";
  24497. import { Skeleton } from "babylonjs/Bones/skeleton";
  24498. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24499. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24500. import { Path3D } from "babylonjs/Maths/math.path";
  24501. import { Plane } from "babylonjs/Maths/math.plane";
  24502. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24503. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24504. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24505. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24506. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24507. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24508. /**
  24509. * @hidden
  24510. **/
  24511. export class _CreationDataStorage {
  24512. closePath?: boolean;
  24513. closeArray?: boolean;
  24514. idx: number[];
  24515. dashSize: number;
  24516. gapSize: number;
  24517. path3D: Path3D;
  24518. pathArray: Vector3[][];
  24519. arc: number;
  24520. radius: number;
  24521. cap: number;
  24522. tessellation: number;
  24523. }
  24524. /**
  24525. * @hidden
  24526. **/
  24527. class _InstanceDataStorage {
  24528. visibleInstances: any;
  24529. batchCache: _InstancesBatch;
  24530. instancesBufferSize: number;
  24531. instancesBuffer: Nullable<Buffer>;
  24532. instancesData: Float32Array;
  24533. overridenInstanceCount: number;
  24534. isFrozen: boolean;
  24535. previousBatch: Nullable<_InstancesBatch>;
  24536. hardwareInstancedRendering: boolean;
  24537. sideOrientation: number;
  24538. manualUpdate: boolean;
  24539. }
  24540. /**
  24541. * @hidden
  24542. **/
  24543. export class _InstancesBatch {
  24544. mustReturn: boolean;
  24545. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24546. renderSelf: boolean[];
  24547. hardwareInstancedRendering: boolean[];
  24548. }
  24549. /**
  24550. * Class used to represent renderable models
  24551. */
  24552. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24553. /**
  24554. * Mesh side orientation : usually the external or front surface
  24555. */
  24556. static readonly FRONTSIDE: number;
  24557. /**
  24558. * Mesh side orientation : usually the internal or back surface
  24559. */
  24560. static readonly BACKSIDE: number;
  24561. /**
  24562. * Mesh side orientation : both internal and external or front and back surfaces
  24563. */
  24564. static readonly DOUBLESIDE: number;
  24565. /**
  24566. * Mesh side orientation : by default, `FRONTSIDE`
  24567. */
  24568. static readonly DEFAULTSIDE: number;
  24569. /**
  24570. * Mesh cap setting : no cap
  24571. */
  24572. static readonly NO_CAP: number;
  24573. /**
  24574. * Mesh cap setting : one cap at the beginning of the mesh
  24575. */
  24576. static readonly CAP_START: number;
  24577. /**
  24578. * Mesh cap setting : one cap at the end of the mesh
  24579. */
  24580. static readonly CAP_END: number;
  24581. /**
  24582. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24583. */
  24584. static readonly CAP_ALL: number;
  24585. /**
  24586. * Mesh pattern setting : no flip or rotate
  24587. */
  24588. static readonly NO_FLIP: number;
  24589. /**
  24590. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24591. */
  24592. static readonly FLIP_TILE: number;
  24593. /**
  24594. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24595. */
  24596. static readonly ROTATE_TILE: number;
  24597. /**
  24598. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24599. */
  24600. static readonly FLIP_ROW: number;
  24601. /**
  24602. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24603. */
  24604. static readonly ROTATE_ROW: number;
  24605. /**
  24606. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24607. */
  24608. static readonly FLIP_N_ROTATE_TILE: number;
  24609. /**
  24610. * Mesh pattern setting : rotate pattern and rotate
  24611. */
  24612. static readonly FLIP_N_ROTATE_ROW: number;
  24613. /**
  24614. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24615. */
  24616. static readonly CENTER: number;
  24617. /**
  24618. * Mesh tile positioning : part tiles on left
  24619. */
  24620. static readonly LEFT: number;
  24621. /**
  24622. * Mesh tile positioning : part tiles on right
  24623. */
  24624. static readonly RIGHT: number;
  24625. /**
  24626. * Mesh tile positioning : part tiles on top
  24627. */
  24628. static readonly TOP: number;
  24629. /**
  24630. * Mesh tile positioning : part tiles on bottom
  24631. */
  24632. static readonly BOTTOM: number;
  24633. /**
  24634. * Gets the default side orientation.
  24635. * @param orientation the orientation to value to attempt to get
  24636. * @returns the default orientation
  24637. * @hidden
  24638. */
  24639. static _GetDefaultSideOrientation(orientation?: number): number;
  24640. private _internalMeshDataInfo;
  24641. /**
  24642. * An event triggered before rendering the mesh
  24643. */
  24644. readonly onBeforeRenderObservable: Observable<Mesh>;
  24645. /**
  24646. * An event triggered before binding the mesh
  24647. */
  24648. readonly onBeforeBindObservable: Observable<Mesh>;
  24649. /**
  24650. * An event triggered after rendering the mesh
  24651. */
  24652. readonly onAfterRenderObservable: Observable<Mesh>;
  24653. /**
  24654. * An event triggered before drawing the mesh
  24655. */
  24656. readonly onBeforeDrawObservable: Observable<Mesh>;
  24657. private _onBeforeDrawObserver;
  24658. /**
  24659. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24660. */
  24661. onBeforeDraw: () => void;
  24662. readonly hasInstances: boolean;
  24663. /**
  24664. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24665. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24666. */
  24667. delayLoadState: number;
  24668. /**
  24669. * Gets the list of instances created from this mesh
  24670. * it is not supposed to be modified manually.
  24671. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24672. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24673. */
  24674. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24675. /**
  24676. * Gets the file containing delay loading data for this mesh
  24677. */
  24678. delayLoadingFile: string;
  24679. /** @hidden */
  24680. _binaryInfo: any;
  24681. /**
  24682. * User defined function used to change how LOD level selection is done
  24683. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24684. */
  24685. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24686. /**
  24687. * Gets or sets the morph target manager
  24688. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24689. */
  24690. morphTargetManager: Nullable<MorphTargetManager>;
  24691. /** @hidden */
  24692. _creationDataStorage: Nullable<_CreationDataStorage>;
  24693. /** @hidden */
  24694. _geometry: Nullable<Geometry>;
  24695. /** @hidden */
  24696. _delayInfo: Array<string>;
  24697. /** @hidden */
  24698. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24699. /** @hidden */
  24700. _instanceDataStorage: _InstanceDataStorage;
  24701. private _effectiveMaterial;
  24702. /** @hidden */
  24703. _shouldGenerateFlatShading: boolean;
  24704. /** @hidden */
  24705. _originalBuilderSideOrientation: number;
  24706. /**
  24707. * Use this property to change the original side orientation defined at construction time
  24708. */
  24709. overrideMaterialSideOrientation: Nullable<number>;
  24710. /**
  24711. * Gets the source mesh (the one used to clone this one from)
  24712. */
  24713. readonly source: Nullable<Mesh>;
  24714. /**
  24715. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24716. */
  24717. isUnIndexed: boolean;
  24718. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24719. readonly worldMatrixInstancedBuffer: Float32Array;
  24720. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24721. manualUpdateOfWorldMatrixInstancedBuffer: boolean;
  24722. /**
  24723. * @constructor
  24724. * @param name The value used by scene.getMeshByName() to do a lookup.
  24725. * @param scene The scene to add this mesh to.
  24726. * @param parent The parent of this mesh, if it has one
  24727. * @param source An optional Mesh from which geometry is shared, cloned.
  24728. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24729. * When false, achieved by calling a clone(), also passing False.
  24730. * This will make creation of children, recursive.
  24731. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24732. */
  24733. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24734. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24735. doNotInstantiate: boolean;
  24736. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24737. /**
  24738. * Gets the class name
  24739. * @returns the string "Mesh".
  24740. */
  24741. getClassName(): string;
  24742. /** @hidden */
  24743. readonly _isMesh: boolean;
  24744. /**
  24745. * Returns a description of this mesh
  24746. * @param fullDetails define if full details about this mesh must be used
  24747. * @returns a descriptive string representing this mesh
  24748. */
  24749. toString(fullDetails?: boolean): string;
  24750. /** @hidden */
  24751. _unBindEffect(): void;
  24752. /**
  24753. * Gets a boolean indicating if this mesh has LOD
  24754. */
  24755. readonly hasLODLevels: boolean;
  24756. /**
  24757. * Gets the list of MeshLODLevel associated with the current mesh
  24758. * @returns an array of MeshLODLevel
  24759. */
  24760. getLODLevels(): MeshLODLevel[];
  24761. private _sortLODLevels;
  24762. /**
  24763. * Add a mesh as LOD level triggered at the given distance.
  24764. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24765. * @param distance The distance from the center of the object to show this level
  24766. * @param mesh The mesh to be added as LOD level (can be null)
  24767. * @return This mesh (for chaining)
  24768. */
  24769. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24770. /**
  24771. * Returns the LOD level mesh at the passed distance or null if not found.
  24772. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24773. * @param distance The distance from the center of the object to show this level
  24774. * @returns a Mesh or `null`
  24775. */
  24776. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24777. /**
  24778. * Remove a mesh from the LOD array
  24779. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24780. * @param mesh defines the mesh to be removed
  24781. * @return This mesh (for chaining)
  24782. */
  24783. removeLODLevel(mesh: Mesh): Mesh;
  24784. /**
  24785. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24786. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24787. * @param camera defines the camera to use to compute distance
  24788. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24789. * @return This mesh (for chaining)
  24790. */
  24791. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24792. /**
  24793. * Gets the mesh internal Geometry object
  24794. */
  24795. readonly geometry: Nullable<Geometry>;
  24796. /**
  24797. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24798. * @returns the total number of vertices
  24799. */
  24800. getTotalVertices(): number;
  24801. /**
  24802. * Returns the content of an associated vertex buffer
  24803. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24804. * - VertexBuffer.PositionKind
  24805. * - VertexBuffer.UVKind
  24806. * - VertexBuffer.UV2Kind
  24807. * - VertexBuffer.UV3Kind
  24808. * - VertexBuffer.UV4Kind
  24809. * - VertexBuffer.UV5Kind
  24810. * - VertexBuffer.UV6Kind
  24811. * - VertexBuffer.ColorKind
  24812. * - VertexBuffer.MatricesIndicesKind
  24813. * - VertexBuffer.MatricesIndicesExtraKind
  24814. * - VertexBuffer.MatricesWeightsKind
  24815. * - VertexBuffer.MatricesWeightsExtraKind
  24816. * @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
  24817. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24818. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24819. */
  24820. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24821. /**
  24822. * Returns the mesh VertexBuffer object from the requested `kind`
  24823. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24824. * - VertexBuffer.PositionKind
  24825. * - VertexBuffer.NormalKind
  24826. * - VertexBuffer.UVKind
  24827. * - VertexBuffer.UV2Kind
  24828. * - VertexBuffer.UV3Kind
  24829. * - VertexBuffer.UV4Kind
  24830. * - VertexBuffer.UV5Kind
  24831. * - VertexBuffer.UV6Kind
  24832. * - VertexBuffer.ColorKind
  24833. * - VertexBuffer.MatricesIndicesKind
  24834. * - VertexBuffer.MatricesIndicesExtraKind
  24835. * - VertexBuffer.MatricesWeightsKind
  24836. * - VertexBuffer.MatricesWeightsExtraKind
  24837. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24838. */
  24839. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24840. /**
  24841. * Tests if a specific vertex buffer is associated with this mesh
  24842. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24843. * - VertexBuffer.PositionKind
  24844. * - VertexBuffer.NormalKind
  24845. * - VertexBuffer.UVKind
  24846. * - VertexBuffer.UV2Kind
  24847. * - VertexBuffer.UV3Kind
  24848. * - VertexBuffer.UV4Kind
  24849. * - VertexBuffer.UV5Kind
  24850. * - VertexBuffer.UV6Kind
  24851. * - VertexBuffer.ColorKind
  24852. * - VertexBuffer.MatricesIndicesKind
  24853. * - VertexBuffer.MatricesIndicesExtraKind
  24854. * - VertexBuffer.MatricesWeightsKind
  24855. * - VertexBuffer.MatricesWeightsExtraKind
  24856. * @returns a boolean
  24857. */
  24858. isVerticesDataPresent(kind: string): boolean;
  24859. /**
  24860. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24861. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24862. * - VertexBuffer.PositionKind
  24863. * - VertexBuffer.UVKind
  24864. * - VertexBuffer.UV2Kind
  24865. * - VertexBuffer.UV3Kind
  24866. * - VertexBuffer.UV4Kind
  24867. * - VertexBuffer.UV5Kind
  24868. * - VertexBuffer.UV6Kind
  24869. * - VertexBuffer.ColorKind
  24870. * - VertexBuffer.MatricesIndicesKind
  24871. * - VertexBuffer.MatricesIndicesExtraKind
  24872. * - VertexBuffer.MatricesWeightsKind
  24873. * - VertexBuffer.MatricesWeightsExtraKind
  24874. * @returns a boolean
  24875. */
  24876. isVertexBufferUpdatable(kind: string): boolean;
  24877. /**
  24878. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24879. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24880. * - VertexBuffer.PositionKind
  24881. * - VertexBuffer.NormalKind
  24882. * - VertexBuffer.UVKind
  24883. * - VertexBuffer.UV2Kind
  24884. * - VertexBuffer.UV3Kind
  24885. * - VertexBuffer.UV4Kind
  24886. * - VertexBuffer.UV5Kind
  24887. * - VertexBuffer.UV6Kind
  24888. * - VertexBuffer.ColorKind
  24889. * - VertexBuffer.MatricesIndicesKind
  24890. * - VertexBuffer.MatricesIndicesExtraKind
  24891. * - VertexBuffer.MatricesWeightsKind
  24892. * - VertexBuffer.MatricesWeightsExtraKind
  24893. * @returns an array of strings
  24894. */
  24895. getVerticesDataKinds(): string[];
  24896. /**
  24897. * Returns a positive integer : the total number of indices in this mesh geometry.
  24898. * @returns the numner of indices or zero if the mesh has no geometry.
  24899. */
  24900. getTotalIndices(): number;
  24901. /**
  24902. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24903. * @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.
  24904. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24905. * @returns the indices array or an empty array if the mesh has no geometry
  24906. */
  24907. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24908. readonly isBlocked: boolean;
  24909. /**
  24910. * Determine if the current mesh is ready to be rendered
  24911. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24912. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24913. * @returns true if all associated assets are ready (material, textures, shaders)
  24914. */
  24915. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24916. /**
  24917. * 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.
  24918. */
  24919. readonly areNormalsFrozen: boolean;
  24920. /**
  24921. * 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.
  24922. * @returns the current mesh
  24923. */
  24924. freezeNormals(): Mesh;
  24925. /**
  24926. * 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
  24927. * @returns the current mesh
  24928. */
  24929. unfreezeNormals(): Mesh;
  24930. /**
  24931. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24932. */
  24933. overridenInstanceCount: number;
  24934. /** @hidden */
  24935. _preActivate(): Mesh;
  24936. /** @hidden */
  24937. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24938. /** @hidden */
  24939. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24940. /**
  24941. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24942. * This means the mesh underlying bounding box and sphere are recomputed.
  24943. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24944. * @returns the current mesh
  24945. */
  24946. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24947. /** @hidden */
  24948. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24949. /**
  24950. * This function will subdivide the mesh into multiple submeshes
  24951. * @param count defines the expected number of submeshes
  24952. */
  24953. subdivide(count: number): void;
  24954. /**
  24955. * Copy a FloatArray into a specific associated vertex buffer
  24956. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24957. * - VertexBuffer.PositionKind
  24958. * - VertexBuffer.UVKind
  24959. * - VertexBuffer.UV2Kind
  24960. * - VertexBuffer.UV3Kind
  24961. * - VertexBuffer.UV4Kind
  24962. * - VertexBuffer.UV5Kind
  24963. * - VertexBuffer.UV6Kind
  24964. * - VertexBuffer.ColorKind
  24965. * - VertexBuffer.MatricesIndicesKind
  24966. * - VertexBuffer.MatricesIndicesExtraKind
  24967. * - VertexBuffer.MatricesWeightsKind
  24968. * - VertexBuffer.MatricesWeightsExtraKind
  24969. * @param data defines the data source
  24970. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24971. * @param stride defines the data stride size (can be null)
  24972. * @returns the current mesh
  24973. */
  24974. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24975. /**
  24976. * Delete a vertex buffer associated with this mesh
  24977. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  24978. * - VertexBuffer.PositionKind
  24979. * - VertexBuffer.UVKind
  24980. * - VertexBuffer.UV2Kind
  24981. * - VertexBuffer.UV3Kind
  24982. * - VertexBuffer.UV4Kind
  24983. * - VertexBuffer.UV5Kind
  24984. * - VertexBuffer.UV6Kind
  24985. * - VertexBuffer.ColorKind
  24986. * - VertexBuffer.MatricesIndicesKind
  24987. * - VertexBuffer.MatricesIndicesExtraKind
  24988. * - VertexBuffer.MatricesWeightsKind
  24989. * - VertexBuffer.MatricesWeightsExtraKind
  24990. */
  24991. removeVerticesData(kind: string): void;
  24992. /**
  24993. * Flags an associated vertex buffer as updatable
  24994. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24995. * - VertexBuffer.PositionKind
  24996. * - VertexBuffer.UVKind
  24997. * - VertexBuffer.UV2Kind
  24998. * - VertexBuffer.UV3Kind
  24999. * - VertexBuffer.UV4Kind
  25000. * - VertexBuffer.UV5Kind
  25001. * - VertexBuffer.UV6Kind
  25002. * - VertexBuffer.ColorKind
  25003. * - VertexBuffer.MatricesIndicesKind
  25004. * - VertexBuffer.MatricesIndicesExtraKind
  25005. * - VertexBuffer.MatricesWeightsKind
  25006. * - VertexBuffer.MatricesWeightsExtraKind
  25007. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25008. */
  25009. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  25010. /**
  25011. * Sets the mesh global Vertex Buffer
  25012. * @param buffer defines the buffer to use
  25013. * @returns the current mesh
  25014. */
  25015. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  25016. /**
  25017. * Update a specific associated vertex buffer
  25018. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25019. * - VertexBuffer.PositionKind
  25020. * - VertexBuffer.UVKind
  25021. * - VertexBuffer.UV2Kind
  25022. * - VertexBuffer.UV3Kind
  25023. * - VertexBuffer.UV4Kind
  25024. * - VertexBuffer.UV5Kind
  25025. * - VertexBuffer.UV6Kind
  25026. * - VertexBuffer.ColorKind
  25027. * - VertexBuffer.MatricesIndicesKind
  25028. * - VertexBuffer.MatricesIndicesExtraKind
  25029. * - VertexBuffer.MatricesWeightsKind
  25030. * - VertexBuffer.MatricesWeightsExtraKind
  25031. * @param data defines the data source
  25032. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25033. * @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)
  25034. * @returns the current mesh
  25035. */
  25036. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25037. /**
  25038. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  25039. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  25040. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  25041. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  25042. * @returns the current mesh
  25043. */
  25044. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  25045. /**
  25046. * Creates a un-shared specific occurence of the geometry for the mesh.
  25047. * @returns the current mesh
  25048. */
  25049. makeGeometryUnique(): Mesh;
  25050. /**
  25051. * Set the index buffer of this mesh
  25052. * @param indices defines the source data
  25053. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  25054. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  25055. * @returns the current mesh
  25056. */
  25057. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  25058. /**
  25059. * Update the current index buffer
  25060. * @param indices defines the source data
  25061. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25062. * @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)
  25063. * @returns the current mesh
  25064. */
  25065. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25066. /**
  25067. * Invert the geometry to move from a right handed system to a left handed one.
  25068. * @returns the current mesh
  25069. */
  25070. toLeftHanded(): Mesh;
  25071. /** @hidden */
  25072. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  25073. /** @hidden */
  25074. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  25075. /**
  25076. * Registers for this mesh a javascript function called just before the rendering process
  25077. * @param func defines the function to call before rendering this mesh
  25078. * @returns the current mesh
  25079. */
  25080. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25081. /**
  25082. * Disposes a previously registered javascript function called before the rendering
  25083. * @param func defines the function to remove
  25084. * @returns the current mesh
  25085. */
  25086. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25087. /**
  25088. * Registers for this mesh a javascript function called just after the rendering is complete
  25089. * @param func defines the function to call after rendering this mesh
  25090. * @returns the current mesh
  25091. */
  25092. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25093. /**
  25094. * Disposes a previously registered javascript function called after the rendering.
  25095. * @param func defines the function to remove
  25096. * @returns the current mesh
  25097. */
  25098. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25099. /** @hidden */
  25100. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  25101. /** @hidden */
  25102. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25103. /** @hidden */
  25104. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25105. /** @hidden */
  25106. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25107. /** @hidden */
  25108. _rebuild(): void;
  25109. /** @hidden */
  25110. _freeze(): void;
  25111. /** @hidden */
  25112. _unFreeze(): void;
  25113. /**
  25114. * 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
  25115. * @param subMesh defines the subMesh to render
  25116. * @param enableAlphaMode defines if alpha mode can be changed
  25117. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25118. * @returns the current mesh
  25119. */
  25120. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25121. private _onBeforeDraw;
  25122. /**
  25123. * Renormalize the mesh and patch it up if there are no weights
  25124. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25125. * However in the case of zero weights then we set just a single influence to 1.
  25126. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25127. */
  25128. cleanMatrixWeights(): void;
  25129. private normalizeSkinFourWeights;
  25130. private normalizeSkinWeightsAndExtra;
  25131. /**
  25132. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25133. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25134. * the user know there was an issue with importing the mesh
  25135. * @returns a validation object with skinned, valid and report string
  25136. */
  25137. validateSkinning(): {
  25138. skinned: boolean;
  25139. valid: boolean;
  25140. report: string;
  25141. };
  25142. /** @hidden */
  25143. _checkDelayState(): Mesh;
  25144. private _queueLoad;
  25145. /**
  25146. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25147. * A mesh is in the frustum if its bounding box intersects the frustum
  25148. * @param frustumPlanes defines the frustum to test
  25149. * @returns true if the mesh is in the frustum planes
  25150. */
  25151. isInFrustum(frustumPlanes: Plane[]): boolean;
  25152. /**
  25153. * Sets the mesh material by the material or multiMaterial `id` property
  25154. * @param id is a string identifying the material or the multiMaterial
  25155. * @returns the current mesh
  25156. */
  25157. setMaterialByID(id: string): Mesh;
  25158. /**
  25159. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25160. * @returns an array of IAnimatable
  25161. */
  25162. getAnimatables(): IAnimatable[];
  25163. /**
  25164. * Modifies the mesh geometry according to the passed transformation matrix.
  25165. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25166. * The mesh normals are modified using the same transformation.
  25167. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25168. * @param transform defines the transform matrix to use
  25169. * @see http://doc.babylonjs.com/resources/baking_transformations
  25170. * @returns the current mesh
  25171. */
  25172. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25173. /**
  25174. * Modifies the mesh geometry according to its own current World Matrix.
  25175. * The mesh World Matrix is then reset.
  25176. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25177. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25178. * @see http://doc.babylonjs.com/resources/baking_transformations
  25179. * @returns the current mesh
  25180. */
  25181. bakeCurrentTransformIntoVertices(): Mesh;
  25182. /** @hidden */
  25183. readonly _positions: Nullable<Vector3[]>;
  25184. /** @hidden */
  25185. _resetPointsArrayCache(): Mesh;
  25186. /** @hidden */
  25187. _generatePointsArray(): boolean;
  25188. /**
  25189. * Returns a new Mesh object generated from the current mesh properties.
  25190. * This method must not get confused with createInstance()
  25191. * @param name is a string, the name given to the new mesh
  25192. * @param newParent can be any Node object (default `null`)
  25193. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25194. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25195. * @returns a new mesh
  25196. */
  25197. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  25198. /**
  25199. * Releases resources associated with this mesh.
  25200. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25201. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25202. */
  25203. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25204. /** @hidden */
  25205. _disposeInstanceSpecificData(): void;
  25206. /**
  25207. * Modifies the mesh geometry according to a displacement map.
  25208. * 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.
  25209. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25210. * @param url is a string, the URL from the image file is to be downloaded.
  25211. * @param minHeight is the lower limit of the displacement.
  25212. * @param maxHeight is the upper limit of the displacement.
  25213. * @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.
  25214. * @param uvOffset is an optional vector2 used to offset UV.
  25215. * @param uvScale is an optional vector2 used to scale UV.
  25216. * @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.
  25217. * @returns the Mesh.
  25218. */
  25219. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25220. /**
  25221. * Modifies the mesh geometry according to a displacementMap buffer.
  25222. * 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.
  25223. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25224. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25225. * @param heightMapWidth is the width of the buffer image.
  25226. * @param heightMapHeight is the height of the buffer image.
  25227. * @param minHeight is the lower limit of the displacement.
  25228. * @param maxHeight is the upper limit of the displacement.
  25229. * @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.
  25230. * @param uvOffset is an optional vector2 used to offset UV.
  25231. * @param uvScale is an optional vector2 used to scale UV.
  25232. * @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.
  25233. * @returns the Mesh.
  25234. */
  25235. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25236. /**
  25237. * Modify the mesh to get a flat shading rendering.
  25238. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25239. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25240. * @returns current mesh
  25241. */
  25242. convertToFlatShadedMesh(): Mesh;
  25243. /**
  25244. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25245. * In other words, more vertices, no more indices and a single bigger VBO.
  25246. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25247. * @returns current mesh
  25248. */
  25249. convertToUnIndexedMesh(): Mesh;
  25250. /**
  25251. * Inverses facet orientations.
  25252. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25253. * @param flipNormals will also inverts the normals
  25254. * @returns current mesh
  25255. */
  25256. flipFaces(flipNormals?: boolean): Mesh;
  25257. /**
  25258. * Increase the number of facets and hence vertices in a mesh
  25259. * Vertex normals are interpolated from existing vertex normals
  25260. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25261. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25262. */
  25263. increaseVertices(numberPerEdge: number): void;
  25264. /**
  25265. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25266. * This will undo any application of covertToFlatShadedMesh
  25267. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25268. */
  25269. forceSharedVertices(): void;
  25270. /** @hidden */
  25271. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25272. /** @hidden */
  25273. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25274. /**
  25275. * Creates a new InstancedMesh object from the mesh model.
  25276. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25277. * @param name defines the name of the new instance
  25278. * @returns a new InstancedMesh
  25279. */
  25280. createInstance(name: string): InstancedMesh;
  25281. /**
  25282. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25283. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25284. * @returns the current mesh
  25285. */
  25286. synchronizeInstances(): Mesh;
  25287. /**
  25288. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25289. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25290. * This should be used together with the simplification to avoid disappearing triangles.
  25291. * @param successCallback an optional success callback to be called after the optimization finished.
  25292. * @returns the current mesh
  25293. */
  25294. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25295. /**
  25296. * Serialize current mesh
  25297. * @param serializationObject defines the object which will receive the serialization data
  25298. */
  25299. serialize(serializationObject: any): void;
  25300. /** @hidden */
  25301. _syncGeometryWithMorphTargetManager(): void;
  25302. /** @hidden */
  25303. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25304. /**
  25305. * Returns a new Mesh object parsed from the source provided.
  25306. * @param parsedMesh is the source
  25307. * @param scene defines the hosting scene
  25308. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25309. * @returns a new Mesh
  25310. */
  25311. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25312. /**
  25313. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25314. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25315. * @param name defines the name of the mesh to create
  25316. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25317. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25318. * @param closePath creates a seam between the first and the last points of each path of the path array
  25319. * @param offset is taken in account only if the `pathArray` is containing a single path
  25320. * @param scene defines the hosting scene
  25321. * @param updatable defines if the mesh must be flagged as updatable
  25322. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25323. * @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)
  25324. * @returns a new Mesh
  25325. */
  25326. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25327. /**
  25328. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25329. * @param name defines the name of the mesh to create
  25330. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25331. * @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
  25332. * @param scene defines the hosting scene
  25333. * @param updatable defines if the mesh must be flagged as updatable
  25334. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25335. * @returns a new Mesh
  25336. */
  25337. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25338. /**
  25339. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25340. * @param name defines the name of the mesh to create
  25341. * @param size sets the size (float) of each box side (default 1)
  25342. * @param scene defines the hosting scene
  25343. * @param updatable defines if the mesh must be flagged as updatable
  25344. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25345. * @returns a new Mesh
  25346. */
  25347. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25348. /**
  25349. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25350. * @param name defines the name of the mesh to create
  25351. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25352. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25353. * @param scene defines the hosting scene
  25354. * @param updatable defines if the mesh must be flagged as updatable
  25355. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25356. * @returns a new Mesh
  25357. */
  25358. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25359. /**
  25360. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25361. * @param name defines the name of the mesh to create
  25362. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25363. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25364. * @param scene defines the hosting scene
  25365. * @returns a new Mesh
  25366. */
  25367. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25368. /**
  25369. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25370. * @param name defines the name of the mesh to create
  25371. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25372. * @param diameterTop set the top cap diameter (floats, default 1)
  25373. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25374. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25375. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25376. * @param scene defines the hosting scene
  25377. * @param updatable defines if the mesh must be flagged as updatable
  25378. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25379. * @returns a new Mesh
  25380. */
  25381. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25382. /**
  25383. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25384. * @param name defines the name of the mesh to create
  25385. * @param diameter sets the diameter size (float) of the torus (default 1)
  25386. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25387. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25388. * @param scene defines the hosting scene
  25389. * @param updatable defines if the mesh must be flagged as updatable
  25390. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25391. * @returns a new Mesh
  25392. */
  25393. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25394. /**
  25395. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25396. * @param name defines the name of the mesh to create
  25397. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25398. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25399. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25400. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25401. * @param p the number of windings on X axis (positive integers, default 2)
  25402. * @param q the number of windings on Y axis (positive integers, default 3)
  25403. * @param scene defines the hosting scene
  25404. * @param updatable defines if the mesh must be flagged as updatable
  25405. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25406. * @returns a new Mesh
  25407. */
  25408. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25409. /**
  25410. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25411. * @param name defines the name of the mesh to create
  25412. * @param points is an array successive Vector3
  25413. * @param scene defines the hosting scene
  25414. * @param updatable defines if the mesh must be flagged as updatable
  25415. * @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).
  25416. * @returns a new Mesh
  25417. */
  25418. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25419. /**
  25420. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25421. * @param name defines the name of the mesh to create
  25422. * @param points is an array successive Vector3
  25423. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25424. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25425. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25426. * @param scene defines the hosting scene
  25427. * @param updatable defines if the mesh must be flagged as updatable
  25428. * @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)
  25429. * @returns a new Mesh
  25430. */
  25431. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25432. /**
  25433. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25434. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25435. * 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.
  25436. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25437. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25438. * Remember you can only change the shape positions, not their number when updating a polygon.
  25439. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25440. * @param name defines the name of the mesh to create
  25441. * @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
  25442. * @param scene defines the hosting scene
  25443. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25444. * @param updatable defines if the mesh must be flagged as updatable
  25445. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25446. * @param earcutInjection can be used to inject your own earcut reference
  25447. * @returns a new Mesh
  25448. */
  25449. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25450. /**
  25451. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25452. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25453. * @param name defines the name of the mesh to create
  25454. * @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
  25455. * @param depth defines the height of extrusion
  25456. * @param scene defines the hosting scene
  25457. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25458. * @param updatable defines if the mesh must be flagged as updatable
  25459. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25460. * @param earcutInjection can be used to inject your own earcut reference
  25461. * @returns a new Mesh
  25462. */
  25463. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25464. /**
  25465. * Creates an extruded shape mesh.
  25466. * 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
  25467. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25468. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25469. * @param name defines the name of the mesh to create
  25470. * @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
  25471. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25472. * @param scale is the value to scale the shape
  25473. * @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
  25474. * @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
  25475. * @param scene defines the hosting scene
  25476. * @param updatable defines if the mesh must be flagged as updatable
  25477. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25478. * @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)
  25479. * @returns a new Mesh
  25480. */
  25481. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25482. /**
  25483. * Creates an custom extruded shape mesh.
  25484. * The custom extrusion is a parametric shape.
  25485. * It has no predefined shape. Its final shape will depend on the input parameters.
  25486. * Please consider using the same method from the MeshBuilder class instead
  25487. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25488. * @param name defines the name of the mesh to create
  25489. * @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
  25490. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25491. * @param scaleFunction is a custom Javascript function called on each path point
  25492. * @param rotationFunction is a custom Javascript function called on each path point
  25493. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25494. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25495. * @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
  25496. * @param scene defines the hosting scene
  25497. * @param updatable defines if the mesh must be flagged as updatable
  25498. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25499. * @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)
  25500. * @returns a new Mesh
  25501. */
  25502. 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;
  25503. /**
  25504. * Creates lathe mesh.
  25505. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25506. * Please consider using the same method from the MeshBuilder class instead
  25507. * @param name defines the name of the mesh to create
  25508. * @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
  25509. * @param radius is the radius value of the lathe
  25510. * @param tessellation is the side number of the lathe.
  25511. * @param scene defines the hosting scene
  25512. * @param updatable defines if the mesh must be flagged as updatable
  25513. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25514. * @returns a new Mesh
  25515. */
  25516. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25517. /**
  25518. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25519. * @param name defines the name of the mesh to create
  25520. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25521. * @param scene defines the hosting scene
  25522. * @param updatable defines if the mesh must be flagged as updatable
  25523. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25524. * @returns a new Mesh
  25525. */
  25526. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25527. /**
  25528. * Creates a ground mesh.
  25529. * Please consider using the same method from the MeshBuilder class instead
  25530. * @param name defines the name of the mesh to create
  25531. * @param width set the width of the ground
  25532. * @param height set the height of the ground
  25533. * @param subdivisions sets the number of subdivisions per side
  25534. * @param scene defines the hosting scene
  25535. * @param updatable defines if the mesh must be flagged as updatable
  25536. * @returns a new Mesh
  25537. */
  25538. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25539. /**
  25540. * Creates a tiled ground mesh.
  25541. * Please consider using the same method from the MeshBuilder class instead
  25542. * @param name defines the name of the mesh to create
  25543. * @param xmin set the ground minimum X coordinate
  25544. * @param zmin set the ground minimum Y coordinate
  25545. * @param xmax set the ground maximum X coordinate
  25546. * @param zmax set the ground maximum Z coordinate
  25547. * @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
  25548. * @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
  25549. * @param scene defines the hosting scene
  25550. * @param updatable defines if the mesh must be flagged as updatable
  25551. * @returns a new Mesh
  25552. */
  25553. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25554. w: number;
  25555. h: number;
  25556. }, precision: {
  25557. w: number;
  25558. h: number;
  25559. }, scene: Scene, updatable?: boolean): Mesh;
  25560. /**
  25561. * Creates a ground mesh from a height map.
  25562. * Please consider using the same method from the MeshBuilder class instead
  25563. * @see http://doc.babylonjs.com/babylon101/height_map
  25564. * @param name defines the name of the mesh to create
  25565. * @param url sets the URL of the height map image resource
  25566. * @param width set the ground width size
  25567. * @param height set the ground height size
  25568. * @param subdivisions sets the number of subdivision per side
  25569. * @param minHeight is the minimum altitude on the ground
  25570. * @param maxHeight is the maximum altitude on the ground
  25571. * @param scene defines the hosting scene
  25572. * @param updatable defines if the mesh must be flagged as updatable
  25573. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25574. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25575. * @returns a new Mesh
  25576. */
  25577. 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;
  25578. /**
  25579. * Creates a tube mesh.
  25580. * The tube is a parametric shape.
  25581. * It has no predefined shape. Its final shape will depend on the input parameters.
  25582. * Please consider using the same method from the MeshBuilder class instead
  25583. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25584. * @param name defines the name of the mesh to create
  25585. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25586. * @param radius sets the tube radius size
  25587. * @param tessellation is the number of sides on the tubular surface
  25588. * @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
  25589. * @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
  25590. * @param scene defines the hosting scene
  25591. * @param updatable defines if the mesh must be flagged as updatable
  25592. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25593. * @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)
  25594. * @returns a new Mesh
  25595. */
  25596. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25597. (i: number, distance: number): number;
  25598. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25599. /**
  25600. * Creates a polyhedron mesh.
  25601. * Please consider using the same method from the MeshBuilder class instead.
  25602. * * 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
  25603. * * The parameter `size` (positive float, default 1) sets the polygon size
  25604. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25605. * * 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`
  25606. * * 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
  25607. * * 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)`)
  25608. * * 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
  25609. * * 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
  25610. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25611. * * If you create a double-sided mesh, you can choose what parts of 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
  25612. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25613. * @param name defines the name of the mesh to create
  25614. * @param options defines the options used to create the mesh
  25615. * @param scene defines the hosting scene
  25616. * @returns a new Mesh
  25617. */
  25618. static CreatePolyhedron(name: string, options: {
  25619. type?: number;
  25620. size?: number;
  25621. sizeX?: number;
  25622. sizeY?: number;
  25623. sizeZ?: number;
  25624. custom?: any;
  25625. faceUV?: Vector4[];
  25626. faceColors?: Color4[];
  25627. updatable?: boolean;
  25628. sideOrientation?: number;
  25629. }, scene: Scene): Mesh;
  25630. /**
  25631. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25632. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25633. * * 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`)
  25634. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25635. * * 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
  25636. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25637. * * If you create a double-sided mesh, you can choose what parts of 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
  25638. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25639. * @param name defines the name of the mesh
  25640. * @param options defines the options used to create the mesh
  25641. * @param scene defines the hosting scene
  25642. * @returns a new Mesh
  25643. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25644. */
  25645. static CreateIcoSphere(name: string, options: {
  25646. radius?: number;
  25647. flat?: boolean;
  25648. subdivisions?: number;
  25649. sideOrientation?: number;
  25650. updatable?: boolean;
  25651. }, scene: Scene): Mesh;
  25652. /**
  25653. * Creates a decal mesh.
  25654. * Please consider using the same method from the MeshBuilder class instead.
  25655. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25656. * @param name defines the name of the mesh
  25657. * @param sourceMesh defines the mesh receiving the decal
  25658. * @param position sets the position of the decal in world coordinates
  25659. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25660. * @param size sets the decal scaling
  25661. * @param angle sets the angle to rotate the decal
  25662. * @returns a new Mesh
  25663. */
  25664. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25665. /**
  25666. * Prepare internal position array for software CPU skinning
  25667. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25668. */
  25669. setPositionsForCPUSkinning(): Float32Array;
  25670. /**
  25671. * Prepare internal normal array for software CPU skinning
  25672. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25673. */
  25674. setNormalsForCPUSkinning(): Float32Array;
  25675. /**
  25676. * Updates the vertex buffer by applying transformation from the bones
  25677. * @param skeleton defines the skeleton to apply to current mesh
  25678. * @returns the current mesh
  25679. */
  25680. applySkeleton(skeleton: Skeleton): Mesh;
  25681. /**
  25682. * 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
  25683. * @param meshes defines the list of meshes to scan
  25684. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25685. */
  25686. static MinMax(meshes: AbstractMesh[]): {
  25687. min: Vector3;
  25688. max: Vector3;
  25689. };
  25690. /**
  25691. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25692. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25693. * @returns a vector3
  25694. */
  25695. static Center(meshesOrMinMaxVector: {
  25696. min: Vector3;
  25697. max: Vector3;
  25698. } | AbstractMesh[]): Vector3;
  25699. /**
  25700. * Merge the array of meshes into a single mesh for performance reasons.
  25701. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25702. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25703. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25704. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25705. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25706. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25707. * @returns a new mesh
  25708. */
  25709. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25710. /** @hidden */
  25711. addInstance(instance: InstancedMesh): void;
  25712. /** @hidden */
  25713. removeInstance(instance: InstancedMesh): void;
  25714. }
  25715. }
  25716. declare module "babylonjs/Cameras/camera" {
  25717. import { SmartArray } from "babylonjs/Misc/smartArray";
  25718. import { Observable } from "babylonjs/Misc/observable";
  25719. import { Nullable } from "babylonjs/types";
  25720. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25721. import { Scene } from "babylonjs/scene";
  25722. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  25723. import { Node } from "babylonjs/node";
  25724. import { Mesh } from "babylonjs/Meshes/mesh";
  25725. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25726. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25727. import { Viewport } from "babylonjs/Maths/math.viewport";
  25728. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25729. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25730. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25731. import { Ray } from "babylonjs/Culling/ray";
  25732. /**
  25733. * This is the base class of all the camera used in the application.
  25734. * @see http://doc.babylonjs.com/features/cameras
  25735. */
  25736. export class Camera extends Node {
  25737. /** @hidden */
  25738. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25739. /**
  25740. * This is the default projection mode used by the cameras.
  25741. * It helps recreating a feeling of perspective and better appreciate depth.
  25742. * This is the best way to simulate real life cameras.
  25743. */
  25744. static readonly PERSPECTIVE_CAMERA: number;
  25745. /**
  25746. * This helps creating camera with an orthographic mode.
  25747. * 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.
  25748. */
  25749. static readonly ORTHOGRAPHIC_CAMERA: number;
  25750. /**
  25751. * This is the default FOV mode for perspective cameras.
  25752. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25753. */
  25754. static readonly FOVMODE_VERTICAL_FIXED: number;
  25755. /**
  25756. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25757. */
  25758. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25759. /**
  25760. * This specifies ther is no need for a camera rig.
  25761. * Basically only one eye is rendered corresponding to the camera.
  25762. */
  25763. static readonly RIG_MODE_NONE: number;
  25764. /**
  25765. * Simulates a camera Rig with one blue eye and one red eye.
  25766. * This can be use with 3d blue and red glasses.
  25767. */
  25768. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25769. /**
  25770. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25771. */
  25772. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25773. /**
  25774. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25775. */
  25776. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25777. /**
  25778. * Defines that both eyes of the camera will be rendered over under each other.
  25779. */
  25780. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25781. /**
  25782. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25783. */
  25784. static readonly RIG_MODE_VR: number;
  25785. /**
  25786. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25787. */
  25788. static readonly RIG_MODE_WEBVR: number;
  25789. /**
  25790. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25791. */
  25792. static readonly RIG_MODE_CUSTOM: number;
  25793. /**
  25794. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25795. */
  25796. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25797. /**
  25798. * Define the input manager associated with the camera.
  25799. */
  25800. inputs: CameraInputsManager<Camera>;
  25801. /** @hidden */
  25802. _position: Vector3;
  25803. /**
  25804. * Define the current local position of the camera in the scene
  25805. */
  25806. position: Vector3;
  25807. /**
  25808. * The vector the camera should consider as up.
  25809. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25810. */
  25811. upVector: Vector3;
  25812. /**
  25813. * Define the current limit on the left side for an orthographic camera
  25814. * In scene unit
  25815. */
  25816. orthoLeft: Nullable<number>;
  25817. /**
  25818. * Define the current limit on the right side for an orthographic camera
  25819. * In scene unit
  25820. */
  25821. orthoRight: Nullable<number>;
  25822. /**
  25823. * Define the current limit on the bottom side for an orthographic camera
  25824. * In scene unit
  25825. */
  25826. orthoBottom: Nullable<number>;
  25827. /**
  25828. * Define the current limit on the top side for an orthographic camera
  25829. * In scene unit
  25830. */
  25831. orthoTop: Nullable<number>;
  25832. /**
  25833. * Field Of View is set in Radians. (default is 0.8)
  25834. */
  25835. fov: number;
  25836. /**
  25837. * Define the minimum distance the camera can see from.
  25838. * This is important to note that the depth buffer are not infinite and the closer it starts
  25839. * the more your scene might encounter depth fighting issue.
  25840. */
  25841. minZ: number;
  25842. /**
  25843. * Define the maximum distance the camera can see to.
  25844. * This is important to note that the depth buffer are not infinite and the further it end
  25845. * the more your scene might encounter depth fighting issue.
  25846. */
  25847. maxZ: number;
  25848. /**
  25849. * Define the default inertia of the camera.
  25850. * This helps giving a smooth feeling to the camera movement.
  25851. */
  25852. inertia: number;
  25853. /**
  25854. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25855. */
  25856. mode: number;
  25857. /**
  25858. * Define wether the camera is intermediate.
  25859. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25860. */
  25861. isIntermediate: boolean;
  25862. /**
  25863. * Define the viewport of the camera.
  25864. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25865. */
  25866. viewport: Viewport;
  25867. /**
  25868. * Restricts the camera to viewing objects with the same layerMask.
  25869. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25870. */
  25871. layerMask: number;
  25872. /**
  25873. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25874. */
  25875. fovMode: number;
  25876. /**
  25877. * Rig mode of the camera.
  25878. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25879. * This is normally controlled byt the camera themselves as internal use.
  25880. */
  25881. cameraRigMode: number;
  25882. /**
  25883. * Defines the distance between both "eyes" in case of a RIG
  25884. */
  25885. interaxialDistance: number;
  25886. /**
  25887. * Defines if stereoscopic rendering is done side by side or over under.
  25888. */
  25889. isStereoscopicSideBySide: boolean;
  25890. /**
  25891. * 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
  25892. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25893. * else in the scene. (Eg. security camera)
  25894. *
  25895. * To change the final output target of the camera, camera.outputRenderTarget should be used instead (eg. webXR renders to a render target corrisponding to an HMD)
  25896. */
  25897. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25898. /**
  25899. * When set, the camera will render to this render target instead of the default canvas
  25900. *
  25901. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25902. */
  25903. outputRenderTarget: Nullable<RenderTargetTexture>;
  25904. /**
  25905. * Observable triggered when the camera view matrix has changed.
  25906. */
  25907. onViewMatrixChangedObservable: Observable<Camera>;
  25908. /**
  25909. * Observable triggered when the camera Projection matrix has changed.
  25910. */
  25911. onProjectionMatrixChangedObservable: Observable<Camera>;
  25912. /**
  25913. * Observable triggered when the inputs have been processed.
  25914. */
  25915. onAfterCheckInputsObservable: Observable<Camera>;
  25916. /**
  25917. * Observable triggered when reset has been called and applied to the camera.
  25918. */
  25919. onRestoreStateObservable: Observable<Camera>;
  25920. /** @hidden */
  25921. _cameraRigParams: any;
  25922. /** @hidden */
  25923. _rigCameras: Camera[];
  25924. /** @hidden */
  25925. _rigPostProcess: Nullable<PostProcess>;
  25926. protected _webvrViewMatrix: Matrix;
  25927. /** @hidden */
  25928. _skipRendering: boolean;
  25929. /** @hidden */
  25930. _projectionMatrix: Matrix;
  25931. /** @hidden */
  25932. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25933. /** @hidden */
  25934. _activeMeshes: SmartArray<AbstractMesh>;
  25935. protected _globalPosition: Vector3;
  25936. /** @hidden */
  25937. _computedViewMatrix: Matrix;
  25938. private _doNotComputeProjectionMatrix;
  25939. private _transformMatrix;
  25940. private _frustumPlanes;
  25941. private _refreshFrustumPlanes;
  25942. private _storedFov;
  25943. private _stateStored;
  25944. /**
  25945. * Instantiates a new camera object.
  25946. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25947. * @see http://doc.babylonjs.com/features/cameras
  25948. * @param name Defines the name of the camera in the scene
  25949. * @param position Defines the position of the camera
  25950. * @param scene Defines the scene the camera belongs too
  25951. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25952. */
  25953. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25954. /**
  25955. * Store current camera state (fov, position, etc..)
  25956. * @returns the camera
  25957. */
  25958. storeState(): Camera;
  25959. /**
  25960. * Restores the camera state values if it has been stored. You must call storeState() first
  25961. */
  25962. protected _restoreStateValues(): boolean;
  25963. /**
  25964. * Restored camera state. You must call storeState() first.
  25965. * @returns true if restored and false otherwise
  25966. */
  25967. restoreState(): boolean;
  25968. /**
  25969. * Gets the class name of the camera.
  25970. * @returns the class name
  25971. */
  25972. getClassName(): string;
  25973. /** @hidden */
  25974. readonly _isCamera: boolean;
  25975. /**
  25976. * Gets a string representation of the camera useful for debug purpose.
  25977. * @param fullDetails Defines that a more verboe level of logging is required
  25978. * @returns the string representation
  25979. */
  25980. toString(fullDetails?: boolean): string;
  25981. /**
  25982. * Gets the current world space position of the camera.
  25983. */
  25984. readonly globalPosition: Vector3;
  25985. /**
  25986. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25987. * @returns the active meshe list
  25988. */
  25989. getActiveMeshes(): SmartArray<AbstractMesh>;
  25990. /**
  25991. * Check wether a mesh is part of the current active mesh list of the camera
  25992. * @param mesh Defines the mesh to check
  25993. * @returns true if active, false otherwise
  25994. */
  25995. isActiveMesh(mesh: Mesh): boolean;
  25996. /**
  25997. * Is this camera ready to be used/rendered
  25998. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25999. * @return true if the camera is ready
  26000. */
  26001. isReady(completeCheck?: boolean): boolean;
  26002. /** @hidden */
  26003. _initCache(): void;
  26004. /** @hidden */
  26005. _updateCache(ignoreParentClass?: boolean): void;
  26006. /** @hidden */
  26007. _isSynchronized(): boolean;
  26008. /** @hidden */
  26009. _isSynchronizedViewMatrix(): boolean;
  26010. /** @hidden */
  26011. _isSynchronizedProjectionMatrix(): boolean;
  26012. /**
  26013. * Attach the input controls to a specific dom element to get the input from.
  26014. * @param element Defines the element the controls should be listened from
  26015. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26016. */
  26017. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  26018. /**
  26019. * Detach the current controls from the specified dom element.
  26020. * @param element Defines the element to stop listening the inputs from
  26021. */
  26022. detachControl(element: HTMLElement): void;
  26023. /**
  26024. * Update the camera state according to the different inputs gathered during the frame.
  26025. */
  26026. update(): void;
  26027. /** @hidden */
  26028. _checkInputs(): void;
  26029. /** @hidden */
  26030. readonly rigCameras: Camera[];
  26031. /**
  26032. * Gets the post process used by the rig cameras
  26033. */
  26034. readonly rigPostProcess: Nullable<PostProcess>;
  26035. /**
  26036. * Internal, gets the first post proces.
  26037. * @returns the first post process to be run on this camera.
  26038. */
  26039. _getFirstPostProcess(): Nullable<PostProcess>;
  26040. private _cascadePostProcessesToRigCams;
  26041. /**
  26042. * Attach a post process to the camera.
  26043. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26044. * @param postProcess The post process to attach to the camera
  26045. * @param insertAt The position of the post process in case several of them are in use in the scene
  26046. * @returns the position the post process has been inserted at
  26047. */
  26048. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  26049. /**
  26050. * Detach a post process to the camera.
  26051. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26052. * @param postProcess The post process to detach from the camera
  26053. */
  26054. detachPostProcess(postProcess: PostProcess): void;
  26055. /**
  26056. * Gets the current world matrix of the camera
  26057. */
  26058. getWorldMatrix(): Matrix;
  26059. /** @hidden */
  26060. _getViewMatrix(): Matrix;
  26061. /**
  26062. * Gets the current view matrix of the camera.
  26063. * @param force forces the camera to recompute the matrix without looking at the cached state
  26064. * @returns the view matrix
  26065. */
  26066. getViewMatrix(force?: boolean): Matrix;
  26067. /**
  26068. * Freeze the projection matrix.
  26069. * It will prevent the cache check of the camera projection compute and can speed up perf
  26070. * if no parameter of the camera are meant to change
  26071. * @param projection Defines manually a projection if necessary
  26072. */
  26073. freezeProjectionMatrix(projection?: Matrix): void;
  26074. /**
  26075. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  26076. */
  26077. unfreezeProjectionMatrix(): void;
  26078. /**
  26079. * Gets the current projection matrix of the camera.
  26080. * @param force forces the camera to recompute the matrix without looking at the cached state
  26081. * @returns the projection matrix
  26082. */
  26083. getProjectionMatrix(force?: boolean): Matrix;
  26084. /**
  26085. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  26086. * @returns a Matrix
  26087. */
  26088. getTransformationMatrix(): Matrix;
  26089. private _updateFrustumPlanes;
  26090. /**
  26091. * Checks if a cullable object (mesh...) is in the camera frustum
  26092. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  26093. * @param target The object to check
  26094. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  26095. * @returns true if the object is in frustum otherwise false
  26096. */
  26097. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26098. /**
  26099. * Checks if a cullable object (mesh...) is in the camera frustum
  26100. * Unlike isInFrustum this cheks the full bounding box
  26101. * @param target The object to check
  26102. * @returns true if the object is in frustum otherwise false
  26103. */
  26104. isCompletelyInFrustum(target: ICullable): boolean;
  26105. /**
  26106. * Gets a ray in the forward direction from the camera.
  26107. * @param length Defines the length of the ray to create
  26108. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26109. * @param origin Defines the start point of the ray which defaults to the camera position
  26110. * @returns the forward ray
  26111. */
  26112. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26113. /**
  26114. * Releases resources associated with this node.
  26115. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26116. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26117. */
  26118. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26119. /** @hidden */
  26120. _isLeftCamera: boolean;
  26121. /**
  26122. * Gets the left camera of a rig setup in case of Rigged Camera
  26123. */
  26124. readonly isLeftCamera: boolean;
  26125. /** @hidden */
  26126. _isRightCamera: boolean;
  26127. /**
  26128. * Gets the right camera of a rig setup in case of Rigged Camera
  26129. */
  26130. readonly isRightCamera: boolean;
  26131. /**
  26132. * Gets the left camera of a rig setup in case of Rigged Camera
  26133. */
  26134. readonly leftCamera: Nullable<FreeCamera>;
  26135. /**
  26136. * Gets the right camera of a rig setup in case of Rigged Camera
  26137. */
  26138. readonly rightCamera: Nullable<FreeCamera>;
  26139. /**
  26140. * Gets the left camera target of a rig setup in case of Rigged Camera
  26141. * @returns the target position
  26142. */
  26143. getLeftTarget(): Nullable<Vector3>;
  26144. /**
  26145. * Gets the right camera target of a rig setup in case of Rigged Camera
  26146. * @returns the target position
  26147. */
  26148. getRightTarget(): Nullable<Vector3>;
  26149. /**
  26150. * @hidden
  26151. */
  26152. setCameraRigMode(mode: number, rigParams: any): void;
  26153. /** @hidden */
  26154. static _setStereoscopicRigMode(camera: Camera): void;
  26155. /** @hidden */
  26156. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26157. /** @hidden */
  26158. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26159. /** @hidden */
  26160. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26161. /** @hidden */
  26162. _getVRProjectionMatrix(): Matrix;
  26163. protected _updateCameraRotationMatrix(): void;
  26164. protected _updateWebVRCameraRotationMatrix(): void;
  26165. /**
  26166. * This function MUST be overwritten by the different WebVR cameras available.
  26167. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26168. * @hidden
  26169. */
  26170. _getWebVRProjectionMatrix(): Matrix;
  26171. /**
  26172. * This function MUST be overwritten by the different WebVR cameras available.
  26173. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26174. * @hidden
  26175. */
  26176. _getWebVRViewMatrix(): Matrix;
  26177. /** @hidden */
  26178. setCameraRigParameter(name: string, value: any): void;
  26179. /**
  26180. * needs to be overridden by children so sub has required properties to be copied
  26181. * @hidden
  26182. */
  26183. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26184. /**
  26185. * May need to be overridden by children
  26186. * @hidden
  26187. */
  26188. _updateRigCameras(): void;
  26189. /** @hidden */
  26190. _setupInputs(): void;
  26191. /**
  26192. * Serialiaze the camera setup to a json represention
  26193. * @returns the JSON representation
  26194. */
  26195. serialize(): any;
  26196. /**
  26197. * Clones the current camera.
  26198. * @param name The cloned camera name
  26199. * @returns the cloned camera
  26200. */
  26201. clone(name: string): Camera;
  26202. /**
  26203. * Gets the direction of the camera relative to a given local axis.
  26204. * @param localAxis Defines the reference axis to provide a relative direction.
  26205. * @return the direction
  26206. */
  26207. getDirection(localAxis: Vector3): Vector3;
  26208. /**
  26209. * Returns the current camera absolute rotation
  26210. */
  26211. readonly absoluteRotation: Quaternion;
  26212. /**
  26213. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26214. * @param localAxis Defines the reference axis to provide a relative direction.
  26215. * @param result Defines the vector to store the result in
  26216. */
  26217. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26218. /**
  26219. * Gets a camera constructor for a given camera type
  26220. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26221. * @param name The name of the camera the result will be able to instantiate
  26222. * @param scene The scene the result will construct the camera in
  26223. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26224. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26225. * @returns a factory method to construc the camera
  26226. */
  26227. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26228. /**
  26229. * Compute the world matrix of the camera.
  26230. * @returns the camera world matrix
  26231. */
  26232. computeWorldMatrix(): Matrix;
  26233. /**
  26234. * Parse a JSON and creates the camera from the parsed information
  26235. * @param parsedCamera The JSON to parse
  26236. * @param scene The scene to instantiate the camera in
  26237. * @returns the newly constructed camera
  26238. */
  26239. static Parse(parsedCamera: any, scene: Scene): Camera;
  26240. }
  26241. }
  26242. declare module "babylonjs/Meshes/Builders/discBuilder" {
  26243. import { Nullable } from "babylonjs/types";
  26244. import { Scene } from "babylonjs/scene";
  26245. import { Vector4 } from "babylonjs/Maths/math.vector";
  26246. import { Mesh } from "babylonjs/Meshes/mesh";
  26247. /**
  26248. * Class containing static functions to help procedurally build meshes
  26249. */
  26250. export class DiscBuilder {
  26251. /**
  26252. * Creates a plane polygonal mesh. By default, this is a disc
  26253. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26254. * * 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
  26255. * * 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
  26256. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26257. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  26258. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26259. * @param name defines the name of the mesh
  26260. * @param options defines the options used to create the mesh
  26261. * @param scene defines the hosting scene
  26262. * @returns the plane polygonal mesh
  26263. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26264. */
  26265. static CreateDisc(name: string, options: {
  26266. radius?: number;
  26267. tessellation?: number;
  26268. arc?: number;
  26269. updatable?: boolean;
  26270. sideOrientation?: number;
  26271. frontUVs?: Vector4;
  26272. backUVs?: Vector4;
  26273. }, scene?: Nullable<Scene>): Mesh;
  26274. }
  26275. }
  26276. declare module "babylonjs/Materials/fresnelParameters" {
  26277. import { Color3 } from "babylonjs/Maths/math.color";
  26278. /**
  26279. * This represents all the required information to add a fresnel effect on a material:
  26280. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26281. */
  26282. export class FresnelParameters {
  26283. private _isEnabled;
  26284. /**
  26285. * Define if the fresnel effect is enable or not.
  26286. */
  26287. isEnabled: boolean;
  26288. /**
  26289. * Define the color used on edges (grazing angle)
  26290. */
  26291. leftColor: Color3;
  26292. /**
  26293. * Define the color used on center
  26294. */
  26295. rightColor: Color3;
  26296. /**
  26297. * Define bias applied to computed fresnel term
  26298. */
  26299. bias: number;
  26300. /**
  26301. * Defined the power exponent applied to fresnel term
  26302. */
  26303. power: number;
  26304. /**
  26305. * Clones the current fresnel and its valuues
  26306. * @returns a clone fresnel configuration
  26307. */
  26308. clone(): FresnelParameters;
  26309. /**
  26310. * Serializes the current fresnel parameters to a JSON representation.
  26311. * @return the JSON serialization
  26312. */
  26313. serialize(): any;
  26314. /**
  26315. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  26316. * @param parsedFresnelParameters Define the JSON representation
  26317. * @returns the parsed parameters
  26318. */
  26319. static Parse(parsedFresnelParameters: any): FresnelParameters;
  26320. }
  26321. }
  26322. declare module "babylonjs/Materials/pushMaterial" {
  26323. import { Nullable } from "babylonjs/types";
  26324. import { Scene } from "babylonjs/scene";
  26325. import { Matrix } from "babylonjs/Maths/math.vector";
  26326. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26327. import { Mesh } from "babylonjs/Meshes/mesh";
  26328. import { Material } from "babylonjs/Materials/material";
  26329. import { Effect } from "babylonjs/Materials/effect";
  26330. /**
  26331. * Base class of materials working in push mode in babylon JS
  26332. * @hidden
  26333. */
  26334. export class PushMaterial extends Material {
  26335. protected _activeEffect: Effect;
  26336. protected _normalMatrix: Matrix;
  26337. /**
  26338. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  26339. * This means that the material can keep using a previous shader while a new one is being compiled.
  26340. * This is mostly used when shader parallel compilation is supported (true by default)
  26341. */
  26342. allowShaderHotSwapping: boolean;
  26343. constructor(name: string, scene: Scene);
  26344. getEffect(): Effect;
  26345. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26346. /**
  26347. * Binds the given world matrix to the active effect
  26348. *
  26349. * @param world the matrix to bind
  26350. */
  26351. bindOnlyWorldMatrix(world: Matrix): void;
  26352. /**
  26353. * Binds the given normal matrix to the active effect
  26354. *
  26355. * @param normalMatrix the matrix to bind
  26356. */
  26357. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26358. bind(world: Matrix, mesh?: Mesh): void;
  26359. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26360. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26361. }
  26362. }
  26363. declare module "babylonjs/Materials/materialFlags" {
  26364. /**
  26365. * This groups all the flags used to control the materials channel.
  26366. */
  26367. export class MaterialFlags {
  26368. private static _DiffuseTextureEnabled;
  26369. /**
  26370. * Are diffuse textures enabled in the application.
  26371. */
  26372. static DiffuseTextureEnabled: boolean;
  26373. private static _AmbientTextureEnabled;
  26374. /**
  26375. * Are ambient textures enabled in the application.
  26376. */
  26377. static AmbientTextureEnabled: boolean;
  26378. private static _OpacityTextureEnabled;
  26379. /**
  26380. * Are opacity textures enabled in the application.
  26381. */
  26382. static OpacityTextureEnabled: boolean;
  26383. private static _ReflectionTextureEnabled;
  26384. /**
  26385. * Are reflection textures enabled in the application.
  26386. */
  26387. static ReflectionTextureEnabled: boolean;
  26388. private static _EmissiveTextureEnabled;
  26389. /**
  26390. * Are emissive textures enabled in the application.
  26391. */
  26392. static EmissiveTextureEnabled: boolean;
  26393. private static _SpecularTextureEnabled;
  26394. /**
  26395. * Are specular textures enabled in the application.
  26396. */
  26397. static SpecularTextureEnabled: boolean;
  26398. private static _BumpTextureEnabled;
  26399. /**
  26400. * Are bump textures enabled in the application.
  26401. */
  26402. static BumpTextureEnabled: boolean;
  26403. private static _LightmapTextureEnabled;
  26404. /**
  26405. * Are lightmap textures enabled in the application.
  26406. */
  26407. static LightmapTextureEnabled: boolean;
  26408. private static _RefractionTextureEnabled;
  26409. /**
  26410. * Are refraction textures enabled in the application.
  26411. */
  26412. static RefractionTextureEnabled: boolean;
  26413. private static _ColorGradingTextureEnabled;
  26414. /**
  26415. * Are color grading textures enabled in the application.
  26416. */
  26417. static ColorGradingTextureEnabled: boolean;
  26418. private static _FresnelEnabled;
  26419. /**
  26420. * Are fresnels enabled in the application.
  26421. */
  26422. static FresnelEnabled: boolean;
  26423. private static _ClearCoatTextureEnabled;
  26424. /**
  26425. * Are clear coat textures enabled in the application.
  26426. */
  26427. static ClearCoatTextureEnabled: boolean;
  26428. private static _ClearCoatBumpTextureEnabled;
  26429. /**
  26430. * Are clear coat bump textures enabled in the application.
  26431. */
  26432. static ClearCoatBumpTextureEnabled: boolean;
  26433. private static _ClearCoatTintTextureEnabled;
  26434. /**
  26435. * Are clear coat tint textures enabled in the application.
  26436. */
  26437. static ClearCoatTintTextureEnabled: boolean;
  26438. private static _SheenTextureEnabled;
  26439. /**
  26440. * Are sheen textures enabled in the application.
  26441. */
  26442. static SheenTextureEnabled: boolean;
  26443. private static _AnisotropicTextureEnabled;
  26444. /**
  26445. * Are anisotropic textures enabled in the application.
  26446. */
  26447. static AnisotropicTextureEnabled: boolean;
  26448. private static _ThicknessTextureEnabled;
  26449. /**
  26450. * Are thickness textures enabled in the application.
  26451. */
  26452. static ThicknessTextureEnabled: boolean;
  26453. }
  26454. }
  26455. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  26456. /** @hidden */
  26457. export var defaultFragmentDeclaration: {
  26458. name: string;
  26459. shader: string;
  26460. };
  26461. }
  26462. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  26463. /** @hidden */
  26464. export var defaultUboDeclaration: {
  26465. name: string;
  26466. shader: string;
  26467. };
  26468. }
  26469. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  26470. /** @hidden */
  26471. export var lightFragmentDeclaration: {
  26472. name: string;
  26473. shader: string;
  26474. };
  26475. }
  26476. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  26477. /** @hidden */
  26478. export var lightUboDeclaration: {
  26479. name: string;
  26480. shader: string;
  26481. };
  26482. }
  26483. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  26484. /** @hidden */
  26485. export var lightsFragmentFunctions: {
  26486. name: string;
  26487. shader: string;
  26488. };
  26489. }
  26490. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  26491. /** @hidden */
  26492. export var shadowsFragmentFunctions: {
  26493. name: string;
  26494. shader: string;
  26495. };
  26496. }
  26497. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  26498. /** @hidden */
  26499. export var fresnelFunction: {
  26500. name: string;
  26501. shader: string;
  26502. };
  26503. }
  26504. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  26505. /** @hidden */
  26506. export var reflectionFunction: {
  26507. name: string;
  26508. shader: string;
  26509. };
  26510. }
  26511. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  26512. /** @hidden */
  26513. export var bumpFragmentFunctions: {
  26514. name: string;
  26515. shader: string;
  26516. };
  26517. }
  26518. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  26519. /** @hidden */
  26520. export var logDepthDeclaration: {
  26521. name: string;
  26522. shader: string;
  26523. };
  26524. }
  26525. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  26526. /** @hidden */
  26527. export var bumpFragment: {
  26528. name: string;
  26529. shader: string;
  26530. };
  26531. }
  26532. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  26533. /** @hidden */
  26534. export var depthPrePass: {
  26535. name: string;
  26536. shader: string;
  26537. };
  26538. }
  26539. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  26540. /** @hidden */
  26541. export var lightFragment: {
  26542. name: string;
  26543. shader: string;
  26544. };
  26545. }
  26546. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  26547. /** @hidden */
  26548. export var logDepthFragment: {
  26549. name: string;
  26550. shader: string;
  26551. };
  26552. }
  26553. declare module "babylonjs/Shaders/default.fragment" {
  26554. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  26555. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  26556. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  26557. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  26558. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  26559. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  26560. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  26561. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  26562. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  26563. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  26564. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  26565. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  26566. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  26567. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  26568. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  26569. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  26570. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  26571. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  26572. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  26573. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  26574. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  26575. /** @hidden */
  26576. export var defaultPixelShader: {
  26577. name: string;
  26578. shader: string;
  26579. };
  26580. }
  26581. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  26582. /** @hidden */
  26583. export var defaultVertexDeclaration: {
  26584. name: string;
  26585. shader: string;
  26586. };
  26587. }
  26588. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  26589. /** @hidden */
  26590. export var bumpVertexDeclaration: {
  26591. name: string;
  26592. shader: string;
  26593. };
  26594. }
  26595. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  26596. /** @hidden */
  26597. export var bumpVertex: {
  26598. name: string;
  26599. shader: string;
  26600. };
  26601. }
  26602. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  26603. /** @hidden */
  26604. export var fogVertex: {
  26605. name: string;
  26606. shader: string;
  26607. };
  26608. }
  26609. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  26610. /** @hidden */
  26611. export var shadowsVertex: {
  26612. name: string;
  26613. shader: string;
  26614. };
  26615. }
  26616. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  26617. /** @hidden */
  26618. export var pointCloudVertex: {
  26619. name: string;
  26620. shader: string;
  26621. };
  26622. }
  26623. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  26624. /** @hidden */
  26625. export var logDepthVertex: {
  26626. name: string;
  26627. shader: string;
  26628. };
  26629. }
  26630. declare module "babylonjs/Shaders/default.vertex" {
  26631. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  26632. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  26633. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  26634. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  26635. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  26636. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  26637. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  26638. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  26639. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  26640. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  26641. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  26642. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  26643. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  26644. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  26645. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  26646. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  26647. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  26648. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  26649. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  26650. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  26651. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  26652. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  26653. /** @hidden */
  26654. export var defaultVertexShader: {
  26655. name: string;
  26656. shader: string;
  26657. };
  26658. }
  26659. declare module "babylonjs/Materials/standardMaterial" {
  26660. import { SmartArray } from "babylonjs/Misc/smartArray";
  26661. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  26662. import { Nullable } from "babylonjs/types";
  26663. import { Scene } from "babylonjs/scene";
  26664. import { Matrix } from "babylonjs/Maths/math.vector";
  26665. import { Color3 } from "babylonjs/Maths/math.color";
  26666. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26667. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26668. import { Mesh } from "babylonjs/Meshes/mesh";
  26669. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  26670. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  26671. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  26672. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  26673. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  26674. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26675. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26676. import "babylonjs/Shaders/default.fragment";
  26677. import "babylonjs/Shaders/default.vertex";
  26678. /** @hidden */
  26679. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  26680. MAINUV1: boolean;
  26681. MAINUV2: boolean;
  26682. DIFFUSE: boolean;
  26683. DIFFUSEDIRECTUV: number;
  26684. AMBIENT: boolean;
  26685. AMBIENTDIRECTUV: number;
  26686. OPACITY: boolean;
  26687. OPACITYDIRECTUV: number;
  26688. OPACITYRGB: boolean;
  26689. REFLECTION: boolean;
  26690. EMISSIVE: boolean;
  26691. EMISSIVEDIRECTUV: number;
  26692. SPECULAR: boolean;
  26693. SPECULARDIRECTUV: number;
  26694. BUMP: boolean;
  26695. BUMPDIRECTUV: number;
  26696. PARALLAX: boolean;
  26697. PARALLAXOCCLUSION: boolean;
  26698. SPECULAROVERALPHA: boolean;
  26699. CLIPPLANE: boolean;
  26700. CLIPPLANE2: boolean;
  26701. CLIPPLANE3: boolean;
  26702. CLIPPLANE4: boolean;
  26703. ALPHATEST: boolean;
  26704. DEPTHPREPASS: boolean;
  26705. ALPHAFROMDIFFUSE: boolean;
  26706. POINTSIZE: boolean;
  26707. FOG: boolean;
  26708. SPECULARTERM: boolean;
  26709. DIFFUSEFRESNEL: boolean;
  26710. OPACITYFRESNEL: boolean;
  26711. REFLECTIONFRESNEL: boolean;
  26712. REFRACTIONFRESNEL: boolean;
  26713. EMISSIVEFRESNEL: boolean;
  26714. FRESNEL: boolean;
  26715. NORMAL: boolean;
  26716. UV1: boolean;
  26717. UV2: boolean;
  26718. VERTEXCOLOR: boolean;
  26719. VERTEXALPHA: boolean;
  26720. NUM_BONE_INFLUENCERS: number;
  26721. BonesPerMesh: number;
  26722. BONETEXTURE: boolean;
  26723. INSTANCES: boolean;
  26724. GLOSSINESS: boolean;
  26725. ROUGHNESS: boolean;
  26726. EMISSIVEASILLUMINATION: boolean;
  26727. LINKEMISSIVEWITHDIFFUSE: boolean;
  26728. REFLECTIONFRESNELFROMSPECULAR: boolean;
  26729. LIGHTMAP: boolean;
  26730. LIGHTMAPDIRECTUV: number;
  26731. OBJECTSPACE_NORMALMAP: boolean;
  26732. USELIGHTMAPASSHADOWMAP: boolean;
  26733. REFLECTIONMAP_3D: boolean;
  26734. REFLECTIONMAP_SPHERICAL: boolean;
  26735. REFLECTIONMAP_PLANAR: boolean;
  26736. REFLECTIONMAP_CUBIC: boolean;
  26737. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26738. REFLECTIONMAP_PROJECTION: boolean;
  26739. REFLECTIONMAP_SKYBOX: boolean;
  26740. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  26741. REFLECTIONMAP_EXPLICIT: boolean;
  26742. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26743. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26744. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26745. INVERTCUBICMAP: boolean;
  26746. LOGARITHMICDEPTH: boolean;
  26747. REFRACTION: boolean;
  26748. REFRACTIONMAP_3D: boolean;
  26749. REFLECTIONOVERALPHA: boolean;
  26750. TWOSIDEDLIGHTING: boolean;
  26751. SHADOWFLOAT: boolean;
  26752. MORPHTARGETS: boolean;
  26753. MORPHTARGETS_NORMAL: boolean;
  26754. MORPHTARGETS_TANGENT: boolean;
  26755. MORPHTARGETS_UV: boolean;
  26756. NUM_MORPH_INFLUENCERS: number;
  26757. NONUNIFORMSCALING: boolean;
  26758. PREMULTIPLYALPHA: boolean;
  26759. IMAGEPROCESSING: boolean;
  26760. VIGNETTE: boolean;
  26761. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26762. VIGNETTEBLENDMODEOPAQUE: boolean;
  26763. TONEMAPPING: boolean;
  26764. TONEMAPPING_ACES: boolean;
  26765. CONTRAST: boolean;
  26766. COLORCURVES: boolean;
  26767. COLORGRADING: boolean;
  26768. COLORGRADING3D: boolean;
  26769. SAMPLER3DGREENDEPTH: boolean;
  26770. SAMPLER3DBGRMAP: boolean;
  26771. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26772. MULTIVIEW: boolean;
  26773. /**
  26774. * If the reflection texture on this material is in linear color space
  26775. * @hidden
  26776. */
  26777. IS_REFLECTION_LINEAR: boolean;
  26778. /**
  26779. * If the refraction texture on this material is in linear color space
  26780. * @hidden
  26781. */
  26782. IS_REFRACTION_LINEAR: boolean;
  26783. EXPOSURE: boolean;
  26784. constructor();
  26785. setReflectionMode(modeToEnable: string): void;
  26786. }
  26787. /**
  26788. * This is the default material used in Babylon. It is the best trade off between quality
  26789. * and performances.
  26790. * @see http://doc.babylonjs.com/babylon101/materials
  26791. */
  26792. export class StandardMaterial extends PushMaterial {
  26793. private _diffuseTexture;
  26794. /**
  26795. * The basic texture of the material as viewed under a light.
  26796. */
  26797. diffuseTexture: Nullable<BaseTexture>;
  26798. private _ambientTexture;
  26799. /**
  26800. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  26801. */
  26802. ambientTexture: Nullable<BaseTexture>;
  26803. private _opacityTexture;
  26804. /**
  26805. * Define the transparency of the material from a texture.
  26806. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  26807. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  26808. */
  26809. opacityTexture: Nullable<BaseTexture>;
  26810. private _reflectionTexture;
  26811. /**
  26812. * Define the texture used to display the reflection.
  26813. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26814. */
  26815. reflectionTexture: Nullable<BaseTexture>;
  26816. private _emissiveTexture;
  26817. /**
  26818. * Define texture of the material as if self lit.
  26819. * This will be mixed in the final result even in the absence of light.
  26820. */
  26821. emissiveTexture: Nullable<BaseTexture>;
  26822. private _specularTexture;
  26823. /**
  26824. * Define how the color and intensity of the highlight given by the light in the material.
  26825. */
  26826. specularTexture: Nullable<BaseTexture>;
  26827. private _bumpTexture;
  26828. /**
  26829. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  26830. * 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.
  26831. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  26832. */
  26833. bumpTexture: Nullable<BaseTexture>;
  26834. private _lightmapTexture;
  26835. /**
  26836. * Complex lighting can be computationally expensive to compute at runtime.
  26837. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  26838. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  26839. */
  26840. lightmapTexture: Nullable<BaseTexture>;
  26841. private _refractionTexture;
  26842. /**
  26843. * Define the texture used to display the refraction.
  26844. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26845. */
  26846. refractionTexture: Nullable<BaseTexture>;
  26847. /**
  26848. * The color of the material lit by the environmental background lighting.
  26849. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  26850. */
  26851. ambientColor: Color3;
  26852. /**
  26853. * The basic color of the material as viewed under a light.
  26854. */
  26855. diffuseColor: Color3;
  26856. /**
  26857. * Define how the color and intensity of the highlight given by the light in the material.
  26858. */
  26859. specularColor: Color3;
  26860. /**
  26861. * Define the color of the material as if self lit.
  26862. * This will be mixed in the final result even in the absence of light.
  26863. */
  26864. emissiveColor: Color3;
  26865. /**
  26866. * Defines how sharp are the highlights in the material.
  26867. * The bigger the value the sharper giving a more glossy feeling to the result.
  26868. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  26869. */
  26870. specularPower: number;
  26871. private _useAlphaFromDiffuseTexture;
  26872. /**
  26873. * Does the transparency come from the diffuse texture alpha channel.
  26874. */
  26875. useAlphaFromDiffuseTexture: boolean;
  26876. private _useEmissiveAsIllumination;
  26877. /**
  26878. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  26879. */
  26880. useEmissiveAsIllumination: boolean;
  26881. private _linkEmissiveWithDiffuse;
  26882. /**
  26883. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  26884. * the emissive level when the final color is close to one.
  26885. */
  26886. linkEmissiveWithDiffuse: boolean;
  26887. private _useSpecularOverAlpha;
  26888. /**
  26889. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  26890. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26891. */
  26892. useSpecularOverAlpha: boolean;
  26893. private _useReflectionOverAlpha;
  26894. /**
  26895. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26896. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26897. */
  26898. useReflectionOverAlpha: boolean;
  26899. private _disableLighting;
  26900. /**
  26901. * Does lights from the scene impacts this material.
  26902. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  26903. */
  26904. disableLighting: boolean;
  26905. private _useObjectSpaceNormalMap;
  26906. /**
  26907. * Allows using an object space normal map (instead of tangent space).
  26908. */
  26909. useObjectSpaceNormalMap: boolean;
  26910. private _useParallax;
  26911. /**
  26912. * Is parallax enabled or not.
  26913. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26914. */
  26915. useParallax: boolean;
  26916. private _useParallaxOcclusion;
  26917. /**
  26918. * Is parallax occlusion enabled or not.
  26919. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  26920. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26921. */
  26922. useParallaxOcclusion: boolean;
  26923. /**
  26924. * 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.
  26925. */
  26926. parallaxScaleBias: number;
  26927. private _roughness;
  26928. /**
  26929. * Helps to define how blurry the reflections should appears in the material.
  26930. */
  26931. roughness: number;
  26932. /**
  26933. * In case of refraction, define the value of the index of refraction.
  26934. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26935. */
  26936. indexOfRefraction: number;
  26937. /**
  26938. * Invert the refraction texture alongside the y axis.
  26939. * It can be useful with procedural textures or probe for instance.
  26940. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26941. */
  26942. invertRefractionY: boolean;
  26943. /**
  26944. * Defines the alpha limits in alpha test mode.
  26945. */
  26946. alphaCutOff: number;
  26947. private _useLightmapAsShadowmap;
  26948. /**
  26949. * In case of light mapping, define whether the map contains light or shadow informations.
  26950. */
  26951. useLightmapAsShadowmap: boolean;
  26952. private _diffuseFresnelParameters;
  26953. /**
  26954. * Define the diffuse fresnel parameters of the material.
  26955. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26956. */
  26957. diffuseFresnelParameters: FresnelParameters;
  26958. private _opacityFresnelParameters;
  26959. /**
  26960. * Define the opacity fresnel parameters of the material.
  26961. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26962. */
  26963. opacityFresnelParameters: FresnelParameters;
  26964. private _reflectionFresnelParameters;
  26965. /**
  26966. * Define the reflection fresnel parameters of the material.
  26967. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26968. */
  26969. reflectionFresnelParameters: FresnelParameters;
  26970. private _refractionFresnelParameters;
  26971. /**
  26972. * Define the refraction fresnel parameters of the material.
  26973. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26974. */
  26975. refractionFresnelParameters: FresnelParameters;
  26976. private _emissiveFresnelParameters;
  26977. /**
  26978. * Define the emissive fresnel parameters of the material.
  26979. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26980. */
  26981. emissiveFresnelParameters: FresnelParameters;
  26982. private _useReflectionFresnelFromSpecular;
  26983. /**
  26984. * If true automatically deducts the fresnels values from the material specularity.
  26985. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26986. */
  26987. useReflectionFresnelFromSpecular: boolean;
  26988. private _useGlossinessFromSpecularMapAlpha;
  26989. /**
  26990. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  26991. */
  26992. useGlossinessFromSpecularMapAlpha: boolean;
  26993. private _maxSimultaneousLights;
  26994. /**
  26995. * Defines the maximum number of lights that can be used in the material
  26996. */
  26997. maxSimultaneousLights: number;
  26998. private _invertNormalMapX;
  26999. /**
  27000. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27001. */
  27002. invertNormalMapX: boolean;
  27003. private _invertNormalMapY;
  27004. /**
  27005. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27006. */
  27007. invertNormalMapY: boolean;
  27008. private _twoSidedLighting;
  27009. /**
  27010. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27011. */
  27012. twoSidedLighting: boolean;
  27013. /**
  27014. * Default configuration related to image processing available in the standard Material.
  27015. */
  27016. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27017. /**
  27018. * Gets the image processing configuration used either in this material.
  27019. */
  27020. /**
  27021. * Sets the Default image processing configuration used either in the this material.
  27022. *
  27023. * If sets to null, the scene one is in use.
  27024. */
  27025. imageProcessingConfiguration: ImageProcessingConfiguration;
  27026. /**
  27027. * Keep track of the image processing observer to allow dispose and replace.
  27028. */
  27029. private _imageProcessingObserver;
  27030. /**
  27031. * Attaches a new image processing configuration to the Standard Material.
  27032. * @param configuration
  27033. */
  27034. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27035. /**
  27036. * Gets wether the color curves effect is enabled.
  27037. */
  27038. /**
  27039. * Sets wether the color curves effect is enabled.
  27040. */
  27041. cameraColorCurvesEnabled: boolean;
  27042. /**
  27043. * Gets wether the color grading effect is enabled.
  27044. */
  27045. /**
  27046. * Gets wether the color grading effect is enabled.
  27047. */
  27048. cameraColorGradingEnabled: boolean;
  27049. /**
  27050. * Gets wether tonemapping is enabled or not.
  27051. */
  27052. /**
  27053. * Sets wether tonemapping is enabled or not
  27054. */
  27055. cameraToneMappingEnabled: boolean;
  27056. /**
  27057. * The camera exposure used on this material.
  27058. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27059. * This corresponds to a photographic exposure.
  27060. */
  27061. /**
  27062. * The camera exposure used on this material.
  27063. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27064. * This corresponds to a photographic exposure.
  27065. */
  27066. cameraExposure: number;
  27067. /**
  27068. * Gets The camera contrast used on this material.
  27069. */
  27070. /**
  27071. * Sets The camera contrast used on this material.
  27072. */
  27073. cameraContrast: number;
  27074. /**
  27075. * Gets the Color Grading 2D Lookup Texture.
  27076. */
  27077. /**
  27078. * Sets the Color Grading 2D Lookup Texture.
  27079. */
  27080. cameraColorGradingTexture: Nullable<BaseTexture>;
  27081. /**
  27082. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27083. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27084. * 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;
  27085. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27086. */
  27087. /**
  27088. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27089. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27090. * 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;
  27091. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27092. */
  27093. cameraColorCurves: Nullable<ColorCurves>;
  27094. /**
  27095. * Custom callback helping to override the default shader used in the material.
  27096. */
  27097. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  27098. protected _renderTargets: SmartArray<RenderTargetTexture>;
  27099. protected _worldViewProjectionMatrix: Matrix;
  27100. protected _globalAmbientColor: Color3;
  27101. protected _useLogarithmicDepth: boolean;
  27102. protected _rebuildInParallel: boolean;
  27103. /**
  27104. * Instantiates a new standard material.
  27105. * This is the default material used in Babylon. It is the best trade off between quality
  27106. * and performances.
  27107. * @see http://doc.babylonjs.com/babylon101/materials
  27108. * @param name Define the name of the material in the scene
  27109. * @param scene Define the scene the material belong to
  27110. */
  27111. constructor(name: string, scene: Scene);
  27112. /**
  27113. * Gets a boolean indicating that current material needs to register RTT
  27114. */
  27115. readonly hasRenderTargetTextures: boolean;
  27116. /**
  27117. * Gets the current class name of the material e.g. "StandardMaterial"
  27118. * Mainly use in serialization.
  27119. * @returns the class name
  27120. */
  27121. getClassName(): string;
  27122. /**
  27123. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  27124. * You can try switching to logarithmic depth.
  27125. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  27126. */
  27127. useLogarithmicDepth: boolean;
  27128. /**
  27129. * Specifies if the material will require alpha blending
  27130. * @returns a boolean specifying if alpha blending is needed
  27131. */
  27132. needAlphaBlending(): boolean;
  27133. /**
  27134. * Specifies if this material should be rendered in alpha test mode
  27135. * @returns a boolean specifying if an alpha test is needed.
  27136. */
  27137. needAlphaTesting(): boolean;
  27138. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  27139. /**
  27140. * Get the texture used for alpha test purpose.
  27141. * @returns the diffuse texture in case of the standard material.
  27142. */
  27143. getAlphaTestTexture(): Nullable<BaseTexture>;
  27144. /**
  27145. * Get if the submesh is ready to be used and all its information available.
  27146. * Child classes can use it to update shaders
  27147. * @param mesh defines the mesh to check
  27148. * @param subMesh defines which submesh to check
  27149. * @param useInstances specifies that instances should be used
  27150. * @returns a boolean indicating that the submesh is ready or not
  27151. */
  27152. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27153. /**
  27154. * Builds the material UBO layouts.
  27155. * Used internally during the effect preparation.
  27156. */
  27157. buildUniformLayout(): void;
  27158. /**
  27159. * Unbinds the material from the mesh
  27160. */
  27161. unbind(): void;
  27162. /**
  27163. * Binds the submesh to this material by preparing the effect and shader to draw
  27164. * @param world defines the world transformation matrix
  27165. * @param mesh defines the mesh containing the submesh
  27166. * @param subMesh defines the submesh to bind the material to
  27167. */
  27168. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27169. /**
  27170. * Get the list of animatables in the material.
  27171. * @returns the list of animatables object used in the material
  27172. */
  27173. getAnimatables(): IAnimatable[];
  27174. /**
  27175. * Gets the active textures from the material
  27176. * @returns an array of textures
  27177. */
  27178. getActiveTextures(): BaseTexture[];
  27179. /**
  27180. * Specifies if the material uses a texture
  27181. * @param texture defines the texture to check against the material
  27182. * @returns a boolean specifying if the material uses the texture
  27183. */
  27184. hasTexture(texture: BaseTexture): boolean;
  27185. /**
  27186. * Disposes the material
  27187. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27188. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27189. */
  27190. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27191. /**
  27192. * Makes a duplicate of the material, and gives it a new name
  27193. * @param name defines the new name for the duplicated material
  27194. * @returns the cloned material
  27195. */
  27196. clone(name: string): StandardMaterial;
  27197. /**
  27198. * Serializes this material in a JSON representation
  27199. * @returns the serialized material object
  27200. */
  27201. serialize(): any;
  27202. /**
  27203. * Creates a standard material from parsed material data
  27204. * @param source defines the JSON representation of the material
  27205. * @param scene defines the hosting scene
  27206. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27207. * @returns a new standard material
  27208. */
  27209. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  27210. /**
  27211. * Are diffuse textures enabled in the application.
  27212. */
  27213. static DiffuseTextureEnabled: boolean;
  27214. /**
  27215. * Are ambient textures enabled in the application.
  27216. */
  27217. static AmbientTextureEnabled: boolean;
  27218. /**
  27219. * Are opacity textures enabled in the application.
  27220. */
  27221. static OpacityTextureEnabled: boolean;
  27222. /**
  27223. * Are reflection textures enabled in the application.
  27224. */
  27225. static ReflectionTextureEnabled: boolean;
  27226. /**
  27227. * Are emissive textures enabled in the application.
  27228. */
  27229. static EmissiveTextureEnabled: boolean;
  27230. /**
  27231. * Are specular textures enabled in the application.
  27232. */
  27233. static SpecularTextureEnabled: boolean;
  27234. /**
  27235. * Are bump textures enabled in the application.
  27236. */
  27237. static BumpTextureEnabled: boolean;
  27238. /**
  27239. * Are lightmap textures enabled in the application.
  27240. */
  27241. static LightmapTextureEnabled: boolean;
  27242. /**
  27243. * Are refraction textures enabled in the application.
  27244. */
  27245. static RefractionTextureEnabled: boolean;
  27246. /**
  27247. * Are color grading textures enabled in the application.
  27248. */
  27249. static ColorGradingTextureEnabled: boolean;
  27250. /**
  27251. * Are fresnels enabled in the application.
  27252. */
  27253. static FresnelEnabled: boolean;
  27254. }
  27255. }
  27256. declare module "babylonjs/Particles/solidParticleSystem" {
  27257. import { Nullable } from "babylonjs/types";
  27258. import { Vector3 } from "babylonjs/Maths/math.vector";
  27259. import { Mesh } from "babylonjs/Meshes/mesh";
  27260. import { Scene, IDisposable } from "babylonjs/scene";
  27261. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  27262. import { Material } from "babylonjs/Materials/material";
  27263. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  27264. /**
  27265. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  27266. *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.
  27267. * The SPS is also a particle system. It provides some methods to manage the particles.
  27268. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  27269. *
  27270. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  27271. */
  27272. export class SolidParticleSystem implements IDisposable {
  27273. /**
  27274. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  27275. * Example : var p = SPS.particles[i];
  27276. */
  27277. particles: SolidParticle[];
  27278. /**
  27279. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  27280. */
  27281. nbParticles: number;
  27282. /**
  27283. * If the particles must ever face the camera (default false). Useful for planar particles.
  27284. */
  27285. billboard: boolean;
  27286. /**
  27287. * Recompute normals when adding a shape
  27288. */
  27289. recomputeNormals: boolean;
  27290. /**
  27291. * This a counter ofr your own usage. It's not set by any SPS functions.
  27292. */
  27293. counter: number;
  27294. /**
  27295. * The SPS name. This name is also given to the underlying mesh.
  27296. */
  27297. name: string;
  27298. /**
  27299. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  27300. */
  27301. mesh: Mesh;
  27302. /**
  27303. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  27304. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  27305. */
  27306. vars: any;
  27307. /**
  27308. * This array is populated when the SPS is set as 'pickable'.
  27309. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  27310. * Each element of this array is an object `{idx: int, faceId: int}`.
  27311. * `idx` is the picked particle index in the `SPS.particles` array
  27312. * `faceId` is the picked face index counted within this particle.
  27313. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27314. */
  27315. pickedParticles: {
  27316. idx: number;
  27317. faceId: number;
  27318. }[];
  27319. /**
  27320. * This array is populated when `enableDepthSort` is set to true.
  27321. * Each element of this array is an instance of the class DepthSortedParticle.
  27322. */
  27323. depthSortedParticles: DepthSortedParticle[];
  27324. /**
  27325. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  27326. * @hidden
  27327. */
  27328. _bSphereOnly: boolean;
  27329. /**
  27330. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  27331. * @hidden
  27332. */
  27333. _bSphereRadiusFactor: number;
  27334. private _scene;
  27335. private _positions;
  27336. private _indices;
  27337. private _normals;
  27338. private _colors;
  27339. private _uvs;
  27340. private _indices32;
  27341. private _positions32;
  27342. private _normals32;
  27343. private _fixedNormal32;
  27344. private _colors32;
  27345. private _uvs32;
  27346. private _index;
  27347. private _updatable;
  27348. private _pickable;
  27349. private _isVisibilityBoxLocked;
  27350. private _alwaysVisible;
  27351. private _depthSort;
  27352. private _expandable;
  27353. private _shapeCounter;
  27354. private _copy;
  27355. private _color;
  27356. private _computeParticleColor;
  27357. private _computeParticleTexture;
  27358. private _computeParticleRotation;
  27359. private _computeParticleVertex;
  27360. private _computeBoundingBox;
  27361. private _depthSortParticles;
  27362. private _camera;
  27363. private _mustUnrotateFixedNormals;
  27364. private _particlesIntersect;
  27365. private _needs32Bits;
  27366. private _isNotBuilt;
  27367. private _lastParticleId;
  27368. private _idxOfId;
  27369. private _multimaterialEnabled;
  27370. private _useModelMaterial;
  27371. private _indicesByMaterial;
  27372. private _materialIndexes;
  27373. private _depthSortFunction;
  27374. private _materialSortFunction;
  27375. private _materials;
  27376. private _multimaterial;
  27377. private _materialIndexesById;
  27378. private _defaultMaterial;
  27379. private _autoUpdateSubMeshes;
  27380. /**
  27381. * Creates a SPS (Solid Particle System) object.
  27382. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27383. * @param scene (Scene) is the scene in which the SPS is added.
  27384. * @param options defines the options of the sps e.g.
  27385. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27386. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27387. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27388. * * useModelMaterial (optional boolean, defaut false) : if the model materials must be used to create the SPS multimaterial. This enables the multimaterial supports of the SPS.
  27389. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27390. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27391. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27392. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27393. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27394. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27395. */
  27396. constructor(name: string, scene: Scene, options?: {
  27397. updatable?: boolean;
  27398. isPickable?: boolean;
  27399. enableDepthSort?: boolean;
  27400. particleIntersection?: boolean;
  27401. boundingSphereOnly?: boolean;
  27402. bSphereRadiusFactor?: number;
  27403. expandable?: boolean;
  27404. useModelMaterial?: boolean;
  27405. enableMultiMaterial?: boolean;
  27406. });
  27407. /**
  27408. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27409. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27410. * @returns the created mesh
  27411. */
  27412. buildMesh(): Mesh;
  27413. /**
  27414. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27415. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27416. * Thus the particles generated from `digest()` have their property `position` set yet.
  27417. * @param mesh ( Mesh ) is the mesh to be digested
  27418. * @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
  27419. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27420. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27421. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27422. * @returns the current SPS
  27423. */
  27424. digest(mesh: Mesh, options?: {
  27425. facetNb?: number;
  27426. number?: number;
  27427. delta?: number;
  27428. storage?: [];
  27429. }): SolidParticleSystem;
  27430. /**
  27431. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27432. * @hidden
  27433. */
  27434. private _unrotateFixedNormals;
  27435. /**
  27436. * Resets the temporary working copy particle
  27437. * @hidden
  27438. */
  27439. private _resetCopy;
  27440. /**
  27441. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27442. * @param p the current index in the positions array to be updated
  27443. * @param ind the current index in the indices array
  27444. * @param shape a Vector3 array, the shape geometry
  27445. * @param positions the positions array to be updated
  27446. * @param meshInd the shape indices array
  27447. * @param indices the indices array to be updated
  27448. * @param meshUV the shape uv array
  27449. * @param uvs the uv array to be updated
  27450. * @param meshCol the shape color array
  27451. * @param colors the color array to be updated
  27452. * @param meshNor the shape normals array
  27453. * @param normals the normals array to be updated
  27454. * @param idx the particle index
  27455. * @param idxInShape the particle index in its shape
  27456. * @param options the addShape() method passed options
  27457. * @model the particle model
  27458. * @hidden
  27459. */
  27460. private _meshBuilder;
  27461. /**
  27462. * Returns a shape Vector3 array from positions float array
  27463. * @param positions float array
  27464. * @returns a vector3 array
  27465. * @hidden
  27466. */
  27467. private _posToShape;
  27468. /**
  27469. * Returns a shapeUV array from a float uvs (array deep copy)
  27470. * @param uvs as a float array
  27471. * @returns a shapeUV array
  27472. * @hidden
  27473. */
  27474. private _uvsToShapeUV;
  27475. /**
  27476. * Adds a new particle object in the particles array
  27477. * @param idx particle index in particles array
  27478. * @param id particle id
  27479. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27480. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27481. * @param model particle ModelShape object
  27482. * @param shapeId model shape identifier
  27483. * @param idxInShape index of the particle in the current model
  27484. * @param bInfo model bounding info object
  27485. * @param storage target storage array, if any
  27486. * @hidden
  27487. */
  27488. private _addParticle;
  27489. /**
  27490. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27491. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27492. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27493. * @param nb (positive integer) the number of particles to be created from this model
  27494. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27495. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27496. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27497. * @returns the number of shapes in the system
  27498. */
  27499. addShape(mesh: Mesh, nb: number, options?: {
  27500. positionFunction?: any;
  27501. vertexFunction?: any;
  27502. storage?: [];
  27503. }): number;
  27504. /**
  27505. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27506. * @hidden
  27507. */
  27508. private _rebuildParticle;
  27509. /**
  27510. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27511. * @param reset boolean, default false : if the particles must be reset at position and rotation zero, scaling 1, color white, initial UVs and not parented.
  27512. * @returns the SPS.
  27513. */
  27514. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27515. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27516. * Returns an array with the removed particles.
  27517. * If the number of particles to remove is lower than zero or greater than the global remaining particle number, then an empty array is returned.
  27518. * The SPS can't be empty so at least one particle needs to remain in place.
  27519. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27520. * @param start index of the first particle to remove
  27521. * @param end index of the last particle to remove (included)
  27522. * @returns an array populated with the removed particles
  27523. */
  27524. removeParticles(start: number, end: number): SolidParticle[];
  27525. /**
  27526. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  27527. * @param solidParticleArray an array populated with Solid Particles objects
  27528. * @returns the SPS
  27529. */
  27530. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27531. /**
  27532. * Creates a new particle and modifies the SPS mesh geometry :
  27533. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27534. * - calls _addParticle() to populate the particle array
  27535. * factorized code from addShape() and insertParticlesFromArray()
  27536. * @param idx particle index in the particles array
  27537. * @param i particle index in its shape
  27538. * @param modelShape particle ModelShape object
  27539. * @param shape shape vertex array
  27540. * @param meshInd shape indices array
  27541. * @param meshUV shape uv array
  27542. * @param meshCol shape color array
  27543. * @param meshNor shape normals array
  27544. * @param bbInfo shape bounding info
  27545. * @param storage target particle storage
  27546. * @options addShape() passed options
  27547. * @hidden
  27548. */
  27549. private _insertNewParticle;
  27550. /**
  27551. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  27552. * This method calls `updateParticle()` for each particle of the SPS.
  27553. * For an animated SPS, it is usually called within the render loop.
  27554. * This methods does nothing if called on a non updatable or not yet built SPS. Example : buildMesh() not called after having added or removed particles from an expandable SPS.
  27555. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  27556. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  27557. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  27558. * @returns the SPS.
  27559. */
  27560. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  27561. /**
  27562. * Disposes the SPS.
  27563. */
  27564. dispose(): void;
  27565. /**
  27566. * Returns a SolidParticle object from its identifier : particle.id
  27567. * @param id (integer) the particle Id
  27568. * @returns the searched particle or null if not found in the SPS.
  27569. */
  27570. getParticleById(id: number): Nullable<SolidParticle>;
  27571. /**
  27572. * Returns a new array populated with the particles having the passed shapeId.
  27573. * @param shapeId (integer) the shape identifier
  27574. * @returns a new solid particle array
  27575. */
  27576. getParticlesByShapeId(shapeId: number): SolidParticle[];
  27577. /**
  27578. * Populates the passed array "ref" with the particles having the passed shapeId.
  27579. * @param shapeId the shape identifier
  27580. * @returns the SPS
  27581. * @param ref
  27582. */
  27583. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  27584. /**
  27585. * Computes the required SubMeshes according the materials assigned to the particles.
  27586. * @returns the solid particle system.
  27587. * Does nothing if called before the SPS mesh is built.
  27588. */
  27589. computeSubMeshes(): SolidParticleSystem;
  27590. /**
  27591. * Sorts the solid particles by material when MultiMaterial is enabled.
  27592. * Updates the indices32 array.
  27593. * Updates the indicesByMaterial array.
  27594. * Updates the mesh indices array.
  27595. * @returns the SPS
  27596. * @hidden
  27597. */
  27598. private _sortParticlesByMaterial;
  27599. /**
  27600. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  27601. * @hidden
  27602. */
  27603. private _setMaterialIndexesById;
  27604. /**
  27605. * Returns an array with unique values of Materials from the passed array
  27606. * @param array the material array to be checked and filtered
  27607. * @hidden
  27608. */
  27609. private _filterUniqueMaterialId;
  27610. /**
  27611. * Sets a new Standard Material as _defaultMaterial if not already set.
  27612. * @hidden
  27613. */
  27614. private _setDefaultMaterial;
  27615. /**
  27616. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  27617. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27618. * @returns the SPS.
  27619. */
  27620. refreshVisibleSize(): SolidParticleSystem;
  27621. /**
  27622. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  27623. * @param size the size (float) of the visibility box
  27624. * note : this doesn't lock the SPS mesh bounding box.
  27625. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27626. */
  27627. setVisibilityBox(size: number): void;
  27628. /**
  27629. * Gets whether the SPS as always visible or not
  27630. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27631. */
  27632. /**
  27633. * Sets the SPS as always visible or not
  27634. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27635. */
  27636. isAlwaysVisible: boolean;
  27637. /**
  27638. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27639. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27640. */
  27641. /**
  27642. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27643. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27644. */
  27645. isVisibilityBoxLocked: boolean;
  27646. /**
  27647. * Tells to `setParticles()` to compute the particle rotations or not.
  27648. * Default value : true. The SPS is faster when it's set to false.
  27649. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27650. */
  27651. /**
  27652. * Gets if `setParticles()` computes the particle rotations or not.
  27653. * Default value : true. The SPS is faster when it's set to false.
  27654. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27655. */
  27656. computeParticleRotation: boolean;
  27657. /**
  27658. * Tells to `setParticles()` to compute the particle colors or not.
  27659. * Default value : true. The SPS is faster when it's set to false.
  27660. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27661. */
  27662. /**
  27663. * Gets if `setParticles()` computes the particle colors or not.
  27664. * Default value : true. The SPS is faster when it's set to false.
  27665. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27666. */
  27667. computeParticleColor: boolean;
  27668. /**
  27669. * Gets if `setParticles()` computes the particle textures or not.
  27670. * Default value : true. The SPS is faster when it's set to false.
  27671. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  27672. */
  27673. computeParticleTexture: boolean;
  27674. /**
  27675. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  27676. * Default value : false. The SPS is faster when it's set to false.
  27677. * Note : the particle custom vertex positions aren't stored values.
  27678. */
  27679. /**
  27680. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  27681. * Default value : false. The SPS is faster when it's set to false.
  27682. * Note : the particle custom vertex positions aren't stored values.
  27683. */
  27684. computeParticleVertex: boolean;
  27685. /**
  27686. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  27687. */
  27688. /**
  27689. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  27690. */
  27691. computeBoundingBox: boolean;
  27692. /**
  27693. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  27694. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27695. * Default : `true`
  27696. */
  27697. /**
  27698. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  27699. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27700. * Default : `true`
  27701. */
  27702. depthSortParticles: boolean;
  27703. /**
  27704. * Gets if the SPS is created as expandable at construction time.
  27705. * Default : `false`
  27706. */
  27707. readonly expandable: boolean;
  27708. /**
  27709. * Gets if the SPS supports the Multi Materials
  27710. */
  27711. readonly multimaterialEnabled: boolean;
  27712. /**
  27713. * Gets if the SPS uses the model materials for its own multimaterial.
  27714. */
  27715. readonly useModelMaterial: boolean;
  27716. /**
  27717. * The SPS used material array.
  27718. */
  27719. readonly materials: Material[];
  27720. /**
  27721. * Sets the SPS MultiMaterial from the passed materials.
  27722. * Note : the passed array is internally copied and not used then by reference.
  27723. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  27724. */
  27725. setMultiMaterial(materials: Material[]): void;
  27726. /**
  27727. * The SPS computed multimaterial object
  27728. */
  27729. multimaterial: MultiMaterial;
  27730. /**
  27731. * If the subMeshes must be updated on the next call to setParticles()
  27732. */
  27733. autoUpdateSubMeshes: boolean;
  27734. /**
  27735. * This function does nothing. It may be overwritten to set all the particle first values.
  27736. * The SPS doesn't call this function, you may have to call it by your own.
  27737. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27738. */
  27739. initParticles(): void;
  27740. /**
  27741. * This function does nothing. It may be overwritten to recycle a particle.
  27742. * The SPS doesn't call this function, you may have to call it by your own.
  27743. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27744. * @param particle The particle to recycle
  27745. * @returns the recycled particle
  27746. */
  27747. recycleParticle(particle: SolidParticle): SolidParticle;
  27748. /**
  27749. * Updates a particle : this function should be overwritten by the user.
  27750. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  27751. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27752. * @example : just set a particle position or velocity and recycle conditions
  27753. * @param particle The particle to update
  27754. * @returns the updated particle
  27755. */
  27756. updateParticle(particle: SolidParticle): SolidParticle;
  27757. /**
  27758. * Updates a vertex of a particle : it can be overwritten by the user.
  27759. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  27760. * @param particle the current particle
  27761. * @param vertex the current index of the current particle
  27762. * @param pt the index of the current vertex in the particle shape
  27763. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  27764. * @example : just set a vertex particle position
  27765. * @returns the updated vertex
  27766. */
  27767. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  27768. /**
  27769. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  27770. * This does nothing and may be overwritten by the user.
  27771. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27772. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27773. * @param update the boolean update value actually passed to setParticles()
  27774. */
  27775. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27776. /**
  27777. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  27778. * This will be passed three parameters.
  27779. * This does nothing and may be overwritten by the user.
  27780. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27781. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27782. * @param update the boolean update value actually passed to setParticles()
  27783. */
  27784. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27785. }
  27786. }
  27787. declare module "babylonjs/Particles/solidParticle" {
  27788. import { Nullable } from "babylonjs/types";
  27789. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  27790. import { Color4 } from "babylonjs/Maths/math.color";
  27791. import { Mesh } from "babylonjs/Meshes/mesh";
  27792. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  27793. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  27794. import { Plane } from "babylonjs/Maths/math.plane";
  27795. import { Material } from "babylonjs/Materials/material";
  27796. /**
  27797. * Represents one particle of a solid particle system.
  27798. */
  27799. export class SolidParticle {
  27800. /**
  27801. * particle global index
  27802. */
  27803. idx: number;
  27804. /**
  27805. * particle identifier
  27806. */
  27807. id: number;
  27808. /**
  27809. * The color of the particle
  27810. */
  27811. color: Nullable<Color4>;
  27812. /**
  27813. * The world space position of the particle.
  27814. */
  27815. position: Vector3;
  27816. /**
  27817. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  27818. */
  27819. rotation: Vector3;
  27820. /**
  27821. * The world space rotation quaternion of the particle.
  27822. */
  27823. rotationQuaternion: Nullable<Quaternion>;
  27824. /**
  27825. * The scaling of the particle.
  27826. */
  27827. scaling: Vector3;
  27828. /**
  27829. * The uvs of the particle.
  27830. */
  27831. uvs: Vector4;
  27832. /**
  27833. * The current speed of the particle.
  27834. */
  27835. velocity: Vector3;
  27836. /**
  27837. * The pivot point in the particle local space.
  27838. */
  27839. pivot: Vector3;
  27840. /**
  27841. * Must the particle be translated from its pivot point in its local space ?
  27842. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  27843. * Default : false
  27844. */
  27845. translateFromPivot: boolean;
  27846. /**
  27847. * Is the particle active or not ?
  27848. */
  27849. alive: boolean;
  27850. /**
  27851. * Is the particle visible or not ?
  27852. */
  27853. isVisible: boolean;
  27854. /**
  27855. * Index of this particle in the global "positions" array (Internal use)
  27856. * @hidden
  27857. */
  27858. _pos: number;
  27859. /**
  27860. * @hidden Index of this particle in the global "indices" array (Internal use)
  27861. */
  27862. _ind: number;
  27863. /**
  27864. * @hidden ModelShape of this particle (Internal use)
  27865. */
  27866. _model: ModelShape;
  27867. /**
  27868. * ModelShape id of this particle
  27869. */
  27870. shapeId: number;
  27871. /**
  27872. * Index of the particle in its shape id
  27873. */
  27874. idxInShape: number;
  27875. /**
  27876. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  27877. */
  27878. _modelBoundingInfo: BoundingInfo;
  27879. /**
  27880. * @hidden Particle BoundingInfo object (Internal use)
  27881. */
  27882. _boundingInfo: BoundingInfo;
  27883. /**
  27884. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  27885. */
  27886. _sps: SolidParticleSystem;
  27887. /**
  27888. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  27889. */
  27890. _stillInvisible: boolean;
  27891. /**
  27892. * @hidden Last computed particle rotation matrix
  27893. */
  27894. _rotationMatrix: number[];
  27895. /**
  27896. * Parent particle Id, if any.
  27897. * Default null.
  27898. */
  27899. parentId: Nullable<number>;
  27900. /**
  27901. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  27902. */
  27903. materialIndex: Nullable<number>;
  27904. /**
  27905. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  27906. * The possible values are :
  27907. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27908. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27909. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27910. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27911. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27912. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  27913. * */
  27914. cullingStrategy: number;
  27915. /**
  27916. * @hidden Internal global position in the SPS.
  27917. */
  27918. _globalPosition: Vector3;
  27919. /**
  27920. * Creates a Solid Particle object.
  27921. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  27922. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  27923. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  27924. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  27925. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  27926. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  27927. * @param shapeId (integer) is the model shape identifier in the SPS.
  27928. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  27929. * @param sps defines the sps it is associated to
  27930. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  27931. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  27932. */
  27933. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  27934. /**
  27935. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  27936. * @param target the particle target
  27937. * @returns the current particle
  27938. */
  27939. copyToRef(target: SolidParticle): SolidParticle;
  27940. /**
  27941. * Legacy support, changed scale to scaling
  27942. */
  27943. /**
  27944. * Legacy support, changed scale to scaling
  27945. */
  27946. scale: Vector3;
  27947. /**
  27948. * Legacy support, changed quaternion to rotationQuaternion
  27949. */
  27950. /**
  27951. * Legacy support, changed quaternion to rotationQuaternion
  27952. */
  27953. quaternion: Nullable<Quaternion>;
  27954. /**
  27955. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  27956. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  27957. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  27958. * @returns true if it intersects
  27959. */
  27960. intersectsMesh(target: Mesh | SolidParticle): boolean;
  27961. /**
  27962. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  27963. * A particle is in the frustum if its bounding box intersects the frustum
  27964. * @param frustumPlanes defines the frustum to test
  27965. * @returns true if the particle is in the frustum planes
  27966. */
  27967. isInFrustum(frustumPlanes: Plane[]): boolean;
  27968. /**
  27969. * get the rotation matrix of the particle
  27970. * @hidden
  27971. */
  27972. getRotationMatrix(m: Matrix): void;
  27973. }
  27974. /**
  27975. * Represents the shape of the model used by one particle of a solid particle system.
  27976. * SPS internal tool, don't use it manually.
  27977. */
  27978. export class ModelShape {
  27979. /**
  27980. * The shape id
  27981. * @hidden
  27982. */
  27983. shapeID: number;
  27984. /**
  27985. * flat array of model positions (internal use)
  27986. * @hidden
  27987. */
  27988. _shape: Vector3[];
  27989. /**
  27990. * flat array of model UVs (internal use)
  27991. * @hidden
  27992. */
  27993. _shapeUV: number[];
  27994. /**
  27995. * color array of the model
  27996. * @hidden
  27997. */
  27998. _shapeColors: number[];
  27999. /**
  28000. * indices array of the model
  28001. * @hidden
  28002. */
  28003. _indices: number[];
  28004. /**
  28005. * normals array of the model
  28006. * @hidden
  28007. */
  28008. _normals: number[];
  28009. /**
  28010. * length of the shape in the model indices array (internal use)
  28011. * @hidden
  28012. */
  28013. _indicesLength: number;
  28014. /**
  28015. * Custom position function (internal use)
  28016. * @hidden
  28017. */
  28018. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  28019. /**
  28020. * Custom vertex function (internal use)
  28021. * @hidden
  28022. */
  28023. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  28024. /**
  28025. * Model material (internal use)
  28026. * @hidden
  28027. */
  28028. _material: Nullable<Material>;
  28029. /**
  28030. * 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.
  28031. * SPS internal tool, don't use it manually.
  28032. * @hidden
  28033. */
  28034. constructor(id: number, shape: Vector3[], indices: number[], normals: number[], colors: number[], shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>, material: Nullable<Material>);
  28035. }
  28036. /**
  28037. * Represents a Depth Sorted Particle in the solid particle system.
  28038. * @hidden
  28039. */
  28040. export class DepthSortedParticle {
  28041. /**
  28042. * Index of the particle in the "indices" array
  28043. */
  28044. ind: number;
  28045. /**
  28046. * Length of the particle shape in the "indices" array
  28047. */
  28048. indicesLength: number;
  28049. /**
  28050. * Squared distance from the particle to the camera
  28051. */
  28052. sqDistance: number;
  28053. /**
  28054. * Material index when used with MultiMaterials
  28055. */
  28056. materialIndex: number;
  28057. /**
  28058. * Creates a new sorted particle
  28059. * @param materialIndex
  28060. */
  28061. constructor(ind: number, indLength: number, materialIndex: number);
  28062. }
  28063. }
  28064. declare module "babylonjs/Collisions/meshCollisionData" {
  28065. import { Collider } from "babylonjs/Collisions/collider";
  28066. import { Vector3 } from "babylonjs/Maths/math.vector";
  28067. import { Nullable } from "babylonjs/types";
  28068. import { Observer } from "babylonjs/Misc/observable";
  28069. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28070. /**
  28071. * @hidden
  28072. */
  28073. export class _MeshCollisionData {
  28074. _checkCollisions: boolean;
  28075. _collisionMask: number;
  28076. _collisionGroup: number;
  28077. _collider: Nullable<Collider>;
  28078. _oldPositionForCollisions: Vector3;
  28079. _diffPositionForCollisions: Vector3;
  28080. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  28081. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  28082. }
  28083. }
  28084. declare module "babylonjs/Meshes/abstractMesh" {
  28085. import { Observable } from "babylonjs/Misc/observable";
  28086. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  28087. import { Camera } from "babylonjs/Cameras/camera";
  28088. import { Scene, IDisposable } from "babylonjs/scene";
  28089. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  28090. import { Node } from "babylonjs/node";
  28091. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  28092. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28093. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28094. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  28095. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28096. import { Material } from "babylonjs/Materials/material";
  28097. import { Light } from "babylonjs/Lights/light";
  28098. import { Skeleton } from "babylonjs/Bones/skeleton";
  28099. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  28100. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  28101. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  28102. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  28103. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  28104. import { Plane } from "babylonjs/Maths/math.plane";
  28105. import { Ray } from "babylonjs/Culling/ray";
  28106. import { Collider } from "babylonjs/Collisions/collider";
  28107. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  28108. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  28109. /** @hidden */
  28110. class _FacetDataStorage {
  28111. facetPositions: Vector3[];
  28112. facetNormals: Vector3[];
  28113. facetPartitioning: number[][];
  28114. facetNb: number;
  28115. partitioningSubdivisions: number;
  28116. partitioningBBoxRatio: number;
  28117. facetDataEnabled: boolean;
  28118. facetParameters: any;
  28119. bbSize: Vector3;
  28120. subDiv: {
  28121. max: number;
  28122. X: number;
  28123. Y: number;
  28124. Z: number;
  28125. };
  28126. facetDepthSort: boolean;
  28127. facetDepthSortEnabled: boolean;
  28128. depthSortedIndices: IndicesArray;
  28129. depthSortedFacets: {
  28130. ind: number;
  28131. sqDistance: number;
  28132. }[];
  28133. facetDepthSortFunction: (f1: {
  28134. ind: number;
  28135. sqDistance: number;
  28136. }, f2: {
  28137. ind: number;
  28138. sqDistance: number;
  28139. }) => number;
  28140. facetDepthSortFrom: Vector3;
  28141. facetDepthSortOrigin: Vector3;
  28142. invertedMatrix: Matrix;
  28143. }
  28144. /**
  28145. * @hidden
  28146. **/
  28147. class _InternalAbstractMeshDataInfo {
  28148. _hasVertexAlpha: boolean;
  28149. _useVertexColors: boolean;
  28150. _numBoneInfluencers: number;
  28151. _applyFog: boolean;
  28152. _receiveShadows: boolean;
  28153. _facetData: _FacetDataStorage;
  28154. _visibility: number;
  28155. _skeleton: Nullable<Skeleton>;
  28156. _layerMask: number;
  28157. _computeBonesUsingShaders: boolean;
  28158. _isActive: boolean;
  28159. _onlyForInstances: boolean;
  28160. _isActiveIntermediate: boolean;
  28161. _onlyForInstancesIntermediate: boolean;
  28162. _actAsRegularMesh: boolean;
  28163. }
  28164. /**
  28165. * Class used to store all common mesh properties
  28166. */
  28167. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  28168. /** No occlusion */
  28169. static OCCLUSION_TYPE_NONE: number;
  28170. /** Occlusion set to optimisitic */
  28171. static OCCLUSION_TYPE_OPTIMISTIC: number;
  28172. /** Occlusion set to strict */
  28173. static OCCLUSION_TYPE_STRICT: number;
  28174. /** Use an accurante occlusion algorithm */
  28175. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  28176. /** Use a conservative occlusion algorithm */
  28177. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  28178. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  28179. * Test order :
  28180. * Is the bounding sphere outside the frustum ?
  28181. * If not, are the bounding box vertices outside the frustum ?
  28182. * It not, then the cullable object is in the frustum.
  28183. */
  28184. static readonly CULLINGSTRATEGY_STANDARD: number;
  28185. /** Culling strategy : Bounding Sphere Only.
  28186. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  28187. * It's also less accurate than the standard because some not visible objects can still be selected.
  28188. * Test : is the bounding sphere outside the frustum ?
  28189. * If not, then the cullable object is in the frustum.
  28190. */
  28191. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  28192. /** Culling strategy : Optimistic Inclusion.
  28193. * This in an inclusion test first, then the standard exclusion test.
  28194. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  28195. * 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.
  28196. * Anyway, it's as accurate as the standard strategy.
  28197. * Test :
  28198. * Is the cullable object bounding sphere center in the frustum ?
  28199. * If not, apply the default culling strategy.
  28200. */
  28201. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  28202. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  28203. * This in an inclusion test first, then the bounding sphere only exclusion test.
  28204. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  28205. * 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.
  28206. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  28207. * Test :
  28208. * Is the cullable object bounding sphere center in the frustum ?
  28209. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  28210. */
  28211. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  28212. /**
  28213. * No billboard
  28214. */
  28215. static readonly BILLBOARDMODE_NONE: number;
  28216. /** Billboard on X axis */
  28217. static readonly BILLBOARDMODE_X: number;
  28218. /** Billboard on Y axis */
  28219. static readonly BILLBOARDMODE_Y: number;
  28220. /** Billboard on Z axis */
  28221. static readonly BILLBOARDMODE_Z: number;
  28222. /** Billboard on all axes */
  28223. static readonly BILLBOARDMODE_ALL: number;
  28224. /** Billboard on using position instead of orientation */
  28225. static readonly BILLBOARDMODE_USE_POSITION: number;
  28226. /** @hidden */
  28227. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  28228. /**
  28229. * The culling strategy to use to check whether the mesh must be rendered or not.
  28230. * This value can be changed at any time and will be used on the next render mesh selection.
  28231. * The possible values are :
  28232. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28233. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28234. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28235. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28236. * Please read each static variable documentation to get details about the culling process.
  28237. * */
  28238. cullingStrategy: number;
  28239. /**
  28240. * Gets the number of facets in the mesh
  28241. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28242. */
  28243. readonly facetNb: number;
  28244. /**
  28245. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  28246. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28247. */
  28248. partitioningSubdivisions: number;
  28249. /**
  28250. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  28251. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  28252. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28253. */
  28254. partitioningBBoxRatio: number;
  28255. /**
  28256. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  28257. * Works only for updatable meshes.
  28258. * Doesn't work with multi-materials
  28259. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28260. */
  28261. mustDepthSortFacets: boolean;
  28262. /**
  28263. * The location (Vector3) where the facet depth sort must be computed from.
  28264. * By default, the active camera position.
  28265. * Used only when facet depth sort is enabled
  28266. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28267. */
  28268. facetDepthSortFrom: Vector3;
  28269. /**
  28270. * gets a boolean indicating if facetData is enabled
  28271. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28272. */
  28273. readonly isFacetDataEnabled: boolean;
  28274. /** @hidden */
  28275. _updateNonUniformScalingState(value: boolean): boolean;
  28276. /**
  28277. * An event triggered when this mesh collides with another one
  28278. */
  28279. onCollideObservable: Observable<AbstractMesh>;
  28280. /** Set a function to call when this mesh collides with another one */
  28281. onCollide: () => void;
  28282. /**
  28283. * An event triggered when the collision's position changes
  28284. */
  28285. onCollisionPositionChangeObservable: Observable<Vector3>;
  28286. /** Set a function to call when the collision's position changes */
  28287. onCollisionPositionChange: () => void;
  28288. /**
  28289. * An event triggered when material is changed
  28290. */
  28291. onMaterialChangedObservable: Observable<AbstractMesh>;
  28292. /**
  28293. * Gets or sets the orientation for POV movement & rotation
  28294. */
  28295. definedFacingForward: boolean;
  28296. /** @hidden */
  28297. _occlusionQuery: Nullable<WebGLQuery>;
  28298. /** @hidden */
  28299. _renderingGroup: Nullable<RenderingGroup>;
  28300. /**
  28301. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28302. */
  28303. /**
  28304. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28305. */
  28306. visibility: number;
  28307. /** Gets or sets the alpha index used to sort transparent meshes
  28308. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  28309. */
  28310. alphaIndex: number;
  28311. /**
  28312. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  28313. */
  28314. isVisible: boolean;
  28315. /**
  28316. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  28317. */
  28318. isPickable: boolean;
  28319. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  28320. showSubMeshesBoundingBox: boolean;
  28321. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  28322. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  28323. */
  28324. isBlocker: boolean;
  28325. /**
  28326. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  28327. */
  28328. enablePointerMoveEvents: boolean;
  28329. /**
  28330. * Specifies the rendering group id for this mesh (0 by default)
  28331. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  28332. */
  28333. renderingGroupId: number;
  28334. private _material;
  28335. /** Gets or sets current material */
  28336. material: Nullable<Material>;
  28337. /**
  28338. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  28339. * @see http://doc.babylonjs.com/babylon101/shadows
  28340. */
  28341. receiveShadows: boolean;
  28342. /** Defines color to use when rendering outline */
  28343. outlineColor: Color3;
  28344. /** Define width to use when rendering outline */
  28345. outlineWidth: number;
  28346. /** Defines color to use when rendering overlay */
  28347. overlayColor: Color3;
  28348. /** Defines alpha to use when rendering overlay */
  28349. overlayAlpha: number;
  28350. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  28351. hasVertexAlpha: boolean;
  28352. /** 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) */
  28353. useVertexColors: boolean;
  28354. /**
  28355. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  28356. */
  28357. computeBonesUsingShaders: boolean;
  28358. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  28359. numBoneInfluencers: number;
  28360. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  28361. applyFog: boolean;
  28362. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  28363. useOctreeForRenderingSelection: boolean;
  28364. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  28365. useOctreeForPicking: boolean;
  28366. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  28367. useOctreeForCollisions: boolean;
  28368. /**
  28369. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  28370. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  28371. */
  28372. layerMask: number;
  28373. /**
  28374. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  28375. */
  28376. alwaysSelectAsActiveMesh: boolean;
  28377. /**
  28378. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  28379. */
  28380. doNotSyncBoundingInfo: boolean;
  28381. /**
  28382. * Gets or sets the current action manager
  28383. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28384. */
  28385. actionManager: Nullable<AbstractActionManager>;
  28386. private _meshCollisionData;
  28387. /**
  28388. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  28389. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28390. */
  28391. ellipsoid: Vector3;
  28392. /**
  28393. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  28394. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28395. */
  28396. ellipsoidOffset: Vector3;
  28397. /**
  28398. * Gets or sets a collision mask used to mask collisions (default is -1).
  28399. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28400. */
  28401. collisionMask: number;
  28402. /**
  28403. * Gets or sets the current collision group mask (-1 by default).
  28404. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28405. */
  28406. collisionGroup: number;
  28407. /**
  28408. * Defines edge width used when edgesRenderer is enabled
  28409. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28410. */
  28411. edgesWidth: number;
  28412. /**
  28413. * Defines edge color used when edgesRenderer is enabled
  28414. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28415. */
  28416. edgesColor: Color4;
  28417. /** @hidden */
  28418. _edgesRenderer: Nullable<IEdgesRenderer>;
  28419. /** @hidden */
  28420. _masterMesh: Nullable<AbstractMesh>;
  28421. /** @hidden */
  28422. _boundingInfo: Nullable<BoundingInfo>;
  28423. /** @hidden */
  28424. _renderId: number;
  28425. /**
  28426. * Gets or sets the list of subMeshes
  28427. * @see http://doc.babylonjs.com/how_to/multi_materials
  28428. */
  28429. subMeshes: SubMesh[];
  28430. /** @hidden */
  28431. _intersectionsInProgress: AbstractMesh[];
  28432. /** @hidden */
  28433. _unIndexed: boolean;
  28434. /** @hidden */
  28435. _lightSources: Light[];
  28436. /** Gets the list of lights affecting that mesh */
  28437. readonly lightSources: Light[];
  28438. /** @hidden */
  28439. readonly _positions: Nullable<Vector3[]>;
  28440. /** @hidden */
  28441. _waitingData: {
  28442. lods: Nullable<any>;
  28443. actions: Nullable<any>;
  28444. freezeWorldMatrix: Nullable<boolean>;
  28445. };
  28446. /** @hidden */
  28447. _bonesTransformMatrices: Nullable<Float32Array>;
  28448. /** @hidden */
  28449. _transformMatrixTexture: Nullable<RawTexture>;
  28450. /**
  28451. * Gets or sets a skeleton to apply skining transformations
  28452. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28453. */
  28454. skeleton: Nullable<Skeleton>;
  28455. /**
  28456. * An event triggered when the mesh is rebuilt.
  28457. */
  28458. onRebuildObservable: Observable<AbstractMesh>;
  28459. /**
  28460. * Creates a new AbstractMesh
  28461. * @param name defines the name of the mesh
  28462. * @param scene defines the hosting scene
  28463. */
  28464. constructor(name: string, scene?: Nullable<Scene>);
  28465. /**
  28466. * Returns the string "AbstractMesh"
  28467. * @returns "AbstractMesh"
  28468. */
  28469. getClassName(): string;
  28470. /**
  28471. * Gets a string representation of the current mesh
  28472. * @param fullDetails defines a boolean indicating if full details must be included
  28473. * @returns a string representation of the current mesh
  28474. */
  28475. toString(fullDetails?: boolean): string;
  28476. /**
  28477. * @hidden
  28478. */
  28479. protected _getEffectiveParent(): Nullable<Node>;
  28480. /** @hidden */
  28481. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28482. /** @hidden */
  28483. _rebuild(): void;
  28484. /** @hidden */
  28485. _resyncLightSources(): void;
  28486. /** @hidden */
  28487. _resyncLightSource(light: Light): void;
  28488. /** @hidden */
  28489. _unBindEffect(): void;
  28490. /** @hidden */
  28491. _removeLightSource(light: Light, dispose: boolean): void;
  28492. private _markSubMeshesAsDirty;
  28493. /** @hidden */
  28494. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  28495. /** @hidden */
  28496. _markSubMeshesAsAttributesDirty(): void;
  28497. /** @hidden */
  28498. _markSubMeshesAsMiscDirty(): void;
  28499. /**
  28500. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  28501. */
  28502. scaling: Vector3;
  28503. /**
  28504. * Returns true if the mesh is blocked. Implemented by child classes
  28505. */
  28506. readonly isBlocked: boolean;
  28507. /**
  28508. * Returns the mesh itself by default. Implemented by child classes
  28509. * @param camera defines the camera to use to pick the right LOD level
  28510. * @returns the currentAbstractMesh
  28511. */
  28512. getLOD(camera: Camera): Nullable<AbstractMesh>;
  28513. /**
  28514. * Returns 0 by default. Implemented by child classes
  28515. * @returns an integer
  28516. */
  28517. getTotalVertices(): number;
  28518. /**
  28519. * Returns a positive integer : the total number of indices in this mesh geometry.
  28520. * @returns the numner of indices or zero if the mesh has no geometry.
  28521. */
  28522. getTotalIndices(): number;
  28523. /**
  28524. * Returns null by default. Implemented by child classes
  28525. * @returns null
  28526. */
  28527. getIndices(): Nullable<IndicesArray>;
  28528. /**
  28529. * Returns the array of the requested vertex data kind. Implemented by child classes
  28530. * @param kind defines the vertex data kind to use
  28531. * @returns null
  28532. */
  28533. getVerticesData(kind: string): Nullable<FloatArray>;
  28534. /**
  28535. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28536. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28537. * Note that a new underlying VertexBuffer object is created each call.
  28538. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28539. * @param kind defines vertex data kind:
  28540. * * VertexBuffer.PositionKind
  28541. * * VertexBuffer.UVKind
  28542. * * VertexBuffer.UV2Kind
  28543. * * VertexBuffer.UV3Kind
  28544. * * VertexBuffer.UV4Kind
  28545. * * VertexBuffer.UV5Kind
  28546. * * VertexBuffer.UV6Kind
  28547. * * VertexBuffer.ColorKind
  28548. * * VertexBuffer.MatricesIndicesKind
  28549. * * VertexBuffer.MatricesIndicesExtraKind
  28550. * * VertexBuffer.MatricesWeightsKind
  28551. * * VertexBuffer.MatricesWeightsExtraKind
  28552. * @param data defines the data source
  28553. * @param updatable defines if the data must be flagged as updatable (or static)
  28554. * @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
  28555. * @returns the current mesh
  28556. */
  28557. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28558. /**
  28559. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28560. * If the mesh has no geometry, it is simply returned as it is.
  28561. * @param kind defines vertex data kind:
  28562. * * VertexBuffer.PositionKind
  28563. * * VertexBuffer.UVKind
  28564. * * VertexBuffer.UV2Kind
  28565. * * VertexBuffer.UV3Kind
  28566. * * VertexBuffer.UV4Kind
  28567. * * VertexBuffer.UV5Kind
  28568. * * VertexBuffer.UV6Kind
  28569. * * VertexBuffer.ColorKind
  28570. * * VertexBuffer.MatricesIndicesKind
  28571. * * VertexBuffer.MatricesIndicesExtraKind
  28572. * * VertexBuffer.MatricesWeightsKind
  28573. * * VertexBuffer.MatricesWeightsExtraKind
  28574. * @param data defines the data source
  28575. * @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
  28576. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  28577. * @returns the current mesh
  28578. */
  28579. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28580. /**
  28581. * Sets the mesh indices,
  28582. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28583. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  28584. * @param totalVertices Defines the total number of vertices
  28585. * @returns the current mesh
  28586. */
  28587. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  28588. /**
  28589. * Gets a boolean indicating if specific vertex data is present
  28590. * @param kind defines the vertex data kind to use
  28591. * @returns true is data kind is present
  28592. */
  28593. isVerticesDataPresent(kind: string): boolean;
  28594. /**
  28595. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  28596. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  28597. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  28598. * @returns a BoundingInfo
  28599. */
  28600. getBoundingInfo(): BoundingInfo;
  28601. /**
  28602. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  28603. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  28604. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  28605. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  28606. * @returns the current mesh
  28607. */
  28608. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  28609. /**
  28610. * Overwrite the current bounding info
  28611. * @param boundingInfo defines the new bounding info
  28612. * @returns the current mesh
  28613. */
  28614. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  28615. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  28616. readonly useBones: boolean;
  28617. /** @hidden */
  28618. _preActivate(): void;
  28619. /** @hidden */
  28620. _preActivateForIntermediateRendering(renderId: number): void;
  28621. /** @hidden */
  28622. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28623. /** @hidden */
  28624. _postActivate(): void;
  28625. /** @hidden */
  28626. _freeze(): void;
  28627. /** @hidden */
  28628. _unFreeze(): void;
  28629. /**
  28630. * Gets the current world matrix
  28631. * @returns a Matrix
  28632. */
  28633. getWorldMatrix(): Matrix;
  28634. /** @hidden */
  28635. _getWorldMatrixDeterminant(): number;
  28636. /**
  28637. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  28638. */
  28639. readonly isAnInstance: boolean;
  28640. /**
  28641. * Gets a boolean indicating if this mesh has instances
  28642. */
  28643. readonly hasInstances: boolean;
  28644. /**
  28645. * Perform relative position change from the point of view of behind the front of the mesh.
  28646. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28647. * Supports definition of mesh facing forward or backward
  28648. * @param amountRight defines the distance on the right axis
  28649. * @param amountUp defines the distance on the up axis
  28650. * @param amountForward defines the distance on the forward axis
  28651. * @returns the current mesh
  28652. */
  28653. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  28654. /**
  28655. * Calculate relative position change from the point of view of behind the front of the mesh.
  28656. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28657. * Supports definition of mesh facing forward or backward
  28658. * @param amountRight defines the distance on the right axis
  28659. * @param amountUp defines the distance on the up axis
  28660. * @param amountForward defines the distance on the forward axis
  28661. * @returns the new displacement vector
  28662. */
  28663. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  28664. /**
  28665. * Perform relative rotation change from the point of view of behind the front of the mesh.
  28666. * Supports definition of mesh facing forward or backward
  28667. * @param flipBack defines the flip
  28668. * @param twirlClockwise defines the twirl
  28669. * @param tiltRight defines the tilt
  28670. * @returns the current mesh
  28671. */
  28672. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  28673. /**
  28674. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  28675. * Supports definition of mesh facing forward or backward.
  28676. * @param flipBack defines the flip
  28677. * @param twirlClockwise defines the twirl
  28678. * @param tiltRight defines the tilt
  28679. * @returns the new rotation vector
  28680. */
  28681. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  28682. /**
  28683. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28684. * This means the mesh underlying bounding box and sphere are recomputed.
  28685. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28686. * @returns the current mesh
  28687. */
  28688. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  28689. /** @hidden */
  28690. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  28691. /** @hidden */
  28692. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  28693. /** @hidden */
  28694. _updateBoundingInfo(): AbstractMesh;
  28695. /** @hidden */
  28696. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  28697. /** @hidden */
  28698. protected _afterComputeWorldMatrix(): void;
  28699. /** @hidden */
  28700. readonly _effectiveMesh: AbstractMesh;
  28701. /**
  28702. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28703. * A mesh is in the frustum if its bounding box intersects the frustum
  28704. * @param frustumPlanes defines the frustum to test
  28705. * @returns true if the mesh is in the frustum planes
  28706. */
  28707. isInFrustum(frustumPlanes: Plane[]): boolean;
  28708. /**
  28709. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  28710. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  28711. * @param frustumPlanes defines the frustum to test
  28712. * @returns true if the mesh is completely in the frustum planes
  28713. */
  28714. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  28715. /**
  28716. * True if the mesh intersects another mesh or a SolidParticle object
  28717. * @param mesh defines a target mesh or SolidParticle to test
  28718. * @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)
  28719. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  28720. * @returns true if there is an intersection
  28721. */
  28722. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  28723. /**
  28724. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  28725. * @param point defines the point to test
  28726. * @returns true if there is an intersection
  28727. */
  28728. intersectsPoint(point: Vector3): boolean;
  28729. /**
  28730. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  28731. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28732. */
  28733. checkCollisions: boolean;
  28734. /**
  28735. * Gets Collider object used to compute collisions (not physics)
  28736. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28737. */
  28738. readonly collider: Nullable<Collider>;
  28739. /**
  28740. * Move the mesh using collision engine
  28741. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28742. * @param displacement defines the requested displacement vector
  28743. * @returns the current mesh
  28744. */
  28745. moveWithCollisions(displacement: Vector3): AbstractMesh;
  28746. private _onCollisionPositionChange;
  28747. /** @hidden */
  28748. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  28749. /** @hidden */
  28750. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  28751. /** @hidden */
  28752. _checkCollision(collider: Collider): AbstractMesh;
  28753. /** @hidden */
  28754. _generatePointsArray(): boolean;
  28755. /**
  28756. * Checks if the passed Ray intersects with the mesh
  28757. * @param ray defines the ray to use
  28758. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  28759. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  28760. * @returns the picking info
  28761. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  28762. */
  28763. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  28764. /**
  28765. * Clones the current mesh
  28766. * @param name defines the mesh name
  28767. * @param newParent defines the new mesh parent
  28768. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  28769. * @returns the new mesh
  28770. */
  28771. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  28772. /**
  28773. * Disposes all the submeshes of the current meshnp
  28774. * @returns the current mesh
  28775. */
  28776. releaseSubMeshes(): AbstractMesh;
  28777. /**
  28778. * Releases resources associated with this abstract mesh.
  28779. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28780. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28781. */
  28782. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28783. /**
  28784. * Adds the passed mesh as a child to the current mesh
  28785. * @param mesh defines the child mesh
  28786. * @returns the current mesh
  28787. */
  28788. addChild(mesh: AbstractMesh): AbstractMesh;
  28789. /**
  28790. * Removes the passed mesh from the current mesh children list
  28791. * @param mesh defines the child mesh
  28792. * @returns the current mesh
  28793. */
  28794. removeChild(mesh: AbstractMesh): AbstractMesh;
  28795. /** @hidden */
  28796. private _initFacetData;
  28797. /**
  28798. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  28799. * This method can be called within the render loop.
  28800. * 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
  28801. * @returns the current mesh
  28802. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28803. */
  28804. updateFacetData(): AbstractMesh;
  28805. /**
  28806. * Returns the facetLocalNormals array.
  28807. * The normals are expressed in the mesh local spac
  28808. * @returns an array of Vector3
  28809. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28810. */
  28811. getFacetLocalNormals(): Vector3[];
  28812. /**
  28813. * Returns the facetLocalPositions array.
  28814. * The facet positions are expressed in the mesh local space
  28815. * @returns an array of Vector3
  28816. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28817. */
  28818. getFacetLocalPositions(): Vector3[];
  28819. /**
  28820. * Returns the facetLocalPartioning array
  28821. * @returns an array of array of numbers
  28822. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28823. */
  28824. getFacetLocalPartitioning(): number[][];
  28825. /**
  28826. * Returns the i-th facet position in the world system.
  28827. * This method allocates a new Vector3 per call
  28828. * @param i defines the facet index
  28829. * @returns a new Vector3
  28830. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28831. */
  28832. getFacetPosition(i: number): Vector3;
  28833. /**
  28834. * Sets the reference Vector3 with the i-th facet position in the world system
  28835. * @param i defines the facet index
  28836. * @param ref defines the target vector
  28837. * @returns the current mesh
  28838. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28839. */
  28840. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  28841. /**
  28842. * Returns the i-th facet normal in the world system.
  28843. * This method allocates a new Vector3 per call
  28844. * @param i defines the facet index
  28845. * @returns a new Vector3
  28846. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28847. */
  28848. getFacetNormal(i: number): Vector3;
  28849. /**
  28850. * Sets the reference Vector3 with the i-th facet normal in the world system
  28851. * @param i defines the facet index
  28852. * @param ref defines the target vector
  28853. * @returns the current mesh
  28854. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28855. */
  28856. getFacetNormalToRef(i: number, ref: Vector3): this;
  28857. /**
  28858. * 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)
  28859. * @param x defines x coordinate
  28860. * @param y defines y coordinate
  28861. * @param z defines z coordinate
  28862. * @returns the array of facet indexes
  28863. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28864. */
  28865. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  28866. /**
  28867. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  28868. * @param projected sets as the (x,y,z) world projection on the facet
  28869. * @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
  28870. * @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
  28871. * @param x defines x coordinate
  28872. * @param y defines y coordinate
  28873. * @param z defines z coordinate
  28874. * @returns the face index if found (or null instead)
  28875. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28876. */
  28877. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28878. /**
  28879. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  28880. * @param projected sets as the (x,y,z) local projection on the facet
  28881. * @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
  28882. * @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
  28883. * @param x defines x coordinate
  28884. * @param y defines y coordinate
  28885. * @param z defines z coordinate
  28886. * @returns the face index if found (or null instead)
  28887. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28888. */
  28889. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28890. /**
  28891. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  28892. * @returns the parameters
  28893. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28894. */
  28895. getFacetDataParameters(): any;
  28896. /**
  28897. * Disables the feature FacetData and frees the related memory
  28898. * @returns the current mesh
  28899. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28900. */
  28901. disableFacetData(): AbstractMesh;
  28902. /**
  28903. * Updates the AbstractMesh indices array
  28904. * @param indices defines the data source
  28905. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28906. * @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)
  28907. * @returns the current mesh
  28908. */
  28909. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28910. /**
  28911. * Creates new normals data for the mesh
  28912. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  28913. * @returns the current mesh
  28914. */
  28915. createNormals(updatable: boolean): AbstractMesh;
  28916. /**
  28917. * Align the mesh with a normal
  28918. * @param normal defines the normal to use
  28919. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  28920. * @returns the current mesh
  28921. */
  28922. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  28923. /** @hidden */
  28924. _checkOcclusionQuery(): boolean;
  28925. /**
  28926. * Disables the mesh edge rendering mode
  28927. * @returns the currentAbstractMesh
  28928. */
  28929. disableEdgesRendering(): AbstractMesh;
  28930. /**
  28931. * Enables the edge rendering mode on the mesh.
  28932. * This mode makes the mesh edges visible
  28933. * @param epsilon defines the maximal distance between two angles to detect a face
  28934. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28935. * @returns the currentAbstractMesh
  28936. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28937. */
  28938. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  28939. }
  28940. }
  28941. declare module "babylonjs/Actions/actionEvent" {
  28942. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28943. import { Nullable } from "babylonjs/types";
  28944. import { Sprite } from "babylonjs/Sprites/sprite";
  28945. import { Scene } from "babylonjs/scene";
  28946. import { Vector2 } from "babylonjs/Maths/math.vector";
  28947. /**
  28948. * Interface used to define ActionEvent
  28949. */
  28950. export interface IActionEvent {
  28951. /** The mesh or sprite that triggered the action */
  28952. source: any;
  28953. /** The X mouse cursor position at the time of the event */
  28954. pointerX: number;
  28955. /** The Y mouse cursor position at the time of the event */
  28956. pointerY: number;
  28957. /** The mesh that is currently pointed at (can be null) */
  28958. meshUnderPointer: Nullable<AbstractMesh>;
  28959. /** the original (browser) event that triggered the ActionEvent */
  28960. sourceEvent?: any;
  28961. /** additional data for the event */
  28962. additionalData?: any;
  28963. }
  28964. /**
  28965. * ActionEvent is the event being sent when an action is triggered.
  28966. */
  28967. export class ActionEvent implements IActionEvent {
  28968. /** The mesh or sprite that triggered the action */
  28969. source: any;
  28970. /** The X mouse cursor position at the time of the event */
  28971. pointerX: number;
  28972. /** The Y mouse cursor position at the time of the event */
  28973. pointerY: number;
  28974. /** The mesh that is currently pointed at (can be null) */
  28975. meshUnderPointer: Nullable<AbstractMesh>;
  28976. /** the original (browser) event that triggered the ActionEvent */
  28977. sourceEvent?: any;
  28978. /** additional data for the event */
  28979. additionalData?: any;
  28980. /**
  28981. * Creates a new ActionEvent
  28982. * @param source The mesh or sprite that triggered the action
  28983. * @param pointerX The X mouse cursor position at the time of the event
  28984. * @param pointerY The Y mouse cursor position at the time of the event
  28985. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  28986. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  28987. * @param additionalData additional data for the event
  28988. */
  28989. constructor(
  28990. /** The mesh or sprite that triggered the action */
  28991. source: any,
  28992. /** The X mouse cursor position at the time of the event */
  28993. pointerX: number,
  28994. /** The Y mouse cursor position at the time of the event */
  28995. pointerY: number,
  28996. /** The mesh that is currently pointed at (can be null) */
  28997. meshUnderPointer: Nullable<AbstractMesh>,
  28998. /** the original (browser) event that triggered the ActionEvent */
  28999. sourceEvent?: any,
  29000. /** additional data for the event */
  29001. additionalData?: any);
  29002. /**
  29003. * Helper function to auto-create an ActionEvent from a source mesh.
  29004. * @param source The source mesh that triggered the event
  29005. * @param evt The original (browser) event
  29006. * @param additionalData additional data for the event
  29007. * @returns the new ActionEvent
  29008. */
  29009. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  29010. /**
  29011. * Helper function to auto-create an ActionEvent from a source sprite
  29012. * @param source The source sprite that triggered the event
  29013. * @param scene Scene associated with the sprite
  29014. * @param evt The original (browser) event
  29015. * @param additionalData additional data for the event
  29016. * @returns the new ActionEvent
  29017. */
  29018. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  29019. /**
  29020. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  29021. * @param scene the scene where the event occurred
  29022. * @param evt The original (browser) event
  29023. * @returns the new ActionEvent
  29024. */
  29025. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  29026. /**
  29027. * Helper function to auto-create an ActionEvent from a primitive
  29028. * @param prim defines the target primitive
  29029. * @param pointerPos defines the pointer position
  29030. * @param evt The original (browser) event
  29031. * @param additionalData additional data for the event
  29032. * @returns the new ActionEvent
  29033. */
  29034. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  29035. }
  29036. }
  29037. declare module "babylonjs/Actions/abstractActionManager" {
  29038. import { IDisposable } from "babylonjs/scene";
  29039. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  29040. import { IAction } from "babylonjs/Actions/action";
  29041. import { Nullable } from "babylonjs/types";
  29042. /**
  29043. * Abstract class used to decouple action Manager from scene and meshes.
  29044. * Do not instantiate.
  29045. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29046. */
  29047. export abstract class AbstractActionManager implements IDisposable {
  29048. /** Gets the list of active triggers */
  29049. static Triggers: {
  29050. [key: string]: number;
  29051. };
  29052. /** Gets the cursor to use when hovering items */
  29053. hoverCursor: string;
  29054. /** Gets the list of actions */
  29055. actions: IAction[];
  29056. /**
  29057. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  29058. */
  29059. isRecursive: boolean;
  29060. /**
  29061. * Releases all associated resources
  29062. */
  29063. abstract dispose(): void;
  29064. /**
  29065. * Does this action manager has pointer triggers
  29066. */
  29067. abstract readonly hasPointerTriggers: boolean;
  29068. /**
  29069. * Does this action manager has pick triggers
  29070. */
  29071. abstract readonly hasPickTriggers: boolean;
  29072. /**
  29073. * Process a specific trigger
  29074. * @param trigger defines the trigger to process
  29075. * @param evt defines the event details to be processed
  29076. */
  29077. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  29078. /**
  29079. * Does this action manager handles actions of any of the given triggers
  29080. * @param triggers defines the triggers to be tested
  29081. * @return a boolean indicating whether one (or more) of the triggers is handled
  29082. */
  29083. abstract hasSpecificTriggers(triggers: number[]): boolean;
  29084. /**
  29085. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  29086. * speed.
  29087. * @param triggerA defines the trigger to be tested
  29088. * @param triggerB defines the trigger to be tested
  29089. * @return a boolean indicating whether one (or more) of the triggers is handled
  29090. */
  29091. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  29092. /**
  29093. * Does this action manager handles actions of a given trigger
  29094. * @param trigger defines the trigger to be tested
  29095. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  29096. * @return whether the trigger is handled
  29097. */
  29098. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  29099. /**
  29100. * Serialize this manager to a JSON object
  29101. * @param name defines the property name to store this manager
  29102. * @returns a JSON representation of this manager
  29103. */
  29104. abstract serialize(name: string): any;
  29105. /**
  29106. * Registers an action to this action manager
  29107. * @param action defines the action to be registered
  29108. * @return the action amended (prepared) after registration
  29109. */
  29110. abstract registerAction(action: IAction): Nullable<IAction>;
  29111. /**
  29112. * Unregisters an action to this action manager
  29113. * @param action defines the action to be unregistered
  29114. * @return a boolean indicating whether the action has been unregistered
  29115. */
  29116. abstract unregisterAction(action: IAction): Boolean;
  29117. /**
  29118. * Does exist one action manager with at least one trigger
  29119. **/
  29120. static readonly HasTriggers: boolean;
  29121. /**
  29122. * Does exist one action manager with at least one pick trigger
  29123. **/
  29124. static readonly HasPickTriggers: boolean;
  29125. /**
  29126. * Does exist one action manager that handles actions of a given trigger
  29127. * @param trigger defines the trigger to be tested
  29128. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  29129. **/
  29130. static HasSpecificTrigger(trigger: number): boolean;
  29131. }
  29132. }
  29133. declare module "babylonjs/node" {
  29134. import { Scene } from "babylonjs/scene";
  29135. import { Nullable } from "babylonjs/types";
  29136. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  29137. import { Engine } from "babylonjs/Engines/engine";
  29138. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  29139. import { Observable } from "babylonjs/Misc/observable";
  29140. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  29141. import { IInspectable } from "babylonjs/Misc/iInspectable";
  29142. import { Animatable } from "babylonjs/Animations/animatable";
  29143. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  29144. import { Animation } from "babylonjs/Animations/animation";
  29145. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29146. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29147. /**
  29148. * Defines how a node can be built from a string name.
  29149. */
  29150. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  29151. /**
  29152. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  29153. */
  29154. export class Node implements IBehaviorAware<Node> {
  29155. /** @hidden */
  29156. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  29157. private static _NodeConstructors;
  29158. /**
  29159. * Add a new node constructor
  29160. * @param type defines the type name of the node to construct
  29161. * @param constructorFunc defines the constructor function
  29162. */
  29163. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  29164. /**
  29165. * Returns a node constructor based on type name
  29166. * @param type defines the type name
  29167. * @param name defines the new node name
  29168. * @param scene defines the hosting scene
  29169. * @param options defines optional options to transmit to constructors
  29170. * @returns the new constructor or null
  29171. */
  29172. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  29173. /**
  29174. * Gets or sets the name of the node
  29175. */
  29176. name: string;
  29177. /**
  29178. * Gets or sets the id of the node
  29179. */
  29180. id: string;
  29181. /**
  29182. * Gets or sets the unique id of the node
  29183. */
  29184. uniqueId: number;
  29185. /**
  29186. * Gets or sets a string used to store user defined state for the node
  29187. */
  29188. state: string;
  29189. /**
  29190. * Gets or sets an object used to store user defined information for the node
  29191. */
  29192. metadata: any;
  29193. /**
  29194. * For internal use only. Please do not use.
  29195. */
  29196. reservedDataStore: any;
  29197. /**
  29198. * List of inspectable custom properties (used by the Inspector)
  29199. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29200. */
  29201. inspectableCustomProperties: IInspectable[];
  29202. private _doNotSerialize;
  29203. /**
  29204. * Gets or sets a boolean used to define if the node must be serialized
  29205. */
  29206. doNotSerialize: boolean;
  29207. /** @hidden */
  29208. _isDisposed: boolean;
  29209. /**
  29210. * Gets a list of Animations associated with the node
  29211. */
  29212. animations: import("babylonjs/Animations/animation").Animation[];
  29213. protected _ranges: {
  29214. [name: string]: Nullable<AnimationRange>;
  29215. };
  29216. /**
  29217. * Callback raised when the node is ready to be used
  29218. */
  29219. onReady: Nullable<(node: Node) => void>;
  29220. private _isEnabled;
  29221. private _isParentEnabled;
  29222. private _isReady;
  29223. /** @hidden */
  29224. _currentRenderId: number;
  29225. private _parentUpdateId;
  29226. /** @hidden */
  29227. _childUpdateId: number;
  29228. /** @hidden */
  29229. _waitingParentId: Nullable<string>;
  29230. /** @hidden */
  29231. _scene: Scene;
  29232. /** @hidden */
  29233. _cache: any;
  29234. private _parentNode;
  29235. private _children;
  29236. /** @hidden */
  29237. _worldMatrix: Matrix;
  29238. /** @hidden */
  29239. _worldMatrixDeterminant: number;
  29240. /** @hidden */
  29241. _worldMatrixDeterminantIsDirty: boolean;
  29242. /** @hidden */
  29243. private _sceneRootNodesIndex;
  29244. /**
  29245. * Gets a boolean indicating if the node has been disposed
  29246. * @returns true if the node was disposed
  29247. */
  29248. isDisposed(): boolean;
  29249. /**
  29250. * Gets or sets the parent of the node (without keeping the current position in the scene)
  29251. * @see https://doc.babylonjs.com/how_to/parenting
  29252. */
  29253. parent: Nullable<Node>;
  29254. /** @hidden */
  29255. _addToSceneRootNodes(): void;
  29256. /** @hidden */
  29257. _removeFromSceneRootNodes(): void;
  29258. private _animationPropertiesOverride;
  29259. /**
  29260. * Gets or sets the animation properties override
  29261. */
  29262. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  29263. /**
  29264. * Gets a string idenfifying the name of the class
  29265. * @returns "Node" string
  29266. */
  29267. getClassName(): string;
  29268. /** @hidden */
  29269. readonly _isNode: boolean;
  29270. /**
  29271. * An event triggered when the mesh is disposed
  29272. */
  29273. onDisposeObservable: Observable<Node>;
  29274. private _onDisposeObserver;
  29275. /**
  29276. * Sets a callback that will be raised when the node will be disposed
  29277. */
  29278. onDispose: () => void;
  29279. /**
  29280. * Creates a new Node
  29281. * @param name the name and id to be given to this node
  29282. * @param scene the scene this node will be added to
  29283. */
  29284. constructor(name: string, scene?: Nullable<Scene>);
  29285. /**
  29286. * Gets the scene of the node
  29287. * @returns a scene
  29288. */
  29289. getScene(): Scene;
  29290. /**
  29291. * Gets the engine of the node
  29292. * @returns a Engine
  29293. */
  29294. getEngine(): Engine;
  29295. private _behaviors;
  29296. /**
  29297. * Attach a behavior to the node
  29298. * @see http://doc.babylonjs.com/features/behaviour
  29299. * @param behavior defines the behavior to attach
  29300. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  29301. * @returns the current Node
  29302. */
  29303. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  29304. /**
  29305. * Remove an attached behavior
  29306. * @see http://doc.babylonjs.com/features/behaviour
  29307. * @param behavior defines the behavior to attach
  29308. * @returns the current Node
  29309. */
  29310. removeBehavior(behavior: Behavior<Node>): Node;
  29311. /**
  29312. * Gets the list of attached behaviors
  29313. * @see http://doc.babylonjs.com/features/behaviour
  29314. */
  29315. readonly behaviors: Behavior<Node>[];
  29316. /**
  29317. * Gets an attached behavior by name
  29318. * @param name defines the name of the behavior to look for
  29319. * @see http://doc.babylonjs.com/features/behaviour
  29320. * @returns null if behavior was not found else the requested behavior
  29321. */
  29322. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  29323. /**
  29324. * Returns the latest update of the World matrix
  29325. * @returns a Matrix
  29326. */
  29327. getWorldMatrix(): Matrix;
  29328. /** @hidden */
  29329. _getWorldMatrixDeterminant(): number;
  29330. /**
  29331. * Returns directly the latest state of the mesh World matrix.
  29332. * A Matrix is returned.
  29333. */
  29334. readonly worldMatrixFromCache: Matrix;
  29335. /** @hidden */
  29336. _initCache(): void;
  29337. /** @hidden */
  29338. updateCache(force?: boolean): void;
  29339. /** @hidden */
  29340. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29341. /** @hidden */
  29342. _updateCache(ignoreParentClass?: boolean): void;
  29343. /** @hidden */
  29344. _isSynchronized(): boolean;
  29345. /** @hidden */
  29346. _markSyncedWithParent(): void;
  29347. /** @hidden */
  29348. isSynchronizedWithParent(): boolean;
  29349. /** @hidden */
  29350. isSynchronized(): boolean;
  29351. /**
  29352. * Is this node ready to be used/rendered
  29353. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29354. * @return true if the node is ready
  29355. */
  29356. isReady(completeCheck?: boolean): boolean;
  29357. /**
  29358. * Is this node enabled?
  29359. * 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
  29360. * @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
  29361. * @return whether this node (and its parent) is enabled
  29362. */
  29363. isEnabled(checkAncestors?: boolean): boolean;
  29364. /** @hidden */
  29365. protected _syncParentEnabledState(): void;
  29366. /**
  29367. * Set the enabled state of this node
  29368. * @param value defines the new enabled state
  29369. */
  29370. setEnabled(value: boolean): void;
  29371. /**
  29372. * Is this node a descendant of the given node?
  29373. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  29374. * @param ancestor defines the parent node to inspect
  29375. * @returns a boolean indicating if this node is a descendant of the given node
  29376. */
  29377. isDescendantOf(ancestor: Node): boolean;
  29378. /** @hidden */
  29379. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  29380. /**
  29381. * Will return all nodes that have this node as ascendant
  29382. * @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
  29383. * @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
  29384. * @return all children nodes of all types
  29385. */
  29386. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  29387. /**
  29388. * Get all child-meshes of this node
  29389. * @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)
  29390. * @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
  29391. * @returns an array of AbstractMesh
  29392. */
  29393. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  29394. /**
  29395. * Get all direct children of this node
  29396. * @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
  29397. * @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)
  29398. * @returns an array of Node
  29399. */
  29400. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  29401. /** @hidden */
  29402. _setReady(state: boolean): void;
  29403. /**
  29404. * Get an animation by name
  29405. * @param name defines the name of the animation to look for
  29406. * @returns null if not found else the requested animation
  29407. */
  29408. getAnimationByName(name: string): Nullable<Animation>;
  29409. /**
  29410. * Creates an animation range for this node
  29411. * @param name defines the name of the range
  29412. * @param from defines the starting key
  29413. * @param to defines the end key
  29414. */
  29415. createAnimationRange(name: string, from: number, to: number): void;
  29416. /**
  29417. * Delete a specific animation range
  29418. * @param name defines the name of the range to delete
  29419. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29420. */
  29421. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29422. /**
  29423. * Get an animation range by name
  29424. * @param name defines the name of the animation range to look for
  29425. * @returns null if not found else the requested animation range
  29426. */
  29427. getAnimationRange(name: string): Nullable<AnimationRange>;
  29428. /**
  29429. * Gets the list of all animation ranges defined on this node
  29430. * @returns an array
  29431. */
  29432. getAnimationRanges(): Nullable<AnimationRange>[];
  29433. /**
  29434. * Will start the animation sequence
  29435. * @param name defines the range frames for animation sequence
  29436. * @param loop defines if the animation should loop (false by default)
  29437. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29438. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29439. * @returns the object created for this animation. If range does not exist, it will return null
  29440. */
  29441. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29442. /**
  29443. * Serialize animation ranges into a JSON compatible object
  29444. * @returns serialization object
  29445. */
  29446. serializeAnimationRanges(): any;
  29447. /**
  29448. * Computes the world matrix of the node
  29449. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29450. * @returns the world matrix
  29451. */
  29452. computeWorldMatrix(force?: boolean): Matrix;
  29453. /**
  29454. * Releases resources associated with this node.
  29455. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29456. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29457. */
  29458. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29459. /**
  29460. * Parse animation range data from a serialization object and store them into a given node
  29461. * @param node defines where to store the animation ranges
  29462. * @param parsedNode defines the serialization object to read data from
  29463. * @param scene defines the hosting scene
  29464. */
  29465. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29466. /**
  29467. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29468. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29469. * @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
  29470. * @returns the new bounding vectors
  29471. */
  29472. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29473. min: Vector3;
  29474. max: Vector3;
  29475. };
  29476. }
  29477. }
  29478. declare module "babylonjs/Animations/animation" {
  29479. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  29480. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  29481. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  29482. import { Nullable } from "babylonjs/types";
  29483. import { Scene } from "babylonjs/scene";
  29484. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  29485. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29486. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  29487. import { Node } from "babylonjs/node";
  29488. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  29489. import { Size } from "babylonjs/Maths/math.size";
  29490. import { Animatable } from "babylonjs/Animations/animatable";
  29491. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  29492. /**
  29493. * @hidden
  29494. */
  29495. export class _IAnimationState {
  29496. key: number;
  29497. repeatCount: number;
  29498. workValue?: any;
  29499. loopMode?: number;
  29500. offsetValue?: any;
  29501. highLimitValue?: any;
  29502. }
  29503. /**
  29504. * Class used to store any kind of animation
  29505. */
  29506. export class Animation {
  29507. /**Name of the animation */
  29508. name: string;
  29509. /**Property to animate */
  29510. targetProperty: string;
  29511. /**The frames per second of the animation */
  29512. framePerSecond: number;
  29513. /**The data type of the animation */
  29514. dataType: number;
  29515. /**The loop mode of the animation */
  29516. loopMode?: number | undefined;
  29517. /**Specifies if blending should be enabled */
  29518. enableBlending?: boolean | undefined;
  29519. /**
  29520. * Use matrix interpolation instead of using direct key value when animating matrices
  29521. */
  29522. static AllowMatricesInterpolation: boolean;
  29523. /**
  29524. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  29525. */
  29526. static AllowMatrixDecomposeForInterpolation: boolean;
  29527. /**
  29528. * Stores the key frames of the animation
  29529. */
  29530. private _keys;
  29531. /**
  29532. * Stores the easing function of the animation
  29533. */
  29534. private _easingFunction;
  29535. /**
  29536. * @hidden Internal use only
  29537. */
  29538. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  29539. /**
  29540. * The set of event that will be linked to this animation
  29541. */
  29542. private _events;
  29543. /**
  29544. * Stores an array of target property paths
  29545. */
  29546. targetPropertyPath: string[];
  29547. /**
  29548. * Stores the blending speed of the animation
  29549. */
  29550. blendingSpeed: number;
  29551. /**
  29552. * Stores the animation ranges for the animation
  29553. */
  29554. private _ranges;
  29555. /**
  29556. * @hidden Internal use
  29557. */
  29558. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  29559. /**
  29560. * Sets up an animation
  29561. * @param property The property to animate
  29562. * @param animationType The animation type to apply
  29563. * @param framePerSecond The frames per second of the animation
  29564. * @param easingFunction The easing function used in the animation
  29565. * @returns The created animation
  29566. */
  29567. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  29568. /**
  29569. * Create and start an animation on a node
  29570. * @param name defines the name of the global animation that will be run on all nodes
  29571. * @param node defines the root node where the animation will take place
  29572. * @param targetProperty defines property to animate
  29573. * @param framePerSecond defines the number of frame per second yo use
  29574. * @param totalFrame defines the number of frames in total
  29575. * @param from defines the initial value
  29576. * @param to defines the final value
  29577. * @param loopMode defines which loop mode you want to use (off by default)
  29578. * @param easingFunction defines the easing function to use (linear by default)
  29579. * @param onAnimationEnd defines the callback to call when animation end
  29580. * @returns the animatable created for this animation
  29581. */
  29582. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29583. /**
  29584. * Create and start an animation on a node and its descendants
  29585. * @param name defines the name of the global animation that will be run on all nodes
  29586. * @param node defines the root node where the animation will take place
  29587. * @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
  29588. * @param targetProperty defines property to animate
  29589. * @param framePerSecond defines the number of frame per second to use
  29590. * @param totalFrame defines the number of frames in total
  29591. * @param from defines the initial value
  29592. * @param to defines the final value
  29593. * @param loopMode defines which loop mode you want to use (off by default)
  29594. * @param easingFunction defines the easing function to use (linear by default)
  29595. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  29596. * @returns the list of animatables created for all nodes
  29597. * @example https://www.babylonjs-playground.com/#MH0VLI
  29598. */
  29599. 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[]>;
  29600. /**
  29601. * Creates a new animation, merges it with the existing animations and starts it
  29602. * @param name Name of the animation
  29603. * @param node Node which contains the scene that begins the animations
  29604. * @param targetProperty Specifies which property to animate
  29605. * @param framePerSecond The frames per second of the animation
  29606. * @param totalFrame The total number of frames
  29607. * @param from The frame at the beginning of the animation
  29608. * @param to The frame at the end of the animation
  29609. * @param loopMode Specifies the loop mode of the animation
  29610. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  29611. * @param onAnimationEnd Callback to run once the animation is complete
  29612. * @returns Nullable animation
  29613. */
  29614. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29615. /**
  29616. * Transition property of an host to the target Value
  29617. * @param property The property to transition
  29618. * @param targetValue The target Value of the property
  29619. * @param host The object where the property to animate belongs
  29620. * @param scene Scene used to run the animation
  29621. * @param frameRate Framerate (in frame/s) to use
  29622. * @param transition The transition type we want to use
  29623. * @param duration The duration of the animation, in milliseconds
  29624. * @param onAnimationEnd Callback trigger at the end of the animation
  29625. * @returns Nullable animation
  29626. */
  29627. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  29628. /**
  29629. * Return the array of runtime animations currently using this animation
  29630. */
  29631. readonly runtimeAnimations: RuntimeAnimation[];
  29632. /**
  29633. * Specifies if any of the runtime animations are currently running
  29634. */
  29635. readonly hasRunningRuntimeAnimations: boolean;
  29636. /**
  29637. * Initializes the animation
  29638. * @param name Name of the animation
  29639. * @param targetProperty Property to animate
  29640. * @param framePerSecond The frames per second of the animation
  29641. * @param dataType The data type of the animation
  29642. * @param loopMode The loop mode of the animation
  29643. * @param enableBlending Specifies if blending should be enabled
  29644. */
  29645. constructor(
  29646. /**Name of the animation */
  29647. name: string,
  29648. /**Property to animate */
  29649. targetProperty: string,
  29650. /**The frames per second of the animation */
  29651. framePerSecond: number,
  29652. /**The data type of the animation */
  29653. dataType: number,
  29654. /**The loop mode of the animation */
  29655. loopMode?: number | undefined,
  29656. /**Specifies if blending should be enabled */
  29657. enableBlending?: boolean | undefined);
  29658. /**
  29659. * Converts the animation to a string
  29660. * @param fullDetails support for multiple levels of logging within scene loading
  29661. * @returns String form of the animation
  29662. */
  29663. toString(fullDetails?: boolean): string;
  29664. /**
  29665. * Add an event to this animation
  29666. * @param event Event to add
  29667. */
  29668. addEvent(event: AnimationEvent): void;
  29669. /**
  29670. * Remove all events found at the given frame
  29671. * @param frame The frame to remove events from
  29672. */
  29673. removeEvents(frame: number): void;
  29674. /**
  29675. * Retrieves all the events from the animation
  29676. * @returns Events from the animation
  29677. */
  29678. getEvents(): AnimationEvent[];
  29679. /**
  29680. * Creates an animation range
  29681. * @param name Name of the animation range
  29682. * @param from Starting frame of the animation range
  29683. * @param to Ending frame of the animation
  29684. */
  29685. createRange(name: string, from: number, to: number): void;
  29686. /**
  29687. * Deletes an animation range by name
  29688. * @param name Name of the animation range to delete
  29689. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  29690. */
  29691. deleteRange(name: string, deleteFrames?: boolean): void;
  29692. /**
  29693. * Gets the animation range by name, or null if not defined
  29694. * @param name Name of the animation range
  29695. * @returns Nullable animation range
  29696. */
  29697. getRange(name: string): Nullable<AnimationRange>;
  29698. /**
  29699. * Gets the key frames from the animation
  29700. * @returns The key frames of the animation
  29701. */
  29702. getKeys(): Array<IAnimationKey>;
  29703. /**
  29704. * Gets the highest frame rate of the animation
  29705. * @returns Highest frame rate of the animation
  29706. */
  29707. getHighestFrame(): number;
  29708. /**
  29709. * Gets the easing function of the animation
  29710. * @returns Easing function of the animation
  29711. */
  29712. getEasingFunction(): IEasingFunction;
  29713. /**
  29714. * Sets the easing function of the animation
  29715. * @param easingFunction A custom mathematical formula for animation
  29716. */
  29717. setEasingFunction(easingFunction: EasingFunction): void;
  29718. /**
  29719. * Interpolates a scalar linearly
  29720. * @param startValue Start value of the animation curve
  29721. * @param endValue End value of the animation curve
  29722. * @param gradient Scalar amount to interpolate
  29723. * @returns Interpolated scalar value
  29724. */
  29725. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  29726. /**
  29727. * Interpolates a scalar cubically
  29728. * @param startValue Start value of the animation curve
  29729. * @param outTangent End tangent of the animation
  29730. * @param endValue End value of the animation curve
  29731. * @param inTangent Start tangent of the animation curve
  29732. * @param gradient Scalar amount to interpolate
  29733. * @returns Interpolated scalar value
  29734. */
  29735. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  29736. /**
  29737. * Interpolates a quaternion using a spherical linear interpolation
  29738. * @param startValue Start value of the animation curve
  29739. * @param endValue End value of the animation curve
  29740. * @param gradient Scalar amount to interpolate
  29741. * @returns Interpolated quaternion value
  29742. */
  29743. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  29744. /**
  29745. * Interpolates a quaternion cubically
  29746. * @param startValue Start value of the animation curve
  29747. * @param outTangent End tangent of the animation curve
  29748. * @param endValue End value of the animation curve
  29749. * @param inTangent Start tangent of the animation curve
  29750. * @param gradient Scalar amount to interpolate
  29751. * @returns Interpolated quaternion value
  29752. */
  29753. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  29754. /**
  29755. * Interpolates a Vector3 linearl
  29756. * @param startValue Start value of the animation curve
  29757. * @param endValue End value of the animation curve
  29758. * @param gradient Scalar amount to interpolate
  29759. * @returns Interpolated scalar value
  29760. */
  29761. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  29762. /**
  29763. * Interpolates a Vector3 cubically
  29764. * @param startValue Start value of the animation curve
  29765. * @param outTangent End tangent of the animation
  29766. * @param endValue End value of the animation curve
  29767. * @param inTangent Start tangent of the animation curve
  29768. * @param gradient Scalar amount to interpolate
  29769. * @returns InterpolatedVector3 value
  29770. */
  29771. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  29772. /**
  29773. * Interpolates a Vector2 linearly
  29774. * @param startValue Start value of the animation curve
  29775. * @param endValue End value of the animation curve
  29776. * @param gradient Scalar amount to interpolate
  29777. * @returns Interpolated Vector2 value
  29778. */
  29779. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  29780. /**
  29781. * Interpolates a Vector2 cubically
  29782. * @param startValue Start value of the animation curve
  29783. * @param outTangent End tangent of the animation
  29784. * @param endValue End value of the animation curve
  29785. * @param inTangent Start tangent of the animation curve
  29786. * @param gradient Scalar amount to interpolate
  29787. * @returns Interpolated Vector2 value
  29788. */
  29789. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  29790. /**
  29791. * Interpolates a size linearly
  29792. * @param startValue Start value of the animation curve
  29793. * @param endValue End value of the animation curve
  29794. * @param gradient Scalar amount to interpolate
  29795. * @returns Interpolated Size value
  29796. */
  29797. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  29798. /**
  29799. * Interpolates a Color3 linearly
  29800. * @param startValue Start value of the animation curve
  29801. * @param endValue End value of the animation curve
  29802. * @param gradient Scalar amount to interpolate
  29803. * @returns Interpolated Color3 value
  29804. */
  29805. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  29806. /**
  29807. * Interpolates a Color4 linearly
  29808. * @param startValue Start value of the animation curve
  29809. * @param endValue End value of the animation curve
  29810. * @param gradient Scalar amount to interpolate
  29811. * @returns Interpolated Color3 value
  29812. */
  29813. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  29814. /**
  29815. * @hidden Internal use only
  29816. */
  29817. _getKeyValue(value: any): any;
  29818. /**
  29819. * @hidden Internal use only
  29820. */
  29821. _interpolate(currentFrame: number, state: _IAnimationState): any;
  29822. /**
  29823. * Defines the function to use to interpolate matrices
  29824. * @param startValue defines the start matrix
  29825. * @param endValue defines the end matrix
  29826. * @param gradient defines the gradient between both matrices
  29827. * @param result defines an optional target matrix where to store the interpolation
  29828. * @returns the interpolated matrix
  29829. */
  29830. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  29831. /**
  29832. * Makes a copy of the animation
  29833. * @returns Cloned animation
  29834. */
  29835. clone(): Animation;
  29836. /**
  29837. * Sets the key frames of the animation
  29838. * @param values The animation key frames to set
  29839. */
  29840. setKeys(values: Array<IAnimationKey>): void;
  29841. /**
  29842. * Serializes the animation to an object
  29843. * @returns Serialized object
  29844. */
  29845. serialize(): any;
  29846. /**
  29847. * Float animation type
  29848. */
  29849. static readonly ANIMATIONTYPE_FLOAT: number;
  29850. /**
  29851. * Vector3 animation type
  29852. */
  29853. static readonly ANIMATIONTYPE_VECTOR3: number;
  29854. /**
  29855. * Quaternion animation type
  29856. */
  29857. static readonly ANIMATIONTYPE_QUATERNION: number;
  29858. /**
  29859. * Matrix animation type
  29860. */
  29861. static readonly ANIMATIONTYPE_MATRIX: number;
  29862. /**
  29863. * Color3 animation type
  29864. */
  29865. static readonly ANIMATIONTYPE_COLOR3: number;
  29866. /**
  29867. * Color3 animation type
  29868. */
  29869. static readonly ANIMATIONTYPE_COLOR4: number;
  29870. /**
  29871. * Vector2 animation type
  29872. */
  29873. static readonly ANIMATIONTYPE_VECTOR2: number;
  29874. /**
  29875. * Size animation type
  29876. */
  29877. static readonly ANIMATIONTYPE_SIZE: number;
  29878. /**
  29879. * Relative Loop Mode
  29880. */
  29881. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  29882. /**
  29883. * Cycle Loop Mode
  29884. */
  29885. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  29886. /**
  29887. * Constant Loop Mode
  29888. */
  29889. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  29890. /** @hidden */
  29891. static _UniversalLerp(left: any, right: any, amount: number): any;
  29892. /**
  29893. * Parses an animation object and creates an animation
  29894. * @param parsedAnimation Parsed animation object
  29895. * @returns Animation object
  29896. */
  29897. static Parse(parsedAnimation: any): Animation;
  29898. /**
  29899. * Appends the serialized animations from the source animations
  29900. * @param source Source containing the animations
  29901. * @param destination Target to store the animations
  29902. */
  29903. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29904. }
  29905. }
  29906. declare module "babylonjs/Animations/animatable.interface" {
  29907. import { Nullable } from "babylonjs/types";
  29908. import { Animation } from "babylonjs/Animations/animation";
  29909. /**
  29910. * Interface containing an array of animations
  29911. */
  29912. export interface IAnimatable {
  29913. /**
  29914. * Array of animations
  29915. */
  29916. animations: Nullable<Array<Animation>>;
  29917. }
  29918. }
  29919. declare module "babylonjs/Misc/decorators" {
  29920. import { Nullable } from "babylonjs/types";
  29921. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  29922. import { Scene } from "babylonjs/scene";
  29923. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29924. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29925. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29926. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29927. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29928. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29929. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29930. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29931. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29932. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29933. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29934. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29935. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29936. /**
  29937. * Decorator used to define property that can be serialized as reference to a camera
  29938. * @param sourceName defines the name of the property to decorate
  29939. */
  29940. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29941. /**
  29942. * Class used to help serialization objects
  29943. */
  29944. export class SerializationHelper {
  29945. /** @hidden */
  29946. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  29947. /** @hidden */
  29948. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  29949. /** @hidden */
  29950. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  29951. /** @hidden */
  29952. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  29953. /**
  29954. * Appends the serialized animations from the source animations
  29955. * @param source Source containing the animations
  29956. * @param destination Target to store the animations
  29957. */
  29958. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29959. /**
  29960. * Static function used to serialized a specific entity
  29961. * @param entity defines the entity to serialize
  29962. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29963. * @returns a JSON compatible object representing the serialization of the entity
  29964. */
  29965. static Serialize<T>(entity: T, serializationObject?: any): any;
  29966. /**
  29967. * Creates a new entity from a serialization data object
  29968. * @param creationFunction defines a function used to instanciated the new entity
  29969. * @param source defines the source serialization data
  29970. * @param scene defines the hosting scene
  29971. * @param rootUrl defines the root url for resources
  29972. * @returns a new entity
  29973. */
  29974. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29975. /**
  29976. * Clones an object
  29977. * @param creationFunction defines the function used to instanciate the new object
  29978. * @param source defines the source object
  29979. * @returns the cloned object
  29980. */
  29981. static Clone<T>(creationFunction: () => T, source: T): T;
  29982. /**
  29983. * Instanciates a new object based on a source one (some data will be shared between both object)
  29984. * @param creationFunction defines the function used to instanciate the new object
  29985. * @param source defines the source object
  29986. * @returns the new object
  29987. */
  29988. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29989. }
  29990. }
  29991. declare module "babylonjs/Misc/guid" {
  29992. /**
  29993. * Class used to manipulate GUIDs
  29994. */
  29995. export class GUID {
  29996. /**
  29997. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  29998. * Be aware Math.random() could cause collisions, but:
  29999. * "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"
  30000. * @returns a pseudo random id
  30001. */
  30002. static RandomId(): string;
  30003. }
  30004. }
  30005. declare module "babylonjs/Materials/Textures/baseTexture" {
  30006. import { Observable } from "babylonjs/Misc/observable";
  30007. import { Nullable } from "babylonjs/types";
  30008. import { Scene } from "babylonjs/scene";
  30009. import { Matrix } from "babylonjs/Maths/math.vector";
  30010. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30011. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30012. import { ISize } from "babylonjs/Maths/math.size";
  30013. /**
  30014. * Base class of all the textures in babylon.
  30015. * It groups all the common properties the materials, post process, lights... might need
  30016. * in order to make a correct use of the texture.
  30017. */
  30018. export class BaseTexture implements IAnimatable {
  30019. /**
  30020. * Default anisotropic filtering level for the application.
  30021. * It is set to 4 as a good tradeoff between perf and quality.
  30022. */
  30023. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  30024. /**
  30025. * Gets or sets the unique id of the texture
  30026. */
  30027. uniqueId: number;
  30028. /**
  30029. * Define the name of the texture.
  30030. */
  30031. name: string;
  30032. /**
  30033. * Gets or sets an object used to store user defined information.
  30034. */
  30035. metadata: any;
  30036. /**
  30037. * For internal use only. Please do not use.
  30038. */
  30039. reservedDataStore: any;
  30040. private _hasAlpha;
  30041. /**
  30042. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  30043. */
  30044. hasAlpha: boolean;
  30045. /**
  30046. * Defines if the alpha value should be determined via the rgb values.
  30047. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  30048. */
  30049. getAlphaFromRGB: boolean;
  30050. /**
  30051. * Intensity or strength of the texture.
  30052. * It is commonly used by materials to fine tune the intensity of the texture
  30053. */
  30054. level: number;
  30055. /**
  30056. * Define the UV chanel to use starting from 0 and defaulting to 0.
  30057. * This is part of the texture as textures usually maps to one uv set.
  30058. */
  30059. coordinatesIndex: number;
  30060. private _coordinatesMode;
  30061. /**
  30062. * How a texture is mapped.
  30063. *
  30064. * | Value | Type | Description |
  30065. * | ----- | ----------------------------------- | ----------- |
  30066. * | 0 | EXPLICIT_MODE | |
  30067. * | 1 | SPHERICAL_MODE | |
  30068. * | 2 | PLANAR_MODE | |
  30069. * | 3 | CUBIC_MODE | |
  30070. * | 4 | PROJECTION_MODE | |
  30071. * | 5 | SKYBOX_MODE | |
  30072. * | 6 | INVCUBIC_MODE | |
  30073. * | 7 | EQUIRECTANGULAR_MODE | |
  30074. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  30075. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  30076. */
  30077. coordinatesMode: number;
  30078. /**
  30079. * | Value | Type | Description |
  30080. * | ----- | ------------------ | ----------- |
  30081. * | 0 | CLAMP_ADDRESSMODE | |
  30082. * | 1 | WRAP_ADDRESSMODE | |
  30083. * | 2 | MIRROR_ADDRESSMODE | |
  30084. */
  30085. wrapU: number;
  30086. /**
  30087. * | Value | Type | Description |
  30088. * | ----- | ------------------ | ----------- |
  30089. * | 0 | CLAMP_ADDRESSMODE | |
  30090. * | 1 | WRAP_ADDRESSMODE | |
  30091. * | 2 | MIRROR_ADDRESSMODE | |
  30092. */
  30093. wrapV: number;
  30094. /**
  30095. * | Value | Type | Description |
  30096. * | ----- | ------------------ | ----------- |
  30097. * | 0 | CLAMP_ADDRESSMODE | |
  30098. * | 1 | WRAP_ADDRESSMODE | |
  30099. * | 2 | MIRROR_ADDRESSMODE | |
  30100. */
  30101. wrapR: number;
  30102. /**
  30103. * With compliant hardware and browser (supporting anisotropic filtering)
  30104. * this defines the level of anisotropic filtering in the texture.
  30105. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  30106. */
  30107. anisotropicFilteringLevel: number;
  30108. /**
  30109. * Define if the texture is a cube texture or if false a 2d texture.
  30110. */
  30111. isCube: boolean;
  30112. /**
  30113. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  30114. */
  30115. is3D: boolean;
  30116. /**
  30117. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  30118. */
  30119. is2DArray: boolean;
  30120. /**
  30121. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  30122. * HDR texture are usually stored in linear space.
  30123. * This only impacts the PBR and Background materials
  30124. */
  30125. gammaSpace: boolean;
  30126. /**
  30127. * Gets or sets whether or not the texture contains RGBD data.
  30128. */
  30129. isRGBD: boolean;
  30130. /**
  30131. * Is Z inverted in the texture (useful in a cube texture).
  30132. */
  30133. invertZ: boolean;
  30134. /**
  30135. * Are mip maps generated for this texture or not.
  30136. */
  30137. readonly noMipmap: boolean;
  30138. /**
  30139. * @hidden
  30140. */
  30141. lodLevelInAlpha: boolean;
  30142. /**
  30143. * With prefiltered texture, defined the offset used during the prefiltering steps.
  30144. */
  30145. lodGenerationOffset: number;
  30146. /**
  30147. * With prefiltered texture, defined the scale used during the prefiltering steps.
  30148. */
  30149. lodGenerationScale: number;
  30150. /**
  30151. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  30152. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  30153. * average roughness values.
  30154. */
  30155. linearSpecularLOD: boolean;
  30156. /**
  30157. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  30158. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  30159. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  30160. */
  30161. irradianceTexture: Nullable<BaseTexture>;
  30162. /**
  30163. * Define if the texture is a render target.
  30164. */
  30165. isRenderTarget: boolean;
  30166. /**
  30167. * Define the unique id of the texture in the scene.
  30168. */
  30169. readonly uid: string;
  30170. /**
  30171. * Return a string representation of the texture.
  30172. * @returns the texture as a string
  30173. */
  30174. toString(): string;
  30175. /**
  30176. * Get the class name of the texture.
  30177. * @returns "BaseTexture"
  30178. */
  30179. getClassName(): string;
  30180. /**
  30181. * Define the list of animation attached to the texture.
  30182. */
  30183. animations: import("babylonjs/Animations/animation").Animation[];
  30184. /**
  30185. * An event triggered when the texture is disposed.
  30186. */
  30187. onDisposeObservable: Observable<BaseTexture>;
  30188. private _onDisposeObserver;
  30189. /**
  30190. * Callback triggered when the texture has been disposed.
  30191. * Kept for back compatibility, you can use the onDisposeObservable instead.
  30192. */
  30193. onDispose: () => void;
  30194. /**
  30195. * Define the current state of the loading sequence when in delayed load mode.
  30196. */
  30197. delayLoadState: number;
  30198. private _scene;
  30199. /** @hidden */
  30200. _texture: Nullable<InternalTexture>;
  30201. private _uid;
  30202. /**
  30203. * Define if the texture is preventinga material to render or not.
  30204. * If not and the texture is not ready, the engine will use a default black texture instead.
  30205. */
  30206. readonly isBlocking: boolean;
  30207. /**
  30208. * Instantiates a new BaseTexture.
  30209. * Base class of all the textures in babylon.
  30210. * It groups all the common properties the materials, post process, lights... might need
  30211. * in order to make a correct use of the texture.
  30212. * @param scene Define the scene the texture blongs to
  30213. */
  30214. constructor(scene: Nullable<Scene>);
  30215. /**
  30216. * Get the scene the texture belongs to.
  30217. * @returns the scene or null if undefined
  30218. */
  30219. getScene(): Nullable<Scene>;
  30220. /**
  30221. * Get the texture transform matrix used to offset tile the texture for istance.
  30222. * @returns the transformation matrix
  30223. */
  30224. getTextureMatrix(): Matrix;
  30225. /**
  30226. * Get the texture reflection matrix used to rotate/transform the reflection.
  30227. * @returns the reflection matrix
  30228. */
  30229. getReflectionTextureMatrix(): Matrix;
  30230. /**
  30231. * Get the underlying lower level texture from Babylon.
  30232. * @returns the insternal texture
  30233. */
  30234. getInternalTexture(): Nullable<InternalTexture>;
  30235. /**
  30236. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  30237. * @returns true if ready or not blocking
  30238. */
  30239. isReadyOrNotBlocking(): boolean;
  30240. /**
  30241. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  30242. * @returns true if fully ready
  30243. */
  30244. isReady(): boolean;
  30245. private _cachedSize;
  30246. /**
  30247. * Get the size of the texture.
  30248. * @returns the texture size.
  30249. */
  30250. getSize(): ISize;
  30251. /**
  30252. * Get the base size of the texture.
  30253. * It can be different from the size if the texture has been resized for POT for instance
  30254. * @returns the base size
  30255. */
  30256. getBaseSize(): ISize;
  30257. /**
  30258. * Update the sampling mode of the texture.
  30259. * Default is Trilinear mode.
  30260. *
  30261. * | Value | Type | Description |
  30262. * | ----- | ------------------ | ----------- |
  30263. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  30264. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  30265. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  30266. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  30267. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  30268. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  30269. * | 7 | NEAREST_LINEAR | |
  30270. * | 8 | NEAREST_NEAREST | |
  30271. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  30272. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  30273. * | 11 | LINEAR_LINEAR | |
  30274. * | 12 | LINEAR_NEAREST | |
  30275. *
  30276. * > _mag_: magnification filter (close to the viewer)
  30277. * > _min_: minification filter (far from the viewer)
  30278. * > _mip_: filter used between mip map levels
  30279. *@param samplingMode Define the new sampling mode of the texture
  30280. */
  30281. updateSamplingMode(samplingMode: number): void;
  30282. /**
  30283. * Scales the texture if is `canRescale()`
  30284. * @param ratio the resize factor we want to use to rescale
  30285. */
  30286. scale(ratio: number): void;
  30287. /**
  30288. * Get if the texture can rescale.
  30289. */
  30290. readonly canRescale: boolean;
  30291. /** @hidden */
  30292. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  30293. /** @hidden */
  30294. _rebuild(): void;
  30295. /**
  30296. * Triggers the load sequence in delayed load mode.
  30297. */
  30298. delayLoad(): void;
  30299. /**
  30300. * Clones the texture.
  30301. * @returns the cloned texture
  30302. */
  30303. clone(): Nullable<BaseTexture>;
  30304. /**
  30305. * Get the texture underlying type (INT, FLOAT...)
  30306. */
  30307. readonly textureType: number;
  30308. /**
  30309. * Get the texture underlying format (RGB, RGBA...)
  30310. */
  30311. readonly textureFormat: number;
  30312. /**
  30313. * Indicates that textures need to be re-calculated for all materials
  30314. */
  30315. protected _markAllSubMeshesAsTexturesDirty(): void;
  30316. /**
  30317. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  30318. * This will returns an RGBA array buffer containing either in values (0-255) or
  30319. * float values (0-1) depending of the underlying buffer type.
  30320. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  30321. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  30322. * @param buffer defines a user defined buffer to fill with data (can be null)
  30323. * @returns The Array buffer containing the pixels data.
  30324. */
  30325. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  30326. /**
  30327. * Release and destroy the underlying lower level texture aka internalTexture.
  30328. */
  30329. releaseInternalTexture(): void;
  30330. /** @hidden */
  30331. readonly _lodTextureHigh: Nullable<BaseTexture>;
  30332. /** @hidden */
  30333. readonly _lodTextureMid: Nullable<BaseTexture>;
  30334. /** @hidden */
  30335. readonly _lodTextureLow: Nullable<BaseTexture>;
  30336. /**
  30337. * Dispose the texture and release its associated resources.
  30338. */
  30339. dispose(): void;
  30340. /**
  30341. * Serialize the texture into a JSON representation that can be parsed later on.
  30342. * @returns the JSON representation of the texture
  30343. */
  30344. serialize(): any;
  30345. /**
  30346. * Helper function to be called back once a list of texture contains only ready textures.
  30347. * @param textures Define the list of textures to wait for
  30348. * @param callback Define the callback triggered once the entire list will be ready
  30349. */
  30350. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  30351. }
  30352. }
  30353. declare module "babylonjs/Materials/effect" {
  30354. import { Observable } from "babylonjs/Misc/observable";
  30355. import { Nullable } from "babylonjs/types";
  30356. import { IDisposable } from "babylonjs/scene";
  30357. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30358. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30359. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  30360. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  30361. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  30362. import { Engine } from "babylonjs/Engines/engine";
  30363. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30364. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30365. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30366. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30367. /**
  30368. * Options to be used when creating an effect.
  30369. */
  30370. export interface IEffectCreationOptions {
  30371. /**
  30372. * Atrributes that will be used in the shader.
  30373. */
  30374. attributes: string[];
  30375. /**
  30376. * Uniform varible names that will be set in the shader.
  30377. */
  30378. uniformsNames: string[];
  30379. /**
  30380. * Uniform buffer variable names that will be set in the shader.
  30381. */
  30382. uniformBuffersNames: string[];
  30383. /**
  30384. * Sampler texture variable names that will be set in the shader.
  30385. */
  30386. samplers: string[];
  30387. /**
  30388. * Define statements that will be set in the shader.
  30389. */
  30390. defines: any;
  30391. /**
  30392. * Possible fallbacks for this effect to improve performance when needed.
  30393. */
  30394. fallbacks: Nullable<IEffectFallbacks>;
  30395. /**
  30396. * Callback that will be called when the shader is compiled.
  30397. */
  30398. onCompiled: Nullable<(effect: Effect) => void>;
  30399. /**
  30400. * Callback that will be called if an error occurs during shader compilation.
  30401. */
  30402. onError: Nullable<(effect: Effect, errors: string) => void>;
  30403. /**
  30404. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30405. */
  30406. indexParameters?: any;
  30407. /**
  30408. * Max number of lights that can be used in the shader.
  30409. */
  30410. maxSimultaneousLights?: number;
  30411. /**
  30412. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30413. */
  30414. transformFeedbackVaryings?: Nullable<string[]>;
  30415. }
  30416. /**
  30417. * Effect containing vertex and fragment shader that can be executed on an object.
  30418. */
  30419. export class Effect implements IDisposable {
  30420. /**
  30421. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30422. */
  30423. static ShadersRepository: string;
  30424. /**
  30425. * Name of the effect.
  30426. */
  30427. name: any;
  30428. /**
  30429. * String container all the define statements that should be set on the shader.
  30430. */
  30431. defines: string;
  30432. /**
  30433. * Callback that will be called when the shader is compiled.
  30434. */
  30435. onCompiled: Nullable<(effect: Effect) => void>;
  30436. /**
  30437. * Callback that will be called if an error occurs during shader compilation.
  30438. */
  30439. onError: Nullable<(effect: Effect, errors: string) => void>;
  30440. /**
  30441. * Callback that will be called when effect is bound.
  30442. */
  30443. onBind: Nullable<(effect: Effect) => void>;
  30444. /**
  30445. * Unique ID of the effect.
  30446. */
  30447. uniqueId: number;
  30448. /**
  30449. * Observable that will be called when the shader is compiled.
  30450. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30451. */
  30452. onCompileObservable: Observable<Effect>;
  30453. /**
  30454. * Observable that will be called if an error occurs during shader compilation.
  30455. */
  30456. onErrorObservable: Observable<Effect>;
  30457. /** @hidden */
  30458. _onBindObservable: Nullable<Observable<Effect>>;
  30459. /**
  30460. * Observable that will be called when effect is bound.
  30461. */
  30462. readonly onBindObservable: Observable<Effect>;
  30463. /** @hidden */
  30464. _bonesComputationForcedToCPU: boolean;
  30465. private static _uniqueIdSeed;
  30466. private _engine;
  30467. private _uniformBuffersNames;
  30468. private _uniformsNames;
  30469. private _samplerList;
  30470. private _samplers;
  30471. private _isReady;
  30472. private _compilationError;
  30473. private _allFallbacksProcessed;
  30474. private _attributesNames;
  30475. private _attributes;
  30476. private _uniforms;
  30477. /**
  30478. * Key for the effect.
  30479. * @hidden
  30480. */
  30481. _key: string;
  30482. private _indexParameters;
  30483. private _fallbacks;
  30484. private _vertexSourceCode;
  30485. private _fragmentSourceCode;
  30486. private _vertexSourceCodeOverride;
  30487. private _fragmentSourceCodeOverride;
  30488. private _transformFeedbackVaryings;
  30489. /**
  30490. * Compiled shader to webGL program.
  30491. * @hidden
  30492. */
  30493. _pipelineContext: Nullable<IPipelineContext>;
  30494. private _valueCache;
  30495. private static _baseCache;
  30496. /**
  30497. * Instantiates an effect.
  30498. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30499. * @param baseName Name of the effect.
  30500. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30501. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30502. * @param samplers List of sampler variables that will be passed to the shader.
  30503. * @param engine Engine to be used to render the effect
  30504. * @param defines Define statements to be added to the shader.
  30505. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30506. * @param onCompiled Callback that will be called when the shader is compiled.
  30507. * @param onError Callback that will be called if an error occurs during shader compilation.
  30508. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30509. */
  30510. constructor(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  30511. private _useFinalCode;
  30512. /**
  30513. * Unique key for this effect
  30514. */
  30515. readonly key: string;
  30516. /**
  30517. * If the effect has been compiled and prepared.
  30518. * @returns if the effect is compiled and prepared.
  30519. */
  30520. isReady(): boolean;
  30521. private _isReadyInternal;
  30522. /**
  30523. * The engine the effect was initialized with.
  30524. * @returns the engine.
  30525. */
  30526. getEngine(): Engine;
  30527. /**
  30528. * The pipeline context for this effect
  30529. * @returns the associated pipeline context
  30530. */
  30531. getPipelineContext(): Nullable<IPipelineContext>;
  30532. /**
  30533. * The set of names of attribute variables for the shader.
  30534. * @returns An array of attribute names.
  30535. */
  30536. getAttributesNames(): string[];
  30537. /**
  30538. * Returns the attribute at the given index.
  30539. * @param index The index of the attribute.
  30540. * @returns The location of the attribute.
  30541. */
  30542. getAttributeLocation(index: number): number;
  30543. /**
  30544. * Returns the attribute based on the name of the variable.
  30545. * @param name of the attribute to look up.
  30546. * @returns the attribute location.
  30547. */
  30548. getAttributeLocationByName(name: string): number;
  30549. /**
  30550. * The number of attributes.
  30551. * @returns the numnber of attributes.
  30552. */
  30553. getAttributesCount(): number;
  30554. /**
  30555. * Gets the index of a uniform variable.
  30556. * @param uniformName of the uniform to look up.
  30557. * @returns the index.
  30558. */
  30559. getUniformIndex(uniformName: string): number;
  30560. /**
  30561. * Returns the attribute based on the name of the variable.
  30562. * @param uniformName of the uniform to look up.
  30563. * @returns the location of the uniform.
  30564. */
  30565. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30566. /**
  30567. * Returns an array of sampler variable names
  30568. * @returns The array of sampler variable neames.
  30569. */
  30570. getSamplers(): string[];
  30571. /**
  30572. * The error from the last compilation.
  30573. * @returns the error string.
  30574. */
  30575. getCompilationError(): string;
  30576. /**
  30577. * Gets a boolean indicating that all fallbacks were used during compilation
  30578. * @returns true if all fallbacks were used
  30579. */
  30580. allFallbacksProcessed(): boolean;
  30581. /**
  30582. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30583. * @param func The callback to be used.
  30584. */
  30585. executeWhenCompiled(func: (effect: Effect) => void): void;
  30586. private _checkIsReady;
  30587. private _loadShader;
  30588. /**
  30589. * Recompiles the webGL program
  30590. * @param vertexSourceCode The source code for the vertex shader.
  30591. * @param fragmentSourceCode The source code for the fragment shader.
  30592. * @param onCompiled Callback called when completed.
  30593. * @param onError Callback called on error.
  30594. * @hidden
  30595. */
  30596. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30597. /**
  30598. * Prepares the effect
  30599. * @hidden
  30600. */
  30601. _prepareEffect(): void;
  30602. private _processCompilationErrors;
  30603. /**
  30604. * Checks if the effect is supported. (Must be called after compilation)
  30605. */
  30606. readonly isSupported: boolean;
  30607. /**
  30608. * Binds a texture to the engine to be used as output of the shader.
  30609. * @param channel Name of the output variable.
  30610. * @param texture Texture to bind.
  30611. * @hidden
  30612. */
  30613. _bindTexture(channel: string, texture: InternalTexture): void;
  30614. /**
  30615. * Sets a texture on the engine to be used in the shader.
  30616. * @param channel Name of the sampler variable.
  30617. * @param texture Texture to set.
  30618. */
  30619. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30620. /**
  30621. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30622. * @param channel Name of the sampler variable.
  30623. * @param texture Texture to set.
  30624. */
  30625. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30626. /**
  30627. * Sets an array of textures on the engine to be used in the shader.
  30628. * @param channel Name of the variable.
  30629. * @param textures Textures to set.
  30630. */
  30631. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30632. /**
  30633. * 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)
  30634. * @param channel Name of the sampler variable.
  30635. * @param postProcess Post process to get the input texture from.
  30636. */
  30637. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30638. /**
  30639. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30640. * 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)
  30641. * @param channel Name of the sampler variable.
  30642. * @param postProcess Post process to get the output texture from.
  30643. */
  30644. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30645. /** @hidden */
  30646. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  30647. /** @hidden */
  30648. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30649. /** @hidden */
  30650. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30651. /** @hidden */
  30652. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30653. /**
  30654. * Binds a buffer to a uniform.
  30655. * @param buffer Buffer to bind.
  30656. * @param name Name of the uniform variable to bind to.
  30657. */
  30658. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30659. /**
  30660. * Binds block to a uniform.
  30661. * @param blockName Name of the block to bind.
  30662. * @param index Index to bind.
  30663. */
  30664. bindUniformBlock(blockName: string, index: number): void;
  30665. /**
  30666. * Sets an interger value on a uniform variable.
  30667. * @param uniformName Name of the variable.
  30668. * @param value Value to be set.
  30669. * @returns this effect.
  30670. */
  30671. setInt(uniformName: string, value: number): Effect;
  30672. /**
  30673. * Sets an int array on a uniform variable.
  30674. * @param uniformName Name of the variable.
  30675. * @param array array to be set.
  30676. * @returns this effect.
  30677. */
  30678. setIntArray(uniformName: string, array: Int32Array): Effect;
  30679. /**
  30680. * 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)
  30681. * @param uniformName Name of the variable.
  30682. * @param array array to be set.
  30683. * @returns this effect.
  30684. */
  30685. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30686. /**
  30687. * 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)
  30688. * @param uniformName Name of the variable.
  30689. * @param array array to be set.
  30690. * @returns this effect.
  30691. */
  30692. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30693. /**
  30694. * 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)
  30695. * @param uniformName Name of the variable.
  30696. * @param array array to be set.
  30697. * @returns this effect.
  30698. */
  30699. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30700. /**
  30701. * Sets an float array on a uniform variable.
  30702. * @param uniformName Name of the variable.
  30703. * @param array array to be set.
  30704. * @returns this effect.
  30705. */
  30706. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30707. /**
  30708. * 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)
  30709. * @param uniformName Name of the variable.
  30710. * @param array array to be set.
  30711. * @returns this effect.
  30712. */
  30713. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30714. /**
  30715. * 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)
  30716. * @param uniformName Name of the variable.
  30717. * @param array array to be set.
  30718. * @returns this effect.
  30719. */
  30720. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30721. /**
  30722. * 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)
  30723. * @param uniformName Name of the variable.
  30724. * @param array array to be set.
  30725. * @returns this effect.
  30726. */
  30727. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30728. /**
  30729. * Sets an array on a uniform variable.
  30730. * @param uniformName Name of the variable.
  30731. * @param array array to be set.
  30732. * @returns this effect.
  30733. */
  30734. setArray(uniformName: string, array: number[]): Effect;
  30735. /**
  30736. * 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)
  30737. * @param uniformName Name of the variable.
  30738. * @param array array to be set.
  30739. * @returns this effect.
  30740. */
  30741. setArray2(uniformName: string, array: number[]): Effect;
  30742. /**
  30743. * 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)
  30744. * @param uniformName Name of the variable.
  30745. * @param array array to be set.
  30746. * @returns this effect.
  30747. */
  30748. setArray3(uniformName: string, array: number[]): Effect;
  30749. /**
  30750. * 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)
  30751. * @param uniformName Name of the variable.
  30752. * @param array array to be set.
  30753. * @returns this effect.
  30754. */
  30755. setArray4(uniformName: string, array: number[]): Effect;
  30756. /**
  30757. * Sets matrices on a uniform variable.
  30758. * @param uniformName Name of the variable.
  30759. * @param matrices matrices to be set.
  30760. * @returns this effect.
  30761. */
  30762. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30763. /**
  30764. * Sets matrix on a uniform variable.
  30765. * @param uniformName Name of the variable.
  30766. * @param matrix matrix to be set.
  30767. * @returns this effect.
  30768. */
  30769. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  30770. /**
  30771. * 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)
  30772. * @param uniformName Name of the variable.
  30773. * @param matrix matrix to be set.
  30774. * @returns this effect.
  30775. */
  30776. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30777. /**
  30778. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30779. * @param uniformName Name of the variable.
  30780. * @param matrix matrix to be set.
  30781. * @returns this effect.
  30782. */
  30783. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30784. /**
  30785. * Sets a float on a uniform variable.
  30786. * @param uniformName Name of the variable.
  30787. * @param value value to be set.
  30788. * @returns this effect.
  30789. */
  30790. setFloat(uniformName: string, value: number): Effect;
  30791. /**
  30792. * Sets a boolean on a uniform variable.
  30793. * @param uniformName Name of the variable.
  30794. * @param bool value to be set.
  30795. * @returns this effect.
  30796. */
  30797. setBool(uniformName: string, bool: boolean): Effect;
  30798. /**
  30799. * Sets a Vector2 on a uniform variable.
  30800. * @param uniformName Name of the variable.
  30801. * @param vector2 vector2 to be set.
  30802. * @returns this effect.
  30803. */
  30804. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  30805. /**
  30806. * Sets a float2 on a uniform variable.
  30807. * @param uniformName Name of the variable.
  30808. * @param x First float in float2.
  30809. * @param y Second float in float2.
  30810. * @returns this effect.
  30811. */
  30812. setFloat2(uniformName: string, x: number, y: number): Effect;
  30813. /**
  30814. * Sets a Vector3 on a uniform variable.
  30815. * @param uniformName Name of the variable.
  30816. * @param vector3 Value to be set.
  30817. * @returns this effect.
  30818. */
  30819. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  30820. /**
  30821. * Sets a float3 on a uniform variable.
  30822. * @param uniformName Name of the variable.
  30823. * @param x First float in float3.
  30824. * @param y Second float in float3.
  30825. * @param z Third float in float3.
  30826. * @returns this effect.
  30827. */
  30828. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30829. /**
  30830. * Sets a Vector4 on a uniform variable.
  30831. * @param uniformName Name of the variable.
  30832. * @param vector4 Value to be set.
  30833. * @returns this effect.
  30834. */
  30835. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  30836. /**
  30837. * Sets a float4 on a uniform variable.
  30838. * @param uniformName Name of the variable.
  30839. * @param x First float in float4.
  30840. * @param y Second float in float4.
  30841. * @param z Third float in float4.
  30842. * @param w Fourth float in float4.
  30843. * @returns this effect.
  30844. */
  30845. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30846. /**
  30847. * Sets a Color3 on a uniform variable.
  30848. * @param uniformName Name of the variable.
  30849. * @param color3 Value to be set.
  30850. * @returns this effect.
  30851. */
  30852. setColor3(uniformName: string, color3: IColor3Like): Effect;
  30853. /**
  30854. * Sets a Color4 on a uniform variable.
  30855. * @param uniformName Name of the variable.
  30856. * @param color3 Value to be set.
  30857. * @param alpha Alpha value to be set.
  30858. * @returns this effect.
  30859. */
  30860. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  30861. /**
  30862. * Sets a Color4 on a uniform variable
  30863. * @param uniformName defines the name of the variable
  30864. * @param color4 defines the value to be set
  30865. * @returns this effect.
  30866. */
  30867. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  30868. /** Release all associated resources */
  30869. dispose(): void;
  30870. /**
  30871. * This function will add a new shader to the shader store
  30872. * @param name the name of the shader
  30873. * @param pixelShader optional pixel shader content
  30874. * @param vertexShader optional vertex shader content
  30875. */
  30876. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30877. /**
  30878. * Store of each shader (The can be looked up using effect.key)
  30879. */
  30880. static ShadersStore: {
  30881. [key: string]: string;
  30882. };
  30883. /**
  30884. * Store of each included file for a shader (The can be looked up using effect.key)
  30885. */
  30886. static IncludesShadersStore: {
  30887. [key: string]: string;
  30888. };
  30889. /**
  30890. * Resets the cache of effects.
  30891. */
  30892. static ResetCache(): void;
  30893. }
  30894. }
  30895. declare module "babylonjs/Engines/engineCapabilities" {
  30896. /**
  30897. * Interface used to describe the capabilities of the engine relatively to the current browser
  30898. */
  30899. export interface EngineCapabilities {
  30900. /** Maximum textures units per fragment shader */
  30901. maxTexturesImageUnits: number;
  30902. /** Maximum texture units per vertex shader */
  30903. maxVertexTextureImageUnits: number;
  30904. /** Maximum textures units in the entire pipeline */
  30905. maxCombinedTexturesImageUnits: number;
  30906. /** Maximum texture size */
  30907. maxTextureSize: number;
  30908. /** Maximum texture samples */
  30909. maxSamples?: number;
  30910. /** Maximum cube texture size */
  30911. maxCubemapTextureSize: number;
  30912. /** Maximum render texture size */
  30913. maxRenderTextureSize: number;
  30914. /** Maximum number of vertex attributes */
  30915. maxVertexAttribs: number;
  30916. /** Maximum number of varyings */
  30917. maxVaryingVectors: number;
  30918. /** Maximum number of uniforms per vertex shader */
  30919. maxVertexUniformVectors: number;
  30920. /** Maximum number of uniforms per fragment shader */
  30921. maxFragmentUniformVectors: number;
  30922. /** Defines if standard derivates (dx/dy) are supported */
  30923. standardDerivatives: boolean;
  30924. /** Defines if s3tc texture compression is supported */
  30925. s3tc?: WEBGL_compressed_texture_s3tc;
  30926. /** Defines if pvrtc texture compression is supported */
  30927. pvrtc: any;
  30928. /** Defines if etc1 texture compression is supported */
  30929. etc1: any;
  30930. /** Defines if etc2 texture compression is supported */
  30931. etc2: any;
  30932. /** Defines if astc texture compression is supported */
  30933. astc: any;
  30934. /** Defines if float textures are supported */
  30935. textureFloat: boolean;
  30936. /** Defines if vertex array objects are supported */
  30937. vertexArrayObject: boolean;
  30938. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30939. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  30940. /** Gets the maximum level of anisotropy supported */
  30941. maxAnisotropy: number;
  30942. /** Defines if instancing is supported */
  30943. instancedArrays: boolean;
  30944. /** Defines if 32 bits indices are supported */
  30945. uintIndices: boolean;
  30946. /** Defines if high precision shaders are supported */
  30947. highPrecisionShaderSupported: boolean;
  30948. /** Defines if depth reading in the fragment shader is supported */
  30949. fragmentDepthSupported: boolean;
  30950. /** Defines if float texture linear filtering is supported*/
  30951. textureFloatLinearFiltering: boolean;
  30952. /** Defines if rendering to float textures is supported */
  30953. textureFloatRender: boolean;
  30954. /** Defines if half float textures are supported*/
  30955. textureHalfFloat: boolean;
  30956. /** Defines if half float texture linear filtering is supported*/
  30957. textureHalfFloatLinearFiltering: boolean;
  30958. /** Defines if rendering to half float textures is supported */
  30959. textureHalfFloatRender: boolean;
  30960. /** Defines if textureLOD shader command is supported */
  30961. textureLOD: boolean;
  30962. /** Defines if draw buffers extension is supported */
  30963. drawBuffersExtension: boolean;
  30964. /** Defines if depth textures are supported */
  30965. depthTextureExtension: boolean;
  30966. /** Defines if float color buffer are supported */
  30967. colorBufferFloat: boolean;
  30968. /** Gets disjoint timer query extension (null if not supported) */
  30969. timerQuery?: EXT_disjoint_timer_query;
  30970. /** Defines if timestamp can be used with timer query */
  30971. canUseTimestampForTimerQuery: boolean;
  30972. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30973. multiview?: any;
  30974. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  30975. oculusMultiview?: any;
  30976. /** Function used to let the system compiles shaders in background */
  30977. parallelShaderCompile?: {
  30978. COMPLETION_STATUS_KHR: number;
  30979. };
  30980. /** Max number of texture samples for MSAA */
  30981. maxMSAASamples: number;
  30982. /** Defines if the blend min max extension is supported */
  30983. blendMinMax: boolean;
  30984. }
  30985. }
  30986. declare module "babylonjs/States/depthCullingState" {
  30987. import { Nullable } from "babylonjs/types";
  30988. /**
  30989. * @hidden
  30990. **/
  30991. export class DepthCullingState {
  30992. private _isDepthTestDirty;
  30993. private _isDepthMaskDirty;
  30994. private _isDepthFuncDirty;
  30995. private _isCullFaceDirty;
  30996. private _isCullDirty;
  30997. private _isZOffsetDirty;
  30998. private _isFrontFaceDirty;
  30999. private _depthTest;
  31000. private _depthMask;
  31001. private _depthFunc;
  31002. private _cull;
  31003. private _cullFace;
  31004. private _zOffset;
  31005. private _frontFace;
  31006. /**
  31007. * Initializes the state.
  31008. */
  31009. constructor();
  31010. readonly isDirty: boolean;
  31011. zOffset: number;
  31012. cullFace: Nullable<number>;
  31013. cull: Nullable<boolean>;
  31014. depthFunc: Nullable<number>;
  31015. depthMask: boolean;
  31016. depthTest: boolean;
  31017. frontFace: Nullable<number>;
  31018. reset(): void;
  31019. apply(gl: WebGLRenderingContext): void;
  31020. }
  31021. }
  31022. declare module "babylonjs/States/stencilState" {
  31023. /**
  31024. * @hidden
  31025. **/
  31026. export class StencilState {
  31027. /** 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 */
  31028. static readonly ALWAYS: number;
  31029. /** Passed to stencilOperation to specify that stencil value must be kept */
  31030. static readonly KEEP: number;
  31031. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31032. static readonly REPLACE: number;
  31033. private _isStencilTestDirty;
  31034. private _isStencilMaskDirty;
  31035. private _isStencilFuncDirty;
  31036. private _isStencilOpDirty;
  31037. private _stencilTest;
  31038. private _stencilMask;
  31039. private _stencilFunc;
  31040. private _stencilFuncRef;
  31041. private _stencilFuncMask;
  31042. private _stencilOpStencilFail;
  31043. private _stencilOpDepthFail;
  31044. private _stencilOpStencilDepthPass;
  31045. readonly isDirty: boolean;
  31046. stencilFunc: number;
  31047. stencilFuncRef: number;
  31048. stencilFuncMask: number;
  31049. stencilOpStencilFail: number;
  31050. stencilOpDepthFail: number;
  31051. stencilOpStencilDepthPass: number;
  31052. stencilMask: number;
  31053. stencilTest: boolean;
  31054. constructor();
  31055. reset(): void;
  31056. apply(gl: WebGLRenderingContext): void;
  31057. }
  31058. }
  31059. declare module "babylonjs/States/alphaCullingState" {
  31060. /**
  31061. * @hidden
  31062. **/
  31063. export class AlphaState {
  31064. private _isAlphaBlendDirty;
  31065. private _isBlendFunctionParametersDirty;
  31066. private _isBlendEquationParametersDirty;
  31067. private _isBlendConstantsDirty;
  31068. private _alphaBlend;
  31069. private _blendFunctionParameters;
  31070. private _blendEquationParameters;
  31071. private _blendConstants;
  31072. /**
  31073. * Initializes the state.
  31074. */
  31075. constructor();
  31076. readonly isDirty: boolean;
  31077. alphaBlend: boolean;
  31078. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  31079. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  31080. setAlphaEquationParameters(rgb: number, alpha: number): void;
  31081. reset(): void;
  31082. apply(gl: WebGLRenderingContext): void;
  31083. }
  31084. }
  31085. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  31086. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31087. /** @hidden */
  31088. export class WebGL2ShaderProcessor implements IShaderProcessor {
  31089. attributeProcessor(attribute: string): string;
  31090. varyingProcessor(varying: string, isFragment: boolean): string;
  31091. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  31092. }
  31093. }
  31094. declare module "babylonjs/Engines/instancingAttributeInfo" {
  31095. /**
  31096. * Interface for attribute information associated with buffer instanciation
  31097. */
  31098. export interface InstancingAttributeInfo {
  31099. /**
  31100. * Index/offset of the attribute in the vertex shader
  31101. */
  31102. index: number;
  31103. /**
  31104. * size of the attribute, 1, 2, 3 or 4
  31105. */
  31106. attributeSize: number;
  31107. /**
  31108. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  31109. * default is FLOAT
  31110. */
  31111. attributeType: number;
  31112. /**
  31113. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  31114. */
  31115. normalized: boolean;
  31116. /**
  31117. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  31118. */
  31119. offset: number;
  31120. /**
  31121. * Name of the GLSL attribute, for debugging purpose only
  31122. */
  31123. attributeName: string;
  31124. }
  31125. }
  31126. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  31127. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31128. import { Nullable } from "babylonjs/types";
  31129. module "babylonjs/Engines/thinEngine" {
  31130. interface ThinEngine {
  31131. /**
  31132. * Update a video texture
  31133. * @param texture defines the texture to update
  31134. * @param video defines the video element to use
  31135. * @param invertY defines if data must be stored with Y axis inverted
  31136. */
  31137. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31138. }
  31139. }
  31140. }
  31141. declare module "babylonjs/Materials/Textures/videoTexture" {
  31142. import { Observable } from "babylonjs/Misc/observable";
  31143. import { Nullable } from "babylonjs/types";
  31144. import { Scene } from "babylonjs/scene";
  31145. import { Texture } from "babylonjs/Materials/Textures/texture";
  31146. import "babylonjs/Engines/Extensions/engine.videoTexture";
  31147. /**
  31148. * Settings for finer control over video usage
  31149. */
  31150. export interface VideoTextureSettings {
  31151. /**
  31152. * Applies `autoplay` to video, if specified
  31153. */
  31154. autoPlay?: boolean;
  31155. /**
  31156. * Applies `loop` to video, if specified
  31157. */
  31158. loop?: boolean;
  31159. /**
  31160. * Automatically updates internal texture from video at every frame in the render loop
  31161. */
  31162. autoUpdateTexture: boolean;
  31163. /**
  31164. * Image src displayed during the video loading or until the user interacts with the video.
  31165. */
  31166. poster?: string;
  31167. }
  31168. /**
  31169. * If you want to display a video in your scene, this is the special texture for that.
  31170. * This special texture works similar to other textures, with the exception of a few parameters.
  31171. * @see https://doc.babylonjs.com/how_to/video_texture
  31172. */
  31173. export class VideoTexture extends Texture {
  31174. /**
  31175. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  31176. */
  31177. readonly autoUpdateTexture: boolean;
  31178. /**
  31179. * The video instance used by the texture internally
  31180. */
  31181. readonly video: HTMLVideoElement;
  31182. private _onUserActionRequestedObservable;
  31183. /**
  31184. * Event triggerd when a dom action is required by the user to play the video.
  31185. * This happens due to recent changes in browser policies preventing video to auto start.
  31186. */
  31187. readonly onUserActionRequestedObservable: Observable<Texture>;
  31188. private _generateMipMaps;
  31189. private _engine;
  31190. private _stillImageCaptured;
  31191. private _displayingPosterTexture;
  31192. private _settings;
  31193. private _createInternalTextureOnEvent;
  31194. private _frameId;
  31195. /**
  31196. * Creates a video texture.
  31197. * If you want to display a video in your scene, this is the special texture for that.
  31198. * This special texture works similar to other textures, with the exception of a few parameters.
  31199. * @see https://doc.babylonjs.com/how_to/video_texture
  31200. * @param name optional name, will detect from video source, if not defined
  31201. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  31202. * @param scene is obviously the current scene.
  31203. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  31204. * @param invertY is false by default but can be used to invert video on Y axis
  31205. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  31206. * @param settings allows finer control over video usage
  31207. */
  31208. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  31209. private _getName;
  31210. private _getVideo;
  31211. private _createInternalTexture;
  31212. private reset;
  31213. /**
  31214. * @hidden Internal method to initiate `update`.
  31215. */
  31216. _rebuild(): void;
  31217. /**
  31218. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  31219. */
  31220. update(): void;
  31221. /**
  31222. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  31223. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  31224. */
  31225. updateTexture(isVisible: boolean): void;
  31226. protected _updateInternalTexture: () => void;
  31227. /**
  31228. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  31229. * @param url New url.
  31230. */
  31231. updateURL(url: string): void;
  31232. /**
  31233. * Dispose the texture and release its associated resources.
  31234. */
  31235. dispose(): void;
  31236. /**
  31237. * Creates a video texture straight from a stream.
  31238. * @param scene Define the scene the texture should be created in
  31239. * @param stream Define the stream the texture should be created from
  31240. * @returns The created video texture as a promise
  31241. */
  31242. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  31243. /**
  31244. * Creates a video texture straight from your WebCam video feed.
  31245. * @param scene Define the scene the texture should be created in
  31246. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31247. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31248. * @returns The created video texture as a promise
  31249. */
  31250. static CreateFromWebCamAsync(scene: Scene, constraints: {
  31251. minWidth: number;
  31252. maxWidth: number;
  31253. minHeight: number;
  31254. maxHeight: number;
  31255. deviceId: string;
  31256. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  31257. /**
  31258. * Creates a video texture straight from your WebCam video feed.
  31259. * @param scene Define the scene the texture should be created in
  31260. * @param onReady Define a callback to triggered once the texture will be ready
  31261. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31262. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31263. */
  31264. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  31265. minWidth: number;
  31266. maxWidth: number;
  31267. minHeight: number;
  31268. maxHeight: number;
  31269. deviceId: string;
  31270. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  31271. }
  31272. }
  31273. declare module "babylonjs/Engines/thinEngine" {
  31274. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  31275. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  31276. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31277. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31278. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  31279. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  31280. import { Observable } from "babylonjs/Misc/observable";
  31281. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  31282. import { StencilState } from "babylonjs/States/stencilState";
  31283. import { AlphaState } from "babylonjs/States/alphaCullingState";
  31284. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31285. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  31286. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31287. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  31288. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31289. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  31290. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  31291. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  31292. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31293. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31294. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  31295. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  31296. /**
  31297. * Defines the interface used by objects working like Scene
  31298. * @hidden
  31299. */
  31300. interface ISceneLike {
  31301. _addPendingData(data: any): void;
  31302. _removePendingData(data: any): void;
  31303. offlineProvider: IOfflineProvider;
  31304. }
  31305. /** Interface defining initialization parameters for Engine class */
  31306. export interface EngineOptions extends WebGLContextAttributes {
  31307. /**
  31308. * Defines if the engine should no exceed a specified device ratio
  31309. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  31310. */
  31311. limitDeviceRatio?: number;
  31312. /**
  31313. * Defines if webvr should be enabled automatically
  31314. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31315. */
  31316. autoEnableWebVR?: boolean;
  31317. /**
  31318. * Defines if webgl2 should be turned off even if supported
  31319. * @see http://doc.babylonjs.com/features/webgl2
  31320. */
  31321. disableWebGL2Support?: boolean;
  31322. /**
  31323. * Defines if webaudio should be initialized as well
  31324. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31325. */
  31326. audioEngine?: boolean;
  31327. /**
  31328. * Defines if animations should run using a deterministic lock step
  31329. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31330. */
  31331. deterministicLockstep?: boolean;
  31332. /** Defines the maximum steps to use with deterministic lock step mode */
  31333. lockstepMaxSteps?: number;
  31334. /** Defines the seconds between each deterministic lock step */
  31335. timeStep?: number;
  31336. /**
  31337. * Defines that engine should ignore context lost events
  31338. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  31339. */
  31340. doNotHandleContextLost?: boolean;
  31341. /**
  31342. * Defines that engine should ignore modifying touch action attribute and style
  31343. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  31344. */
  31345. doNotHandleTouchAction?: boolean;
  31346. /**
  31347. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  31348. */
  31349. useHighPrecisionFloats?: boolean;
  31350. }
  31351. /**
  31352. * The base engine class (root of all engines)
  31353. */
  31354. export class ThinEngine {
  31355. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  31356. static ExceptionList: ({
  31357. key: string;
  31358. capture: string;
  31359. captureConstraint: number;
  31360. targets: string[];
  31361. } | {
  31362. key: string;
  31363. capture: null;
  31364. captureConstraint: null;
  31365. targets: string[];
  31366. })[];
  31367. /** @hidden */
  31368. static _TextureLoaders: IInternalTextureLoader[];
  31369. /**
  31370. * Returns the current npm package of the sdk
  31371. */
  31372. static readonly NpmPackage: string;
  31373. /**
  31374. * Returns the current version of the framework
  31375. */
  31376. static readonly Version: string;
  31377. /**
  31378. * Returns a string describing the current engine
  31379. */
  31380. readonly description: string;
  31381. /**
  31382. * Gets or sets the epsilon value used by collision engine
  31383. */
  31384. static CollisionsEpsilon: number;
  31385. /**
  31386. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31387. */
  31388. static ShadersRepository: string;
  31389. /**
  31390. * Gets or sets the textures that the engine should not attempt to load as compressed
  31391. */
  31392. protected _excludedCompressedTextures: string[];
  31393. /**
  31394. * Filters the compressed texture formats to only include
  31395. * files that are not included in the skippable list
  31396. *
  31397. * @param url the current extension
  31398. * @param textureFormatInUse the current compressed texture format
  31399. * @returns "format" string
  31400. */
  31401. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  31402. /** @hidden */
  31403. _shaderProcessor: IShaderProcessor;
  31404. /**
  31405. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  31406. */
  31407. forcePOTTextures: boolean;
  31408. /**
  31409. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  31410. */
  31411. isFullscreen: boolean;
  31412. /**
  31413. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31414. */
  31415. cullBackFaces: boolean;
  31416. /**
  31417. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31418. */
  31419. renderEvenInBackground: boolean;
  31420. /**
  31421. * Gets or sets a boolean indicating that cache can be kept between frames
  31422. */
  31423. preventCacheWipeBetweenFrames: boolean;
  31424. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31425. validateShaderPrograms: boolean;
  31426. /**
  31427. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  31428. * This can provide greater z depth for distant objects.
  31429. */
  31430. useReverseDepthBuffer: boolean;
  31431. /**
  31432. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31433. */
  31434. disableUniformBuffers: boolean;
  31435. /** @hidden */
  31436. _uniformBuffers: UniformBuffer[];
  31437. /**
  31438. * Gets a boolean indicating that the engine supports uniform buffers
  31439. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31440. */
  31441. readonly supportsUniformBuffers: boolean;
  31442. /** @hidden */
  31443. _gl: WebGLRenderingContext;
  31444. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  31445. protected _windowIsBackground: boolean;
  31446. protected _webGLVersion: number;
  31447. protected _creationOptions: EngineOptions;
  31448. protected _highPrecisionShadersAllowed: boolean;
  31449. /** @hidden */
  31450. readonly _shouldUseHighPrecisionShader: boolean;
  31451. /**
  31452. * Gets a boolean indicating that only power of 2 textures are supported
  31453. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31454. */
  31455. readonly needPOTTextures: boolean;
  31456. /** @hidden */
  31457. _badOS: boolean;
  31458. /** @hidden */
  31459. _badDesktopOS: boolean;
  31460. private _hardwareScalingLevel;
  31461. /** @hidden */
  31462. _caps: EngineCapabilities;
  31463. private _isStencilEnable;
  31464. protected _colorWrite: boolean;
  31465. private _glVersion;
  31466. private _glRenderer;
  31467. private _glVendor;
  31468. /** @hidden */
  31469. _videoTextureSupported: boolean;
  31470. protected _renderingQueueLaunched: boolean;
  31471. protected _activeRenderLoops: (() => void)[];
  31472. /**
  31473. * Observable signaled when a context lost event is raised
  31474. */
  31475. onContextLostObservable: Observable<ThinEngine>;
  31476. /**
  31477. * Observable signaled when a context restored event is raised
  31478. */
  31479. onContextRestoredObservable: Observable<ThinEngine>;
  31480. private _onContextLost;
  31481. private _onContextRestored;
  31482. protected _contextWasLost: boolean;
  31483. /** @hidden */
  31484. _doNotHandleContextLost: boolean;
  31485. /**
  31486. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31487. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31488. */
  31489. doNotHandleContextLost: boolean;
  31490. /**
  31491. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31492. */
  31493. disableVertexArrayObjects: boolean;
  31494. /** @hidden */
  31495. protected _depthCullingState: DepthCullingState;
  31496. /** @hidden */
  31497. protected _stencilState: StencilState;
  31498. /** @hidden */
  31499. protected _alphaState: AlphaState;
  31500. /** @hidden */
  31501. _internalTexturesCache: InternalTexture[];
  31502. /** @hidden */
  31503. protected _activeChannel: number;
  31504. private _currentTextureChannel;
  31505. /** @hidden */
  31506. protected _boundTexturesCache: {
  31507. [key: string]: Nullable<InternalTexture>;
  31508. };
  31509. /** @hidden */
  31510. protected _currentEffect: Nullable<Effect>;
  31511. /** @hidden */
  31512. protected _currentProgram: Nullable<WebGLProgram>;
  31513. private _compiledEffects;
  31514. private _vertexAttribArraysEnabled;
  31515. /** @hidden */
  31516. protected _cachedViewport: Nullable<IViewportLike>;
  31517. private _cachedVertexArrayObject;
  31518. /** @hidden */
  31519. protected _cachedVertexBuffers: any;
  31520. /** @hidden */
  31521. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31522. /** @hidden */
  31523. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31524. /** @hidden */
  31525. _currentRenderTarget: Nullable<InternalTexture>;
  31526. private _uintIndicesCurrentlySet;
  31527. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  31528. /** @hidden */
  31529. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31530. private _currentBufferPointers;
  31531. private _currentInstanceLocations;
  31532. private _currentInstanceBuffers;
  31533. private _textureUnits;
  31534. /** @hidden */
  31535. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31536. /** @hidden */
  31537. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31538. /** @hidden */
  31539. _boundRenderFunction: any;
  31540. private _vaoRecordInProgress;
  31541. private _mustWipeVertexAttributes;
  31542. private _emptyTexture;
  31543. private _emptyCubeTexture;
  31544. private _emptyTexture3D;
  31545. private _emptyTexture2DArray;
  31546. /** @hidden */
  31547. _frameHandler: number;
  31548. private _nextFreeTextureSlots;
  31549. private _maxSimultaneousTextures;
  31550. private _activeRequests;
  31551. protected _texturesSupported: string[];
  31552. /** @hidden */
  31553. _textureFormatInUse: Nullable<string>;
  31554. protected readonly _supportsHardwareTextureRescaling: boolean;
  31555. /**
  31556. * Gets the list of texture formats supported
  31557. */
  31558. readonly texturesSupported: Array<string>;
  31559. /**
  31560. * Gets the list of texture formats in use
  31561. */
  31562. readonly textureFormatInUse: Nullable<string>;
  31563. /**
  31564. * Gets the current viewport
  31565. */
  31566. readonly currentViewport: Nullable<IViewportLike>;
  31567. /**
  31568. * Gets the default empty texture
  31569. */
  31570. readonly emptyTexture: InternalTexture;
  31571. /**
  31572. * Gets the default empty 3D texture
  31573. */
  31574. readonly emptyTexture3D: InternalTexture;
  31575. /**
  31576. * Gets the default empty 2D array texture
  31577. */
  31578. readonly emptyTexture2DArray: InternalTexture;
  31579. /**
  31580. * Gets the default empty cube texture
  31581. */
  31582. readonly emptyCubeTexture: InternalTexture;
  31583. /**
  31584. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31585. */
  31586. readonly premultipliedAlpha: boolean;
  31587. /**
  31588. * Observable event triggered before each texture is initialized
  31589. */
  31590. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  31591. /**
  31592. * Creates a new engine
  31593. * @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
  31594. * @param antialias defines enable antialiasing (default: false)
  31595. * @param options defines further options to be sent to the getContext() function
  31596. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31597. */
  31598. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31599. private _rebuildInternalTextures;
  31600. private _rebuildEffects;
  31601. /**
  31602. * Gets a boolean indicating if all created effects are ready
  31603. * @returns true if all effects are ready
  31604. */
  31605. areAllEffectsReady(): boolean;
  31606. protected _rebuildBuffers(): void;
  31607. private _initGLContext;
  31608. /**
  31609. * Gets version of the current webGL context
  31610. */
  31611. readonly webGLVersion: number;
  31612. /**
  31613. * Gets a string idenfifying the name of the class
  31614. * @returns "Engine" string
  31615. */
  31616. getClassName(): string;
  31617. /**
  31618. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31619. */
  31620. readonly isStencilEnable: boolean;
  31621. /** @hidden */
  31622. _prepareWorkingCanvas(): void;
  31623. /**
  31624. * Reset the texture cache to empty state
  31625. */
  31626. resetTextureCache(): void;
  31627. /**
  31628. * Gets an object containing information about the current webGL context
  31629. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31630. */
  31631. getGlInfo(): {
  31632. vendor: string;
  31633. renderer: string;
  31634. version: string;
  31635. };
  31636. /**
  31637. * Defines the hardware scaling level.
  31638. * By default the hardware scaling level is computed from the window device ratio.
  31639. * 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.
  31640. * @param level defines the level to use
  31641. */
  31642. setHardwareScalingLevel(level: number): void;
  31643. /**
  31644. * Gets the current hardware scaling level.
  31645. * By default the hardware scaling level is computed from the window device ratio.
  31646. * 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.
  31647. * @returns a number indicating the current hardware scaling level
  31648. */
  31649. getHardwareScalingLevel(): number;
  31650. /**
  31651. * Gets the list of loaded textures
  31652. * @returns an array containing all loaded textures
  31653. */
  31654. getLoadedTexturesCache(): InternalTexture[];
  31655. /**
  31656. * Gets the object containing all engine capabilities
  31657. * @returns the EngineCapabilities object
  31658. */
  31659. getCaps(): EngineCapabilities;
  31660. /**
  31661. * stop executing a render loop function and remove it from the execution array
  31662. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31663. */
  31664. stopRenderLoop(renderFunction?: () => void): void;
  31665. /** @hidden */
  31666. _renderLoop(): void;
  31667. /**
  31668. * Gets the HTML canvas attached with the current webGL context
  31669. * @returns a HTML canvas
  31670. */
  31671. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31672. /**
  31673. * Gets host window
  31674. * @returns the host window object
  31675. */
  31676. getHostWindow(): Nullable<Window>;
  31677. /**
  31678. * Gets the current render width
  31679. * @param useScreen defines if screen size must be used (or the current render target if any)
  31680. * @returns a number defining the current render width
  31681. */
  31682. getRenderWidth(useScreen?: boolean): number;
  31683. /**
  31684. * Gets the current render height
  31685. * @param useScreen defines if screen size must be used (or the current render target if any)
  31686. * @returns a number defining the current render height
  31687. */
  31688. getRenderHeight(useScreen?: boolean): number;
  31689. /**
  31690. * Can be used to override the current requestAnimationFrame requester.
  31691. * @hidden
  31692. */
  31693. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31694. /**
  31695. * Register and execute a render loop. The engine can have more than one render function
  31696. * @param renderFunction defines the function to continuously execute
  31697. */
  31698. runRenderLoop(renderFunction: () => void): void;
  31699. /**
  31700. * Clear the current render buffer or the current render target (if any is set up)
  31701. * @param color defines the color to use
  31702. * @param backBuffer defines if the back buffer must be cleared
  31703. * @param depth defines if the depth buffer must be cleared
  31704. * @param stencil defines if the stencil buffer must be cleared
  31705. */
  31706. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31707. private _viewportCached;
  31708. /** @hidden */
  31709. _viewport(x: number, y: number, width: number, height: number): void;
  31710. /**
  31711. * Set the WebGL's viewport
  31712. * @param viewport defines the viewport element to be used
  31713. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31714. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31715. */
  31716. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31717. /**
  31718. * Begin a new frame
  31719. */
  31720. beginFrame(): void;
  31721. /**
  31722. * Enf the current frame
  31723. */
  31724. endFrame(): void;
  31725. /**
  31726. * Resize the view according to the canvas' size
  31727. */
  31728. resize(): void;
  31729. /**
  31730. * Force a specific size of the canvas
  31731. * @param width defines the new canvas' width
  31732. * @param height defines the new canvas' height
  31733. */
  31734. setSize(width: number, height: number): void;
  31735. /**
  31736. * Binds the frame buffer to the specified texture.
  31737. * @param texture The texture to render to or null for the default canvas
  31738. * @param faceIndex The face of the texture to render to in case of cube texture
  31739. * @param requiredWidth The width of the target to render to
  31740. * @param requiredHeight The height of the target to render to
  31741. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31742. * @param depthStencilTexture The depth stencil texture to use to render
  31743. * @param lodLevel defines le lod level to bind to the frame buffer
  31744. */
  31745. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  31746. /** @hidden */
  31747. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31748. /**
  31749. * Unbind the current render target texture from the webGL context
  31750. * @param texture defines the render target texture to unbind
  31751. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31752. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31753. */
  31754. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31755. /**
  31756. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31757. */
  31758. flushFramebuffer(): void;
  31759. /**
  31760. * Unbind the current render target and bind the default framebuffer
  31761. */
  31762. restoreDefaultFramebuffer(): void;
  31763. /** @hidden */
  31764. protected _resetVertexBufferBinding(): void;
  31765. /**
  31766. * Creates a vertex buffer
  31767. * @param data the data for the vertex buffer
  31768. * @returns the new WebGL static buffer
  31769. */
  31770. createVertexBuffer(data: DataArray): DataBuffer;
  31771. private _createVertexBuffer;
  31772. /**
  31773. * Creates a dynamic vertex buffer
  31774. * @param data the data for the dynamic vertex buffer
  31775. * @returns the new WebGL dynamic buffer
  31776. */
  31777. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31778. protected _resetIndexBufferBinding(): void;
  31779. /**
  31780. * Creates a new index buffer
  31781. * @param indices defines the content of the index buffer
  31782. * @param updatable defines if the index buffer must be updatable
  31783. * @returns a new webGL buffer
  31784. */
  31785. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31786. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  31787. /**
  31788. * Bind a webGL buffer to the webGL context
  31789. * @param buffer defines the buffer to bind
  31790. */
  31791. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31792. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  31793. private bindBuffer;
  31794. /**
  31795. * update the bound buffer with the given data
  31796. * @param data defines the data to update
  31797. */
  31798. updateArrayBuffer(data: Float32Array): void;
  31799. private _vertexAttribPointer;
  31800. private _bindIndexBufferWithCache;
  31801. private _bindVertexBuffersAttributes;
  31802. /**
  31803. * Records a vertex array object
  31804. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31805. * @param vertexBuffers defines the list of vertex buffers to store
  31806. * @param indexBuffer defines the index buffer to store
  31807. * @param effect defines the effect to store
  31808. * @returns the new vertex array object
  31809. */
  31810. recordVertexArrayObject(vertexBuffers: {
  31811. [key: string]: VertexBuffer;
  31812. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31813. /**
  31814. * Bind a specific vertex array object
  31815. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31816. * @param vertexArrayObject defines the vertex array object to bind
  31817. * @param indexBuffer defines the index buffer to bind
  31818. */
  31819. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31820. /**
  31821. * Bind webGl buffers directly to the webGL context
  31822. * @param vertexBuffer defines the vertex buffer to bind
  31823. * @param indexBuffer defines the index buffer to bind
  31824. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31825. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31826. * @param effect defines the effect associated with the vertex buffer
  31827. */
  31828. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31829. private _unbindVertexArrayObject;
  31830. /**
  31831. * Bind a list of vertex buffers to the webGL context
  31832. * @param vertexBuffers defines the list of vertex buffers to bind
  31833. * @param indexBuffer defines the index buffer to bind
  31834. * @param effect defines the effect associated with the vertex buffers
  31835. */
  31836. bindBuffers(vertexBuffers: {
  31837. [key: string]: Nullable<VertexBuffer>;
  31838. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31839. /**
  31840. * Unbind all instance attributes
  31841. */
  31842. unbindInstanceAttributes(): void;
  31843. /**
  31844. * Release and free the memory of a vertex array object
  31845. * @param vao defines the vertex array object to delete
  31846. */
  31847. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31848. /** @hidden */
  31849. _releaseBuffer(buffer: DataBuffer): boolean;
  31850. protected _deleteBuffer(buffer: DataBuffer): void;
  31851. /**
  31852. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31853. * @param instancesBuffer defines the webGL buffer to update and bind
  31854. * @param data defines the data to store in the buffer
  31855. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31856. */
  31857. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31858. /**
  31859. * Apply all cached states (depth, culling, stencil and alpha)
  31860. */
  31861. applyStates(): void;
  31862. /**
  31863. * Send a draw order
  31864. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31865. * @param indexStart defines the starting index
  31866. * @param indexCount defines the number of index to draw
  31867. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31868. */
  31869. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31870. /**
  31871. * Draw a list of points
  31872. * @param verticesStart defines the index of first vertex to draw
  31873. * @param verticesCount defines the count of vertices to draw
  31874. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31875. */
  31876. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31877. /**
  31878. * Draw a list of unindexed primitives
  31879. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31880. * @param verticesStart defines the index of first vertex to draw
  31881. * @param verticesCount defines the count of vertices to draw
  31882. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31883. */
  31884. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31885. /**
  31886. * Draw a list of indexed primitives
  31887. * @param fillMode defines the primitive to use
  31888. * @param indexStart defines the starting index
  31889. * @param indexCount defines the number of index to draw
  31890. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31891. */
  31892. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31893. /**
  31894. * Draw a list of unindexed primitives
  31895. * @param fillMode defines the primitive to use
  31896. * @param verticesStart defines the index of first vertex to draw
  31897. * @param verticesCount defines the count of vertices to draw
  31898. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31899. */
  31900. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31901. private _drawMode;
  31902. /** @hidden */
  31903. protected _reportDrawCall(): void;
  31904. /** @hidden */
  31905. _releaseEffect(effect: Effect): void;
  31906. /** @hidden */
  31907. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31908. /**
  31909. * Create a new effect (used to store vertex/fragment shaders)
  31910. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31911. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  31912. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31913. * @param samplers defines an array of string used to represent textures
  31914. * @param defines defines the string containing the defines to use to compile the shaders
  31915. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31916. * @param onCompiled defines a function to call when the effect creation is successful
  31917. * @param onError defines a function to call when the effect creation has failed
  31918. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31919. * @returns the new Effect
  31920. */
  31921. createEffect(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  31922. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  31923. private _compileShader;
  31924. private _compileRawShader;
  31925. /**
  31926. * Directly creates a webGL program
  31927. * @param pipelineContext defines the pipeline context to attach to
  31928. * @param vertexCode defines the vertex shader code to use
  31929. * @param fragmentCode defines the fragment shader code to use
  31930. * @param context defines the webGL context to use (if not set, the current one will be used)
  31931. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31932. * @returns the new webGL program
  31933. */
  31934. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31935. /**
  31936. * Creates a webGL program
  31937. * @param pipelineContext defines the pipeline context to attach to
  31938. * @param vertexCode defines the vertex shader code to use
  31939. * @param fragmentCode defines the fragment shader code to use
  31940. * @param defines defines the string containing the defines to use to compile the shaders
  31941. * @param context defines the webGL context to use (if not set, the current one will be used)
  31942. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31943. * @returns the new webGL program
  31944. */
  31945. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31946. /**
  31947. * Creates a new pipeline context
  31948. * @returns the new pipeline
  31949. */
  31950. createPipelineContext(): IPipelineContext;
  31951. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31952. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  31953. /** @hidden */
  31954. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31955. /** @hidden */
  31956. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31957. /** @hidden */
  31958. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31959. /**
  31960. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31961. * @param pipelineContext defines the pipeline context to use
  31962. * @param uniformsNames defines the list of uniform names
  31963. * @returns an array of webGL uniform locations
  31964. */
  31965. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31966. /**
  31967. * Gets the lsit of active attributes for a given webGL program
  31968. * @param pipelineContext defines the pipeline context to use
  31969. * @param attributesNames defines the list of attribute names to get
  31970. * @returns an array of indices indicating the offset of each attribute
  31971. */
  31972. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31973. /**
  31974. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31975. * @param effect defines the effect to activate
  31976. */
  31977. enableEffect(effect: Nullable<Effect>): void;
  31978. /**
  31979. * Set the value of an uniform to a number (int)
  31980. * @param uniform defines the webGL uniform location where to store the value
  31981. * @param value defines the int number to store
  31982. */
  31983. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31984. /**
  31985. * Set the value of an uniform to an array of int32
  31986. * @param uniform defines the webGL uniform location where to store the value
  31987. * @param array defines the array of int32 to store
  31988. */
  31989. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31990. /**
  31991. * Set the value of an uniform to an array of int32 (stored as vec2)
  31992. * @param uniform defines the webGL uniform location where to store the value
  31993. * @param array defines the array of int32 to store
  31994. */
  31995. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31996. /**
  31997. * Set the value of an uniform to an array of int32 (stored as vec3)
  31998. * @param uniform defines the webGL uniform location where to store the value
  31999. * @param array defines the array of int32 to store
  32000. */
  32001. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32002. /**
  32003. * Set the value of an uniform to an array of int32 (stored as vec4)
  32004. * @param uniform defines the webGL uniform location where to store the value
  32005. * @param array defines the array of int32 to store
  32006. */
  32007. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32008. /**
  32009. * Set the value of an uniform to an array of number
  32010. * @param uniform defines the webGL uniform location where to store the value
  32011. * @param array defines the array of number to store
  32012. */
  32013. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32014. /**
  32015. * Set the value of an uniform to an array of number (stored as vec2)
  32016. * @param uniform defines the webGL uniform location where to store the value
  32017. * @param array defines the array of number to store
  32018. */
  32019. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32020. /**
  32021. * Set the value of an uniform to an array of number (stored as vec3)
  32022. * @param uniform defines the webGL uniform location where to store the value
  32023. * @param array defines the array of number to store
  32024. */
  32025. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32026. /**
  32027. * Set the value of an uniform to an array of number (stored as vec4)
  32028. * @param uniform defines the webGL uniform location where to store the value
  32029. * @param array defines the array of number to store
  32030. */
  32031. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32032. /**
  32033. * Set the value of an uniform to an array of float32 (stored as matrices)
  32034. * @param uniform defines the webGL uniform location where to store the value
  32035. * @param matrices defines the array of float32 to store
  32036. */
  32037. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  32038. /**
  32039. * Set the value of an uniform to a matrix (3x3)
  32040. * @param uniform defines the webGL uniform location where to store the value
  32041. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32042. */
  32043. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32044. /**
  32045. * Set the value of an uniform to a matrix (2x2)
  32046. * @param uniform defines the webGL uniform location where to store the value
  32047. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32048. */
  32049. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32050. /**
  32051. * Set the value of an uniform to a number (float)
  32052. * @param uniform defines the webGL uniform location where to store the value
  32053. * @param value defines the float number to store
  32054. */
  32055. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32056. /**
  32057. * Set the value of an uniform to a vec2
  32058. * @param uniform defines the webGL uniform location where to store the value
  32059. * @param x defines the 1st component of the value
  32060. * @param y defines the 2nd component of the value
  32061. */
  32062. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32063. /**
  32064. * Set the value of an uniform to a vec3
  32065. * @param uniform defines the webGL uniform location where to store the value
  32066. * @param x defines the 1st component of the value
  32067. * @param y defines the 2nd component of the value
  32068. * @param z defines the 3rd component of the value
  32069. */
  32070. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32071. /**
  32072. * Set the value of an uniform to a vec4
  32073. * @param uniform defines the webGL uniform location where to store the value
  32074. * @param x defines the 1st component of the value
  32075. * @param y defines the 2nd component of the value
  32076. * @param z defines the 3rd component of the value
  32077. * @param w defines the 4th component of the value
  32078. */
  32079. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32080. /**
  32081. * Gets the depth culling state manager
  32082. */
  32083. readonly depthCullingState: DepthCullingState;
  32084. /**
  32085. * Gets the alpha state manager
  32086. */
  32087. readonly alphaState: AlphaState;
  32088. /**
  32089. * Gets the stencil state manager
  32090. */
  32091. readonly stencilState: StencilState;
  32092. /**
  32093. * Clears the list of texture accessible through engine.
  32094. * This can help preventing texture load conflict due to name collision.
  32095. */
  32096. clearInternalTexturesCache(): void;
  32097. /**
  32098. * Force the entire cache to be cleared
  32099. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32100. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32101. */
  32102. wipeCaches(bruteForce?: boolean): void;
  32103. /** @hidden */
  32104. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32105. min: number;
  32106. mag: number;
  32107. };
  32108. /** @hidden */
  32109. _createTexture(): WebGLTexture;
  32110. /**
  32111. * Usually called from Texture.ts.
  32112. * Passed information to create a WebGLTexture
  32113. * @param urlArg defines a value which contains one of the following:
  32114. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32115. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32116. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32117. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32118. * @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)
  32119. * @param scene needed for loading to the correct scene
  32120. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32121. * @param onLoad optional callback to be called upon successful completion
  32122. * @param onError optional callback to be called upon failure
  32123. * @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
  32124. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32125. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32126. * @param forcedExtension defines the extension to use to pick the right loader
  32127. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  32128. * @param mimeType defines an optional mime type
  32129. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32130. */
  32131. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>, mimeType?: string): InternalTexture;
  32132. /**
  32133. * @hidden
  32134. */
  32135. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32136. /**
  32137. * Creates a raw texture
  32138. * @param data defines the data to store in the texture
  32139. * @param width defines the width of the texture
  32140. * @param height defines the height of the texture
  32141. * @param format defines the format of the data
  32142. * @param generateMipMaps defines if the engine should generate the mip levels
  32143. * @param invertY defines if data must be stored with Y axis inverted
  32144. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32145. * @param compression defines the compression used (null by default)
  32146. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  32147. * @returns the raw texture inside an InternalTexture
  32148. */
  32149. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  32150. /**
  32151. * Creates a new raw cube texture
  32152. * @param data defines the array of data to use to create each face
  32153. * @param size defines the size of the textures
  32154. * @param format defines the format of the data
  32155. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32156. * @param generateMipMaps defines if the engine should generate the mip levels
  32157. * @param invertY defines if data must be stored with Y axis inverted
  32158. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32159. * @param compression defines the compression used (null by default)
  32160. * @returns the cube texture as an InternalTexture
  32161. */
  32162. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  32163. /**
  32164. * Creates a new raw 3D texture
  32165. * @param data defines the data used to create the texture
  32166. * @param width defines the width of the texture
  32167. * @param height defines the height of the texture
  32168. * @param depth defines the depth of the texture
  32169. * @param format defines the format of the texture
  32170. * @param generateMipMaps defines if the engine must generate mip levels
  32171. * @param invertY defines if data must be stored with Y axis inverted
  32172. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32173. * @param compression defines the compressed used (can be null)
  32174. * @param textureType defines the compressed used (can be null)
  32175. * @returns a new raw 3D texture (stored in an InternalTexture)
  32176. */
  32177. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32178. /**
  32179. * Creates a new raw 2D array texture
  32180. * @param data defines the data used to create the texture
  32181. * @param width defines the width of the texture
  32182. * @param height defines the height of the texture
  32183. * @param depth defines the number of layers of the texture
  32184. * @param format defines the format of the texture
  32185. * @param generateMipMaps defines if the engine must generate mip levels
  32186. * @param invertY defines if data must be stored with Y axis inverted
  32187. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32188. * @param compression defines the compressed used (can be null)
  32189. * @param textureType defines the compressed used (can be null)
  32190. * @returns a new raw 2D array texture (stored in an InternalTexture)
  32191. */
  32192. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32193. private _unpackFlipYCached;
  32194. /**
  32195. * In case you are sharing the context with other applications, it might
  32196. * be interested to not cache the unpack flip y state to ensure a consistent
  32197. * value would be set.
  32198. */
  32199. enableUnpackFlipYCached: boolean;
  32200. /** @hidden */
  32201. _unpackFlipY(value: boolean): void;
  32202. /** @hidden */
  32203. _getUnpackAlignement(): number;
  32204. /**
  32205. * Update the sampling mode of a given texture
  32206. * @param samplingMode defines the required sampling mode
  32207. * @param texture defines the texture to update
  32208. */
  32209. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  32210. /** @hidden */
  32211. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32212. width: number;
  32213. height: number;
  32214. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32215. /** @hidden */
  32216. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32217. /** @hidden */
  32218. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32219. /** @hidden */
  32220. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32221. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32222. private _prepareWebGLTexture;
  32223. /** @hidden */
  32224. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32225. /** @hidden */
  32226. _releaseFramebufferObjects(texture: InternalTexture): void;
  32227. /** @hidden */
  32228. _releaseTexture(texture: InternalTexture): void;
  32229. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32230. protected _setProgram(program: WebGLProgram): void;
  32231. protected _boundUniforms: {
  32232. [key: number]: WebGLUniformLocation;
  32233. };
  32234. /**
  32235. * Binds an effect to the webGL context
  32236. * @param effect defines the effect to bind
  32237. */
  32238. bindSamplers(effect: Effect): void;
  32239. private _activateCurrentTexture;
  32240. /** @hidden */
  32241. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32242. /** @hidden */
  32243. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32244. /**
  32245. * Unbind all textures from the webGL context
  32246. */
  32247. unbindAllTextures(): void;
  32248. /**
  32249. * Sets a texture to the according uniform.
  32250. * @param channel The texture channel
  32251. * @param uniform The uniform to set
  32252. * @param texture The texture to apply
  32253. */
  32254. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32255. private _bindSamplerUniformToChannel;
  32256. private _getTextureWrapMode;
  32257. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32258. /**
  32259. * Sets an array of texture to the webGL context
  32260. * @param channel defines the channel where the texture array must be set
  32261. * @param uniform defines the associated uniform location
  32262. * @param textures defines the array of textures to bind
  32263. */
  32264. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32265. /** @hidden */
  32266. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  32267. private _setTextureParameterFloat;
  32268. private _setTextureParameterInteger;
  32269. /**
  32270. * Unbind all vertex attributes from the webGL context
  32271. */
  32272. unbindAllAttributes(): void;
  32273. /**
  32274. * 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
  32275. */
  32276. releaseEffects(): void;
  32277. /**
  32278. * Dispose and release all associated resources
  32279. */
  32280. dispose(): void;
  32281. /**
  32282. * Attach a new callback raised when context lost event is fired
  32283. * @param callback defines the callback to call
  32284. */
  32285. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32286. /**
  32287. * Attach a new callback raised when context restored event is fired
  32288. * @param callback defines the callback to call
  32289. */
  32290. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32291. /**
  32292. * Get the current error code of the webGL context
  32293. * @returns the error code
  32294. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32295. */
  32296. getError(): number;
  32297. private _canRenderToFloatFramebuffer;
  32298. private _canRenderToHalfFloatFramebuffer;
  32299. private _canRenderToFramebuffer;
  32300. /** @hidden */
  32301. _getWebGLTextureType(type: number): number;
  32302. /** @hidden */
  32303. _getInternalFormat(format: number): number;
  32304. /** @hidden */
  32305. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32306. /** @hidden */
  32307. _getRGBAMultiSampleBufferFormat(type: number): number;
  32308. /** @hidden */
  32309. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: IWebRequest, exception?: any) => void): IFileRequest;
  32310. /**
  32311. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32312. * @returns true if the engine can be created
  32313. * @ignorenaming
  32314. */
  32315. static isSupported(): boolean;
  32316. /**
  32317. * Find the next highest power of two.
  32318. * @param x Number to start search from.
  32319. * @return Next highest power of two.
  32320. */
  32321. static CeilingPOT(x: number): number;
  32322. /**
  32323. * Find the next lowest power of two.
  32324. * @param x Number to start search from.
  32325. * @return Next lowest power of two.
  32326. */
  32327. static FloorPOT(x: number): number;
  32328. /**
  32329. * Find the nearest power of two.
  32330. * @param x Number to start search from.
  32331. * @return Next nearest power of two.
  32332. */
  32333. static NearestPOT(x: number): number;
  32334. /**
  32335. * Get the closest exponent of two
  32336. * @param value defines the value to approximate
  32337. * @param max defines the maximum value to return
  32338. * @param mode defines how to define the closest value
  32339. * @returns closest exponent of two of the given value
  32340. */
  32341. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32342. /**
  32343. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32344. * @param func - the function to be called
  32345. * @param requester - the object that will request the next frame. Falls back to window.
  32346. * @returns frame number
  32347. */
  32348. static QueueNewFrame(func: () => void, requester?: any): number;
  32349. /**
  32350. * Gets host document
  32351. * @returns the host document object
  32352. */
  32353. getHostDocument(): Document;
  32354. }
  32355. }
  32356. declare module "babylonjs/Maths/sphericalPolynomial" {
  32357. import { Vector3 } from "babylonjs/Maths/math.vector";
  32358. import { Color3 } from "babylonjs/Maths/math.color";
  32359. /**
  32360. * Class representing spherical harmonics coefficients to the 3rd degree
  32361. */
  32362. export class SphericalHarmonics {
  32363. /**
  32364. * Defines whether or not the harmonics have been prescaled for rendering.
  32365. */
  32366. preScaled: boolean;
  32367. /**
  32368. * The l0,0 coefficients of the spherical harmonics
  32369. */
  32370. l00: Vector3;
  32371. /**
  32372. * The l1,-1 coefficients of the spherical harmonics
  32373. */
  32374. l1_1: Vector3;
  32375. /**
  32376. * The l1,0 coefficients of the spherical harmonics
  32377. */
  32378. l10: Vector3;
  32379. /**
  32380. * The l1,1 coefficients of the spherical harmonics
  32381. */
  32382. l11: Vector3;
  32383. /**
  32384. * The l2,-2 coefficients of the spherical harmonics
  32385. */
  32386. l2_2: Vector3;
  32387. /**
  32388. * The l2,-1 coefficients of the spherical harmonics
  32389. */
  32390. l2_1: Vector3;
  32391. /**
  32392. * The l2,0 coefficients of the spherical harmonics
  32393. */
  32394. l20: Vector3;
  32395. /**
  32396. * The l2,1 coefficients of the spherical harmonics
  32397. */
  32398. l21: Vector3;
  32399. /**
  32400. * The l2,2 coefficients of the spherical harmonics
  32401. */
  32402. l22: Vector3;
  32403. /**
  32404. * Adds a light to the spherical harmonics
  32405. * @param direction the direction of the light
  32406. * @param color the color of the light
  32407. * @param deltaSolidAngle the delta solid angle of the light
  32408. */
  32409. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  32410. /**
  32411. * Scales the spherical harmonics by the given amount
  32412. * @param scale the amount to scale
  32413. */
  32414. scaleInPlace(scale: number): void;
  32415. /**
  32416. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  32417. *
  32418. * ```
  32419. * E_lm = A_l * L_lm
  32420. * ```
  32421. *
  32422. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  32423. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  32424. * the scaling factors are given in equation 9.
  32425. */
  32426. convertIncidentRadianceToIrradiance(): void;
  32427. /**
  32428. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  32429. *
  32430. * ```
  32431. * L = (1/pi) * E * rho
  32432. * ```
  32433. *
  32434. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  32435. */
  32436. convertIrradianceToLambertianRadiance(): void;
  32437. /**
  32438. * Integrates the reconstruction coefficients directly in to the SH preventing further
  32439. * required operations at run time.
  32440. *
  32441. * This is simply done by scaling back the SH with Ylm constants parameter.
  32442. * The trigonometric part being applied by the shader at run time.
  32443. */
  32444. preScaleForRendering(): void;
  32445. /**
  32446. * Constructs a spherical harmonics from an array.
  32447. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  32448. * @returns the spherical harmonics
  32449. */
  32450. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  32451. /**
  32452. * Gets the spherical harmonics from polynomial
  32453. * @param polynomial the spherical polynomial
  32454. * @returns the spherical harmonics
  32455. */
  32456. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  32457. }
  32458. /**
  32459. * Class representing spherical polynomial coefficients to the 3rd degree
  32460. */
  32461. export class SphericalPolynomial {
  32462. private _harmonics;
  32463. /**
  32464. * The spherical harmonics used to create the polynomials.
  32465. */
  32466. readonly preScaledHarmonics: SphericalHarmonics;
  32467. /**
  32468. * The x coefficients of the spherical polynomial
  32469. */
  32470. x: Vector3;
  32471. /**
  32472. * The y coefficients of the spherical polynomial
  32473. */
  32474. y: Vector3;
  32475. /**
  32476. * The z coefficients of the spherical polynomial
  32477. */
  32478. z: Vector3;
  32479. /**
  32480. * The xx coefficients of the spherical polynomial
  32481. */
  32482. xx: Vector3;
  32483. /**
  32484. * The yy coefficients of the spherical polynomial
  32485. */
  32486. yy: Vector3;
  32487. /**
  32488. * The zz coefficients of the spherical polynomial
  32489. */
  32490. zz: Vector3;
  32491. /**
  32492. * The xy coefficients of the spherical polynomial
  32493. */
  32494. xy: Vector3;
  32495. /**
  32496. * The yz coefficients of the spherical polynomial
  32497. */
  32498. yz: Vector3;
  32499. /**
  32500. * The zx coefficients of the spherical polynomial
  32501. */
  32502. zx: Vector3;
  32503. /**
  32504. * Adds an ambient color to the spherical polynomial
  32505. * @param color the color to add
  32506. */
  32507. addAmbient(color: Color3): void;
  32508. /**
  32509. * Scales the spherical polynomial by the given amount
  32510. * @param scale the amount to scale
  32511. */
  32512. scaleInPlace(scale: number): void;
  32513. /**
  32514. * Gets the spherical polynomial from harmonics
  32515. * @param harmonics the spherical harmonics
  32516. * @returns the spherical polynomial
  32517. */
  32518. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  32519. /**
  32520. * Constructs a spherical polynomial from an array.
  32521. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  32522. * @returns the spherical polynomial
  32523. */
  32524. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  32525. }
  32526. }
  32527. declare module "babylonjs/Materials/Textures/internalTexture" {
  32528. import { Observable } from "babylonjs/Misc/observable";
  32529. import { Nullable, int } from "babylonjs/types";
  32530. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  32531. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32532. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  32533. /**
  32534. * Defines the source of the internal texture
  32535. */
  32536. export enum InternalTextureSource {
  32537. /**
  32538. * The source of the texture data is unknown
  32539. */
  32540. Unknown = 0,
  32541. /**
  32542. * Texture data comes from an URL
  32543. */
  32544. Url = 1,
  32545. /**
  32546. * Texture data is only used for temporary storage
  32547. */
  32548. Temp = 2,
  32549. /**
  32550. * Texture data comes from raw data (ArrayBuffer)
  32551. */
  32552. Raw = 3,
  32553. /**
  32554. * Texture content is dynamic (video or dynamic texture)
  32555. */
  32556. Dynamic = 4,
  32557. /**
  32558. * Texture content is generated by rendering to it
  32559. */
  32560. RenderTarget = 5,
  32561. /**
  32562. * Texture content is part of a multi render target process
  32563. */
  32564. MultiRenderTarget = 6,
  32565. /**
  32566. * Texture data comes from a cube data file
  32567. */
  32568. Cube = 7,
  32569. /**
  32570. * Texture data comes from a raw cube data
  32571. */
  32572. CubeRaw = 8,
  32573. /**
  32574. * Texture data come from a prefiltered cube data file
  32575. */
  32576. CubePrefiltered = 9,
  32577. /**
  32578. * Texture content is raw 3D data
  32579. */
  32580. Raw3D = 10,
  32581. /**
  32582. * Texture content is raw 2D array data
  32583. */
  32584. Raw2DArray = 11,
  32585. /**
  32586. * Texture content is a depth texture
  32587. */
  32588. Depth = 12,
  32589. /**
  32590. * Texture data comes from a raw cube data encoded with RGBD
  32591. */
  32592. CubeRawRGBD = 13
  32593. }
  32594. /**
  32595. * Class used to store data associated with WebGL texture data for the engine
  32596. * This class should not be used directly
  32597. */
  32598. export class InternalTexture {
  32599. /** @hidden */
  32600. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  32601. /**
  32602. * Defines if the texture is ready
  32603. */
  32604. isReady: boolean;
  32605. /**
  32606. * Defines if the texture is a cube texture
  32607. */
  32608. isCube: boolean;
  32609. /**
  32610. * Defines if the texture contains 3D data
  32611. */
  32612. is3D: boolean;
  32613. /**
  32614. * Defines if the texture contains 2D array data
  32615. */
  32616. is2DArray: boolean;
  32617. /**
  32618. * Defines if the texture contains multiview data
  32619. */
  32620. isMultiview: boolean;
  32621. /**
  32622. * Gets the URL used to load this texture
  32623. */
  32624. url: string;
  32625. /**
  32626. * Gets the sampling mode of the texture
  32627. */
  32628. samplingMode: number;
  32629. /**
  32630. * Gets a boolean indicating if the texture needs mipmaps generation
  32631. */
  32632. generateMipMaps: boolean;
  32633. /**
  32634. * Gets the number of samples used by the texture (WebGL2+ only)
  32635. */
  32636. samples: number;
  32637. /**
  32638. * Gets the type of the texture (int, float...)
  32639. */
  32640. type: number;
  32641. /**
  32642. * Gets the format of the texture (RGB, RGBA...)
  32643. */
  32644. format: number;
  32645. /**
  32646. * Observable called when the texture is loaded
  32647. */
  32648. onLoadedObservable: Observable<InternalTexture>;
  32649. /**
  32650. * Gets the width of the texture
  32651. */
  32652. width: number;
  32653. /**
  32654. * Gets the height of the texture
  32655. */
  32656. height: number;
  32657. /**
  32658. * Gets the depth of the texture
  32659. */
  32660. depth: number;
  32661. /**
  32662. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  32663. */
  32664. baseWidth: number;
  32665. /**
  32666. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  32667. */
  32668. baseHeight: number;
  32669. /**
  32670. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  32671. */
  32672. baseDepth: number;
  32673. /**
  32674. * Gets a boolean indicating if the texture is inverted on Y axis
  32675. */
  32676. invertY: boolean;
  32677. /** @hidden */
  32678. _invertVScale: boolean;
  32679. /** @hidden */
  32680. _associatedChannel: number;
  32681. /** @hidden */
  32682. _source: InternalTextureSource;
  32683. /** @hidden */
  32684. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  32685. /** @hidden */
  32686. _bufferView: Nullable<ArrayBufferView>;
  32687. /** @hidden */
  32688. _bufferViewArray: Nullable<ArrayBufferView[]>;
  32689. /** @hidden */
  32690. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  32691. /** @hidden */
  32692. _size: number;
  32693. /** @hidden */
  32694. _extension: string;
  32695. /** @hidden */
  32696. _files: Nullable<string[]>;
  32697. /** @hidden */
  32698. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32699. /** @hidden */
  32700. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32701. /** @hidden */
  32702. _framebuffer: Nullable<WebGLFramebuffer>;
  32703. /** @hidden */
  32704. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  32705. /** @hidden */
  32706. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  32707. /** @hidden */
  32708. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  32709. /** @hidden */
  32710. _attachments: Nullable<number[]>;
  32711. /** @hidden */
  32712. _cachedCoordinatesMode: Nullable<number>;
  32713. /** @hidden */
  32714. _cachedWrapU: Nullable<number>;
  32715. /** @hidden */
  32716. _cachedWrapV: Nullable<number>;
  32717. /** @hidden */
  32718. _cachedWrapR: Nullable<number>;
  32719. /** @hidden */
  32720. _cachedAnisotropicFilteringLevel: Nullable<number>;
  32721. /** @hidden */
  32722. _isDisabled: boolean;
  32723. /** @hidden */
  32724. _compression: Nullable<string>;
  32725. /** @hidden */
  32726. _generateStencilBuffer: boolean;
  32727. /** @hidden */
  32728. _generateDepthBuffer: boolean;
  32729. /** @hidden */
  32730. _comparisonFunction: number;
  32731. /** @hidden */
  32732. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  32733. /** @hidden */
  32734. _lodGenerationScale: number;
  32735. /** @hidden */
  32736. _lodGenerationOffset: number;
  32737. /** @hidden */
  32738. _colorTextureArray: Nullable<WebGLTexture>;
  32739. /** @hidden */
  32740. _depthStencilTextureArray: Nullable<WebGLTexture>;
  32741. /** @hidden */
  32742. _lodTextureHigh: Nullable<BaseTexture>;
  32743. /** @hidden */
  32744. _lodTextureMid: Nullable<BaseTexture>;
  32745. /** @hidden */
  32746. _lodTextureLow: Nullable<BaseTexture>;
  32747. /** @hidden */
  32748. _isRGBD: boolean;
  32749. /** @hidden */
  32750. _linearSpecularLOD: boolean;
  32751. /** @hidden */
  32752. _irradianceTexture: Nullable<BaseTexture>;
  32753. /** @hidden */
  32754. _webGLTexture: Nullable<WebGLTexture>;
  32755. /** @hidden */
  32756. _references: number;
  32757. private _engine;
  32758. /**
  32759. * Gets the Engine the texture belongs to.
  32760. * @returns The babylon engine
  32761. */
  32762. getEngine(): ThinEngine;
  32763. /**
  32764. * Gets the data source type of the texture
  32765. */
  32766. readonly source: InternalTextureSource;
  32767. /**
  32768. * Creates a new InternalTexture
  32769. * @param engine defines the engine to use
  32770. * @param source defines the type of data that will be used
  32771. * @param delayAllocation if the texture allocation should be delayed (default: false)
  32772. */
  32773. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  32774. /**
  32775. * Increments the number of references (ie. the number of Texture that point to it)
  32776. */
  32777. incrementReferences(): void;
  32778. /**
  32779. * Change the size of the texture (not the size of the content)
  32780. * @param width defines the new width
  32781. * @param height defines the new height
  32782. * @param depth defines the new depth (1 by default)
  32783. */
  32784. updateSize(width: int, height: int, depth?: int): void;
  32785. /** @hidden */
  32786. _rebuild(): void;
  32787. /** @hidden */
  32788. _swapAndDie(target: InternalTexture): void;
  32789. /**
  32790. * Dispose the current allocated resources
  32791. */
  32792. dispose(): void;
  32793. }
  32794. }
  32795. declare module "babylonjs/Audio/analyser" {
  32796. import { Scene } from "babylonjs/scene";
  32797. /**
  32798. * Class used to work with sound analyzer using fast fourier transform (FFT)
  32799. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32800. */
  32801. export class Analyser {
  32802. /**
  32803. * Gets or sets the smoothing
  32804. * @ignorenaming
  32805. */
  32806. SMOOTHING: number;
  32807. /**
  32808. * Gets or sets the FFT table size
  32809. * @ignorenaming
  32810. */
  32811. FFT_SIZE: number;
  32812. /**
  32813. * Gets or sets the bar graph amplitude
  32814. * @ignorenaming
  32815. */
  32816. BARGRAPHAMPLITUDE: number;
  32817. /**
  32818. * Gets or sets the position of the debug canvas
  32819. * @ignorenaming
  32820. */
  32821. DEBUGCANVASPOS: {
  32822. x: number;
  32823. y: number;
  32824. };
  32825. /**
  32826. * Gets or sets the debug canvas size
  32827. * @ignorenaming
  32828. */
  32829. DEBUGCANVASSIZE: {
  32830. width: number;
  32831. height: number;
  32832. };
  32833. private _byteFreqs;
  32834. private _byteTime;
  32835. private _floatFreqs;
  32836. private _webAudioAnalyser;
  32837. private _debugCanvas;
  32838. private _debugCanvasContext;
  32839. private _scene;
  32840. private _registerFunc;
  32841. private _audioEngine;
  32842. /**
  32843. * Creates a new analyser
  32844. * @param scene defines hosting scene
  32845. */
  32846. constructor(scene: Scene);
  32847. /**
  32848. * Get the number of data values you will have to play with for the visualization
  32849. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  32850. * @returns a number
  32851. */
  32852. getFrequencyBinCount(): number;
  32853. /**
  32854. * Gets the current frequency data as a byte array
  32855. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32856. * @returns a Uint8Array
  32857. */
  32858. getByteFrequencyData(): Uint8Array;
  32859. /**
  32860. * Gets the current waveform as a byte array
  32861. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  32862. * @returns a Uint8Array
  32863. */
  32864. getByteTimeDomainData(): Uint8Array;
  32865. /**
  32866. * Gets the current frequency data as a float array
  32867. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32868. * @returns a Float32Array
  32869. */
  32870. getFloatFrequencyData(): Float32Array;
  32871. /**
  32872. * Renders the debug canvas
  32873. */
  32874. drawDebugCanvas(): void;
  32875. /**
  32876. * Stops rendering the debug canvas and removes it
  32877. */
  32878. stopDebugCanvas(): void;
  32879. /**
  32880. * Connects two audio nodes
  32881. * @param inputAudioNode defines first node to connect
  32882. * @param outputAudioNode defines second node to connect
  32883. */
  32884. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  32885. /**
  32886. * Releases all associated resources
  32887. */
  32888. dispose(): void;
  32889. }
  32890. }
  32891. declare module "babylonjs/Audio/audioEngine" {
  32892. import { IDisposable } from "babylonjs/scene";
  32893. import { Analyser } from "babylonjs/Audio/analyser";
  32894. import { Nullable } from "babylonjs/types";
  32895. import { Observable } from "babylonjs/Misc/observable";
  32896. /**
  32897. * This represents an audio engine and it is responsible
  32898. * to play, synchronize and analyse sounds throughout the application.
  32899. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32900. */
  32901. export interface IAudioEngine extends IDisposable {
  32902. /**
  32903. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32904. */
  32905. readonly canUseWebAudio: boolean;
  32906. /**
  32907. * Gets the current AudioContext if available.
  32908. */
  32909. readonly audioContext: Nullable<AudioContext>;
  32910. /**
  32911. * The master gain node defines the global audio volume of your audio engine.
  32912. */
  32913. readonly masterGain: GainNode;
  32914. /**
  32915. * Gets whether or not mp3 are supported by your browser.
  32916. */
  32917. readonly isMP3supported: boolean;
  32918. /**
  32919. * Gets whether or not ogg are supported by your browser.
  32920. */
  32921. readonly isOGGsupported: boolean;
  32922. /**
  32923. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32924. * @ignoreNaming
  32925. */
  32926. WarnedWebAudioUnsupported: boolean;
  32927. /**
  32928. * Defines if the audio engine relies on a custom unlocked button.
  32929. * In this case, the embedded button will not be displayed.
  32930. */
  32931. useCustomUnlockedButton: boolean;
  32932. /**
  32933. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  32934. */
  32935. readonly unlocked: boolean;
  32936. /**
  32937. * Event raised when audio has been unlocked on the browser.
  32938. */
  32939. onAudioUnlockedObservable: Observable<AudioEngine>;
  32940. /**
  32941. * Event raised when audio has been locked on the browser.
  32942. */
  32943. onAudioLockedObservable: Observable<AudioEngine>;
  32944. /**
  32945. * Flags the audio engine in Locked state.
  32946. * This happens due to new browser policies preventing audio to autoplay.
  32947. */
  32948. lock(): void;
  32949. /**
  32950. * Unlocks the audio engine once a user action has been done on the dom.
  32951. * This is helpful to resume play once browser policies have been satisfied.
  32952. */
  32953. unlock(): void;
  32954. }
  32955. /**
  32956. * This represents the default audio engine used in babylon.
  32957. * It is responsible to play, synchronize and analyse sounds throughout the application.
  32958. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32959. */
  32960. export class AudioEngine implements IAudioEngine {
  32961. private _audioContext;
  32962. private _audioContextInitialized;
  32963. private _muteButton;
  32964. private _hostElement;
  32965. /**
  32966. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32967. */
  32968. canUseWebAudio: boolean;
  32969. /**
  32970. * The master gain node defines the global audio volume of your audio engine.
  32971. */
  32972. masterGain: GainNode;
  32973. /**
  32974. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32975. * @ignoreNaming
  32976. */
  32977. WarnedWebAudioUnsupported: boolean;
  32978. /**
  32979. * Gets whether or not mp3 are supported by your browser.
  32980. */
  32981. isMP3supported: boolean;
  32982. /**
  32983. * Gets whether or not ogg are supported by your browser.
  32984. */
  32985. isOGGsupported: boolean;
  32986. /**
  32987. * Gets whether audio has been unlocked on the device.
  32988. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  32989. * a user interaction has happened.
  32990. */
  32991. unlocked: boolean;
  32992. /**
  32993. * Defines if the audio engine relies on a custom unlocked button.
  32994. * In this case, the embedded button will not be displayed.
  32995. */
  32996. useCustomUnlockedButton: boolean;
  32997. /**
  32998. * Event raised when audio has been unlocked on the browser.
  32999. */
  33000. onAudioUnlockedObservable: Observable<AudioEngine>;
  33001. /**
  33002. * Event raised when audio has been locked on the browser.
  33003. */
  33004. onAudioLockedObservable: Observable<AudioEngine>;
  33005. /**
  33006. * Gets the current AudioContext if available.
  33007. */
  33008. readonly audioContext: Nullable<AudioContext>;
  33009. private _connectedAnalyser;
  33010. /**
  33011. * Instantiates a new audio engine.
  33012. *
  33013. * There should be only one per page as some browsers restrict the number
  33014. * of audio contexts you can create.
  33015. * @param hostElement defines the host element where to display the mute icon if necessary
  33016. */
  33017. constructor(hostElement?: Nullable<HTMLElement>);
  33018. /**
  33019. * Flags the audio engine in Locked state.
  33020. * This happens due to new browser policies preventing audio to autoplay.
  33021. */
  33022. lock(): void;
  33023. /**
  33024. * Unlocks the audio engine once a user action has been done on the dom.
  33025. * This is helpful to resume play once browser policies have been satisfied.
  33026. */
  33027. unlock(): void;
  33028. private _resumeAudioContext;
  33029. private _initializeAudioContext;
  33030. private _tryToRun;
  33031. private _triggerRunningState;
  33032. private _triggerSuspendedState;
  33033. private _displayMuteButton;
  33034. private _moveButtonToTopLeft;
  33035. private _onResize;
  33036. private _hideMuteButton;
  33037. /**
  33038. * Destroy and release the resources associated with the audio ccontext.
  33039. */
  33040. dispose(): void;
  33041. /**
  33042. * Gets the global volume sets on the master gain.
  33043. * @returns the global volume if set or -1 otherwise
  33044. */
  33045. getGlobalVolume(): number;
  33046. /**
  33047. * Sets the global volume of your experience (sets on the master gain).
  33048. * @param newVolume Defines the new global volume of the application
  33049. */
  33050. setGlobalVolume(newVolume: number): void;
  33051. /**
  33052. * Connect the audio engine to an audio analyser allowing some amazing
  33053. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33054. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33055. * @param analyser The analyser to connect to the engine
  33056. */
  33057. connectToAnalyser(analyser: Analyser): void;
  33058. }
  33059. }
  33060. declare module "babylonjs/Loading/loadingScreen" {
  33061. /**
  33062. * Interface used to present a loading screen while loading a scene
  33063. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33064. */
  33065. export interface ILoadingScreen {
  33066. /**
  33067. * Function called to display the loading screen
  33068. */
  33069. displayLoadingUI: () => void;
  33070. /**
  33071. * Function called to hide the loading screen
  33072. */
  33073. hideLoadingUI: () => void;
  33074. /**
  33075. * Gets or sets the color to use for the background
  33076. */
  33077. loadingUIBackgroundColor: string;
  33078. /**
  33079. * Gets or sets the text to display while loading
  33080. */
  33081. loadingUIText: string;
  33082. }
  33083. /**
  33084. * Class used for the default loading screen
  33085. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33086. */
  33087. export class DefaultLoadingScreen implements ILoadingScreen {
  33088. private _renderingCanvas;
  33089. private _loadingText;
  33090. private _loadingDivBackgroundColor;
  33091. private _loadingDiv;
  33092. private _loadingTextDiv;
  33093. /** Gets or sets the logo url to use for the default loading screen */
  33094. static DefaultLogoUrl: string;
  33095. /** Gets or sets the spinner url to use for the default loading screen */
  33096. static DefaultSpinnerUrl: string;
  33097. /**
  33098. * Creates a new default loading screen
  33099. * @param _renderingCanvas defines the canvas used to render the scene
  33100. * @param _loadingText defines the default text to display
  33101. * @param _loadingDivBackgroundColor defines the default background color
  33102. */
  33103. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  33104. /**
  33105. * Function called to display the loading screen
  33106. */
  33107. displayLoadingUI(): void;
  33108. /**
  33109. * Function called to hide the loading screen
  33110. */
  33111. hideLoadingUI(): void;
  33112. /**
  33113. * Gets or sets the text to display while loading
  33114. */
  33115. loadingUIText: string;
  33116. /**
  33117. * Gets or sets the color to use for the background
  33118. */
  33119. loadingUIBackgroundColor: string;
  33120. private _resizeLoadingUI;
  33121. }
  33122. }
  33123. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  33124. /**
  33125. * Interface for any object that can request an animation frame
  33126. */
  33127. export interface ICustomAnimationFrameRequester {
  33128. /**
  33129. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  33130. */
  33131. renderFunction?: Function;
  33132. /**
  33133. * Called to request the next frame to render to
  33134. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  33135. */
  33136. requestAnimationFrame: Function;
  33137. /**
  33138. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  33139. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  33140. */
  33141. requestID?: number;
  33142. }
  33143. }
  33144. declare module "babylonjs/Misc/performanceMonitor" {
  33145. /**
  33146. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  33147. */
  33148. export class PerformanceMonitor {
  33149. private _enabled;
  33150. private _rollingFrameTime;
  33151. private _lastFrameTimeMs;
  33152. /**
  33153. * constructor
  33154. * @param frameSampleSize The number of samples required to saturate the sliding window
  33155. */
  33156. constructor(frameSampleSize?: number);
  33157. /**
  33158. * Samples current frame
  33159. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  33160. */
  33161. sampleFrame(timeMs?: number): void;
  33162. /**
  33163. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33164. */
  33165. readonly averageFrameTime: number;
  33166. /**
  33167. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33168. */
  33169. readonly averageFrameTimeVariance: number;
  33170. /**
  33171. * Returns the frame time of the most recent frame
  33172. */
  33173. readonly instantaneousFrameTime: number;
  33174. /**
  33175. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  33176. */
  33177. readonly averageFPS: number;
  33178. /**
  33179. * Returns the average framerate in frames per second using the most recent frame time
  33180. */
  33181. readonly instantaneousFPS: number;
  33182. /**
  33183. * Returns true if enough samples have been taken to completely fill the sliding window
  33184. */
  33185. readonly isSaturated: boolean;
  33186. /**
  33187. * Enables contributions to the sliding window sample set
  33188. */
  33189. enable(): void;
  33190. /**
  33191. * Disables contributions to the sliding window sample set
  33192. * Samples will not be interpolated over the disabled period
  33193. */
  33194. disable(): void;
  33195. /**
  33196. * Returns true if sampling is enabled
  33197. */
  33198. readonly isEnabled: boolean;
  33199. /**
  33200. * Resets performance monitor
  33201. */
  33202. reset(): void;
  33203. }
  33204. /**
  33205. * RollingAverage
  33206. *
  33207. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  33208. */
  33209. export class RollingAverage {
  33210. /**
  33211. * Current average
  33212. */
  33213. average: number;
  33214. /**
  33215. * Current variance
  33216. */
  33217. variance: number;
  33218. protected _samples: Array<number>;
  33219. protected _sampleCount: number;
  33220. protected _pos: number;
  33221. protected _m2: number;
  33222. /**
  33223. * constructor
  33224. * @param length The number of samples required to saturate the sliding window
  33225. */
  33226. constructor(length: number);
  33227. /**
  33228. * Adds a sample to the sample set
  33229. * @param v The sample value
  33230. */
  33231. add(v: number): void;
  33232. /**
  33233. * Returns previously added values or null if outside of history or outside the sliding window domain
  33234. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  33235. * @return Value previously recorded with add() or null if outside of range
  33236. */
  33237. history(i: number): number;
  33238. /**
  33239. * Returns true if enough samples have been taken to completely fill the sliding window
  33240. * @return true if sample-set saturated
  33241. */
  33242. isSaturated(): boolean;
  33243. /**
  33244. * Resets the rolling average (equivalent to 0 samples taken so far)
  33245. */
  33246. reset(): void;
  33247. /**
  33248. * Wraps a value around the sample range boundaries
  33249. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  33250. * @return Wrapped position in sample range
  33251. */
  33252. protected _wrapPosition(i: number): number;
  33253. }
  33254. }
  33255. declare module "babylonjs/Misc/perfCounter" {
  33256. /**
  33257. * This class is used to track a performance counter which is number based.
  33258. * The user has access to many properties which give statistics of different nature.
  33259. *
  33260. * The implementer can track two kinds of Performance Counter: time and count.
  33261. * 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.
  33262. * 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.
  33263. */
  33264. export class PerfCounter {
  33265. /**
  33266. * Gets or sets a global boolean to turn on and off all the counters
  33267. */
  33268. static Enabled: boolean;
  33269. /**
  33270. * Returns the smallest value ever
  33271. */
  33272. readonly min: number;
  33273. /**
  33274. * Returns the biggest value ever
  33275. */
  33276. readonly max: number;
  33277. /**
  33278. * Returns the average value since the performance counter is running
  33279. */
  33280. readonly average: number;
  33281. /**
  33282. * Returns the average value of the last second the counter was monitored
  33283. */
  33284. readonly lastSecAverage: number;
  33285. /**
  33286. * Returns the current value
  33287. */
  33288. readonly current: number;
  33289. /**
  33290. * Gets the accumulated total
  33291. */
  33292. readonly total: number;
  33293. /**
  33294. * Gets the total value count
  33295. */
  33296. readonly count: number;
  33297. /**
  33298. * Creates a new counter
  33299. */
  33300. constructor();
  33301. /**
  33302. * Call this method to start monitoring a new frame.
  33303. * 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.
  33304. */
  33305. fetchNewFrame(): void;
  33306. /**
  33307. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  33308. * @param newCount the count value to add to the monitored count
  33309. * @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.
  33310. */
  33311. addCount(newCount: number, fetchResult: boolean): void;
  33312. /**
  33313. * Start monitoring this performance counter
  33314. */
  33315. beginMonitoring(): void;
  33316. /**
  33317. * Compute the time lapsed since the previous beginMonitoring() call.
  33318. * @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
  33319. */
  33320. endMonitoring(newFrame?: boolean): void;
  33321. private _fetchResult;
  33322. private _startMonitoringTime;
  33323. private _min;
  33324. private _max;
  33325. private _average;
  33326. private _current;
  33327. private _totalValueCount;
  33328. private _totalAccumulated;
  33329. private _lastSecAverage;
  33330. private _lastSecAccumulated;
  33331. private _lastSecTime;
  33332. private _lastSecValueCount;
  33333. }
  33334. }
  33335. declare module "babylonjs/Engines/engine" {
  33336. import { Observable } from "babylonjs/Misc/observable";
  33337. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  33338. import { Scene } from "babylonjs/scene";
  33339. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  33340. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  33341. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33342. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  33343. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  33344. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  33345. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  33346. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  33347. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  33348. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33349. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  33350. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  33351. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  33352. import { Material } from "babylonjs/Materials/material";
  33353. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33354. /**
  33355. * Defines the interface used by display changed events
  33356. */
  33357. export interface IDisplayChangedEventArgs {
  33358. /** Gets the vrDisplay object (if any) */
  33359. vrDisplay: Nullable<any>;
  33360. /** Gets a boolean indicating if webVR is supported */
  33361. vrSupported: boolean;
  33362. }
  33363. /**
  33364. * Defines the interface used by objects containing a viewport (like a camera)
  33365. */
  33366. interface IViewportOwnerLike {
  33367. /**
  33368. * Gets or sets the viewport
  33369. */
  33370. viewport: IViewportLike;
  33371. }
  33372. /**
  33373. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  33374. */
  33375. export class Engine extends ThinEngine {
  33376. /** Defines that alpha blending is disabled */
  33377. static readonly ALPHA_DISABLE: number;
  33378. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  33379. static readonly ALPHA_ADD: number;
  33380. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  33381. static readonly ALPHA_COMBINE: number;
  33382. /** Defines that alpha blending to DEST - SRC * DEST */
  33383. static readonly ALPHA_SUBTRACT: number;
  33384. /** Defines that alpha blending to SRC * DEST */
  33385. static readonly ALPHA_MULTIPLY: number;
  33386. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  33387. static readonly ALPHA_MAXIMIZED: number;
  33388. /** Defines that alpha blending to SRC + DEST */
  33389. static readonly ALPHA_ONEONE: number;
  33390. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  33391. static readonly ALPHA_PREMULTIPLIED: number;
  33392. /**
  33393. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  33394. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  33395. */
  33396. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  33397. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  33398. static readonly ALPHA_INTERPOLATE: number;
  33399. /**
  33400. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  33401. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  33402. */
  33403. static readonly ALPHA_SCREENMODE: number;
  33404. /** Defines that the ressource is not delayed*/
  33405. static readonly DELAYLOADSTATE_NONE: number;
  33406. /** Defines that the ressource was successfully delay loaded */
  33407. static readonly DELAYLOADSTATE_LOADED: number;
  33408. /** Defines that the ressource is currently delay loading */
  33409. static readonly DELAYLOADSTATE_LOADING: number;
  33410. /** Defines that the ressource is delayed and has not started loading */
  33411. static readonly DELAYLOADSTATE_NOTLOADED: number;
  33412. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  33413. static readonly NEVER: number;
  33414. /** 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 */
  33415. static readonly ALWAYS: number;
  33416. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  33417. static readonly LESS: number;
  33418. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  33419. static readonly EQUAL: number;
  33420. /** 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 */
  33421. static readonly LEQUAL: number;
  33422. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  33423. static readonly GREATER: number;
  33424. /** 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 */
  33425. static readonly GEQUAL: number;
  33426. /** 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 */
  33427. static readonly NOTEQUAL: number;
  33428. /** Passed to stencilOperation to specify that stencil value must be kept */
  33429. static readonly KEEP: number;
  33430. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33431. static readonly REPLACE: number;
  33432. /** Passed to stencilOperation to specify that stencil value must be incremented */
  33433. static readonly INCR: number;
  33434. /** Passed to stencilOperation to specify that stencil value must be decremented */
  33435. static readonly DECR: number;
  33436. /** Passed to stencilOperation to specify that stencil value must be inverted */
  33437. static readonly INVERT: number;
  33438. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  33439. static readonly INCR_WRAP: number;
  33440. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  33441. static readonly DECR_WRAP: number;
  33442. /** Texture is not repeating outside of 0..1 UVs */
  33443. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  33444. /** Texture is repeating outside of 0..1 UVs */
  33445. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  33446. /** Texture is repeating and mirrored */
  33447. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  33448. /** ALPHA */
  33449. static readonly TEXTUREFORMAT_ALPHA: number;
  33450. /** LUMINANCE */
  33451. static readonly TEXTUREFORMAT_LUMINANCE: number;
  33452. /** LUMINANCE_ALPHA */
  33453. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  33454. /** RGB */
  33455. static readonly TEXTUREFORMAT_RGB: number;
  33456. /** RGBA */
  33457. static readonly TEXTUREFORMAT_RGBA: number;
  33458. /** RED */
  33459. static readonly TEXTUREFORMAT_RED: number;
  33460. /** RED (2nd reference) */
  33461. static readonly TEXTUREFORMAT_R: number;
  33462. /** RG */
  33463. static readonly TEXTUREFORMAT_RG: number;
  33464. /** RED_INTEGER */
  33465. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  33466. /** RED_INTEGER (2nd reference) */
  33467. static readonly TEXTUREFORMAT_R_INTEGER: number;
  33468. /** RG_INTEGER */
  33469. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  33470. /** RGB_INTEGER */
  33471. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  33472. /** RGBA_INTEGER */
  33473. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  33474. /** UNSIGNED_BYTE */
  33475. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  33476. /** UNSIGNED_BYTE (2nd reference) */
  33477. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  33478. /** FLOAT */
  33479. static readonly TEXTURETYPE_FLOAT: number;
  33480. /** HALF_FLOAT */
  33481. static readonly TEXTURETYPE_HALF_FLOAT: number;
  33482. /** BYTE */
  33483. static readonly TEXTURETYPE_BYTE: number;
  33484. /** SHORT */
  33485. static readonly TEXTURETYPE_SHORT: number;
  33486. /** UNSIGNED_SHORT */
  33487. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  33488. /** INT */
  33489. static readonly TEXTURETYPE_INT: number;
  33490. /** UNSIGNED_INT */
  33491. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  33492. /** UNSIGNED_SHORT_4_4_4_4 */
  33493. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  33494. /** UNSIGNED_SHORT_5_5_5_1 */
  33495. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  33496. /** UNSIGNED_SHORT_5_6_5 */
  33497. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  33498. /** UNSIGNED_INT_2_10_10_10_REV */
  33499. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  33500. /** UNSIGNED_INT_24_8 */
  33501. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  33502. /** UNSIGNED_INT_10F_11F_11F_REV */
  33503. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  33504. /** UNSIGNED_INT_5_9_9_9_REV */
  33505. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  33506. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  33507. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  33508. /** nearest is mag = nearest and min = nearest and mip = linear */
  33509. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  33510. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33511. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  33512. /** Trilinear is mag = linear and min = linear and mip = linear */
  33513. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  33514. /** nearest is mag = nearest and min = nearest and mip = linear */
  33515. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  33516. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33517. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  33518. /** Trilinear is mag = linear and min = linear and mip = linear */
  33519. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  33520. /** mag = nearest and min = nearest and mip = nearest */
  33521. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  33522. /** mag = nearest and min = linear and mip = nearest */
  33523. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  33524. /** mag = nearest and min = linear and mip = linear */
  33525. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  33526. /** mag = nearest and min = linear and mip = none */
  33527. static readonly TEXTURE_NEAREST_LINEAR: number;
  33528. /** mag = nearest and min = nearest and mip = none */
  33529. static readonly TEXTURE_NEAREST_NEAREST: number;
  33530. /** mag = linear and min = nearest and mip = nearest */
  33531. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  33532. /** mag = linear and min = nearest and mip = linear */
  33533. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  33534. /** mag = linear and min = linear and mip = none */
  33535. static readonly TEXTURE_LINEAR_LINEAR: number;
  33536. /** mag = linear and min = nearest and mip = none */
  33537. static readonly TEXTURE_LINEAR_NEAREST: number;
  33538. /** Explicit coordinates mode */
  33539. static readonly TEXTURE_EXPLICIT_MODE: number;
  33540. /** Spherical coordinates mode */
  33541. static readonly TEXTURE_SPHERICAL_MODE: number;
  33542. /** Planar coordinates mode */
  33543. static readonly TEXTURE_PLANAR_MODE: number;
  33544. /** Cubic coordinates mode */
  33545. static readonly TEXTURE_CUBIC_MODE: number;
  33546. /** Projection coordinates mode */
  33547. static readonly TEXTURE_PROJECTION_MODE: number;
  33548. /** Skybox coordinates mode */
  33549. static readonly TEXTURE_SKYBOX_MODE: number;
  33550. /** Inverse Cubic coordinates mode */
  33551. static readonly TEXTURE_INVCUBIC_MODE: number;
  33552. /** Equirectangular coordinates mode */
  33553. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  33554. /** Equirectangular Fixed coordinates mode */
  33555. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  33556. /** Equirectangular Fixed Mirrored coordinates mode */
  33557. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  33558. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  33559. static readonly SCALEMODE_FLOOR: number;
  33560. /** Defines that texture rescaling will look for the nearest power of 2 size */
  33561. static readonly SCALEMODE_NEAREST: number;
  33562. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  33563. static readonly SCALEMODE_CEILING: number;
  33564. /**
  33565. * Returns the current npm package of the sdk
  33566. */
  33567. static readonly NpmPackage: string;
  33568. /**
  33569. * Returns the current version of the framework
  33570. */
  33571. static readonly Version: string;
  33572. /** Gets the list of created engines */
  33573. static readonly Instances: Engine[];
  33574. /**
  33575. * Gets the latest created engine
  33576. */
  33577. static readonly LastCreatedEngine: Nullable<Engine>;
  33578. /**
  33579. * Gets the latest created scene
  33580. */
  33581. static readonly LastCreatedScene: Nullable<Scene>;
  33582. /**
  33583. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  33584. * @param flag defines which part of the materials must be marked as dirty
  33585. * @param predicate defines a predicate used to filter which materials should be affected
  33586. */
  33587. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33588. /**
  33589. * Method called to create the default loading screen.
  33590. * This can be overriden in your own app.
  33591. * @param canvas The rendering canvas element
  33592. * @returns The loading screen
  33593. */
  33594. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  33595. /**
  33596. * Method called to create the default rescale post process on each engine.
  33597. */
  33598. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  33599. /**
  33600. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  33601. **/
  33602. enableOfflineSupport: boolean;
  33603. /**
  33604. * 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)
  33605. **/
  33606. disableManifestCheck: boolean;
  33607. /**
  33608. * Gets the list of created scenes
  33609. */
  33610. scenes: Scene[];
  33611. /**
  33612. * Event raised when a new scene is created
  33613. */
  33614. onNewSceneAddedObservable: Observable<Scene>;
  33615. /**
  33616. * Gets the list of created postprocesses
  33617. */
  33618. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  33619. /**
  33620. * Gets a boolean indicating if the pointer is currently locked
  33621. */
  33622. isPointerLock: boolean;
  33623. /**
  33624. * Observable event triggered each time the rendering canvas is resized
  33625. */
  33626. onResizeObservable: Observable<Engine>;
  33627. /**
  33628. * Observable event triggered each time the canvas loses focus
  33629. */
  33630. onCanvasBlurObservable: Observable<Engine>;
  33631. /**
  33632. * Observable event triggered each time the canvas gains focus
  33633. */
  33634. onCanvasFocusObservable: Observable<Engine>;
  33635. /**
  33636. * Observable event triggered each time the canvas receives pointerout event
  33637. */
  33638. onCanvasPointerOutObservable: Observable<PointerEvent>;
  33639. /**
  33640. * Observable raised when the engine begins a new frame
  33641. */
  33642. onBeginFrameObservable: Observable<Engine>;
  33643. /**
  33644. * If set, will be used to request the next animation frame for the render loop
  33645. */
  33646. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  33647. /**
  33648. * Observable raised when the engine ends the current frame
  33649. */
  33650. onEndFrameObservable: Observable<Engine>;
  33651. /**
  33652. * Observable raised when the engine is about to compile a shader
  33653. */
  33654. onBeforeShaderCompilationObservable: Observable<Engine>;
  33655. /**
  33656. * Observable raised when the engine has jsut compiled a shader
  33657. */
  33658. onAfterShaderCompilationObservable: Observable<Engine>;
  33659. /**
  33660. * Gets the audio engine
  33661. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33662. * @ignorenaming
  33663. */
  33664. static audioEngine: IAudioEngine;
  33665. /**
  33666. * Default AudioEngine factory responsible of creating the Audio Engine.
  33667. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  33668. */
  33669. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  33670. /**
  33671. * Default offline support factory responsible of creating a tool used to store data locally.
  33672. * By default, this will create a Database object if the workload has been embedded.
  33673. */
  33674. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  33675. private _loadingScreen;
  33676. private _pointerLockRequested;
  33677. private _dummyFramebuffer;
  33678. private _rescalePostProcess;
  33679. /** @hidden */
  33680. protected _alphaMode: number;
  33681. /** @hidden */
  33682. protected _alphaEquation: number;
  33683. private _deterministicLockstep;
  33684. private _lockstepMaxSteps;
  33685. private _timeStep;
  33686. protected readonly _supportsHardwareTextureRescaling: boolean;
  33687. private _fps;
  33688. private _deltaTime;
  33689. /** @hidden */
  33690. _drawCalls: PerfCounter;
  33691. /**
  33692. * Turn this value on if you want to pause FPS computation when in background
  33693. */
  33694. disablePerformanceMonitorInBackground: boolean;
  33695. private _performanceMonitor;
  33696. /**
  33697. * Gets the performance monitor attached to this engine
  33698. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  33699. */
  33700. readonly performanceMonitor: PerformanceMonitor;
  33701. private _onFocus;
  33702. private _onBlur;
  33703. private _onCanvasPointerOut;
  33704. private _onCanvasBlur;
  33705. private _onCanvasFocus;
  33706. private _onFullscreenChange;
  33707. private _onPointerLockChange;
  33708. /**
  33709. * Gets the HTML element used to attach event listeners
  33710. * @returns a HTML element
  33711. */
  33712. getInputElement(): Nullable<HTMLElement>;
  33713. /**
  33714. * Creates a new engine
  33715. * @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
  33716. * @param antialias defines enable antialiasing (default: false)
  33717. * @param options defines further options to be sent to the getContext() function
  33718. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  33719. */
  33720. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  33721. /**
  33722. * Gets current aspect ratio
  33723. * @param viewportOwner defines the camera to use to get the aspect ratio
  33724. * @param useScreen defines if screen size must be used (or the current render target if any)
  33725. * @returns a number defining the aspect ratio
  33726. */
  33727. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  33728. /**
  33729. * Gets current screen aspect ratio
  33730. * @returns a number defining the aspect ratio
  33731. */
  33732. getScreenAspectRatio(): number;
  33733. /**
  33734. * Gets the client rect of the HTML canvas attached with the current webGL context
  33735. * @returns a client rectanglee
  33736. */
  33737. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  33738. /**
  33739. * Gets the client rect of the HTML element used for events
  33740. * @returns a client rectanglee
  33741. */
  33742. getInputElementClientRect(): Nullable<ClientRect>;
  33743. /**
  33744. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  33745. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33746. * @returns true if engine is in deterministic lock step mode
  33747. */
  33748. isDeterministicLockStep(): boolean;
  33749. /**
  33750. * Gets the max steps when engine is running in deterministic lock step
  33751. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33752. * @returns the max steps
  33753. */
  33754. getLockstepMaxSteps(): number;
  33755. /**
  33756. * Returns the time in ms between steps when using deterministic lock step.
  33757. * @returns time step in (ms)
  33758. */
  33759. getTimeStep(): number;
  33760. /**
  33761. * Force the mipmap generation for the given render target texture
  33762. * @param texture defines the render target texture to use
  33763. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  33764. */
  33765. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  33766. /** States */
  33767. /**
  33768. * Set various states to the webGL context
  33769. * @param culling defines backface culling state
  33770. * @param zOffset defines the value to apply to zOffset (0 by default)
  33771. * @param force defines if states must be applied even if cache is up to date
  33772. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  33773. */
  33774. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  33775. /**
  33776. * Set the z offset to apply to current rendering
  33777. * @param value defines the offset to apply
  33778. */
  33779. setZOffset(value: number): void;
  33780. /**
  33781. * Gets the current value of the zOffset
  33782. * @returns the current zOffset state
  33783. */
  33784. getZOffset(): number;
  33785. /**
  33786. * Enable or disable depth buffering
  33787. * @param enable defines the state to set
  33788. */
  33789. setDepthBuffer(enable: boolean): void;
  33790. /**
  33791. * Gets a boolean indicating if depth writing is enabled
  33792. * @returns the current depth writing state
  33793. */
  33794. getDepthWrite(): boolean;
  33795. /**
  33796. * Enable or disable depth writing
  33797. * @param enable defines the state to set
  33798. */
  33799. setDepthWrite(enable: boolean): void;
  33800. /**
  33801. * Enable or disable color writing
  33802. * @param enable defines the state to set
  33803. */
  33804. setColorWrite(enable: boolean): void;
  33805. /**
  33806. * Gets a boolean indicating if color writing is enabled
  33807. * @returns the current color writing state
  33808. */
  33809. getColorWrite(): boolean;
  33810. /**
  33811. * Sets alpha constants used by some alpha blending modes
  33812. * @param r defines the red component
  33813. * @param g defines the green component
  33814. * @param b defines the blue component
  33815. * @param a defines the alpha component
  33816. */
  33817. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  33818. /**
  33819. * Sets the current alpha mode
  33820. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  33821. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  33822. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33823. */
  33824. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  33825. /**
  33826. * Gets the current alpha mode
  33827. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33828. * @returns the current alpha mode
  33829. */
  33830. getAlphaMode(): number;
  33831. /**
  33832. * Sets the current alpha equation
  33833. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  33834. */
  33835. setAlphaEquation(equation: number): void;
  33836. /**
  33837. * Gets the current alpha equation.
  33838. * @returns the current alpha equation
  33839. */
  33840. getAlphaEquation(): number;
  33841. /**
  33842. * Gets a boolean indicating if stencil buffer is enabled
  33843. * @returns the current stencil buffer state
  33844. */
  33845. getStencilBuffer(): boolean;
  33846. /**
  33847. * Enable or disable the stencil buffer
  33848. * @param enable defines if the stencil buffer must be enabled or disabled
  33849. */
  33850. setStencilBuffer(enable: boolean): void;
  33851. /**
  33852. * Gets the current stencil mask
  33853. * @returns a number defining the new stencil mask to use
  33854. */
  33855. getStencilMask(): number;
  33856. /**
  33857. * Sets the current stencil mask
  33858. * @param mask defines the new stencil mask to use
  33859. */
  33860. setStencilMask(mask: number): void;
  33861. /**
  33862. * Gets the current stencil function
  33863. * @returns a number defining the stencil function to use
  33864. */
  33865. getStencilFunction(): number;
  33866. /**
  33867. * Gets the current stencil reference value
  33868. * @returns a number defining the stencil reference value to use
  33869. */
  33870. getStencilFunctionReference(): number;
  33871. /**
  33872. * Gets the current stencil mask
  33873. * @returns a number defining the stencil mask to use
  33874. */
  33875. getStencilFunctionMask(): number;
  33876. /**
  33877. * Sets the current stencil function
  33878. * @param stencilFunc defines the new stencil function to use
  33879. */
  33880. setStencilFunction(stencilFunc: number): void;
  33881. /**
  33882. * Sets the current stencil reference
  33883. * @param reference defines the new stencil reference to use
  33884. */
  33885. setStencilFunctionReference(reference: number): void;
  33886. /**
  33887. * Sets the current stencil mask
  33888. * @param mask defines the new stencil mask to use
  33889. */
  33890. setStencilFunctionMask(mask: number): void;
  33891. /**
  33892. * Gets the current stencil operation when stencil fails
  33893. * @returns a number defining stencil operation to use when stencil fails
  33894. */
  33895. getStencilOperationFail(): number;
  33896. /**
  33897. * Gets the current stencil operation when depth fails
  33898. * @returns a number defining stencil operation to use when depth fails
  33899. */
  33900. getStencilOperationDepthFail(): number;
  33901. /**
  33902. * Gets the current stencil operation when stencil passes
  33903. * @returns a number defining stencil operation to use when stencil passes
  33904. */
  33905. getStencilOperationPass(): number;
  33906. /**
  33907. * Sets the stencil operation to use when stencil fails
  33908. * @param operation defines the stencil operation to use when stencil fails
  33909. */
  33910. setStencilOperationFail(operation: number): void;
  33911. /**
  33912. * Sets the stencil operation to use when depth fails
  33913. * @param operation defines the stencil operation to use when depth fails
  33914. */
  33915. setStencilOperationDepthFail(operation: number): void;
  33916. /**
  33917. * Sets the stencil operation to use when stencil passes
  33918. * @param operation defines the stencil operation to use when stencil passes
  33919. */
  33920. setStencilOperationPass(operation: number): void;
  33921. /**
  33922. * Sets a boolean indicating if the dithering state is enabled or disabled
  33923. * @param value defines the dithering state
  33924. */
  33925. setDitheringState(value: boolean): void;
  33926. /**
  33927. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  33928. * @param value defines the rasterizer state
  33929. */
  33930. setRasterizerState(value: boolean): void;
  33931. /**
  33932. * Gets the current depth function
  33933. * @returns a number defining the depth function
  33934. */
  33935. getDepthFunction(): Nullable<number>;
  33936. /**
  33937. * Sets the current depth function
  33938. * @param depthFunc defines the function to use
  33939. */
  33940. setDepthFunction(depthFunc: number): void;
  33941. /**
  33942. * Sets the current depth function to GREATER
  33943. */
  33944. setDepthFunctionToGreater(): void;
  33945. /**
  33946. * Sets the current depth function to GEQUAL
  33947. */
  33948. setDepthFunctionToGreaterOrEqual(): void;
  33949. /**
  33950. * Sets the current depth function to LESS
  33951. */
  33952. setDepthFunctionToLess(): void;
  33953. /**
  33954. * Sets the current depth function to LEQUAL
  33955. */
  33956. setDepthFunctionToLessOrEqual(): void;
  33957. private _cachedStencilBuffer;
  33958. private _cachedStencilFunction;
  33959. private _cachedStencilMask;
  33960. private _cachedStencilOperationPass;
  33961. private _cachedStencilOperationFail;
  33962. private _cachedStencilOperationDepthFail;
  33963. private _cachedStencilReference;
  33964. /**
  33965. * Caches the the state of the stencil buffer
  33966. */
  33967. cacheStencilState(): void;
  33968. /**
  33969. * Restores the state of the stencil buffer
  33970. */
  33971. restoreStencilState(): void;
  33972. /**
  33973. * Directly set the WebGL Viewport
  33974. * @param x defines the x coordinate of the viewport (in screen space)
  33975. * @param y defines the y coordinate of the viewport (in screen space)
  33976. * @param width defines the width of the viewport (in screen space)
  33977. * @param height defines the height of the viewport (in screen space)
  33978. * @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
  33979. */
  33980. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  33981. /**
  33982. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  33983. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33984. * @param y defines the y-coordinate of the corner of the clear rectangle
  33985. * @param width defines the width of the clear rectangle
  33986. * @param height defines the height of the clear rectangle
  33987. * @param clearColor defines the clear color
  33988. */
  33989. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  33990. /**
  33991. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  33992. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33993. * @param y defines the y-coordinate of the corner of the clear rectangle
  33994. * @param width defines the width of the clear rectangle
  33995. * @param height defines the height of the clear rectangle
  33996. */
  33997. enableScissor(x: number, y: number, width: number, height: number): void;
  33998. /**
  33999. * Disable previously set scissor test rectangle
  34000. */
  34001. disableScissor(): void;
  34002. protected _reportDrawCall(): void;
  34003. /**
  34004. * Initializes a webVR display and starts listening to display change events
  34005. * The onVRDisplayChangedObservable will be notified upon these changes
  34006. * @returns The onVRDisplayChangedObservable
  34007. */
  34008. initWebVR(): Observable<IDisplayChangedEventArgs>;
  34009. /** @hidden */
  34010. _prepareVRComponent(): void;
  34011. /** @hidden */
  34012. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  34013. /** @hidden */
  34014. _submitVRFrame(): void;
  34015. /**
  34016. * Call this function to leave webVR mode
  34017. * Will do nothing if webVR is not supported or if there is no webVR device
  34018. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34019. */
  34020. disableVR(): void;
  34021. /**
  34022. * Gets a boolean indicating that the system is in VR mode and is presenting
  34023. * @returns true if VR mode is engaged
  34024. */
  34025. isVRPresenting(): boolean;
  34026. /** @hidden */
  34027. _requestVRFrame(): void;
  34028. /** @hidden */
  34029. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34030. /**
  34031. * Gets the source code of the vertex shader associated with a specific webGL program
  34032. * @param program defines the program to use
  34033. * @returns a string containing the source code of the vertex shader associated with the program
  34034. */
  34035. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  34036. /**
  34037. * Gets the source code of the fragment shader associated with a specific webGL program
  34038. * @param program defines the program to use
  34039. * @returns a string containing the source code of the fragment shader associated with the program
  34040. */
  34041. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  34042. /**
  34043. * Reads pixels from the current frame buffer. Please note that this function can be slow
  34044. * @param x defines the x coordinate of the rectangle where pixels must be read
  34045. * @param y defines the y coordinate of the rectangle where pixels must be read
  34046. * @param width defines the width of the rectangle where pixels must be read
  34047. * @param height defines the height of the rectangle where pixels must be read
  34048. * @returns a Uint8Array containing RGBA colors
  34049. */
  34050. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  34051. /**
  34052. * Sets a depth stencil texture from a render target to the according uniform.
  34053. * @param channel The texture channel
  34054. * @param uniform The uniform to set
  34055. * @param texture The render target texture containing the depth stencil texture to apply
  34056. */
  34057. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  34058. /**
  34059. * Sets a texture to the webGL context from a postprocess
  34060. * @param channel defines the channel to use
  34061. * @param postProcess defines the source postprocess
  34062. */
  34063. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  34064. /**
  34065. * Binds the output of the passed in post process to the texture channel specified
  34066. * @param channel The channel the texture should be bound to
  34067. * @param postProcess The post process which's output should be bound
  34068. */
  34069. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  34070. /** @hidden */
  34071. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  34072. protected _rebuildBuffers(): void;
  34073. /** @hidden */
  34074. _renderFrame(): void;
  34075. _renderLoop(): void;
  34076. /** @hidden */
  34077. _renderViews(): boolean;
  34078. /**
  34079. * Toggle full screen mode
  34080. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34081. */
  34082. switchFullscreen(requestPointerLock: boolean): void;
  34083. /**
  34084. * Enters full screen mode
  34085. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34086. */
  34087. enterFullscreen(requestPointerLock: boolean): void;
  34088. /**
  34089. * Exits full screen mode
  34090. */
  34091. exitFullscreen(): void;
  34092. /**
  34093. * Enters Pointerlock mode
  34094. */
  34095. enterPointerlock(): void;
  34096. /**
  34097. * Exits Pointerlock mode
  34098. */
  34099. exitPointerlock(): void;
  34100. /**
  34101. * Begin a new frame
  34102. */
  34103. beginFrame(): void;
  34104. /**
  34105. * Enf the current frame
  34106. */
  34107. endFrame(): void;
  34108. resize(): void;
  34109. /**
  34110. * Set the compressed texture format to use, based on the formats you have, and the formats
  34111. * supported by the hardware / browser.
  34112. *
  34113. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  34114. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  34115. * to API arguments needed to compressed textures. This puts the burden on the container
  34116. * generator to house the arcane code for determining these for current & future formats.
  34117. *
  34118. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  34119. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  34120. *
  34121. * Note: The result of this call is not taken into account when a texture is base64.
  34122. *
  34123. * @param formatsAvailable defines the list of those format families you have created
  34124. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  34125. *
  34126. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  34127. * @returns The extension selected.
  34128. */
  34129. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  34130. /**
  34131. * Set the compressed texture extensions or file names to skip.
  34132. *
  34133. * @param skippedFiles defines the list of those texture files you want to skip
  34134. * Example: [".dds", ".env", "myfile.png"]
  34135. */
  34136. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  34137. /**
  34138. * Force a specific size of the canvas
  34139. * @param width defines the new canvas' width
  34140. * @param height defines the new canvas' height
  34141. */
  34142. setSize(width: number, height: number): void;
  34143. /**
  34144. * Updates a dynamic vertex buffer.
  34145. * @param vertexBuffer the vertex buffer to update
  34146. * @param data the data used to update the vertex buffer
  34147. * @param byteOffset the byte offset of the data
  34148. * @param byteLength the byte length of the data
  34149. */
  34150. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  34151. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34152. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34153. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34154. _releaseTexture(texture: InternalTexture): void;
  34155. /**
  34156. * @hidden
  34157. * Rescales a texture
  34158. * @param source input texutre
  34159. * @param destination destination texture
  34160. * @param scene scene to use to render the resize
  34161. * @param internalFormat format to use when resizing
  34162. * @param onComplete callback to be called when resize has completed
  34163. */
  34164. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34165. /**
  34166. * Gets the current framerate
  34167. * @returns a number representing the framerate
  34168. */
  34169. getFps(): number;
  34170. /**
  34171. * Gets the time spent between current and previous frame
  34172. * @returns a number representing the delta time in ms
  34173. */
  34174. getDeltaTime(): number;
  34175. private _measureFps;
  34176. /** @hidden */
  34177. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  34178. /**
  34179. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  34180. * @param renderTarget The render target to set the frame buffer for
  34181. */
  34182. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  34183. /**
  34184. * Update a dynamic index buffer
  34185. * @param indexBuffer defines the target index buffer
  34186. * @param indices defines the data to update
  34187. * @param offset defines the offset in the target index buffer where update should start
  34188. */
  34189. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  34190. /**
  34191. * Updates the sample count of a render target texture
  34192. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  34193. * @param texture defines the texture to update
  34194. * @param samples defines the sample count to set
  34195. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  34196. */
  34197. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  34198. /**
  34199. * Updates a depth texture Comparison Mode and Function.
  34200. * If the comparison Function is equal to 0, the mode will be set to none.
  34201. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  34202. * @param texture The texture to set the comparison function for
  34203. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  34204. */
  34205. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  34206. /**
  34207. * Creates a webGL buffer to use with instanciation
  34208. * @param capacity defines the size of the buffer
  34209. * @returns the webGL buffer
  34210. */
  34211. createInstancesBuffer(capacity: number): DataBuffer;
  34212. /**
  34213. * Delete a webGL buffer used with instanciation
  34214. * @param buffer defines the webGL buffer to delete
  34215. */
  34216. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  34217. /** @hidden */
  34218. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  34219. dispose(): void;
  34220. private _disableTouchAction;
  34221. /**
  34222. * Display the loading screen
  34223. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34224. */
  34225. displayLoadingUI(): void;
  34226. /**
  34227. * Hide the loading screen
  34228. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34229. */
  34230. hideLoadingUI(): void;
  34231. /**
  34232. * Gets the current loading screen object
  34233. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34234. */
  34235. /**
  34236. * Sets the current loading screen object
  34237. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34238. */
  34239. loadingScreen: ILoadingScreen;
  34240. /**
  34241. * Sets the current loading screen text
  34242. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34243. */
  34244. loadingUIText: string;
  34245. /**
  34246. * Sets the current loading screen background color
  34247. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34248. */
  34249. loadingUIBackgroundColor: string;
  34250. /** Pointerlock and fullscreen */
  34251. /**
  34252. * Ask the browser to promote the current element to pointerlock mode
  34253. * @param element defines the DOM element to promote
  34254. */
  34255. static _RequestPointerlock(element: HTMLElement): void;
  34256. /**
  34257. * Asks the browser to exit pointerlock mode
  34258. */
  34259. static _ExitPointerlock(): void;
  34260. /**
  34261. * Ask the browser to promote the current element to fullscreen rendering mode
  34262. * @param element defines the DOM element to promote
  34263. */
  34264. static _RequestFullscreen(element: HTMLElement): void;
  34265. /**
  34266. * Asks the browser to exit fullscreen mode
  34267. */
  34268. static _ExitFullscreen(): void;
  34269. }
  34270. }
  34271. declare module "babylonjs/Engines/engineStore" {
  34272. import { Nullable } from "babylonjs/types";
  34273. import { Engine } from "babylonjs/Engines/engine";
  34274. import { Scene } from "babylonjs/scene";
  34275. /**
  34276. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34277. * during the life time of the application.
  34278. */
  34279. export class EngineStore {
  34280. /** Gets the list of created engines */
  34281. static Instances: import("babylonjs/Engines/engine").Engine[];
  34282. /** @hidden */
  34283. static _LastCreatedScene: Nullable<Scene>;
  34284. /**
  34285. * Gets the latest created engine
  34286. */
  34287. static readonly LastCreatedEngine: Nullable<Engine>;
  34288. /**
  34289. * Gets the latest created scene
  34290. */
  34291. static readonly LastCreatedScene: Nullable<Scene>;
  34292. /**
  34293. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34294. * @ignorenaming
  34295. */
  34296. static UseFallbackTexture: boolean;
  34297. /**
  34298. * Texture content used if a texture cannot loaded
  34299. * @ignorenaming
  34300. */
  34301. static FallbackTexture: string;
  34302. }
  34303. }
  34304. declare module "babylonjs/Misc/promise" {
  34305. /**
  34306. * Helper class that provides a small promise polyfill
  34307. */
  34308. export class PromisePolyfill {
  34309. /**
  34310. * Static function used to check if the polyfill is required
  34311. * If this is the case then the function will inject the polyfill to window.Promise
  34312. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  34313. */
  34314. static Apply(force?: boolean): void;
  34315. }
  34316. }
  34317. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  34318. /**
  34319. * Interface for screenshot methods with describe argument called `size` as object with options
  34320. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  34321. */
  34322. export interface IScreenshotSize {
  34323. /**
  34324. * number in pixels for canvas height
  34325. */
  34326. height?: number;
  34327. /**
  34328. * multiplier allowing render at a higher or lower resolution
  34329. * If value is defined then height and width will be ignored and taken from camera
  34330. */
  34331. precision?: number;
  34332. /**
  34333. * number in pixels for canvas width
  34334. */
  34335. width?: number;
  34336. }
  34337. }
  34338. declare module "babylonjs/Misc/tools" {
  34339. import { Nullable, float } from "babylonjs/types";
  34340. import { DomManagement } from "babylonjs/Misc/domManagement";
  34341. import { WebRequest } from "babylonjs/Misc/webRequest";
  34342. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  34343. import { ReadFileError } from "babylonjs/Misc/fileTools";
  34344. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34345. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  34346. import { Camera } from "babylonjs/Cameras/camera";
  34347. import { Engine } from "babylonjs/Engines/engine";
  34348. interface IColor4Like {
  34349. r: float;
  34350. g: float;
  34351. b: float;
  34352. a: float;
  34353. }
  34354. /**
  34355. * Class containing a set of static utilities functions
  34356. */
  34357. export class Tools {
  34358. /**
  34359. * Gets or sets the base URL to use to load assets
  34360. */
  34361. static BaseUrl: string;
  34362. /**
  34363. * Enable/Disable Custom HTTP Request Headers globally.
  34364. * default = false
  34365. * @see CustomRequestHeaders
  34366. */
  34367. static UseCustomRequestHeaders: boolean;
  34368. /**
  34369. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  34370. * i.e. when loading files, where the server/service expects an Authorization header
  34371. */
  34372. static CustomRequestHeaders: {
  34373. [key: string]: string;
  34374. };
  34375. /**
  34376. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  34377. */
  34378. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  34379. /**
  34380. * Default behaviour for cors in the application.
  34381. * It can be a string if the expected behavior is identical in the entire app.
  34382. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  34383. */
  34384. static CorsBehavior: string | ((url: string | string[]) => string);
  34385. /**
  34386. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34387. * @ignorenaming
  34388. */
  34389. static UseFallbackTexture: boolean;
  34390. /**
  34391. * Use this object to register external classes like custom textures or material
  34392. * to allow the laoders to instantiate them
  34393. */
  34394. static RegisteredExternalClasses: {
  34395. [key: string]: Object;
  34396. };
  34397. /**
  34398. * Texture content used if a texture cannot loaded
  34399. * @ignorenaming
  34400. */
  34401. static fallbackTexture: string;
  34402. /**
  34403. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  34404. * @param u defines the coordinate on X axis
  34405. * @param v defines the coordinate on Y axis
  34406. * @param width defines the width of the source data
  34407. * @param height defines the height of the source data
  34408. * @param pixels defines the source byte array
  34409. * @param color defines the output color
  34410. */
  34411. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  34412. /**
  34413. * Interpolates between a and b via alpha
  34414. * @param a The lower value (returned when alpha = 0)
  34415. * @param b The upper value (returned when alpha = 1)
  34416. * @param alpha The interpolation-factor
  34417. * @return The mixed value
  34418. */
  34419. static Mix(a: number, b: number, alpha: number): number;
  34420. /**
  34421. * Tries to instantiate a new object from a given class name
  34422. * @param className defines the class name to instantiate
  34423. * @returns the new object or null if the system was not able to do the instantiation
  34424. */
  34425. static Instantiate(className: string): any;
  34426. /**
  34427. * Provides a slice function that will work even on IE
  34428. * @param data defines the array to slice
  34429. * @param start defines the start of the data (optional)
  34430. * @param end defines the end of the data (optional)
  34431. * @returns the new sliced array
  34432. */
  34433. static Slice<T>(data: T, start?: number, end?: number): T;
  34434. /**
  34435. * Polyfill for setImmediate
  34436. * @param action defines the action to execute after the current execution block
  34437. */
  34438. static SetImmediate(action: () => void): void;
  34439. /**
  34440. * Function indicating if a number is an exponent of 2
  34441. * @param value defines the value to test
  34442. * @returns true if the value is an exponent of 2
  34443. */
  34444. static IsExponentOfTwo(value: number): boolean;
  34445. private static _tmpFloatArray;
  34446. /**
  34447. * Returns the nearest 32-bit single precision float representation of a Number
  34448. * @param value A Number. If the parameter is of a different type, it will get converted
  34449. * to a number or to NaN if it cannot be converted
  34450. * @returns number
  34451. */
  34452. static FloatRound(value: number): number;
  34453. /**
  34454. * Extracts the filename from a path
  34455. * @param path defines the path to use
  34456. * @returns the filename
  34457. */
  34458. static GetFilename(path: string): string;
  34459. /**
  34460. * Extracts the "folder" part of a path (everything before the filename).
  34461. * @param uri The URI to extract the info from
  34462. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  34463. * @returns The "folder" part of the path
  34464. */
  34465. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  34466. /**
  34467. * Extracts text content from a DOM element hierarchy
  34468. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  34469. */
  34470. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  34471. /**
  34472. * Convert an angle in radians to degrees
  34473. * @param angle defines the angle to convert
  34474. * @returns the angle in degrees
  34475. */
  34476. static ToDegrees(angle: number): number;
  34477. /**
  34478. * Convert an angle in degrees to radians
  34479. * @param angle defines the angle to convert
  34480. * @returns the angle in radians
  34481. */
  34482. static ToRadians(angle: number): number;
  34483. /**
  34484. * Returns an array if obj is not an array
  34485. * @param obj defines the object to evaluate as an array
  34486. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  34487. * @returns either obj directly if obj is an array or a new array containing obj
  34488. */
  34489. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  34490. /**
  34491. * Gets the pointer prefix to use
  34492. * @returns "pointer" if touch is enabled. Else returns "mouse"
  34493. */
  34494. static GetPointerPrefix(): string;
  34495. /**
  34496. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  34497. * @param url define the url we are trying
  34498. * @param element define the dom element where to configure the cors policy
  34499. */
  34500. static SetCorsBehavior(url: string | string[], element: {
  34501. crossOrigin: string | null;
  34502. }): void;
  34503. /**
  34504. * Removes unwanted characters from an url
  34505. * @param url defines the url to clean
  34506. * @returns the cleaned url
  34507. */
  34508. static CleanUrl(url: string): string;
  34509. /**
  34510. * Gets or sets a function used to pre-process url before using them to load assets
  34511. */
  34512. static PreprocessUrl: (url: string) => string;
  34513. /**
  34514. * Loads an image as an HTMLImageElement.
  34515. * @param input url string, ArrayBuffer, or Blob to load
  34516. * @param onLoad callback called when the image successfully loads
  34517. * @param onError callback called when the image fails to load
  34518. * @param offlineProvider offline provider for caching
  34519. * @param mimeType optional mime type
  34520. * @returns the HTMLImageElement of the loaded image
  34521. */
  34522. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  34523. /**
  34524. * Loads a file from a url
  34525. * @param url url string, ArrayBuffer, or Blob to load
  34526. * @param onSuccess callback called when the file successfully loads
  34527. * @param onProgress callback called while file is loading (if the server supports this mode)
  34528. * @param offlineProvider defines the offline provider for caching
  34529. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34530. * @param onError callback called when the file fails to load
  34531. * @returns a file request object
  34532. */
  34533. 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;
  34534. /**
  34535. * Loads a file from a url
  34536. * @param url the file url to load
  34537. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  34538. */
  34539. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  34540. /**
  34541. * Load a script (identified by an url). When the url returns, the
  34542. * content of this file is added into a new script element, attached to the DOM (body element)
  34543. * @param scriptUrl defines the url of the script to laod
  34544. * @param onSuccess defines the callback called when the script is loaded
  34545. * @param onError defines the callback to call if an error occurs
  34546. * @param scriptId defines the id of the script element
  34547. */
  34548. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  34549. /**
  34550. * Load an asynchronous script (identified by an url). When the url returns, the
  34551. * content of this file is added into a new script element, attached to the DOM (body element)
  34552. * @param scriptUrl defines the url of the script to laod
  34553. * @param scriptId defines the id of the script element
  34554. * @returns a promise request object
  34555. */
  34556. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  34557. /**
  34558. * Loads a file from a blob
  34559. * @param fileToLoad defines the blob to use
  34560. * @param callback defines the callback to call when data is loaded
  34561. * @param progressCallback defines the callback to call during loading process
  34562. * @returns a file request object
  34563. */
  34564. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  34565. /**
  34566. * Reads a file from a File object
  34567. * @param file defines the file to load
  34568. * @param onSuccess defines the callback to call when data is loaded
  34569. * @param onProgress defines the callback to call during loading process
  34570. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  34571. * @param onError defines the callback to call when an error occurs
  34572. * @returns a file request object
  34573. */
  34574. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  34575. /**
  34576. * Creates a data url from a given string content
  34577. * @param content defines the content to convert
  34578. * @returns the new data url link
  34579. */
  34580. static FileAsURL(content: string): string;
  34581. /**
  34582. * Format the given number to a specific decimal format
  34583. * @param value defines the number to format
  34584. * @param decimals defines the number of decimals to use
  34585. * @returns the formatted string
  34586. */
  34587. static Format(value: number, decimals?: number): string;
  34588. /**
  34589. * Tries to copy an object by duplicating every property
  34590. * @param source defines the source object
  34591. * @param destination defines the target object
  34592. * @param doNotCopyList defines a list of properties to avoid
  34593. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  34594. */
  34595. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  34596. /**
  34597. * Gets a boolean indicating if the given object has no own property
  34598. * @param obj defines the object to test
  34599. * @returns true if object has no own property
  34600. */
  34601. static IsEmpty(obj: any): boolean;
  34602. /**
  34603. * Function used to register events at window level
  34604. * @param windowElement defines the Window object to use
  34605. * @param events defines the events to register
  34606. */
  34607. static RegisterTopRootEvents(windowElement: Window, events: {
  34608. name: string;
  34609. handler: Nullable<(e: FocusEvent) => any>;
  34610. }[]): void;
  34611. /**
  34612. * Function used to unregister events from window level
  34613. * @param windowElement defines the Window object to use
  34614. * @param events defines the events to unregister
  34615. */
  34616. static UnregisterTopRootEvents(windowElement: Window, events: {
  34617. name: string;
  34618. handler: Nullable<(e: FocusEvent) => any>;
  34619. }[]): void;
  34620. /**
  34621. * @ignore
  34622. */
  34623. static _ScreenshotCanvas: HTMLCanvasElement;
  34624. /**
  34625. * Dumps the current bound framebuffer
  34626. * @param width defines the rendering width
  34627. * @param height defines the rendering height
  34628. * @param engine defines the hosting engine
  34629. * @param successCallback defines the callback triggered once the data are available
  34630. * @param mimeType defines the mime type of the result
  34631. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  34632. */
  34633. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34634. /**
  34635. * Converts the canvas data to blob.
  34636. * This acts as a polyfill for browsers not supporting the to blob function.
  34637. * @param canvas Defines the canvas to extract the data from
  34638. * @param successCallback Defines the callback triggered once the data are available
  34639. * @param mimeType Defines the mime type of the result
  34640. */
  34641. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  34642. /**
  34643. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  34644. * @param successCallback defines the callback triggered once the data are available
  34645. * @param mimeType defines the mime type of the result
  34646. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  34647. */
  34648. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34649. /**
  34650. * Downloads a blob in the browser
  34651. * @param blob defines the blob to download
  34652. * @param fileName defines the name of the downloaded file
  34653. */
  34654. static Download(blob: Blob, fileName: string): void;
  34655. /**
  34656. * Captures a screenshot of the current rendering
  34657. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34658. * @param engine defines the rendering engine
  34659. * @param camera defines the source camera
  34660. * @param size This parameter can be set to a single number or to an object with the
  34661. * following (optional) properties: precision, width, height. If a single number is passed,
  34662. * it will be used for both width and height. If an object is passed, the screenshot size
  34663. * will be derived from the parameters. The precision property is a multiplier allowing
  34664. * rendering at a higher or lower resolution
  34665. * @param successCallback defines the callback receives a single parameter which contains the
  34666. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34667. * src parameter of an <img> to display it
  34668. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34669. * Check your browser for supported MIME types
  34670. */
  34671. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  34672. /**
  34673. * Captures a screenshot of the current rendering
  34674. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34675. * @param engine defines the rendering engine
  34676. * @param camera defines the source camera
  34677. * @param size This parameter can be set to a single number or to an object with the
  34678. * following (optional) properties: precision, width, height. If a single number is passed,
  34679. * it will be used for both width and height. If an object is passed, the screenshot size
  34680. * will be derived from the parameters. The precision property is a multiplier allowing
  34681. * rendering at a higher or lower resolution
  34682. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34683. * Check your browser for supported MIME types
  34684. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34685. * to the src parameter of an <img> to display it
  34686. */
  34687. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  34688. /**
  34689. * Generates an image screenshot from the specified camera.
  34690. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34691. * @param engine The engine to use for rendering
  34692. * @param camera The camera to use for rendering
  34693. * @param size This parameter can be set to a single number or to an object with the
  34694. * following (optional) properties: precision, width, height. If a single number is passed,
  34695. * it will be used for both width and height. If an object is passed, the screenshot size
  34696. * will be derived from the parameters. The precision property is a multiplier allowing
  34697. * rendering at a higher or lower resolution
  34698. * @param successCallback The callback receives a single parameter which contains the
  34699. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34700. * src parameter of an <img> to display it
  34701. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34702. * Check your browser for supported MIME types
  34703. * @param samples Texture samples (default: 1)
  34704. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34705. * @param fileName A name for for the downloaded file.
  34706. */
  34707. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  34708. /**
  34709. * Generates an image screenshot from the specified camera.
  34710. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34711. * @param engine The engine to use for rendering
  34712. * @param camera The camera to use for rendering
  34713. * @param size This parameter can be set to a single number or to an object with the
  34714. * following (optional) properties: precision, width, height. If a single number is passed,
  34715. * it will be used for both width and height. If an object is passed, the screenshot size
  34716. * will be derived from the parameters. The precision property is a multiplier allowing
  34717. * rendering at a higher or lower resolution
  34718. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34719. * Check your browser for supported MIME types
  34720. * @param samples Texture samples (default: 1)
  34721. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34722. * @param fileName A name for for the downloaded file.
  34723. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34724. * to the src parameter of an <img> to display it
  34725. */
  34726. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  34727. /**
  34728. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  34729. * Be aware Math.random() could cause collisions, but:
  34730. * "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"
  34731. * @returns a pseudo random id
  34732. */
  34733. static RandomId(): string;
  34734. /**
  34735. * Test if the given uri is a base64 string
  34736. * @param uri The uri to test
  34737. * @return True if the uri is a base64 string or false otherwise
  34738. */
  34739. static IsBase64(uri: string): boolean;
  34740. /**
  34741. * Decode the given base64 uri.
  34742. * @param uri The uri to decode
  34743. * @return The decoded base64 data.
  34744. */
  34745. static DecodeBase64(uri: string): ArrayBuffer;
  34746. /**
  34747. * Gets the absolute url.
  34748. * @param url the input url
  34749. * @return the absolute url
  34750. */
  34751. static GetAbsoluteUrl(url: string): string;
  34752. /**
  34753. * No log
  34754. */
  34755. static readonly NoneLogLevel: number;
  34756. /**
  34757. * Only message logs
  34758. */
  34759. static readonly MessageLogLevel: number;
  34760. /**
  34761. * Only warning logs
  34762. */
  34763. static readonly WarningLogLevel: number;
  34764. /**
  34765. * Only error logs
  34766. */
  34767. static readonly ErrorLogLevel: number;
  34768. /**
  34769. * All logs
  34770. */
  34771. static readonly AllLogLevel: number;
  34772. /**
  34773. * Gets a value indicating the number of loading errors
  34774. * @ignorenaming
  34775. */
  34776. static readonly errorsCount: number;
  34777. /**
  34778. * Callback called when a new log is added
  34779. */
  34780. static OnNewCacheEntry: (entry: string) => void;
  34781. /**
  34782. * Log a message to the console
  34783. * @param message defines the message to log
  34784. */
  34785. static Log(message: string): void;
  34786. /**
  34787. * Write a warning message to the console
  34788. * @param message defines the message to log
  34789. */
  34790. static Warn(message: string): void;
  34791. /**
  34792. * Write an error message to the console
  34793. * @param message defines the message to log
  34794. */
  34795. static Error(message: string): void;
  34796. /**
  34797. * Gets current log cache (list of logs)
  34798. */
  34799. static readonly LogCache: string;
  34800. /**
  34801. * Clears the log cache
  34802. */
  34803. static ClearLogCache(): void;
  34804. /**
  34805. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  34806. */
  34807. static LogLevels: number;
  34808. /**
  34809. * Checks if the window object exists
  34810. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  34811. */
  34812. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  34813. /**
  34814. * No performance log
  34815. */
  34816. static readonly PerformanceNoneLogLevel: number;
  34817. /**
  34818. * Use user marks to log performance
  34819. */
  34820. static readonly PerformanceUserMarkLogLevel: number;
  34821. /**
  34822. * Log performance to the console
  34823. */
  34824. static readonly PerformanceConsoleLogLevel: number;
  34825. private static _performance;
  34826. /**
  34827. * Sets the current performance log level
  34828. */
  34829. static PerformanceLogLevel: number;
  34830. private static _StartPerformanceCounterDisabled;
  34831. private static _EndPerformanceCounterDisabled;
  34832. private static _StartUserMark;
  34833. private static _EndUserMark;
  34834. private static _StartPerformanceConsole;
  34835. private static _EndPerformanceConsole;
  34836. /**
  34837. * Starts a performance counter
  34838. */
  34839. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34840. /**
  34841. * Ends a specific performance coutner
  34842. */
  34843. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34844. /**
  34845. * Gets either window.performance.now() if supported or Date.now() else
  34846. */
  34847. static readonly Now: number;
  34848. /**
  34849. * This method will return the name of the class used to create the instance of the given object.
  34850. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  34851. * @param object the object to get the class name from
  34852. * @param isType defines if the object is actually a type
  34853. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  34854. */
  34855. static GetClassName(object: any, isType?: boolean): string;
  34856. /**
  34857. * Gets the first element of an array satisfying a given predicate
  34858. * @param array defines the array to browse
  34859. * @param predicate defines the predicate to use
  34860. * @returns null if not found or the element
  34861. */
  34862. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  34863. /**
  34864. * This method will return the name of the full name of the class, including its owning module (if any).
  34865. * 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).
  34866. * @param object the object to get the class name from
  34867. * @param isType defines if the object is actually a type
  34868. * @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.
  34869. * @ignorenaming
  34870. */
  34871. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  34872. /**
  34873. * Returns a promise that resolves after the given amount of time.
  34874. * @param delay Number of milliseconds to delay
  34875. * @returns Promise that resolves after the given amount of time
  34876. */
  34877. static DelayAsync(delay: number): Promise<void>;
  34878. }
  34879. /**
  34880. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  34881. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  34882. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  34883. * @param name The name of the class, case should be preserved
  34884. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  34885. */
  34886. export function className(name: string, module?: string): (target: Object) => void;
  34887. /**
  34888. * An implementation of a loop for asynchronous functions.
  34889. */
  34890. export class AsyncLoop {
  34891. /**
  34892. * Defines the number of iterations for the loop
  34893. */
  34894. iterations: number;
  34895. /**
  34896. * Defines the current index of the loop.
  34897. */
  34898. index: number;
  34899. private _done;
  34900. private _fn;
  34901. private _successCallback;
  34902. /**
  34903. * Constructor.
  34904. * @param iterations the number of iterations.
  34905. * @param func the function to run each iteration
  34906. * @param successCallback the callback that will be called upon succesful execution
  34907. * @param offset starting offset.
  34908. */
  34909. constructor(
  34910. /**
  34911. * Defines the number of iterations for the loop
  34912. */
  34913. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  34914. /**
  34915. * Execute the next iteration. Must be called after the last iteration was finished.
  34916. */
  34917. executeNext(): void;
  34918. /**
  34919. * Break the loop and run the success callback.
  34920. */
  34921. breakLoop(): void;
  34922. /**
  34923. * Create and run an async loop.
  34924. * @param iterations the number of iterations.
  34925. * @param fn the function to run each iteration
  34926. * @param successCallback the callback that will be called upon succesful execution
  34927. * @param offset starting offset.
  34928. * @returns the created async loop object
  34929. */
  34930. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  34931. /**
  34932. * A for-loop that will run a given number of iterations synchronous and the rest async.
  34933. * @param iterations total number of iterations
  34934. * @param syncedIterations number of synchronous iterations in each async iteration.
  34935. * @param fn the function to call each iteration.
  34936. * @param callback a success call back that will be called when iterating stops.
  34937. * @param breakFunction a break condition (optional)
  34938. * @param timeout timeout settings for the setTimeout function. default - 0.
  34939. * @returns the created async loop object
  34940. */
  34941. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  34942. }
  34943. }
  34944. declare module "babylonjs/Misc/stringDictionary" {
  34945. import { Nullable } from "babylonjs/types";
  34946. /**
  34947. * This class implement a typical dictionary using a string as key and the generic type T as value.
  34948. * The underlying implementation relies on an associative array to ensure the best performances.
  34949. * The value can be anything including 'null' but except 'undefined'
  34950. */
  34951. export class StringDictionary<T> {
  34952. /**
  34953. * This will clear this dictionary and copy the content from the 'source' one.
  34954. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  34955. * @param source the dictionary to take the content from and copy to this dictionary
  34956. */
  34957. copyFrom(source: StringDictionary<T>): void;
  34958. /**
  34959. * Get a value based from its key
  34960. * @param key the given key to get the matching value from
  34961. * @return the value if found, otherwise undefined is returned
  34962. */
  34963. get(key: string): T | undefined;
  34964. /**
  34965. * Get a value from its key or add it if it doesn't exist.
  34966. * This method will ensure you that a given key/data will be present in the dictionary.
  34967. * @param key the given key to get the matching value from
  34968. * @param factory the factory that will create the value if the key is not present in the dictionary.
  34969. * The factory will only be invoked if there's no data for the given key.
  34970. * @return the value corresponding to the key.
  34971. */
  34972. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  34973. /**
  34974. * Get a value from its key if present in the dictionary otherwise add it
  34975. * @param key the key to get the value from
  34976. * @param val if there's no such key/value pair in the dictionary add it with this value
  34977. * @return the value corresponding to the key
  34978. */
  34979. getOrAdd(key: string, val: T): T;
  34980. /**
  34981. * Check if there's a given key in the dictionary
  34982. * @param key the key to check for
  34983. * @return true if the key is present, false otherwise
  34984. */
  34985. contains(key: string): boolean;
  34986. /**
  34987. * Add a new key and its corresponding value
  34988. * @param key the key to add
  34989. * @param value the value corresponding to the key
  34990. * @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
  34991. */
  34992. add(key: string, value: T): boolean;
  34993. /**
  34994. * Update a specific value associated to a key
  34995. * @param key defines the key to use
  34996. * @param value defines the value to store
  34997. * @returns true if the value was updated (or false if the key was not found)
  34998. */
  34999. set(key: string, value: T): boolean;
  35000. /**
  35001. * Get the element of the given key and remove it from the dictionary
  35002. * @param key defines the key to search
  35003. * @returns the value associated with the key or null if not found
  35004. */
  35005. getAndRemove(key: string): Nullable<T>;
  35006. /**
  35007. * Remove a key/value from the dictionary.
  35008. * @param key the key to remove
  35009. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  35010. */
  35011. remove(key: string): boolean;
  35012. /**
  35013. * Clear the whole content of the dictionary
  35014. */
  35015. clear(): void;
  35016. /**
  35017. * Gets the current count
  35018. */
  35019. readonly count: number;
  35020. /**
  35021. * Execute a callback on each key/val of the dictionary.
  35022. * Note that you can remove any element in this dictionary in the callback implementation
  35023. * @param callback the callback to execute on a given key/value pair
  35024. */
  35025. forEach(callback: (key: string, val: T) => void): void;
  35026. /**
  35027. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  35028. * If the callback returns null or undefined the method will iterate to the next key/value pair
  35029. * Note that you can remove any element in this dictionary in the callback implementation
  35030. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  35031. * @returns the first item
  35032. */
  35033. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  35034. private _count;
  35035. private _data;
  35036. }
  35037. }
  35038. declare module "babylonjs/Collisions/collisionCoordinator" {
  35039. import { Nullable } from "babylonjs/types";
  35040. import { Scene } from "babylonjs/scene";
  35041. import { Vector3 } from "babylonjs/Maths/math.vector";
  35042. import { Collider } from "babylonjs/Collisions/collider";
  35043. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35044. /** @hidden */
  35045. export interface ICollisionCoordinator {
  35046. createCollider(): Collider;
  35047. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35048. init(scene: Scene): void;
  35049. }
  35050. /** @hidden */
  35051. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  35052. private _scene;
  35053. private _scaledPosition;
  35054. private _scaledVelocity;
  35055. private _finalPosition;
  35056. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35057. createCollider(): Collider;
  35058. init(scene: Scene): void;
  35059. private _collideWithWorld;
  35060. }
  35061. }
  35062. declare module "babylonjs/Inputs/scene.inputManager" {
  35063. import { Nullable } from "babylonjs/types";
  35064. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35065. import { Vector2 } from "babylonjs/Maths/math.vector";
  35066. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35067. import { Scene } from "babylonjs/scene";
  35068. /**
  35069. * Class used to manage all inputs for the scene.
  35070. */
  35071. export class InputManager {
  35072. /** The distance in pixel that you have to move to prevent some events */
  35073. static DragMovementThreshold: number;
  35074. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  35075. static LongPressDelay: number;
  35076. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  35077. static DoubleClickDelay: number;
  35078. /** If you need to check double click without raising a single click at first click, enable this flag */
  35079. static ExclusiveDoubleClickMode: boolean;
  35080. private _wheelEventName;
  35081. private _onPointerMove;
  35082. private _onPointerDown;
  35083. private _onPointerUp;
  35084. private _initClickEvent;
  35085. private _initActionManager;
  35086. private _delayedSimpleClick;
  35087. private _delayedSimpleClickTimeout;
  35088. private _previousDelayedSimpleClickTimeout;
  35089. private _meshPickProceed;
  35090. private _previousButtonPressed;
  35091. private _currentPickResult;
  35092. private _previousPickResult;
  35093. private _totalPointersPressed;
  35094. private _doubleClickOccured;
  35095. private _pointerOverMesh;
  35096. private _pickedDownMesh;
  35097. private _pickedUpMesh;
  35098. private _pointerX;
  35099. private _pointerY;
  35100. private _unTranslatedPointerX;
  35101. private _unTranslatedPointerY;
  35102. private _startingPointerPosition;
  35103. private _previousStartingPointerPosition;
  35104. private _startingPointerTime;
  35105. private _previousStartingPointerTime;
  35106. private _pointerCaptures;
  35107. private _onKeyDown;
  35108. private _onKeyUp;
  35109. private _onCanvasFocusObserver;
  35110. private _onCanvasBlurObserver;
  35111. private _scene;
  35112. /**
  35113. * Creates a new InputManager
  35114. * @param scene defines the hosting scene
  35115. */
  35116. constructor(scene: Scene);
  35117. /**
  35118. * Gets the mesh that is currently under the pointer
  35119. */
  35120. readonly meshUnderPointer: Nullable<AbstractMesh>;
  35121. /**
  35122. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  35123. */
  35124. readonly unTranslatedPointer: Vector2;
  35125. /**
  35126. * Gets or sets the current on-screen X position of the pointer
  35127. */
  35128. pointerX: number;
  35129. /**
  35130. * Gets or sets the current on-screen Y position of the pointer
  35131. */
  35132. pointerY: number;
  35133. private _updatePointerPosition;
  35134. private _processPointerMove;
  35135. private _setRayOnPointerInfo;
  35136. private _checkPrePointerObservable;
  35137. /**
  35138. * Use this method to simulate a pointer move on a mesh
  35139. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35140. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35141. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35142. */
  35143. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35144. /**
  35145. * Use this method to simulate a pointer down on a mesh
  35146. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35147. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35148. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35149. */
  35150. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35151. private _processPointerDown;
  35152. /** @hidden */
  35153. _isPointerSwiping(): boolean;
  35154. /**
  35155. * Use this method to simulate a pointer up on a mesh
  35156. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35157. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35158. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35159. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35160. */
  35161. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  35162. private _processPointerUp;
  35163. /**
  35164. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35165. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35166. * @returns true if the pointer was captured
  35167. */
  35168. isPointerCaptured(pointerId?: number): boolean;
  35169. /**
  35170. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35171. * @param attachUp defines if you want to attach events to pointerup
  35172. * @param attachDown defines if you want to attach events to pointerdown
  35173. * @param attachMove defines if you want to attach events to pointermove
  35174. */
  35175. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  35176. /**
  35177. * Detaches all event handlers
  35178. */
  35179. detachControl(): void;
  35180. /**
  35181. * Force the value of meshUnderPointer
  35182. * @param mesh defines the mesh to use
  35183. */
  35184. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35185. /**
  35186. * Gets the mesh under the pointer
  35187. * @returns a Mesh or null if no mesh is under the pointer
  35188. */
  35189. getPointerOverMesh(): Nullable<AbstractMesh>;
  35190. }
  35191. }
  35192. declare module "babylonjs/Misc/uniqueIdGenerator" {
  35193. /**
  35194. * Helper class used to generate session unique ID
  35195. */
  35196. export class UniqueIdGenerator {
  35197. private static _UniqueIdCounter;
  35198. /**
  35199. * Gets an unique (relatively to the current scene) Id
  35200. */
  35201. static readonly UniqueId: number;
  35202. }
  35203. }
  35204. declare module "babylonjs/Animations/animationGroup" {
  35205. import { Animatable } from "babylonjs/Animations/animatable";
  35206. import { Animation } from "babylonjs/Animations/animation";
  35207. import { Scene, IDisposable } from "babylonjs/scene";
  35208. import { Observable } from "babylonjs/Misc/observable";
  35209. import { Nullable } from "babylonjs/types";
  35210. import "babylonjs/Animations/animatable";
  35211. /**
  35212. * This class defines the direct association between an animation and a target
  35213. */
  35214. export class TargetedAnimation {
  35215. /**
  35216. * Animation to perform
  35217. */
  35218. animation: Animation;
  35219. /**
  35220. * Target to animate
  35221. */
  35222. target: any;
  35223. /**
  35224. * Serialize the object
  35225. * @returns the JSON object representing the current entity
  35226. */
  35227. serialize(): any;
  35228. }
  35229. /**
  35230. * Use this class to create coordinated animations on multiple targets
  35231. */
  35232. export class AnimationGroup implements IDisposable {
  35233. /** The name of the animation group */
  35234. name: string;
  35235. private _scene;
  35236. private _targetedAnimations;
  35237. private _animatables;
  35238. private _from;
  35239. private _to;
  35240. private _isStarted;
  35241. private _isPaused;
  35242. private _speedRatio;
  35243. private _loopAnimation;
  35244. /**
  35245. * Gets or sets the unique id of the node
  35246. */
  35247. uniqueId: number;
  35248. /**
  35249. * This observable will notify when one animation have ended
  35250. */
  35251. onAnimationEndObservable: Observable<TargetedAnimation>;
  35252. /**
  35253. * Observer raised when one animation loops
  35254. */
  35255. onAnimationLoopObservable: Observable<TargetedAnimation>;
  35256. /**
  35257. * Observer raised when all animations have looped
  35258. */
  35259. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  35260. /**
  35261. * This observable will notify when all animations have ended.
  35262. */
  35263. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  35264. /**
  35265. * This observable will notify when all animations have paused.
  35266. */
  35267. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  35268. /**
  35269. * This observable will notify when all animations are playing.
  35270. */
  35271. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  35272. /**
  35273. * Gets the first frame
  35274. */
  35275. readonly from: number;
  35276. /**
  35277. * Gets the last frame
  35278. */
  35279. readonly to: number;
  35280. /**
  35281. * Define if the animations are started
  35282. */
  35283. readonly isStarted: boolean;
  35284. /**
  35285. * Gets a value indicating that the current group is playing
  35286. */
  35287. readonly isPlaying: boolean;
  35288. /**
  35289. * Gets or sets the speed ratio to use for all animations
  35290. */
  35291. /**
  35292. * Gets or sets the speed ratio to use for all animations
  35293. */
  35294. speedRatio: number;
  35295. /**
  35296. * Gets or sets if all animations should loop or not
  35297. */
  35298. loopAnimation: boolean;
  35299. /**
  35300. * Gets the targeted animations for this animation group
  35301. */
  35302. readonly targetedAnimations: Array<TargetedAnimation>;
  35303. /**
  35304. * returning the list of animatables controlled by this animation group.
  35305. */
  35306. readonly animatables: Array<Animatable>;
  35307. /**
  35308. * Instantiates a new Animation Group.
  35309. * This helps managing several animations at once.
  35310. * @see http://doc.babylonjs.com/how_to/group
  35311. * @param name Defines the name of the group
  35312. * @param scene Defines the scene the group belongs to
  35313. */
  35314. constructor(
  35315. /** The name of the animation group */
  35316. name: string, scene?: Nullable<Scene>);
  35317. /**
  35318. * Add an animation (with its target) in the group
  35319. * @param animation defines the animation we want to add
  35320. * @param target defines the target of the animation
  35321. * @returns the TargetedAnimation object
  35322. */
  35323. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  35324. /**
  35325. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  35326. * It can add constant keys at begin or end
  35327. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  35328. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  35329. * @returns the animation group
  35330. */
  35331. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  35332. private _animationLoopCount;
  35333. private _animationLoopFlags;
  35334. private _processLoop;
  35335. /**
  35336. * Start all animations on given targets
  35337. * @param loop defines if animations must loop
  35338. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  35339. * @param from defines the from key (optional)
  35340. * @param to defines the to key (optional)
  35341. * @returns the current animation group
  35342. */
  35343. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  35344. /**
  35345. * Pause all animations
  35346. * @returns the animation group
  35347. */
  35348. pause(): AnimationGroup;
  35349. /**
  35350. * Play all animations to initial state
  35351. * This function will start() the animations if they were not started or will restart() them if they were paused
  35352. * @param loop defines if animations must loop
  35353. * @returns the animation group
  35354. */
  35355. play(loop?: boolean): AnimationGroup;
  35356. /**
  35357. * Reset all animations to initial state
  35358. * @returns the animation group
  35359. */
  35360. reset(): AnimationGroup;
  35361. /**
  35362. * Restart animations from key 0
  35363. * @returns the animation group
  35364. */
  35365. restart(): AnimationGroup;
  35366. /**
  35367. * Stop all animations
  35368. * @returns the animation group
  35369. */
  35370. stop(): AnimationGroup;
  35371. /**
  35372. * Set animation weight for all animatables
  35373. * @param weight defines the weight to use
  35374. * @return the animationGroup
  35375. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35376. */
  35377. setWeightForAllAnimatables(weight: number): AnimationGroup;
  35378. /**
  35379. * Synchronize and normalize all animatables with a source animatable
  35380. * @param root defines the root animatable to synchronize with
  35381. * @return the animationGroup
  35382. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35383. */
  35384. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  35385. /**
  35386. * Goes to a specific frame in this animation group
  35387. * @param frame the frame number to go to
  35388. * @return the animationGroup
  35389. */
  35390. goToFrame(frame: number): AnimationGroup;
  35391. /**
  35392. * Dispose all associated resources
  35393. */
  35394. dispose(): void;
  35395. private _checkAnimationGroupEnded;
  35396. /**
  35397. * Clone the current animation group and returns a copy
  35398. * @param newName defines the name of the new group
  35399. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  35400. * @returns the new aniamtion group
  35401. */
  35402. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  35403. /**
  35404. * Serializes the animationGroup to an object
  35405. * @returns Serialized object
  35406. */
  35407. serialize(): any;
  35408. /**
  35409. * Returns a new AnimationGroup object parsed from the source provided.
  35410. * @param parsedAnimationGroup defines the source
  35411. * @param scene defines the scene that will receive the animationGroup
  35412. * @returns a new AnimationGroup
  35413. */
  35414. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  35415. /**
  35416. * Returns the string "AnimationGroup"
  35417. * @returns "AnimationGroup"
  35418. */
  35419. getClassName(): string;
  35420. /**
  35421. * Creates a detailled string about the object
  35422. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  35423. * @returns a string representing the object
  35424. */
  35425. toString(fullDetails?: boolean): string;
  35426. }
  35427. }
  35428. declare module "babylonjs/scene" {
  35429. import { Nullable } from "babylonjs/types";
  35430. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  35431. import { Observable } from "babylonjs/Misc/observable";
  35432. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  35433. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  35434. import { Geometry } from "babylonjs/Meshes/geometry";
  35435. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35436. import { SubMesh } from "babylonjs/Meshes/subMesh";
  35437. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35438. import { Mesh } from "babylonjs/Meshes/mesh";
  35439. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35440. import { Bone } from "babylonjs/Bones/bone";
  35441. import { Skeleton } from "babylonjs/Bones/skeleton";
  35442. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35443. import { Camera } from "babylonjs/Cameras/camera";
  35444. import { AbstractScene } from "babylonjs/abstractScene";
  35445. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35446. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  35447. import { Material } from "babylonjs/Materials/material";
  35448. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  35449. import { Effect } from "babylonjs/Materials/effect";
  35450. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  35451. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35452. import { Light } from "babylonjs/Lights/light";
  35453. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35454. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  35455. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  35456. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  35457. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  35458. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  35459. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  35460. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  35461. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  35462. import { Engine } from "babylonjs/Engines/engine";
  35463. import { Node } from "babylonjs/node";
  35464. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  35465. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35466. import { WebRequest } from "babylonjs/Misc/webRequest";
  35467. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  35468. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  35469. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  35470. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  35471. import { Plane } from "babylonjs/Maths/math.plane";
  35472. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  35473. import { Ray } from "babylonjs/Culling/ray";
  35474. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  35475. import { Animation } from "babylonjs/Animations/animation";
  35476. import { Animatable } from "babylonjs/Animations/animatable";
  35477. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35478. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  35479. import { Collider } from "babylonjs/Collisions/collider";
  35480. /**
  35481. * Define an interface for all classes that will hold resources
  35482. */
  35483. export interface IDisposable {
  35484. /**
  35485. * Releases all held resources
  35486. */
  35487. dispose(): void;
  35488. }
  35489. /** Interface defining initialization parameters for Scene class */
  35490. export interface SceneOptions {
  35491. /**
  35492. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  35493. * It will improve performance when the number of geometries becomes important.
  35494. */
  35495. useGeometryUniqueIdsMap?: boolean;
  35496. /**
  35497. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  35498. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35499. */
  35500. useMaterialMeshMap?: boolean;
  35501. /**
  35502. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  35503. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35504. */
  35505. useClonedMeshhMap?: boolean;
  35506. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  35507. virtual?: boolean;
  35508. }
  35509. /**
  35510. * Represents a scene to be rendered by the engine.
  35511. * @see http://doc.babylonjs.com/features/scene
  35512. */
  35513. export class Scene extends AbstractScene implements IAnimatable {
  35514. /** The fog is deactivated */
  35515. static readonly FOGMODE_NONE: number;
  35516. /** The fog density is following an exponential function */
  35517. static readonly FOGMODE_EXP: number;
  35518. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  35519. static readonly FOGMODE_EXP2: number;
  35520. /** The fog density is following a linear function. */
  35521. static readonly FOGMODE_LINEAR: number;
  35522. /**
  35523. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  35524. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35525. */
  35526. static MinDeltaTime: number;
  35527. /**
  35528. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  35529. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35530. */
  35531. static MaxDeltaTime: number;
  35532. /**
  35533. * Factory used to create the default material.
  35534. * @param name The name of the material to create
  35535. * @param scene The scene to create the material for
  35536. * @returns The default material
  35537. */
  35538. static DefaultMaterialFactory(scene: Scene): Material;
  35539. /**
  35540. * Factory used to create the a collision coordinator.
  35541. * @returns The collision coordinator
  35542. */
  35543. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  35544. /** @hidden */
  35545. _inputManager: InputManager;
  35546. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  35547. cameraToUseForPointers: Nullable<Camera>;
  35548. /** @hidden */
  35549. readonly _isScene: boolean;
  35550. /**
  35551. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  35552. */
  35553. autoClear: boolean;
  35554. /**
  35555. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  35556. */
  35557. autoClearDepthAndStencil: boolean;
  35558. /**
  35559. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  35560. */
  35561. clearColor: Color4;
  35562. /**
  35563. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  35564. */
  35565. ambientColor: Color3;
  35566. /**
  35567. * This is use to store the default BRDF lookup for PBR materials in your scene.
  35568. * It should only be one of the following (if not the default embedded one):
  35569. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  35570. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  35571. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  35572. * The material properties need to be setup according to the type of texture in use.
  35573. */
  35574. environmentBRDFTexture: BaseTexture;
  35575. /** @hidden */
  35576. protected _environmentTexture: Nullable<BaseTexture>;
  35577. /**
  35578. * Texture used in all pbr material as the reflection texture.
  35579. * As in the majority of the scene they are the same (exception for multi room and so on),
  35580. * this is easier to reference from here than from all the materials.
  35581. */
  35582. /**
  35583. * Texture used in all pbr material as the reflection texture.
  35584. * As in the majority of the scene they are the same (exception for multi room and so on),
  35585. * this is easier to set here than in all the materials.
  35586. */
  35587. environmentTexture: Nullable<BaseTexture>;
  35588. /** @hidden */
  35589. protected _environmentIntensity: number;
  35590. /**
  35591. * Intensity of the environment in all pbr material.
  35592. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35593. * As in the majority of the scene they are the same (exception for multi room and so on),
  35594. * this is easier to reference from here than from all the materials.
  35595. */
  35596. /**
  35597. * Intensity of the environment in all pbr material.
  35598. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35599. * As in the majority of the scene they are the same (exception for multi room and so on),
  35600. * this is easier to set here than in all the materials.
  35601. */
  35602. environmentIntensity: number;
  35603. /** @hidden */
  35604. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35605. /**
  35606. * Default image processing configuration used either in the rendering
  35607. * Forward main pass or through the imageProcessingPostProcess if present.
  35608. * As in the majority of the scene they are the same (exception for multi camera),
  35609. * this is easier to reference from here than from all the materials and post process.
  35610. *
  35611. * No setter as we it is a shared configuration, you can set the values instead.
  35612. */
  35613. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  35614. private _forceWireframe;
  35615. /**
  35616. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  35617. */
  35618. forceWireframe: boolean;
  35619. private _forcePointsCloud;
  35620. /**
  35621. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  35622. */
  35623. forcePointsCloud: boolean;
  35624. /**
  35625. * Gets or sets the active clipplane 1
  35626. */
  35627. clipPlane: Nullable<Plane>;
  35628. /**
  35629. * Gets or sets the active clipplane 2
  35630. */
  35631. clipPlane2: Nullable<Plane>;
  35632. /**
  35633. * Gets or sets the active clipplane 3
  35634. */
  35635. clipPlane3: Nullable<Plane>;
  35636. /**
  35637. * Gets or sets the active clipplane 4
  35638. */
  35639. clipPlane4: Nullable<Plane>;
  35640. /**
  35641. * Gets or sets a boolean indicating if animations are enabled
  35642. */
  35643. animationsEnabled: boolean;
  35644. private _animationPropertiesOverride;
  35645. /**
  35646. * Gets or sets the animation properties override
  35647. */
  35648. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  35649. /**
  35650. * Gets or sets a boolean indicating if a constant deltatime has to be used
  35651. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  35652. */
  35653. useConstantAnimationDeltaTime: boolean;
  35654. /**
  35655. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  35656. * Please note that it requires to run a ray cast through the scene on every frame
  35657. */
  35658. constantlyUpdateMeshUnderPointer: boolean;
  35659. /**
  35660. * Defines the HTML cursor to use when hovering over interactive elements
  35661. */
  35662. hoverCursor: string;
  35663. /**
  35664. * Defines the HTML default cursor to use (empty by default)
  35665. */
  35666. defaultCursor: string;
  35667. /**
  35668. * Defines wether cursors are handled by the scene.
  35669. */
  35670. doNotHandleCursors: boolean;
  35671. /**
  35672. * This is used to call preventDefault() on pointer down
  35673. * in order to block unwanted artifacts like system double clicks
  35674. */
  35675. preventDefaultOnPointerDown: boolean;
  35676. /**
  35677. * This is used to call preventDefault() on pointer up
  35678. * in order to block unwanted artifacts like system double clicks
  35679. */
  35680. preventDefaultOnPointerUp: boolean;
  35681. /**
  35682. * Gets or sets user defined metadata
  35683. */
  35684. metadata: any;
  35685. /**
  35686. * For internal use only. Please do not use.
  35687. */
  35688. reservedDataStore: any;
  35689. /**
  35690. * Gets the name of the plugin used to load this scene (null by default)
  35691. */
  35692. loadingPluginName: string;
  35693. /**
  35694. * Use this array to add regular expressions used to disable offline support for specific urls
  35695. */
  35696. disableOfflineSupportExceptionRules: RegExp[];
  35697. /**
  35698. * An event triggered when the scene is disposed.
  35699. */
  35700. onDisposeObservable: Observable<Scene>;
  35701. private _onDisposeObserver;
  35702. /** Sets a function to be executed when this scene is disposed. */
  35703. onDispose: () => void;
  35704. /**
  35705. * An event triggered before rendering the scene (right after animations and physics)
  35706. */
  35707. onBeforeRenderObservable: Observable<Scene>;
  35708. private _onBeforeRenderObserver;
  35709. /** Sets a function to be executed before rendering this scene */
  35710. beforeRender: Nullable<() => void>;
  35711. /**
  35712. * An event triggered after rendering the scene
  35713. */
  35714. onAfterRenderObservable: Observable<Scene>;
  35715. /**
  35716. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  35717. */
  35718. onAfterRenderCameraObservable: Observable<Camera>;
  35719. private _onAfterRenderObserver;
  35720. /** Sets a function to be executed after rendering this scene */
  35721. afterRender: Nullable<() => void>;
  35722. /**
  35723. * An event triggered before animating the scene
  35724. */
  35725. onBeforeAnimationsObservable: Observable<Scene>;
  35726. /**
  35727. * An event triggered after animations processing
  35728. */
  35729. onAfterAnimationsObservable: Observable<Scene>;
  35730. /**
  35731. * An event triggered before draw calls are ready to be sent
  35732. */
  35733. onBeforeDrawPhaseObservable: Observable<Scene>;
  35734. /**
  35735. * An event triggered after draw calls have been sent
  35736. */
  35737. onAfterDrawPhaseObservable: Observable<Scene>;
  35738. /**
  35739. * An event triggered when the scene is ready
  35740. */
  35741. onReadyObservable: Observable<Scene>;
  35742. /**
  35743. * An event triggered before rendering a camera
  35744. */
  35745. onBeforeCameraRenderObservable: Observable<Camera>;
  35746. private _onBeforeCameraRenderObserver;
  35747. /** Sets a function to be executed before rendering a camera*/
  35748. beforeCameraRender: () => void;
  35749. /**
  35750. * An event triggered after rendering a camera
  35751. */
  35752. onAfterCameraRenderObservable: Observable<Camera>;
  35753. private _onAfterCameraRenderObserver;
  35754. /** Sets a function to be executed after rendering a camera*/
  35755. afterCameraRender: () => void;
  35756. /**
  35757. * An event triggered when active meshes evaluation is about to start
  35758. */
  35759. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  35760. /**
  35761. * An event triggered when active meshes evaluation is done
  35762. */
  35763. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  35764. /**
  35765. * An event triggered when particles rendering is about to start
  35766. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35767. */
  35768. onBeforeParticlesRenderingObservable: Observable<Scene>;
  35769. /**
  35770. * An event triggered when particles rendering is done
  35771. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35772. */
  35773. onAfterParticlesRenderingObservable: Observable<Scene>;
  35774. /**
  35775. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  35776. */
  35777. onDataLoadedObservable: Observable<Scene>;
  35778. /**
  35779. * An event triggered when a camera is created
  35780. */
  35781. onNewCameraAddedObservable: Observable<Camera>;
  35782. /**
  35783. * An event triggered when a camera is removed
  35784. */
  35785. onCameraRemovedObservable: Observable<Camera>;
  35786. /**
  35787. * An event triggered when a light is created
  35788. */
  35789. onNewLightAddedObservable: Observable<Light>;
  35790. /**
  35791. * An event triggered when a light is removed
  35792. */
  35793. onLightRemovedObservable: Observable<Light>;
  35794. /**
  35795. * An event triggered when a geometry is created
  35796. */
  35797. onNewGeometryAddedObservable: Observable<Geometry>;
  35798. /**
  35799. * An event triggered when a geometry is removed
  35800. */
  35801. onGeometryRemovedObservable: Observable<Geometry>;
  35802. /**
  35803. * An event triggered when a transform node is created
  35804. */
  35805. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  35806. /**
  35807. * An event triggered when a transform node is removed
  35808. */
  35809. onTransformNodeRemovedObservable: Observable<TransformNode>;
  35810. /**
  35811. * An event triggered when a mesh is created
  35812. */
  35813. onNewMeshAddedObservable: Observable<AbstractMesh>;
  35814. /**
  35815. * An event triggered when a mesh is removed
  35816. */
  35817. onMeshRemovedObservable: Observable<AbstractMesh>;
  35818. /**
  35819. * An event triggered when a skeleton is created
  35820. */
  35821. onNewSkeletonAddedObservable: Observable<Skeleton>;
  35822. /**
  35823. * An event triggered when a skeleton is removed
  35824. */
  35825. onSkeletonRemovedObservable: Observable<Skeleton>;
  35826. /**
  35827. * An event triggered when a material is created
  35828. */
  35829. onNewMaterialAddedObservable: Observable<Material>;
  35830. /**
  35831. * An event triggered when a material is removed
  35832. */
  35833. onMaterialRemovedObservable: Observable<Material>;
  35834. /**
  35835. * An event triggered when a texture is created
  35836. */
  35837. onNewTextureAddedObservable: Observable<BaseTexture>;
  35838. /**
  35839. * An event triggered when a texture is removed
  35840. */
  35841. onTextureRemovedObservable: Observable<BaseTexture>;
  35842. /**
  35843. * An event triggered when render targets are about to be rendered
  35844. * Can happen multiple times per frame.
  35845. */
  35846. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  35847. /**
  35848. * An event triggered when render targets were rendered.
  35849. * Can happen multiple times per frame.
  35850. */
  35851. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  35852. /**
  35853. * An event triggered before calculating deterministic simulation step
  35854. */
  35855. onBeforeStepObservable: Observable<Scene>;
  35856. /**
  35857. * An event triggered after calculating deterministic simulation step
  35858. */
  35859. onAfterStepObservable: Observable<Scene>;
  35860. /**
  35861. * An event triggered when the activeCamera property is updated
  35862. */
  35863. onActiveCameraChanged: Observable<Scene>;
  35864. /**
  35865. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  35866. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35867. * 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)
  35868. */
  35869. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35870. /**
  35871. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  35872. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35873. * 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)
  35874. */
  35875. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35876. /**
  35877. * This Observable will when a mesh has been imported into the scene.
  35878. */
  35879. onMeshImportedObservable: Observable<AbstractMesh>;
  35880. /**
  35881. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  35882. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  35883. */
  35884. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  35885. /** @hidden */
  35886. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  35887. /**
  35888. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  35889. */
  35890. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  35891. /**
  35892. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  35893. */
  35894. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  35895. /**
  35896. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  35897. */
  35898. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  35899. /** Callback called when a pointer move is detected */
  35900. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35901. /** Callback called when a pointer down is detected */
  35902. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35903. /** Callback called when a pointer up is detected */
  35904. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  35905. /** Callback called when a pointer pick is detected */
  35906. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  35907. /**
  35908. * 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).
  35909. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  35910. */
  35911. onPrePointerObservable: Observable<PointerInfoPre>;
  35912. /**
  35913. * Observable event triggered each time an input event is received from the rendering canvas
  35914. */
  35915. onPointerObservable: Observable<PointerInfo>;
  35916. /**
  35917. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  35918. */
  35919. readonly unTranslatedPointer: Vector2;
  35920. /**
  35921. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  35922. */
  35923. static DragMovementThreshold: number;
  35924. /**
  35925. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  35926. */
  35927. static LongPressDelay: number;
  35928. /**
  35929. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  35930. */
  35931. static DoubleClickDelay: number;
  35932. /** If you need to check double click without raising a single click at first click, enable this flag */
  35933. static ExclusiveDoubleClickMode: boolean;
  35934. /** @hidden */
  35935. _mirroredCameraPosition: Nullable<Vector3>;
  35936. /**
  35937. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  35938. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  35939. */
  35940. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  35941. /**
  35942. * Observable event triggered each time an keyboard event is received from the hosting window
  35943. */
  35944. onKeyboardObservable: Observable<KeyboardInfo>;
  35945. private _useRightHandedSystem;
  35946. /**
  35947. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  35948. */
  35949. useRightHandedSystem: boolean;
  35950. private _timeAccumulator;
  35951. private _currentStepId;
  35952. private _currentInternalStep;
  35953. /**
  35954. * Sets the step Id used by deterministic lock step
  35955. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35956. * @param newStepId defines the step Id
  35957. */
  35958. setStepId(newStepId: number): void;
  35959. /**
  35960. * Gets the step Id used by deterministic lock step
  35961. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35962. * @returns the step Id
  35963. */
  35964. getStepId(): number;
  35965. /**
  35966. * Gets the internal step used by deterministic lock step
  35967. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35968. * @returns the internal step
  35969. */
  35970. getInternalStep(): number;
  35971. private _fogEnabled;
  35972. /**
  35973. * Gets or sets a boolean indicating if fog is enabled on this scene
  35974. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35975. * (Default is true)
  35976. */
  35977. fogEnabled: boolean;
  35978. private _fogMode;
  35979. /**
  35980. * Gets or sets the fog mode to use
  35981. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35982. * | mode | value |
  35983. * | --- | --- |
  35984. * | FOGMODE_NONE | 0 |
  35985. * | FOGMODE_EXP | 1 |
  35986. * | FOGMODE_EXP2 | 2 |
  35987. * | FOGMODE_LINEAR | 3 |
  35988. */
  35989. fogMode: number;
  35990. /**
  35991. * Gets or sets the fog color to use
  35992. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35993. * (Default is Color3(0.2, 0.2, 0.3))
  35994. */
  35995. fogColor: Color3;
  35996. /**
  35997. * Gets or sets the fog density to use
  35998. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35999. * (Default is 0.1)
  36000. */
  36001. fogDensity: number;
  36002. /**
  36003. * Gets or sets the fog start distance to use
  36004. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36005. * (Default is 0)
  36006. */
  36007. fogStart: number;
  36008. /**
  36009. * Gets or sets the fog end distance to use
  36010. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36011. * (Default is 1000)
  36012. */
  36013. fogEnd: number;
  36014. private _shadowsEnabled;
  36015. /**
  36016. * Gets or sets a boolean indicating if shadows are enabled on this scene
  36017. */
  36018. shadowsEnabled: boolean;
  36019. private _lightsEnabled;
  36020. /**
  36021. * Gets or sets a boolean indicating if lights are enabled on this scene
  36022. */
  36023. lightsEnabled: boolean;
  36024. /** All of the active cameras added to this scene. */
  36025. activeCameras: Camera[];
  36026. /** @hidden */
  36027. _activeCamera: Nullable<Camera>;
  36028. /** Gets or sets the current active camera */
  36029. activeCamera: Nullable<Camera>;
  36030. private _defaultMaterial;
  36031. /** The default material used on meshes when no material is affected */
  36032. /** The default material used on meshes when no material is affected */
  36033. defaultMaterial: Material;
  36034. private _texturesEnabled;
  36035. /**
  36036. * Gets or sets a boolean indicating if textures are enabled on this scene
  36037. */
  36038. texturesEnabled: boolean;
  36039. /**
  36040. * Gets or sets a boolean indicating if particles are enabled on this scene
  36041. */
  36042. particlesEnabled: boolean;
  36043. /**
  36044. * Gets or sets a boolean indicating if sprites are enabled on this scene
  36045. */
  36046. spritesEnabled: boolean;
  36047. private _skeletonsEnabled;
  36048. /**
  36049. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  36050. */
  36051. skeletonsEnabled: boolean;
  36052. /**
  36053. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  36054. */
  36055. lensFlaresEnabled: boolean;
  36056. /**
  36057. * Gets or sets a boolean indicating if collisions are enabled on this scene
  36058. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36059. */
  36060. collisionsEnabled: boolean;
  36061. private _collisionCoordinator;
  36062. /** @hidden */
  36063. readonly collisionCoordinator: ICollisionCoordinator;
  36064. /**
  36065. * Defines the gravity applied to this scene (used only for collisions)
  36066. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36067. */
  36068. gravity: Vector3;
  36069. /**
  36070. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  36071. */
  36072. postProcessesEnabled: boolean;
  36073. /**
  36074. * The list of postprocesses added to the scene
  36075. */
  36076. postProcesses: PostProcess[];
  36077. /**
  36078. * Gets the current postprocess manager
  36079. */
  36080. postProcessManager: PostProcessManager;
  36081. /**
  36082. * Gets or sets a boolean indicating if render targets are enabled on this scene
  36083. */
  36084. renderTargetsEnabled: boolean;
  36085. /**
  36086. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  36087. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  36088. */
  36089. dumpNextRenderTargets: boolean;
  36090. /**
  36091. * The list of user defined render targets added to the scene
  36092. */
  36093. customRenderTargets: RenderTargetTexture[];
  36094. /**
  36095. * Defines if texture loading must be delayed
  36096. * If true, textures will only be loaded when they need to be rendered
  36097. */
  36098. useDelayedTextureLoading: boolean;
  36099. /**
  36100. * Gets the list of meshes imported to the scene through SceneLoader
  36101. */
  36102. importedMeshesFiles: String[];
  36103. /**
  36104. * Gets or sets a boolean indicating if probes are enabled on this scene
  36105. */
  36106. probesEnabled: boolean;
  36107. /**
  36108. * Gets or sets the current offline provider to use to store scene data
  36109. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  36110. */
  36111. offlineProvider: IOfflineProvider;
  36112. /**
  36113. * Gets or sets the action manager associated with the scene
  36114. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36115. */
  36116. actionManager: AbstractActionManager;
  36117. private _meshesForIntersections;
  36118. /**
  36119. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  36120. */
  36121. proceduralTexturesEnabled: boolean;
  36122. private _engine;
  36123. private _totalVertices;
  36124. /** @hidden */
  36125. _activeIndices: PerfCounter;
  36126. /** @hidden */
  36127. _activeParticles: PerfCounter;
  36128. /** @hidden */
  36129. _activeBones: PerfCounter;
  36130. private _animationRatio;
  36131. /** @hidden */
  36132. _animationTimeLast: number;
  36133. /** @hidden */
  36134. _animationTime: number;
  36135. /**
  36136. * Gets or sets a general scale for animation speed
  36137. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  36138. */
  36139. animationTimeScale: number;
  36140. /** @hidden */
  36141. _cachedMaterial: Nullable<Material>;
  36142. /** @hidden */
  36143. _cachedEffect: Nullable<Effect>;
  36144. /** @hidden */
  36145. _cachedVisibility: Nullable<number>;
  36146. private _renderId;
  36147. private _frameId;
  36148. private _executeWhenReadyTimeoutId;
  36149. private _intermediateRendering;
  36150. private _viewUpdateFlag;
  36151. private _projectionUpdateFlag;
  36152. /** @hidden */
  36153. _toBeDisposed: Nullable<IDisposable>[];
  36154. private _activeRequests;
  36155. /** @hidden */
  36156. _pendingData: any[];
  36157. private _isDisposed;
  36158. /**
  36159. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  36160. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  36161. */
  36162. dispatchAllSubMeshesOfActiveMeshes: boolean;
  36163. private _activeMeshes;
  36164. private _processedMaterials;
  36165. private _renderTargets;
  36166. /** @hidden */
  36167. _activeParticleSystems: SmartArray<IParticleSystem>;
  36168. private _activeSkeletons;
  36169. private _softwareSkinnedMeshes;
  36170. private _renderingManager;
  36171. /** @hidden */
  36172. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  36173. private _transformMatrix;
  36174. private _sceneUbo;
  36175. /** @hidden */
  36176. _viewMatrix: Matrix;
  36177. private _projectionMatrix;
  36178. /** @hidden */
  36179. _forcedViewPosition: Nullable<Vector3>;
  36180. /** @hidden */
  36181. _frustumPlanes: Plane[];
  36182. /**
  36183. * Gets the list of frustum planes (built from the active camera)
  36184. */
  36185. readonly frustumPlanes: Plane[];
  36186. /**
  36187. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  36188. * This is useful if there are more lights that the maximum simulteanous authorized
  36189. */
  36190. requireLightSorting: boolean;
  36191. /** @hidden */
  36192. readonly useMaterialMeshMap: boolean;
  36193. /** @hidden */
  36194. readonly useClonedMeshhMap: boolean;
  36195. private _externalData;
  36196. private _uid;
  36197. /**
  36198. * @hidden
  36199. * Backing store of defined scene components.
  36200. */
  36201. _components: ISceneComponent[];
  36202. /**
  36203. * @hidden
  36204. * Backing store of defined scene components.
  36205. */
  36206. _serializableComponents: ISceneSerializableComponent[];
  36207. /**
  36208. * List of components to register on the next registration step.
  36209. */
  36210. private _transientComponents;
  36211. /**
  36212. * Registers the transient components if needed.
  36213. */
  36214. private _registerTransientComponents;
  36215. /**
  36216. * @hidden
  36217. * Add a component to the scene.
  36218. * Note that the ccomponent could be registered on th next frame if this is called after
  36219. * the register component stage.
  36220. * @param component Defines the component to add to the scene
  36221. */
  36222. _addComponent(component: ISceneComponent): void;
  36223. /**
  36224. * @hidden
  36225. * Gets a component from the scene.
  36226. * @param name defines the name of the component to retrieve
  36227. * @returns the component or null if not present
  36228. */
  36229. _getComponent(name: string): Nullable<ISceneComponent>;
  36230. /**
  36231. * @hidden
  36232. * Defines the actions happening before camera updates.
  36233. */
  36234. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  36235. /**
  36236. * @hidden
  36237. * Defines the actions happening before clear the canvas.
  36238. */
  36239. _beforeClearStage: Stage<SimpleStageAction>;
  36240. /**
  36241. * @hidden
  36242. * Defines the actions when collecting render targets for the frame.
  36243. */
  36244. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36245. /**
  36246. * @hidden
  36247. * Defines the actions happening for one camera in the frame.
  36248. */
  36249. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36250. /**
  36251. * @hidden
  36252. * Defines the actions happening during the per mesh ready checks.
  36253. */
  36254. _isReadyForMeshStage: Stage<MeshStageAction>;
  36255. /**
  36256. * @hidden
  36257. * Defines the actions happening before evaluate active mesh checks.
  36258. */
  36259. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  36260. /**
  36261. * @hidden
  36262. * Defines the actions happening during the evaluate sub mesh checks.
  36263. */
  36264. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  36265. /**
  36266. * @hidden
  36267. * Defines the actions happening during the active mesh stage.
  36268. */
  36269. _activeMeshStage: Stage<ActiveMeshStageAction>;
  36270. /**
  36271. * @hidden
  36272. * Defines the actions happening during the per camera render target step.
  36273. */
  36274. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  36275. /**
  36276. * @hidden
  36277. * Defines the actions happening just before the active camera is drawing.
  36278. */
  36279. _beforeCameraDrawStage: Stage<CameraStageAction>;
  36280. /**
  36281. * @hidden
  36282. * Defines the actions happening just before a render target is drawing.
  36283. */
  36284. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36285. /**
  36286. * @hidden
  36287. * Defines the actions happening just before a rendering group is drawing.
  36288. */
  36289. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36290. /**
  36291. * @hidden
  36292. * Defines the actions happening just before a mesh is drawing.
  36293. */
  36294. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36295. /**
  36296. * @hidden
  36297. * Defines the actions happening just after a mesh has been drawn.
  36298. */
  36299. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36300. /**
  36301. * @hidden
  36302. * Defines the actions happening just after a rendering group has been drawn.
  36303. */
  36304. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36305. /**
  36306. * @hidden
  36307. * Defines the actions happening just after the active camera has been drawn.
  36308. */
  36309. _afterCameraDrawStage: Stage<CameraStageAction>;
  36310. /**
  36311. * @hidden
  36312. * Defines the actions happening just after a render target has been drawn.
  36313. */
  36314. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36315. /**
  36316. * @hidden
  36317. * Defines the actions happening just after rendering all cameras and computing intersections.
  36318. */
  36319. _afterRenderStage: Stage<SimpleStageAction>;
  36320. /**
  36321. * @hidden
  36322. * Defines the actions happening when a pointer move event happens.
  36323. */
  36324. _pointerMoveStage: Stage<PointerMoveStageAction>;
  36325. /**
  36326. * @hidden
  36327. * Defines the actions happening when a pointer down event happens.
  36328. */
  36329. _pointerDownStage: Stage<PointerUpDownStageAction>;
  36330. /**
  36331. * @hidden
  36332. * Defines the actions happening when a pointer up event happens.
  36333. */
  36334. _pointerUpStage: Stage<PointerUpDownStageAction>;
  36335. /**
  36336. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  36337. */
  36338. private geometriesByUniqueId;
  36339. /**
  36340. * Creates a new Scene
  36341. * @param engine defines the engine to use to render this scene
  36342. * @param options defines the scene options
  36343. */
  36344. constructor(engine: Engine, options?: SceneOptions);
  36345. /**
  36346. * Gets a string idenfifying the name of the class
  36347. * @returns "Scene" string
  36348. */
  36349. getClassName(): string;
  36350. private _defaultMeshCandidates;
  36351. /**
  36352. * @hidden
  36353. */
  36354. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  36355. private _defaultSubMeshCandidates;
  36356. /**
  36357. * @hidden
  36358. */
  36359. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  36360. /**
  36361. * Sets the default candidate providers for the scene.
  36362. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  36363. * and getCollidingSubMeshCandidates to their default function
  36364. */
  36365. setDefaultCandidateProviders(): void;
  36366. /**
  36367. * Gets the mesh that is currently under the pointer
  36368. */
  36369. readonly meshUnderPointer: Nullable<AbstractMesh>;
  36370. /**
  36371. * Gets or sets the current on-screen X position of the pointer
  36372. */
  36373. pointerX: number;
  36374. /**
  36375. * Gets or sets the current on-screen Y position of the pointer
  36376. */
  36377. pointerY: number;
  36378. /**
  36379. * Gets the cached material (ie. the latest rendered one)
  36380. * @returns the cached material
  36381. */
  36382. getCachedMaterial(): Nullable<Material>;
  36383. /**
  36384. * Gets the cached effect (ie. the latest rendered one)
  36385. * @returns the cached effect
  36386. */
  36387. getCachedEffect(): Nullable<Effect>;
  36388. /**
  36389. * Gets the cached visibility state (ie. the latest rendered one)
  36390. * @returns the cached visibility state
  36391. */
  36392. getCachedVisibility(): Nullable<number>;
  36393. /**
  36394. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  36395. * @param material defines the current material
  36396. * @param effect defines the current effect
  36397. * @param visibility defines the current visibility state
  36398. * @returns true if one parameter is not cached
  36399. */
  36400. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  36401. /**
  36402. * Gets the engine associated with the scene
  36403. * @returns an Engine
  36404. */
  36405. getEngine(): Engine;
  36406. /**
  36407. * Gets the total number of vertices rendered per frame
  36408. * @returns the total number of vertices rendered per frame
  36409. */
  36410. getTotalVertices(): number;
  36411. /**
  36412. * Gets the performance counter for total vertices
  36413. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36414. */
  36415. readonly totalVerticesPerfCounter: PerfCounter;
  36416. /**
  36417. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  36418. * @returns the total number of active indices rendered per frame
  36419. */
  36420. getActiveIndices(): number;
  36421. /**
  36422. * Gets the performance counter for active indices
  36423. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36424. */
  36425. readonly totalActiveIndicesPerfCounter: PerfCounter;
  36426. /**
  36427. * Gets the total number of active particles rendered per frame
  36428. * @returns the total number of active particles rendered per frame
  36429. */
  36430. getActiveParticles(): number;
  36431. /**
  36432. * Gets the performance counter for active particles
  36433. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36434. */
  36435. readonly activeParticlesPerfCounter: PerfCounter;
  36436. /**
  36437. * Gets the total number of active bones rendered per frame
  36438. * @returns the total number of active bones rendered per frame
  36439. */
  36440. getActiveBones(): number;
  36441. /**
  36442. * Gets the performance counter for active bones
  36443. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36444. */
  36445. readonly activeBonesPerfCounter: PerfCounter;
  36446. /**
  36447. * Gets the array of active meshes
  36448. * @returns an array of AbstractMesh
  36449. */
  36450. getActiveMeshes(): SmartArray<AbstractMesh>;
  36451. /**
  36452. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  36453. * @returns a number
  36454. */
  36455. getAnimationRatio(): number;
  36456. /**
  36457. * Gets an unique Id for the current render phase
  36458. * @returns a number
  36459. */
  36460. getRenderId(): number;
  36461. /**
  36462. * Gets an unique Id for the current frame
  36463. * @returns a number
  36464. */
  36465. getFrameId(): number;
  36466. /** Call this function if you want to manually increment the render Id*/
  36467. incrementRenderId(): void;
  36468. private _createUbo;
  36469. /**
  36470. * Use this method to simulate a pointer move on a mesh
  36471. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36472. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36473. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36474. * @returns the current scene
  36475. */
  36476. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36477. /**
  36478. * Use this method to simulate a pointer down on a mesh
  36479. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36480. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36481. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36482. * @returns the current scene
  36483. */
  36484. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36485. /**
  36486. * Use this method to simulate a pointer up on a mesh
  36487. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36488. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36489. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36490. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  36491. * @returns the current scene
  36492. */
  36493. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  36494. /**
  36495. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  36496. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  36497. * @returns true if the pointer was captured
  36498. */
  36499. isPointerCaptured(pointerId?: number): boolean;
  36500. /**
  36501. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  36502. * @param attachUp defines if you want to attach events to pointerup
  36503. * @param attachDown defines if you want to attach events to pointerdown
  36504. * @param attachMove defines if you want to attach events to pointermove
  36505. */
  36506. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  36507. /** Detaches all event handlers*/
  36508. detachControl(): void;
  36509. /**
  36510. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  36511. * Delay loaded resources are not taking in account
  36512. * @return true if all required resources are ready
  36513. */
  36514. isReady(): boolean;
  36515. /** Resets all cached information relative to material (including effect and visibility) */
  36516. resetCachedMaterial(): void;
  36517. /**
  36518. * Registers a function to be called before every frame render
  36519. * @param func defines the function to register
  36520. */
  36521. registerBeforeRender(func: () => void): void;
  36522. /**
  36523. * Unregisters a function called before every frame render
  36524. * @param func defines the function to unregister
  36525. */
  36526. unregisterBeforeRender(func: () => void): void;
  36527. /**
  36528. * Registers a function to be called after every frame render
  36529. * @param func defines the function to register
  36530. */
  36531. registerAfterRender(func: () => void): void;
  36532. /**
  36533. * Unregisters a function called after every frame render
  36534. * @param func defines the function to unregister
  36535. */
  36536. unregisterAfterRender(func: () => void): void;
  36537. private _executeOnceBeforeRender;
  36538. /**
  36539. * The provided function will run before render once and will be disposed afterwards.
  36540. * A timeout delay can be provided so that the function will be executed in N ms.
  36541. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  36542. * @param func The function to be executed.
  36543. * @param timeout optional delay in ms
  36544. */
  36545. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  36546. /** @hidden */
  36547. _addPendingData(data: any): void;
  36548. /** @hidden */
  36549. _removePendingData(data: any): void;
  36550. /**
  36551. * Returns the number of items waiting to be loaded
  36552. * @returns the number of items waiting to be loaded
  36553. */
  36554. getWaitingItemsCount(): number;
  36555. /**
  36556. * Returns a boolean indicating if the scene is still loading data
  36557. */
  36558. readonly isLoading: boolean;
  36559. /**
  36560. * Registers a function to be executed when the scene is ready
  36561. * @param {Function} func - the function to be executed
  36562. */
  36563. executeWhenReady(func: () => void): void;
  36564. /**
  36565. * Returns a promise that resolves when the scene is ready
  36566. * @returns A promise that resolves when the scene is ready
  36567. */
  36568. whenReadyAsync(): Promise<void>;
  36569. /** @hidden */
  36570. _checkIsReady(): void;
  36571. /**
  36572. * Gets all animatable attached to the scene
  36573. */
  36574. readonly animatables: Animatable[];
  36575. /**
  36576. * Resets the last animation time frame.
  36577. * Useful to override when animations start running when loading a scene for the first time.
  36578. */
  36579. resetLastAnimationTimeFrame(): void;
  36580. /**
  36581. * Gets the current view matrix
  36582. * @returns a Matrix
  36583. */
  36584. getViewMatrix(): Matrix;
  36585. /**
  36586. * Gets the current projection matrix
  36587. * @returns a Matrix
  36588. */
  36589. getProjectionMatrix(): Matrix;
  36590. /**
  36591. * Gets the current transform matrix
  36592. * @returns a Matrix made of View * Projection
  36593. */
  36594. getTransformMatrix(): Matrix;
  36595. /**
  36596. * Sets the current transform matrix
  36597. * @param viewL defines the View matrix to use
  36598. * @param projectionL defines the Projection matrix to use
  36599. * @param viewR defines the right View matrix to use (if provided)
  36600. * @param projectionR defines the right Projection matrix to use (if provided)
  36601. */
  36602. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  36603. /**
  36604. * Gets the uniform buffer used to store scene data
  36605. * @returns a UniformBuffer
  36606. */
  36607. getSceneUniformBuffer(): UniformBuffer;
  36608. /**
  36609. * Gets an unique (relatively to the current scene) Id
  36610. * @returns an unique number for the scene
  36611. */
  36612. getUniqueId(): number;
  36613. /**
  36614. * Add a mesh to the list of scene's meshes
  36615. * @param newMesh defines the mesh to add
  36616. * @param recursive if all child meshes should also be added to the scene
  36617. */
  36618. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  36619. /**
  36620. * Remove a mesh for the list of scene's meshes
  36621. * @param toRemove defines the mesh to remove
  36622. * @param recursive if all child meshes should also be removed from the scene
  36623. * @returns the index where the mesh was in the mesh list
  36624. */
  36625. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  36626. /**
  36627. * Add a transform node to the list of scene's transform nodes
  36628. * @param newTransformNode defines the transform node to add
  36629. */
  36630. addTransformNode(newTransformNode: TransformNode): void;
  36631. /**
  36632. * Remove a transform node for the list of scene's transform nodes
  36633. * @param toRemove defines the transform node to remove
  36634. * @returns the index where the transform node was in the transform node list
  36635. */
  36636. removeTransformNode(toRemove: TransformNode): number;
  36637. /**
  36638. * Remove a skeleton for the list of scene's skeletons
  36639. * @param toRemove defines the skeleton to remove
  36640. * @returns the index where the skeleton was in the skeleton list
  36641. */
  36642. removeSkeleton(toRemove: Skeleton): number;
  36643. /**
  36644. * Remove a morph target for the list of scene's morph targets
  36645. * @param toRemove defines the morph target to remove
  36646. * @returns the index where the morph target was in the morph target list
  36647. */
  36648. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  36649. /**
  36650. * Remove a light for the list of scene's lights
  36651. * @param toRemove defines the light to remove
  36652. * @returns the index where the light was in the light list
  36653. */
  36654. removeLight(toRemove: Light): number;
  36655. /**
  36656. * Remove a camera for the list of scene's cameras
  36657. * @param toRemove defines the camera to remove
  36658. * @returns the index where the camera was in the camera list
  36659. */
  36660. removeCamera(toRemove: Camera): number;
  36661. /**
  36662. * Remove a particle system for the list of scene's particle systems
  36663. * @param toRemove defines the particle system to remove
  36664. * @returns the index where the particle system was in the particle system list
  36665. */
  36666. removeParticleSystem(toRemove: IParticleSystem): number;
  36667. /**
  36668. * Remove a animation for the list of scene's animations
  36669. * @param toRemove defines the animation to remove
  36670. * @returns the index where the animation was in the animation list
  36671. */
  36672. removeAnimation(toRemove: Animation): number;
  36673. /**
  36674. * Will stop the animation of the given target
  36675. * @param target - the target
  36676. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  36677. * @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)
  36678. */
  36679. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  36680. /**
  36681. * Removes the given animation group from this scene.
  36682. * @param toRemove The animation group to remove
  36683. * @returns The index of the removed animation group
  36684. */
  36685. removeAnimationGroup(toRemove: AnimationGroup): number;
  36686. /**
  36687. * Removes the given multi-material from this scene.
  36688. * @param toRemove The multi-material to remove
  36689. * @returns The index of the removed multi-material
  36690. */
  36691. removeMultiMaterial(toRemove: MultiMaterial): number;
  36692. /**
  36693. * Removes the given material from this scene.
  36694. * @param toRemove The material to remove
  36695. * @returns The index of the removed material
  36696. */
  36697. removeMaterial(toRemove: Material): number;
  36698. /**
  36699. * Removes the given action manager from this scene.
  36700. * @param toRemove The action manager to remove
  36701. * @returns The index of the removed action manager
  36702. */
  36703. removeActionManager(toRemove: AbstractActionManager): number;
  36704. /**
  36705. * Removes the given texture from this scene.
  36706. * @param toRemove The texture to remove
  36707. * @returns The index of the removed texture
  36708. */
  36709. removeTexture(toRemove: BaseTexture): number;
  36710. /**
  36711. * Adds the given light to this scene
  36712. * @param newLight The light to add
  36713. */
  36714. addLight(newLight: Light): void;
  36715. /**
  36716. * Sorts the list list based on light priorities
  36717. */
  36718. sortLightsByPriority(): void;
  36719. /**
  36720. * Adds the given camera to this scene
  36721. * @param newCamera The camera to add
  36722. */
  36723. addCamera(newCamera: Camera): void;
  36724. /**
  36725. * Adds the given skeleton to this scene
  36726. * @param newSkeleton The skeleton to add
  36727. */
  36728. addSkeleton(newSkeleton: Skeleton): void;
  36729. /**
  36730. * Adds the given particle system to this scene
  36731. * @param newParticleSystem The particle system to add
  36732. */
  36733. addParticleSystem(newParticleSystem: IParticleSystem): void;
  36734. /**
  36735. * Adds the given animation to this scene
  36736. * @param newAnimation The animation to add
  36737. */
  36738. addAnimation(newAnimation: Animation): void;
  36739. /**
  36740. * Adds the given animation group to this scene.
  36741. * @param newAnimationGroup The animation group to add
  36742. */
  36743. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  36744. /**
  36745. * Adds the given multi-material to this scene
  36746. * @param newMultiMaterial The multi-material to add
  36747. */
  36748. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  36749. /**
  36750. * Adds the given material to this scene
  36751. * @param newMaterial The material to add
  36752. */
  36753. addMaterial(newMaterial: Material): void;
  36754. /**
  36755. * Adds the given morph target to this scene
  36756. * @param newMorphTargetManager The morph target to add
  36757. */
  36758. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  36759. /**
  36760. * Adds the given geometry to this scene
  36761. * @param newGeometry The geometry to add
  36762. */
  36763. addGeometry(newGeometry: Geometry): void;
  36764. /**
  36765. * Adds the given action manager to this scene
  36766. * @param newActionManager The action manager to add
  36767. */
  36768. addActionManager(newActionManager: AbstractActionManager): void;
  36769. /**
  36770. * Adds the given texture to this scene.
  36771. * @param newTexture The texture to add
  36772. */
  36773. addTexture(newTexture: BaseTexture): void;
  36774. /**
  36775. * Switch active camera
  36776. * @param newCamera defines the new active camera
  36777. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  36778. */
  36779. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  36780. /**
  36781. * sets the active camera of the scene using its ID
  36782. * @param id defines the camera's ID
  36783. * @return the new active camera or null if none found.
  36784. */
  36785. setActiveCameraByID(id: string): Nullable<Camera>;
  36786. /**
  36787. * sets the active camera of the scene using its name
  36788. * @param name defines the camera's name
  36789. * @returns the new active camera or null if none found.
  36790. */
  36791. setActiveCameraByName(name: string): Nullable<Camera>;
  36792. /**
  36793. * get an animation group using its name
  36794. * @param name defines the material's name
  36795. * @return the animation group or null if none found.
  36796. */
  36797. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  36798. /**
  36799. * Get a material using its unique id
  36800. * @param uniqueId defines the material's unique id
  36801. * @return the material or null if none found.
  36802. */
  36803. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  36804. /**
  36805. * get a material using its id
  36806. * @param id defines the material's ID
  36807. * @return the material or null if none found.
  36808. */
  36809. getMaterialByID(id: string): Nullable<Material>;
  36810. /**
  36811. * Gets a the last added material using a given id
  36812. * @param id defines the material's ID
  36813. * @return the last material with the given id or null if none found.
  36814. */
  36815. getLastMaterialByID(id: string): Nullable<Material>;
  36816. /**
  36817. * Gets a material using its name
  36818. * @param name defines the material's name
  36819. * @return the material or null if none found.
  36820. */
  36821. getMaterialByName(name: string): Nullable<Material>;
  36822. /**
  36823. * Get a texture using its unique id
  36824. * @param uniqueId defines the texture's unique id
  36825. * @return the texture or null if none found.
  36826. */
  36827. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  36828. /**
  36829. * Gets a camera using its id
  36830. * @param id defines the id to look for
  36831. * @returns the camera or null if not found
  36832. */
  36833. getCameraByID(id: string): Nullable<Camera>;
  36834. /**
  36835. * Gets a camera using its unique id
  36836. * @param uniqueId defines the unique id to look for
  36837. * @returns the camera or null if not found
  36838. */
  36839. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  36840. /**
  36841. * Gets a camera using its name
  36842. * @param name defines the camera's name
  36843. * @return the camera or null if none found.
  36844. */
  36845. getCameraByName(name: string): Nullable<Camera>;
  36846. /**
  36847. * Gets a bone using its id
  36848. * @param id defines the bone's id
  36849. * @return the bone or null if not found
  36850. */
  36851. getBoneByID(id: string): Nullable<Bone>;
  36852. /**
  36853. * Gets a bone using its id
  36854. * @param name defines the bone's name
  36855. * @return the bone or null if not found
  36856. */
  36857. getBoneByName(name: string): Nullable<Bone>;
  36858. /**
  36859. * Gets a light node using its name
  36860. * @param name defines the the light's name
  36861. * @return the light or null if none found.
  36862. */
  36863. getLightByName(name: string): Nullable<Light>;
  36864. /**
  36865. * Gets a light node using its id
  36866. * @param id defines the light's id
  36867. * @return the light or null if none found.
  36868. */
  36869. getLightByID(id: string): Nullable<Light>;
  36870. /**
  36871. * Gets a light node using its scene-generated unique ID
  36872. * @param uniqueId defines the light's unique id
  36873. * @return the light or null if none found.
  36874. */
  36875. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  36876. /**
  36877. * Gets a particle system by id
  36878. * @param id defines the particle system id
  36879. * @return the corresponding system or null if none found
  36880. */
  36881. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  36882. /**
  36883. * Gets a geometry using its ID
  36884. * @param id defines the geometry's id
  36885. * @return the geometry or null if none found.
  36886. */
  36887. getGeometryByID(id: string): Nullable<Geometry>;
  36888. private _getGeometryByUniqueID;
  36889. /**
  36890. * Add a new geometry to this scene
  36891. * @param geometry defines the geometry to be added to the scene.
  36892. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  36893. * @return a boolean defining if the geometry was added or not
  36894. */
  36895. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  36896. /**
  36897. * Removes an existing geometry
  36898. * @param geometry defines the geometry to be removed from the scene
  36899. * @return a boolean defining if the geometry was removed or not
  36900. */
  36901. removeGeometry(geometry: Geometry): boolean;
  36902. /**
  36903. * Gets the list of geometries attached to the scene
  36904. * @returns an array of Geometry
  36905. */
  36906. getGeometries(): Geometry[];
  36907. /**
  36908. * Gets the first added mesh found of a given ID
  36909. * @param id defines the id to search for
  36910. * @return the mesh found or null if not found at all
  36911. */
  36912. getMeshByID(id: string): Nullable<AbstractMesh>;
  36913. /**
  36914. * Gets a list of meshes using their id
  36915. * @param id defines the id to search for
  36916. * @returns a list of meshes
  36917. */
  36918. getMeshesByID(id: string): Array<AbstractMesh>;
  36919. /**
  36920. * Gets the first added transform node found of a given ID
  36921. * @param id defines the id to search for
  36922. * @return the found transform node or null if not found at all.
  36923. */
  36924. getTransformNodeByID(id: string): Nullable<TransformNode>;
  36925. /**
  36926. * Gets a transform node with its auto-generated unique id
  36927. * @param uniqueId efines the unique id to search for
  36928. * @return the found transform node or null if not found at all.
  36929. */
  36930. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  36931. /**
  36932. * Gets a list of transform nodes using their id
  36933. * @param id defines the id to search for
  36934. * @returns a list of transform nodes
  36935. */
  36936. getTransformNodesByID(id: string): Array<TransformNode>;
  36937. /**
  36938. * Gets a mesh with its auto-generated unique id
  36939. * @param uniqueId defines the unique id to search for
  36940. * @return the found mesh or null if not found at all.
  36941. */
  36942. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  36943. /**
  36944. * Gets a the last added mesh using a given id
  36945. * @param id defines the id to search for
  36946. * @return the found mesh or null if not found at all.
  36947. */
  36948. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  36949. /**
  36950. * Gets a the last added node (Mesh, Camera, Light) using a given id
  36951. * @param id defines the id to search for
  36952. * @return the found node or null if not found at all
  36953. */
  36954. getLastEntryByID(id: string): Nullable<Node>;
  36955. /**
  36956. * Gets a node (Mesh, Camera, Light) using a given id
  36957. * @param id defines the id to search for
  36958. * @return the found node or null if not found at all
  36959. */
  36960. getNodeByID(id: string): Nullable<Node>;
  36961. /**
  36962. * Gets a node (Mesh, Camera, Light) using a given name
  36963. * @param name defines the name to search for
  36964. * @return the found node or null if not found at all.
  36965. */
  36966. getNodeByName(name: string): Nullable<Node>;
  36967. /**
  36968. * Gets a mesh using a given name
  36969. * @param name defines the name to search for
  36970. * @return the found mesh or null if not found at all.
  36971. */
  36972. getMeshByName(name: string): Nullable<AbstractMesh>;
  36973. /**
  36974. * Gets a transform node using a given name
  36975. * @param name defines the name to search for
  36976. * @return the found transform node or null if not found at all.
  36977. */
  36978. getTransformNodeByName(name: string): Nullable<TransformNode>;
  36979. /**
  36980. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  36981. * @param id defines the id to search for
  36982. * @return the found skeleton or null if not found at all.
  36983. */
  36984. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  36985. /**
  36986. * Gets a skeleton using a given auto generated unique id
  36987. * @param uniqueId defines the unique id to search for
  36988. * @return the found skeleton or null if not found at all.
  36989. */
  36990. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  36991. /**
  36992. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  36993. * @param id defines the id to search for
  36994. * @return the found skeleton or null if not found at all.
  36995. */
  36996. getSkeletonById(id: string): Nullable<Skeleton>;
  36997. /**
  36998. * Gets a skeleton using a given name
  36999. * @param name defines the name to search for
  37000. * @return the found skeleton or null if not found at all.
  37001. */
  37002. getSkeletonByName(name: string): Nullable<Skeleton>;
  37003. /**
  37004. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  37005. * @param id defines the id to search for
  37006. * @return the found morph target manager or null if not found at all.
  37007. */
  37008. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  37009. /**
  37010. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  37011. * @param id defines the id to search for
  37012. * @return the found morph target or null if not found at all.
  37013. */
  37014. getMorphTargetById(id: string): Nullable<MorphTarget>;
  37015. /**
  37016. * Gets a boolean indicating if the given mesh is active
  37017. * @param mesh defines the mesh to look for
  37018. * @returns true if the mesh is in the active list
  37019. */
  37020. isActiveMesh(mesh: AbstractMesh): boolean;
  37021. /**
  37022. * Return a unique id as a string which can serve as an identifier for the scene
  37023. */
  37024. readonly uid: string;
  37025. /**
  37026. * Add an externaly attached data from its key.
  37027. * This method call will fail and return false, if such key already exists.
  37028. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  37029. * @param key the unique key that identifies the data
  37030. * @param data the data object to associate to the key for this Engine instance
  37031. * @return true if no such key were already present and the data was added successfully, false otherwise
  37032. */
  37033. addExternalData<T>(key: string, data: T): boolean;
  37034. /**
  37035. * Get an externaly attached data from its key
  37036. * @param key the unique key that identifies the data
  37037. * @return the associated data, if present (can be null), or undefined if not present
  37038. */
  37039. getExternalData<T>(key: string): Nullable<T>;
  37040. /**
  37041. * Get an externaly attached data from its key, create it using a factory if it's not already present
  37042. * @param key the unique key that identifies the data
  37043. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  37044. * @return the associated data, can be null if the factory returned null.
  37045. */
  37046. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  37047. /**
  37048. * Remove an externaly attached data from the Engine instance
  37049. * @param key the unique key that identifies the data
  37050. * @return true if the data was successfully removed, false if it doesn't exist
  37051. */
  37052. removeExternalData(key: string): boolean;
  37053. private _evaluateSubMesh;
  37054. /**
  37055. * Clear the processed materials smart array preventing retention point in material dispose.
  37056. */
  37057. freeProcessedMaterials(): void;
  37058. private _preventFreeActiveMeshesAndRenderingGroups;
  37059. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  37060. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  37061. * when disposing several meshes in a row or a hierarchy of meshes.
  37062. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  37063. */
  37064. blockfreeActiveMeshesAndRenderingGroups: boolean;
  37065. /**
  37066. * Clear the active meshes smart array preventing retention point in mesh dispose.
  37067. */
  37068. freeActiveMeshes(): void;
  37069. /**
  37070. * Clear the info related to rendering groups preventing retention points during dispose.
  37071. */
  37072. freeRenderingGroups(): void;
  37073. /** @hidden */
  37074. _isInIntermediateRendering(): boolean;
  37075. /**
  37076. * Lambda returning the list of potentially active meshes.
  37077. */
  37078. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  37079. /**
  37080. * Lambda returning the list of potentially active sub meshes.
  37081. */
  37082. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  37083. /**
  37084. * Lambda returning the list of potentially intersecting sub meshes.
  37085. */
  37086. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  37087. /**
  37088. * Lambda returning the list of potentially colliding sub meshes.
  37089. */
  37090. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  37091. private _activeMeshesFrozen;
  37092. private _skipEvaluateActiveMeshesCompletely;
  37093. /**
  37094. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  37095. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  37096. * @returns the current scene
  37097. */
  37098. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  37099. /**
  37100. * Use this function to restart evaluating active meshes on every frame
  37101. * @returns the current scene
  37102. */
  37103. unfreezeActiveMeshes(): Scene;
  37104. private _evaluateActiveMeshes;
  37105. private _activeMesh;
  37106. /**
  37107. * Update the transform matrix to update from the current active camera
  37108. * @param force defines a boolean used to force the update even if cache is up to date
  37109. */
  37110. updateTransformMatrix(force?: boolean): void;
  37111. private _bindFrameBuffer;
  37112. /** @hidden */
  37113. _allowPostProcessClearColor: boolean;
  37114. /** @hidden */
  37115. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  37116. private _processSubCameras;
  37117. private _checkIntersections;
  37118. /** @hidden */
  37119. _advancePhysicsEngineStep(step: number): void;
  37120. /**
  37121. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  37122. */
  37123. getDeterministicFrameTime: () => number;
  37124. /** @hidden */
  37125. _animate(): void;
  37126. /** Execute all animations (for a frame) */
  37127. animate(): void;
  37128. /**
  37129. * Render the scene
  37130. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  37131. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  37132. */
  37133. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  37134. /**
  37135. * Freeze all materials
  37136. * A frozen material will not be updatable but should be faster to render
  37137. */
  37138. freezeMaterials(): void;
  37139. /**
  37140. * Unfreeze all materials
  37141. * A frozen material will not be updatable but should be faster to render
  37142. */
  37143. unfreezeMaterials(): void;
  37144. /**
  37145. * Releases all held ressources
  37146. */
  37147. dispose(): void;
  37148. /**
  37149. * Gets if the scene is already disposed
  37150. */
  37151. readonly isDisposed: boolean;
  37152. /**
  37153. * Call this function to reduce memory footprint of the scene.
  37154. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  37155. */
  37156. clearCachedVertexData(): void;
  37157. /**
  37158. * This function will remove the local cached buffer data from texture.
  37159. * It will save memory but will prevent the texture from being rebuilt
  37160. */
  37161. cleanCachedTextureBuffer(): void;
  37162. /**
  37163. * Get the world extend vectors with an optional filter
  37164. *
  37165. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  37166. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  37167. */
  37168. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  37169. min: Vector3;
  37170. max: Vector3;
  37171. };
  37172. /**
  37173. * Creates a ray that can be used to pick in the scene
  37174. * @param x defines the x coordinate of the origin (on-screen)
  37175. * @param y defines the y coordinate of the origin (on-screen)
  37176. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37177. * @param camera defines the camera to use for the picking
  37178. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37179. * @returns a Ray
  37180. */
  37181. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  37182. /**
  37183. * Creates a ray that can be used to pick in the scene
  37184. * @param x defines the x coordinate of the origin (on-screen)
  37185. * @param y defines the y coordinate of the origin (on-screen)
  37186. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37187. * @param result defines the ray where to store the picking ray
  37188. * @param camera defines the camera to use for the picking
  37189. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37190. * @returns the current scene
  37191. */
  37192. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  37193. /**
  37194. * Creates a ray that can be used to pick in the scene
  37195. * @param x defines the x coordinate of the origin (on-screen)
  37196. * @param y defines the y coordinate of the origin (on-screen)
  37197. * @param camera defines the camera to use for the picking
  37198. * @returns a Ray
  37199. */
  37200. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  37201. /**
  37202. * Creates a ray that can be used to pick in the scene
  37203. * @param x defines the x coordinate of the origin (on-screen)
  37204. * @param y defines the y coordinate of the origin (on-screen)
  37205. * @param result defines the ray where to store the picking ray
  37206. * @param camera defines the camera to use for the picking
  37207. * @returns the current scene
  37208. */
  37209. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  37210. /** Launch a ray to try to pick a mesh in the scene
  37211. * @param x position on screen
  37212. * @param y position on screen
  37213. * @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
  37214. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37215. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37216. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37217. * @returns a PickingInfo
  37218. */
  37219. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37220. /** Use the given ray to pick a mesh in the scene
  37221. * @param ray The ray to use to pick meshes
  37222. * @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
  37223. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  37224. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37225. * @returns a PickingInfo
  37226. */
  37227. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37228. /**
  37229. * Launch a ray to try to pick a mesh in the scene
  37230. * @param x X position on screen
  37231. * @param y Y position on screen
  37232. * @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
  37233. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37234. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37235. * @returns an array of PickingInfo
  37236. */
  37237. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37238. /**
  37239. * Launch a ray to try to pick a mesh in the scene
  37240. * @param ray Ray to use
  37241. * @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
  37242. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37243. * @returns an array of PickingInfo
  37244. */
  37245. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37246. /**
  37247. * Force the value of meshUnderPointer
  37248. * @param mesh defines the mesh to use
  37249. */
  37250. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37251. /**
  37252. * Gets the mesh under the pointer
  37253. * @returns a Mesh or null if no mesh is under the pointer
  37254. */
  37255. getPointerOverMesh(): Nullable<AbstractMesh>;
  37256. /** @hidden */
  37257. _rebuildGeometries(): void;
  37258. /** @hidden */
  37259. _rebuildTextures(): void;
  37260. private _getByTags;
  37261. /**
  37262. * Get a list of meshes by tags
  37263. * @param tagsQuery defines the tags query to use
  37264. * @param forEach defines a predicate used to filter results
  37265. * @returns an array of Mesh
  37266. */
  37267. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  37268. /**
  37269. * Get a list of cameras by tags
  37270. * @param tagsQuery defines the tags query to use
  37271. * @param forEach defines a predicate used to filter results
  37272. * @returns an array of Camera
  37273. */
  37274. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  37275. /**
  37276. * Get a list of lights by tags
  37277. * @param tagsQuery defines the tags query to use
  37278. * @param forEach defines a predicate used to filter results
  37279. * @returns an array of Light
  37280. */
  37281. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  37282. /**
  37283. * Get a list of materials by tags
  37284. * @param tagsQuery defines the tags query to use
  37285. * @param forEach defines a predicate used to filter results
  37286. * @returns an array of Material
  37287. */
  37288. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  37289. /**
  37290. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37291. * This allowed control for front to back rendering or reversly depending of the special needs.
  37292. *
  37293. * @param renderingGroupId The rendering group id corresponding to its index
  37294. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37295. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37296. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37297. */
  37298. 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;
  37299. /**
  37300. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37301. *
  37302. * @param renderingGroupId The rendering group id corresponding to its index
  37303. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37304. * @param depth Automatically clears depth between groups if true and autoClear is true.
  37305. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  37306. */
  37307. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  37308. /**
  37309. * Gets the current auto clear configuration for one rendering group of the rendering
  37310. * manager.
  37311. * @param index the rendering group index to get the information for
  37312. * @returns The auto clear setup for the requested rendering group
  37313. */
  37314. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  37315. private _blockMaterialDirtyMechanism;
  37316. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  37317. blockMaterialDirtyMechanism: boolean;
  37318. /**
  37319. * Will flag all materials as dirty to trigger new shader compilation
  37320. * @param flag defines the flag used to specify which material part must be marked as dirty
  37321. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  37322. */
  37323. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37324. /** @hidden */
  37325. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  37326. /** @hidden */
  37327. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37328. /** @hidden */
  37329. _requestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  37330. /** @hidden */
  37331. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  37332. /** @hidden */
  37333. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37334. /** @hidden */
  37335. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37336. }
  37337. }
  37338. declare module "babylonjs/assetContainer" {
  37339. import { AbstractScene } from "babylonjs/abstractScene";
  37340. import { Scene } from "babylonjs/scene";
  37341. import { Mesh } from "babylonjs/Meshes/mesh";
  37342. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37343. import { Skeleton } from "babylonjs/Bones/skeleton";
  37344. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  37345. /**
  37346. * Set of assets to keep when moving a scene into an asset container.
  37347. */
  37348. export class KeepAssets extends AbstractScene {
  37349. }
  37350. /**
  37351. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  37352. */
  37353. export class InstantiatedEntries {
  37354. /**
  37355. * List of new root nodes (eg. nodes with no parent)
  37356. */
  37357. rootNodes: TransformNode[];
  37358. /**
  37359. * List of new skeletons
  37360. */
  37361. skeletons: Skeleton[];
  37362. /**
  37363. * List of new animation groups
  37364. */
  37365. animationGroups: AnimationGroup[];
  37366. }
  37367. /**
  37368. * Container with a set of assets that can be added or removed from a scene.
  37369. */
  37370. export class AssetContainer extends AbstractScene {
  37371. /**
  37372. * The scene the AssetContainer belongs to.
  37373. */
  37374. scene: Scene;
  37375. /**
  37376. * Instantiates an AssetContainer.
  37377. * @param scene The scene the AssetContainer belongs to.
  37378. */
  37379. constructor(scene: Scene);
  37380. /**
  37381. * Instantiate or clone all meshes and add the new ones to the scene.
  37382. * Skeletons and animation groups will all be cloned
  37383. * @param nameFunction defines an optional function used to get new names for clones
  37384. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  37385. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  37386. */
  37387. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  37388. /**
  37389. * Adds all the assets from the container to the scene.
  37390. */
  37391. addAllToScene(): void;
  37392. /**
  37393. * Removes all the assets in the container from the scene
  37394. */
  37395. removeAllFromScene(): void;
  37396. /**
  37397. * Disposes all the assets in the container
  37398. */
  37399. dispose(): void;
  37400. private _moveAssets;
  37401. /**
  37402. * Removes all the assets contained in the scene and adds them to the container.
  37403. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  37404. */
  37405. moveAllFromScene(keepAssets?: KeepAssets): void;
  37406. /**
  37407. * 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.
  37408. * @returns the root mesh
  37409. */
  37410. createRootMesh(): Mesh;
  37411. }
  37412. }
  37413. declare module "babylonjs/abstractScene" {
  37414. import { Scene } from "babylonjs/scene";
  37415. import { Nullable } from "babylonjs/types";
  37416. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37417. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37418. import { Geometry } from "babylonjs/Meshes/geometry";
  37419. import { Skeleton } from "babylonjs/Bones/skeleton";
  37420. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  37421. import { AssetContainer } from "babylonjs/assetContainer";
  37422. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  37423. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  37424. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  37425. import { Material } from "babylonjs/Materials/material";
  37426. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  37427. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  37428. import { Camera } from "babylonjs/Cameras/camera";
  37429. import { Light } from "babylonjs/Lights/light";
  37430. import { Node } from "babylonjs/node";
  37431. import { Animation } from "babylonjs/Animations/animation";
  37432. /**
  37433. * Defines how the parser contract is defined.
  37434. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  37435. */
  37436. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  37437. /**
  37438. * Defines how the individual parser contract is defined.
  37439. * These parser can parse an individual asset
  37440. */
  37441. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  37442. /**
  37443. * Base class of the scene acting as a container for the different elements composing a scene.
  37444. * This class is dynamically extended by the different components of the scene increasing
  37445. * flexibility and reducing coupling
  37446. */
  37447. export abstract class AbstractScene {
  37448. /**
  37449. * Stores the list of available parsers in the application.
  37450. */
  37451. private static _BabylonFileParsers;
  37452. /**
  37453. * Stores the list of available individual parsers in the application.
  37454. */
  37455. private static _IndividualBabylonFileParsers;
  37456. /**
  37457. * Adds a parser in the list of available ones
  37458. * @param name Defines the name of the parser
  37459. * @param parser Defines the parser to add
  37460. */
  37461. static AddParser(name: string, parser: BabylonFileParser): void;
  37462. /**
  37463. * Gets a general parser from the list of avaialble ones
  37464. * @param name Defines the name of the parser
  37465. * @returns the requested parser or null
  37466. */
  37467. static GetParser(name: string): Nullable<BabylonFileParser>;
  37468. /**
  37469. * Adds n individual parser in the list of available ones
  37470. * @param name Defines the name of the parser
  37471. * @param parser Defines the parser to add
  37472. */
  37473. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  37474. /**
  37475. * Gets an individual parser from the list of avaialble ones
  37476. * @param name Defines the name of the parser
  37477. * @returns the requested parser or null
  37478. */
  37479. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  37480. /**
  37481. * Parser json data and populate both a scene and its associated container object
  37482. * @param jsonData Defines the data to parse
  37483. * @param scene Defines the scene to parse the data for
  37484. * @param container Defines the container attached to the parsing sequence
  37485. * @param rootUrl Defines the root url of the data
  37486. */
  37487. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  37488. /**
  37489. * Gets the list of root nodes (ie. nodes with no parent)
  37490. */
  37491. rootNodes: Node[];
  37492. /** All of the cameras added to this scene
  37493. * @see http://doc.babylonjs.com/babylon101/cameras
  37494. */
  37495. cameras: Camera[];
  37496. /**
  37497. * All of the lights added to this scene
  37498. * @see http://doc.babylonjs.com/babylon101/lights
  37499. */
  37500. lights: Light[];
  37501. /**
  37502. * All of the (abstract) meshes added to this scene
  37503. */
  37504. meshes: AbstractMesh[];
  37505. /**
  37506. * The list of skeletons added to the scene
  37507. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  37508. */
  37509. skeletons: Skeleton[];
  37510. /**
  37511. * All of the particle systems added to this scene
  37512. * @see http://doc.babylonjs.com/babylon101/particles
  37513. */
  37514. particleSystems: IParticleSystem[];
  37515. /**
  37516. * Gets a list of Animations associated with the scene
  37517. */
  37518. animations: Animation[];
  37519. /**
  37520. * All of the animation groups added to this scene
  37521. * @see http://doc.babylonjs.com/how_to/group
  37522. */
  37523. animationGroups: AnimationGroup[];
  37524. /**
  37525. * All of the multi-materials added to this scene
  37526. * @see http://doc.babylonjs.com/how_to/multi_materials
  37527. */
  37528. multiMaterials: MultiMaterial[];
  37529. /**
  37530. * All of the materials added to this scene
  37531. * In the context of a Scene, it is not supposed to be modified manually.
  37532. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  37533. * Note also that the order of the Material within the array is not significant and might change.
  37534. * @see http://doc.babylonjs.com/babylon101/materials
  37535. */
  37536. materials: Material[];
  37537. /**
  37538. * The list of morph target managers added to the scene
  37539. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  37540. */
  37541. morphTargetManagers: MorphTargetManager[];
  37542. /**
  37543. * The list of geometries used in the scene.
  37544. */
  37545. geometries: Geometry[];
  37546. /**
  37547. * All of the tranform nodes added to this scene
  37548. * In the context of a Scene, it is not supposed to be modified manually.
  37549. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  37550. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  37551. * @see http://doc.babylonjs.com/how_to/transformnode
  37552. */
  37553. transformNodes: TransformNode[];
  37554. /**
  37555. * ActionManagers available on the scene.
  37556. */
  37557. actionManagers: AbstractActionManager[];
  37558. /**
  37559. * Textures to keep.
  37560. */
  37561. textures: BaseTexture[];
  37562. /**
  37563. * Environment texture for the scene
  37564. */
  37565. environmentTexture: Nullable<BaseTexture>;
  37566. }
  37567. }
  37568. declare module "babylonjs/Audio/sound" {
  37569. import { Observable } from "babylonjs/Misc/observable";
  37570. import { Vector3 } from "babylonjs/Maths/math.vector";
  37571. import { Nullable } from "babylonjs/types";
  37572. import { Scene } from "babylonjs/scene";
  37573. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37574. /**
  37575. * Interface used to define options for Sound class
  37576. */
  37577. export interface ISoundOptions {
  37578. /**
  37579. * Does the sound autoplay once loaded.
  37580. */
  37581. autoplay?: boolean;
  37582. /**
  37583. * Does the sound loop after it finishes playing once.
  37584. */
  37585. loop?: boolean;
  37586. /**
  37587. * Sound's volume
  37588. */
  37589. volume?: number;
  37590. /**
  37591. * Is it a spatial sound?
  37592. */
  37593. spatialSound?: boolean;
  37594. /**
  37595. * Maximum distance to hear that sound
  37596. */
  37597. maxDistance?: number;
  37598. /**
  37599. * Uses user defined attenuation function
  37600. */
  37601. useCustomAttenuation?: boolean;
  37602. /**
  37603. * Define the roll off factor of spatial sounds.
  37604. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37605. */
  37606. rolloffFactor?: number;
  37607. /**
  37608. * Define the reference distance the sound should be heard perfectly.
  37609. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37610. */
  37611. refDistance?: number;
  37612. /**
  37613. * Define the distance attenuation model the sound will follow.
  37614. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37615. */
  37616. distanceModel?: string;
  37617. /**
  37618. * Defines the playback speed (1 by default)
  37619. */
  37620. playbackRate?: number;
  37621. /**
  37622. * Defines if the sound is from a streaming source
  37623. */
  37624. streaming?: boolean;
  37625. /**
  37626. * Defines an optional length (in seconds) inside the sound file
  37627. */
  37628. length?: number;
  37629. /**
  37630. * Defines an optional offset (in seconds) inside the sound file
  37631. */
  37632. offset?: number;
  37633. /**
  37634. * If true, URLs will not be required to state the audio file codec to use.
  37635. */
  37636. skipCodecCheck?: boolean;
  37637. }
  37638. /**
  37639. * Defines a sound that can be played in the application.
  37640. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  37641. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37642. */
  37643. export class Sound {
  37644. /**
  37645. * The name of the sound in the scene.
  37646. */
  37647. name: string;
  37648. /**
  37649. * Does the sound autoplay once loaded.
  37650. */
  37651. autoplay: boolean;
  37652. /**
  37653. * Does the sound loop after it finishes playing once.
  37654. */
  37655. loop: boolean;
  37656. /**
  37657. * Does the sound use a custom attenuation curve to simulate the falloff
  37658. * happening when the source gets further away from the camera.
  37659. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37660. */
  37661. useCustomAttenuation: boolean;
  37662. /**
  37663. * The sound track id this sound belongs to.
  37664. */
  37665. soundTrackId: number;
  37666. /**
  37667. * Is this sound currently played.
  37668. */
  37669. isPlaying: boolean;
  37670. /**
  37671. * Is this sound currently paused.
  37672. */
  37673. isPaused: boolean;
  37674. /**
  37675. * Does this sound enables spatial sound.
  37676. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37677. */
  37678. spatialSound: boolean;
  37679. /**
  37680. * Define the reference distance the sound should be heard perfectly.
  37681. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37682. */
  37683. refDistance: number;
  37684. /**
  37685. * Define the roll off factor of spatial sounds.
  37686. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37687. */
  37688. rolloffFactor: number;
  37689. /**
  37690. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  37691. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37692. */
  37693. maxDistance: number;
  37694. /**
  37695. * Define the distance attenuation model the sound will follow.
  37696. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37697. */
  37698. distanceModel: string;
  37699. /**
  37700. * @hidden
  37701. * Back Compat
  37702. **/
  37703. onended: () => any;
  37704. /**
  37705. * Observable event when the current playing sound finishes.
  37706. */
  37707. onEndedObservable: Observable<Sound>;
  37708. private _panningModel;
  37709. private _playbackRate;
  37710. private _streaming;
  37711. private _startTime;
  37712. private _startOffset;
  37713. private _position;
  37714. /** @hidden */
  37715. _positionInEmitterSpace: boolean;
  37716. private _localDirection;
  37717. private _volume;
  37718. private _isReadyToPlay;
  37719. private _isDirectional;
  37720. private _readyToPlayCallback;
  37721. private _audioBuffer;
  37722. private _soundSource;
  37723. private _streamingSource;
  37724. private _soundPanner;
  37725. private _soundGain;
  37726. private _inputAudioNode;
  37727. private _outputAudioNode;
  37728. private _coneInnerAngle;
  37729. private _coneOuterAngle;
  37730. private _coneOuterGain;
  37731. private _scene;
  37732. private _connectedTransformNode;
  37733. private _customAttenuationFunction;
  37734. private _registerFunc;
  37735. private _isOutputConnected;
  37736. private _htmlAudioElement;
  37737. private _urlType;
  37738. private _length?;
  37739. private _offset?;
  37740. /** @hidden */
  37741. static _SceneComponentInitialization: (scene: Scene) => void;
  37742. /**
  37743. * Create a sound and attach it to a scene
  37744. * @param name Name of your sound
  37745. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  37746. * @param scene defines the scene the sound belongs to
  37747. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  37748. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  37749. */
  37750. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  37751. /**
  37752. * Release the sound and its associated resources
  37753. */
  37754. dispose(): void;
  37755. /**
  37756. * Gets if the sounds is ready to be played or not.
  37757. * @returns true if ready, otherwise false
  37758. */
  37759. isReady(): boolean;
  37760. private _soundLoaded;
  37761. /**
  37762. * Sets the data of the sound from an audiobuffer
  37763. * @param audioBuffer The audioBuffer containing the data
  37764. */
  37765. setAudioBuffer(audioBuffer: AudioBuffer): void;
  37766. /**
  37767. * Updates the current sounds options such as maxdistance, loop...
  37768. * @param options A JSON object containing values named as the object properties
  37769. */
  37770. updateOptions(options: ISoundOptions): void;
  37771. private _createSpatialParameters;
  37772. private _updateSpatialParameters;
  37773. /**
  37774. * Switch the panning model to HRTF:
  37775. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37776. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37777. */
  37778. switchPanningModelToHRTF(): void;
  37779. /**
  37780. * Switch the panning model to Equal Power:
  37781. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37782. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37783. */
  37784. switchPanningModelToEqualPower(): void;
  37785. private _switchPanningModel;
  37786. /**
  37787. * Connect this sound to a sound track audio node like gain...
  37788. * @param soundTrackAudioNode the sound track audio node to connect to
  37789. */
  37790. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  37791. /**
  37792. * Transform this sound into a directional source
  37793. * @param coneInnerAngle Size of the inner cone in degree
  37794. * @param coneOuterAngle Size of the outer cone in degree
  37795. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  37796. */
  37797. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  37798. /**
  37799. * Gets or sets the inner angle for the directional cone.
  37800. */
  37801. /**
  37802. * Gets or sets the inner angle for the directional cone.
  37803. */
  37804. directionalConeInnerAngle: number;
  37805. /**
  37806. * Gets or sets the outer angle for the directional cone.
  37807. */
  37808. /**
  37809. * Gets or sets the outer angle for the directional cone.
  37810. */
  37811. directionalConeOuterAngle: number;
  37812. /**
  37813. * Sets the position of the emitter if spatial sound is enabled
  37814. * @param newPosition Defines the new posisiton
  37815. */
  37816. setPosition(newPosition: Vector3): void;
  37817. /**
  37818. * Sets the local direction of the emitter if spatial sound is enabled
  37819. * @param newLocalDirection Defines the new local direction
  37820. */
  37821. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  37822. private _updateDirection;
  37823. /** @hidden */
  37824. updateDistanceFromListener(): void;
  37825. /**
  37826. * Sets a new custom attenuation function for the sound.
  37827. * @param callback Defines the function used for the attenuation
  37828. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37829. */
  37830. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  37831. /**
  37832. * Play the sound
  37833. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  37834. * @param offset (optional) Start the sound at a specific time in seconds
  37835. * @param length (optional) Sound duration (in seconds)
  37836. */
  37837. play(time?: number, offset?: number, length?: number): void;
  37838. private _onended;
  37839. /**
  37840. * Stop the sound
  37841. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  37842. */
  37843. stop(time?: number): void;
  37844. /**
  37845. * Put the sound in pause
  37846. */
  37847. pause(): void;
  37848. /**
  37849. * Sets a dedicated volume for this sounds
  37850. * @param newVolume Define the new volume of the sound
  37851. * @param time Define time for gradual change to new volume
  37852. */
  37853. setVolume(newVolume: number, time?: number): void;
  37854. /**
  37855. * Set the sound play back rate
  37856. * @param newPlaybackRate Define the playback rate the sound should be played at
  37857. */
  37858. setPlaybackRate(newPlaybackRate: number): void;
  37859. /**
  37860. * Gets the volume of the sound.
  37861. * @returns the volume of the sound
  37862. */
  37863. getVolume(): number;
  37864. /**
  37865. * Attach the sound to a dedicated mesh
  37866. * @param transformNode The transform node to connect the sound with
  37867. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37868. */
  37869. attachToMesh(transformNode: TransformNode): void;
  37870. /**
  37871. * Detach the sound from the previously attached mesh
  37872. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37873. */
  37874. detachFromMesh(): void;
  37875. private _onRegisterAfterWorldMatrixUpdate;
  37876. /**
  37877. * Clone the current sound in the scene.
  37878. * @returns the new sound clone
  37879. */
  37880. clone(): Nullable<Sound>;
  37881. /**
  37882. * Gets the current underlying audio buffer containing the data
  37883. * @returns the audio buffer
  37884. */
  37885. getAudioBuffer(): Nullable<AudioBuffer>;
  37886. /**
  37887. * Serializes the Sound in a JSON representation
  37888. * @returns the JSON representation of the sound
  37889. */
  37890. serialize(): any;
  37891. /**
  37892. * Parse a JSON representation of a sound to innstantiate in a given scene
  37893. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  37894. * @param scene Define the scene the new parsed sound should be created in
  37895. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  37896. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  37897. * @returns the newly parsed sound
  37898. */
  37899. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  37900. }
  37901. }
  37902. declare module "babylonjs/Actions/directAudioActions" {
  37903. import { Action } from "babylonjs/Actions/action";
  37904. import { Condition } from "babylonjs/Actions/condition";
  37905. import { Sound } from "babylonjs/Audio/sound";
  37906. /**
  37907. * This defines an action helpful to play a defined sound on a triggered action.
  37908. */
  37909. export class PlaySoundAction extends Action {
  37910. private _sound;
  37911. /**
  37912. * Instantiate the action
  37913. * @param triggerOptions defines the trigger options
  37914. * @param sound defines the sound to play
  37915. * @param condition defines the trigger related conditions
  37916. */
  37917. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37918. /** @hidden */
  37919. _prepare(): void;
  37920. /**
  37921. * Execute the action and play the sound.
  37922. */
  37923. execute(): void;
  37924. /**
  37925. * Serializes the actions and its related information.
  37926. * @param parent defines the object to serialize in
  37927. * @returns the serialized object
  37928. */
  37929. serialize(parent: any): any;
  37930. }
  37931. /**
  37932. * This defines an action helpful to stop a defined sound on a triggered action.
  37933. */
  37934. export class StopSoundAction extends Action {
  37935. private _sound;
  37936. /**
  37937. * Instantiate the action
  37938. * @param triggerOptions defines the trigger options
  37939. * @param sound defines the sound to stop
  37940. * @param condition defines the trigger related conditions
  37941. */
  37942. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37943. /** @hidden */
  37944. _prepare(): void;
  37945. /**
  37946. * Execute the action and stop the sound.
  37947. */
  37948. execute(): void;
  37949. /**
  37950. * Serializes the actions and its related information.
  37951. * @param parent defines the object to serialize in
  37952. * @returns the serialized object
  37953. */
  37954. serialize(parent: any): any;
  37955. }
  37956. }
  37957. declare module "babylonjs/Actions/interpolateValueAction" {
  37958. import { Action } from "babylonjs/Actions/action";
  37959. import { Condition } from "babylonjs/Actions/condition";
  37960. import { Observable } from "babylonjs/Misc/observable";
  37961. /**
  37962. * This defines an action responsible to change the value of a property
  37963. * by interpolating between its current value and the newly set one once triggered.
  37964. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  37965. */
  37966. export class InterpolateValueAction extends Action {
  37967. /**
  37968. * Defines the path of the property where the value should be interpolated
  37969. */
  37970. propertyPath: string;
  37971. /**
  37972. * Defines the target value at the end of the interpolation.
  37973. */
  37974. value: any;
  37975. /**
  37976. * Defines the time it will take for the property to interpolate to the value.
  37977. */
  37978. duration: number;
  37979. /**
  37980. * Defines if the other scene animations should be stopped when the action has been triggered
  37981. */
  37982. stopOtherAnimations?: boolean;
  37983. /**
  37984. * Defines a callback raised once the interpolation animation has been done.
  37985. */
  37986. onInterpolationDone?: () => void;
  37987. /**
  37988. * Observable triggered once the interpolation animation has been done.
  37989. */
  37990. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  37991. private _target;
  37992. private _effectiveTarget;
  37993. private _property;
  37994. /**
  37995. * Instantiate the action
  37996. * @param triggerOptions defines the trigger options
  37997. * @param target defines the object containing the value to interpolate
  37998. * @param propertyPath defines the path to the property in the target object
  37999. * @param value defines the target value at the end of the interpolation
  38000. * @param duration deines the time it will take for the property to interpolate to the value.
  38001. * @param condition defines the trigger related conditions
  38002. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  38003. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  38004. */
  38005. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  38006. /** @hidden */
  38007. _prepare(): void;
  38008. /**
  38009. * Execute the action starts the value interpolation.
  38010. */
  38011. execute(): void;
  38012. /**
  38013. * Serializes the actions and its related information.
  38014. * @param parent defines the object to serialize in
  38015. * @returns the serialized object
  38016. */
  38017. serialize(parent: any): any;
  38018. }
  38019. }
  38020. declare module "babylonjs/Actions/index" {
  38021. export * from "babylonjs/Actions/abstractActionManager";
  38022. export * from "babylonjs/Actions/action";
  38023. export * from "babylonjs/Actions/actionEvent";
  38024. export * from "babylonjs/Actions/actionManager";
  38025. export * from "babylonjs/Actions/condition";
  38026. export * from "babylonjs/Actions/directActions";
  38027. export * from "babylonjs/Actions/directAudioActions";
  38028. export * from "babylonjs/Actions/interpolateValueAction";
  38029. }
  38030. declare module "babylonjs/Animations/index" {
  38031. export * from "babylonjs/Animations/animatable";
  38032. export * from "babylonjs/Animations/animation";
  38033. export * from "babylonjs/Animations/animationGroup";
  38034. export * from "babylonjs/Animations/animationPropertiesOverride";
  38035. export * from "babylonjs/Animations/easing";
  38036. export * from "babylonjs/Animations/runtimeAnimation";
  38037. export * from "babylonjs/Animations/animationEvent";
  38038. export * from "babylonjs/Animations/animationGroup";
  38039. export * from "babylonjs/Animations/animationKey";
  38040. export * from "babylonjs/Animations/animationRange";
  38041. export * from "babylonjs/Animations/animatable.interface";
  38042. }
  38043. declare module "babylonjs/Audio/soundTrack" {
  38044. import { Sound } from "babylonjs/Audio/sound";
  38045. import { Analyser } from "babylonjs/Audio/analyser";
  38046. import { Scene } from "babylonjs/scene";
  38047. /**
  38048. * Options allowed during the creation of a sound track.
  38049. */
  38050. export interface ISoundTrackOptions {
  38051. /**
  38052. * The volume the sound track should take during creation
  38053. */
  38054. volume?: number;
  38055. /**
  38056. * Define if the sound track is the main sound track of the scene
  38057. */
  38058. mainTrack?: boolean;
  38059. }
  38060. /**
  38061. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  38062. * It will be also used in a future release to apply effects on a specific track.
  38063. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38064. */
  38065. export class SoundTrack {
  38066. /**
  38067. * The unique identifier of the sound track in the scene.
  38068. */
  38069. id: number;
  38070. /**
  38071. * The list of sounds included in the sound track.
  38072. */
  38073. soundCollection: Array<Sound>;
  38074. private _outputAudioNode;
  38075. private _scene;
  38076. private _connectedAnalyser;
  38077. private _options;
  38078. private _isInitialized;
  38079. /**
  38080. * Creates a new sound track.
  38081. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38082. * @param scene Define the scene the sound track belongs to
  38083. * @param options
  38084. */
  38085. constructor(scene: Scene, options?: ISoundTrackOptions);
  38086. private _initializeSoundTrackAudioGraph;
  38087. /**
  38088. * Release the sound track and its associated resources
  38089. */
  38090. dispose(): void;
  38091. /**
  38092. * Adds a sound to this sound track
  38093. * @param sound define the cound to add
  38094. * @ignoreNaming
  38095. */
  38096. AddSound(sound: Sound): void;
  38097. /**
  38098. * Removes a sound to this sound track
  38099. * @param sound define the cound to remove
  38100. * @ignoreNaming
  38101. */
  38102. RemoveSound(sound: Sound): void;
  38103. /**
  38104. * Set a global volume for the full sound track.
  38105. * @param newVolume Define the new volume of the sound track
  38106. */
  38107. setVolume(newVolume: number): void;
  38108. /**
  38109. * Switch the panning model to HRTF:
  38110. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38111. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38112. */
  38113. switchPanningModelToHRTF(): void;
  38114. /**
  38115. * Switch the panning model to Equal Power:
  38116. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38117. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38118. */
  38119. switchPanningModelToEqualPower(): void;
  38120. /**
  38121. * Connect the sound track to an audio analyser allowing some amazing
  38122. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38123. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38124. * @param analyser The analyser to connect to the engine
  38125. */
  38126. connectToAnalyser(analyser: Analyser): void;
  38127. }
  38128. }
  38129. declare module "babylonjs/Audio/audioSceneComponent" {
  38130. import { Sound } from "babylonjs/Audio/sound";
  38131. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  38132. import { Nullable } from "babylonjs/types";
  38133. import { Vector3 } from "babylonjs/Maths/math.vector";
  38134. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  38135. import { Scene } from "babylonjs/scene";
  38136. import { AbstractScene } from "babylonjs/abstractScene";
  38137. import "babylonjs/Audio/audioEngine";
  38138. module "babylonjs/abstractScene" {
  38139. interface AbstractScene {
  38140. /**
  38141. * The list of sounds used in the scene.
  38142. */
  38143. sounds: Nullable<Array<Sound>>;
  38144. }
  38145. }
  38146. module "babylonjs/scene" {
  38147. interface Scene {
  38148. /**
  38149. * @hidden
  38150. * Backing field
  38151. */
  38152. _mainSoundTrack: SoundTrack;
  38153. /**
  38154. * The main sound track played by the scene.
  38155. * It cotains your primary collection of sounds.
  38156. */
  38157. mainSoundTrack: SoundTrack;
  38158. /**
  38159. * The list of sound tracks added to the scene
  38160. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38161. */
  38162. soundTracks: Nullable<Array<SoundTrack>>;
  38163. /**
  38164. * Gets a sound using a given name
  38165. * @param name defines the name to search for
  38166. * @return the found sound or null if not found at all.
  38167. */
  38168. getSoundByName(name: string): Nullable<Sound>;
  38169. /**
  38170. * Gets or sets if audio support is enabled
  38171. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38172. */
  38173. audioEnabled: boolean;
  38174. /**
  38175. * Gets or sets if audio will be output to headphones
  38176. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38177. */
  38178. headphone: boolean;
  38179. /**
  38180. * Gets or sets custom audio listener position provider
  38181. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38182. */
  38183. audioListenerPositionProvider: Nullable<() => Vector3>;
  38184. /**
  38185. * Gets or sets a refresh rate when using 3D audio positioning
  38186. */
  38187. audioPositioningRefreshRate: number;
  38188. }
  38189. }
  38190. /**
  38191. * Defines the sound scene component responsible to manage any sounds
  38192. * in a given scene.
  38193. */
  38194. export class AudioSceneComponent implements ISceneSerializableComponent {
  38195. /**
  38196. * The component name helpfull to identify the component in the list of scene components.
  38197. */
  38198. readonly name: string;
  38199. /**
  38200. * The scene the component belongs to.
  38201. */
  38202. scene: Scene;
  38203. private _audioEnabled;
  38204. /**
  38205. * Gets whether audio is enabled or not.
  38206. * Please use related enable/disable method to switch state.
  38207. */
  38208. readonly audioEnabled: boolean;
  38209. private _headphone;
  38210. /**
  38211. * Gets whether audio is outputing to headphone or not.
  38212. * Please use the according Switch methods to change output.
  38213. */
  38214. readonly headphone: boolean;
  38215. /**
  38216. * Gets or sets a refresh rate when using 3D audio positioning
  38217. */
  38218. audioPositioningRefreshRate: number;
  38219. private _audioListenerPositionProvider;
  38220. /**
  38221. * Gets the current audio listener position provider
  38222. */
  38223. /**
  38224. * Sets a custom listener position for all sounds in the scene
  38225. * By default, this is the position of the first active camera
  38226. */
  38227. audioListenerPositionProvider: Nullable<() => Vector3>;
  38228. /**
  38229. * Creates a new instance of the component for the given scene
  38230. * @param scene Defines the scene to register the component in
  38231. */
  38232. constructor(scene: Scene);
  38233. /**
  38234. * Registers the component in a given scene
  38235. */
  38236. register(): void;
  38237. /**
  38238. * Rebuilds the elements related to this component in case of
  38239. * context lost for instance.
  38240. */
  38241. rebuild(): void;
  38242. /**
  38243. * Serializes the component data to the specified json object
  38244. * @param serializationObject The object to serialize to
  38245. */
  38246. serialize(serializationObject: any): void;
  38247. /**
  38248. * Adds all the elements from the container to the scene
  38249. * @param container the container holding the elements
  38250. */
  38251. addFromContainer(container: AbstractScene): void;
  38252. /**
  38253. * Removes all the elements in the container from the scene
  38254. * @param container contains the elements to remove
  38255. * @param dispose if the removed element should be disposed (default: false)
  38256. */
  38257. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  38258. /**
  38259. * Disposes the component and the associated ressources.
  38260. */
  38261. dispose(): void;
  38262. /**
  38263. * Disables audio in the associated scene.
  38264. */
  38265. disableAudio(): void;
  38266. /**
  38267. * Enables audio in the associated scene.
  38268. */
  38269. enableAudio(): void;
  38270. /**
  38271. * Switch audio to headphone output.
  38272. */
  38273. switchAudioModeForHeadphones(): void;
  38274. /**
  38275. * Switch audio to normal speakers.
  38276. */
  38277. switchAudioModeForNormalSpeakers(): void;
  38278. private _cachedCameraDirection;
  38279. private _cachedCameraPosition;
  38280. private _lastCheck;
  38281. private _afterRender;
  38282. }
  38283. }
  38284. declare module "babylonjs/Audio/weightedsound" {
  38285. import { Sound } from "babylonjs/Audio/sound";
  38286. /**
  38287. * Wraps one or more Sound objects and selects one with random weight for playback.
  38288. */
  38289. export class WeightedSound {
  38290. /** When true a Sound will be selected and played when the current playing Sound completes. */
  38291. loop: boolean;
  38292. private _coneInnerAngle;
  38293. private _coneOuterAngle;
  38294. private _volume;
  38295. /** A Sound is currently playing. */
  38296. isPlaying: boolean;
  38297. /** A Sound is currently paused. */
  38298. isPaused: boolean;
  38299. private _sounds;
  38300. private _weights;
  38301. private _currentIndex?;
  38302. /**
  38303. * Creates a new WeightedSound from the list of sounds given.
  38304. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  38305. * @param sounds Array of Sounds that will be selected from.
  38306. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  38307. */
  38308. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  38309. /**
  38310. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  38311. */
  38312. /**
  38313. * The size of cone in degress for a directional sound in which there will be no attenuation.
  38314. */
  38315. directionalConeInnerAngle: number;
  38316. /**
  38317. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38318. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38319. */
  38320. /**
  38321. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38322. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38323. */
  38324. directionalConeOuterAngle: number;
  38325. /**
  38326. * Playback volume.
  38327. */
  38328. /**
  38329. * Playback volume.
  38330. */
  38331. volume: number;
  38332. private _onended;
  38333. /**
  38334. * Suspend playback
  38335. */
  38336. pause(): void;
  38337. /**
  38338. * Stop playback
  38339. */
  38340. stop(): void;
  38341. /**
  38342. * Start playback.
  38343. * @param startOffset Position the clip head at a specific time in seconds.
  38344. */
  38345. play(startOffset?: number): void;
  38346. }
  38347. }
  38348. declare module "babylonjs/Audio/index" {
  38349. export * from "babylonjs/Audio/analyser";
  38350. export * from "babylonjs/Audio/audioEngine";
  38351. export * from "babylonjs/Audio/audioSceneComponent";
  38352. export * from "babylonjs/Audio/sound";
  38353. export * from "babylonjs/Audio/soundTrack";
  38354. export * from "babylonjs/Audio/weightedsound";
  38355. }
  38356. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  38357. import { Behavior } from "babylonjs/Behaviors/behavior";
  38358. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38359. import { BackEase } from "babylonjs/Animations/easing";
  38360. /**
  38361. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  38362. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38363. */
  38364. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  38365. /**
  38366. * Gets the name of the behavior.
  38367. */
  38368. readonly name: string;
  38369. /**
  38370. * The easing function used by animations
  38371. */
  38372. static EasingFunction: BackEase;
  38373. /**
  38374. * The easing mode used by animations
  38375. */
  38376. static EasingMode: number;
  38377. /**
  38378. * The duration of the animation, in milliseconds
  38379. */
  38380. transitionDuration: number;
  38381. /**
  38382. * Length of the distance animated by the transition when lower radius is reached
  38383. */
  38384. lowerRadiusTransitionRange: number;
  38385. /**
  38386. * Length of the distance animated by the transition when upper radius is reached
  38387. */
  38388. upperRadiusTransitionRange: number;
  38389. private _autoTransitionRange;
  38390. /**
  38391. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38392. */
  38393. /**
  38394. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38395. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  38396. */
  38397. autoTransitionRange: boolean;
  38398. private _attachedCamera;
  38399. private _onAfterCheckInputsObserver;
  38400. private _onMeshTargetChangedObserver;
  38401. /**
  38402. * Initializes the behavior.
  38403. */
  38404. init(): void;
  38405. /**
  38406. * Attaches the behavior to its arc rotate camera.
  38407. * @param camera Defines the camera to attach the behavior to
  38408. */
  38409. attach(camera: ArcRotateCamera): void;
  38410. /**
  38411. * Detaches the behavior from its current arc rotate camera.
  38412. */
  38413. detach(): void;
  38414. private _radiusIsAnimating;
  38415. private _radiusBounceTransition;
  38416. private _animatables;
  38417. private _cachedWheelPrecision;
  38418. /**
  38419. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  38420. * @param radiusLimit The limit to check against.
  38421. * @return Bool to indicate if at limit.
  38422. */
  38423. private _isRadiusAtLimit;
  38424. /**
  38425. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  38426. * @param radiusDelta The delta by which to animate to. Can be negative.
  38427. */
  38428. private _applyBoundRadiusAnimation;
  38429. /**
  38430. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  38431. */
  38432. protected _clearAnimationLocks(): void;
  38433. /**
  38434. * Stops and removes all animations that have been applied to the camera
  38435. */
  38436. stopAllAnimations(): void;
  38437. }
  38438. }
  38439. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  38440. import { Behavior } from "babylonjs/Behaviors/behavior";
  38441. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38442. import { ExponentialEase } from "babylonjs/Animations/easing";
  38443. import { Nullable } from "babylonjs/types";
  38444. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38445. import { Vector3 } from "babylonjs/Maths/math.vector";
  38446. /**
  38447. * 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.
  38448. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38449. */
  38450. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  38451. /**
  38452. * Gets the name of the behavior.
  38453. */
  38454. readonly name: string;
  38455. private _mode;
  38456. private _radiusScale;
  38457. private _positionScale;
  38458. private _defaultElevation;
  38459. private _elevationReturnTime;
  38460. private _elevationReturnWaitTime;
  38461. private _zoomStopsAnimation;
  38462. private _framingTime;
  38463. /**
  38464. * The easing function used by animations
  38465. */
  38466. static EasingFunction: ExponentialEase;
  38467. /**
  38468. * The easing mode used by animations
  38469. */
  38470. static EasingMode: number;
  38471. /**
  38472. * Sets the current mode used by the behavior
  38473. */
  38474. /**
  38475. * Gets current mode used by the behavior.
  38476. */
  38477. mode: number;
  38478. /**
  38479. * Sets the scale applied to the radius (1 by default)
  38480. */
  38481. /**
  38482. * Gets the scale applied to the radius
  38483. */
  38484. radiusScale: number;
  38485. /**
  38486. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38487. */
  38488. /**
  38489. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38490. */
  38491. positionScale: number;
  38492. /**
  38493. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38494. * behaviour is triggered, in radians.
  38495. */
  38496. /**
  38497. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38498. * behaviour is triggered, in radians.
  38499. */
  38500. defaultElevation: number;
  38501. /**
  38502. * Sets the time (in milliseconds) taken to return to the default beta position.
  38503. * Negative value indicates camera should not return to default.
  38504. */
  38505. /**
  38506. * Gets the time (in milliseconds) taken to return to the default beta position.
  38507. * Negative value indicates camera should not return to default.
  38508. */
  38509. elevationReturnTime: number;
  38510. /**
  38511. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38512. */
  38513. /**
  38514. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38515. */
  38516. elevationReturnWaitTime: number;
  38517. /**
  38518. * Sets the flag that indicates if user zooming should stop animation.
  38519. */
  38520. /**
  38521. * Gets the flag that indicates if user zooming should stop animation.
  38522. */
  38523. zoomStopsAnimation: boolean;
  38524. /**
  38525. * Sets the transition time when framing the mesh, in milliseconds
  38526. */
  38527. /**
  38528. * Gets the transition time when framing the mesh, in milliseconds
  38529. */
  38530. framingTime: number;
  38531. /**
  38532. * Define if the behavior should automatically change the configured
  38533. * camera limits and sensibilities.
  38534. */
  38535. autoCorrectCameraLimitsAndSensibility: boolean;
  38536. private _onPrePointerObservableObserver;
  38537. private _onAfterCheckInputsObserver;
  38538. private _onMeshTargetChangedObserver;
  38539. private _attachedCamera;
  38540. private _isPointerDown;
  38541. private _lastInteractionTime;
  38542. /**
  38543. * Initializes the behavior.
  38544. */
  38545. init(): void;
  38546. /**
  38547. * Attaches the behavior to its arc rotate camera.
  38548. * @param camera Defines the camera to attach the behavior to
  38549. */
  38550. attach(camera: ArcRotateCamera): void;
  38551. /**
  38552. * Detaches the behavior from its current arc rotate camera.
  38553. */
  38554. detach(): void;
  38555. private _animatables;
  38556. private _betaIsAnimating;
  38557. private _betaTransition;
  38558. private _radiusTransition;
  38559. private _vectorTransition;
  38560. /**
  38561. * Targets the given mesh and updates zoom level accordingly.
  38562. * @param mesh The mesh to target.
  38563. * @param radius Optional. If a cached radius position already exists, overrides default.
  38564. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  38565. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38566. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38567. */
  38568. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38569. /**
  38570. * Targets the given mesh with its children and updates zoom level accordingly.
  38571. * @param mesh The mesh to target.
  38572. * @param radius Optional. If a cached radius position already exists, overrides default.
  38573. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  38574. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38575. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38576. */
  38577. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38578. /**
  38579. * Targets the given meshes with their children and updates zoom level accordingly.
  38580. * @param meshes The mesh to target.
  38581. * @param radius Optional. If a cached radius position already exists, overrides default.
  38582. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  38583. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38584. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38585. */
  38586. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38587. /**
  38588. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  38589. * @param minimumWorld Determines the smaller position of the bounding box extend
  38590. * @param maximumWorld Determines the bigger position of the bounding box extend
  38591. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38592. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38593. */
  38594. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38595. /**
  38596. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  38597. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  38598. * frustum width.
  38599. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  38600. * to fully enclose the mesh in the viewing frustum.
  38601. */
  38602. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  38603. /**
  38604. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  38605. * is automatically returned to its default position (expected to be above ground plane).
  38606. */
  38607. private _maintainCameraAboveGround;
  38608. /**
  38609. * Returns the frustum slope based on the canvas ratio and camera FOV
  38610. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  38611. */
  38612. private _getFrustumSlope;
  38613. /**
  38614. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  38615. */
  38616. private _clearAnimationLocks;
  38617. /**
  38618. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38619. */
  38620. private _applyUserInteraction;
  38621. /**
  38622. * Stops and removes all animations that have been applied to the camera
  38623. */
  38624. stopAllAnimations(): void;
  38625. /**
  38626. * Gets a value indicating if the user is moving the camera
  38627. */
  38628. readonly isUserIsMoving: boolean;
  38629. /**
  38630. * The camera can move all the way towards the mesh.
  38631. */
  38632. static IgnoreBoundsSizeMode: number;
  38633. /**
  38634. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  38635. */
  38636. static FitFrustumSidesMode: number;
  38637. }
  38638. }
  38639. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  38640. import { Nullable } from "babylonjs/types";
  38641. import { Camera } from "babylonjs/Cameras/camera";
  38642. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38643. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  38644. /**
  38645. * Base class for Camera Pointer Inputs.
  38646. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  38647. * for example usage.
  38648. */
  38649. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  38650. /**
  38651. * Defines the camera the input is attached to.
  38652. */
  38653. abstract camera: Camera;
  38654. /**
  38655. * Whether keyboard modifier keys are pressed at time of last mouse event.
  38656. */
  38657. protected _altKey: boolean;
  38658. protected _ctrlKey: boolean;
  38659. protected _metaKey: boolean;
  38660. protected _shiftKey: boolean;
  38661. /**
  38662. * Which mouse buttons were pressed at time of last mouse event.
  38663. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  38664. */
  38665. protected _buttonsPressed: number;
  38666. /**
  38667. * Defines the buttons associated with the input to handle camera move.
  38668. */
  38669. buttons: number[];
  38670. /**
  38671. * Attach the input controls to a specific dom element to get the input from.
  38672. * @param element Defines the element the controls should be listened from
  38673. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38674. */
  38675. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38676. /**
  38677. * Detach the current controls from the specified dom element.
  38678. * @param element Defines the element to stop listening the inputs from
  38679. */
  38680. detachControl(element: Nullable<HTMLElement>): void;
  38681. /**
  38682. * Gets the class name of the current input.
  38683. * @returns the class name
  38684. */
  38685. getClassName(): string;
  38686. /**
  38687. * Get the friendly name associated with the input class.
  38688. * @returns the input friendly name
  38689. */
  38690. getSimpleName(): string;
  38691. /**
  38692. * Called on pointer POINTERDOUBLETAP event.
  38693. * Override this method to provide functionality on POINTERDOUBLETAP event.
  38694. */
  38695. protected onDoubleTap(type: string): void;
  38696. /**
  38697. * Called on pointer POINTERMOVE event if only a single touch is active.
  38698. * Override this method to provide functionality.
  38699. */
  38700. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38701. /**
  38702. * Called on pointer POINTERMOVE event if multiple touches are active.
  38703. * Override this method to provide functionality.
  38704. */
  38705. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38706. /**
  38707. * Called on JS contextmenu event.
  38708. * Override this method to provide functionality.
  38709. */
  38710. protected onContextMenu(evt: PointerEvent): void;
  38711. /**
  38712. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38713. * press.
  38714. * Override this method to provide functionality.
  38715. */
  38716. protected onButtonDown(evt: PointerEvent): void;
  38717. /**
  38718. * Called each time a new POINTERUP event occurs. Ie, for each button
  38719. * release.
  38720. * Override this method to provide functionality.
  38721. */
  38722. protected onButtonUp(evt: PointerEvent): void;
  38723. /**
  38724. * Called when window becomes inactive.
  38725. * Override this method to provide functionality.
  38726. */
  38727. protected onLostFocus(): void;
  38728. private _pointerInput;
  38729. private _observer;
  38730. private _onLostFocus;
  38731. private pointA;
  38732. private pointB;
  38733. }
  38734. }
  38735. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  38736. import { Nullable } from "babylonjs/types";
  38737. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38738. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  38739. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  38740. /**
  38741. * Manage the pointers inputs to control an arc rotate camera.
  38742. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38743. */
  38744. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  38745. /**
  38746. * Defines the camera the input is attached to.
  38747. */
  38748. camera: ArcRotateCamera;
  38749. /**
  38750. * Gets the class name of the current input.
  38751. * @returns the class name
  38752. */
  38753. getClassName(): string;
  38754. /**
  38755. * Defines the buttons associated with the input to handle camera move.
  38756. */
  38757. buttons: number[];
  38758. /**
  38759. * Defines the pointer angular sensibility along the X axis or how fast is
  38760. * the camera rotating.
  38761. */
  38762. angularSensibilityX: number;
  38763. /**
  38764. * Defines the pointer angular sensibility along the Y axis or how fast is
  38765. * the camera rotating.
  38766. */
  38767. angularSensibilityY: number;
  38768. /**
  38769. * Defines the pointer pinch precision or how fast is the camera zooming.
  38770. */
  38771. pinchPrecision: number;
  38772. /**
  38773. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38774. * from 0.
  38775. * It defines the percentage of current camera.radius to use as delta when
  38776. * pinch zoom is used.
  38777. */
  38778. pinchDeltaPercentage: number;
  38779. /**
  38780. * Defines the pointer panning sensibility or how fast is the camera moving.
  38781. */
  38782. panningSensibility: number;
  38783. /**
  38784. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  38785. */
  38786. multiTouchPanning: boolean;
  38787. /**
  38788. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  38789. * zoom (pinch) through multitouch.
  38790. */
  38791. multiTouchPanAndZoom: boolean;
  38792. /**
  38793. * Revers pinch action direction.
  38794. */
  38795. pinchInwards: boolean;
  38796. private _isPanClick;
  38797. private _twoFingerActivityCount;
  38798. private _isPinching;
  38799. /**
  38800. * Called on pointer POINTERMOVE event if only a single touch is active.
  38801. */
  38802. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38803. /**
  38804. * Called on pointer POINTERDOUBLETAP event.
  38805. */
  38806. protected onDoubleTap(type: string): void;
  38807. /**
  38808. * Called on pointer POINTERMOVE event if multiple touches are active.
  38809. */
  38810. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38811. /**
  38812. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38813. * press.
  38814. */
  38815. protected onButtonDown(evt: PointerEvent): void;
  38816. /**
  38817. * Called each time a new POINTERUP event occurs. Ie, for each button
  38818. * release.
  38819. */
  38820. protected onButtonUp(evt: PointerEvent): void;
  38821. /**
  38822. * Called when window becomes inactive.
  38823. */
  38824. protected onLostFocus(): void;
  38825. }
  38826. }
  38827. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  38828. import { Nullable } from "babylonjs/types";
  38829. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38830. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38831. /**
  38832. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  38833. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38834. */
  38835. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  38836. /**
  38837. * Defines the camera the input is attached to.
  38838. */
  38839. camera: ArcRotateCamera;
  38840. /**
  38841. * Defines the list of key codes associated with the up action (increase alpha)
  38842. */
  38843. keysUp: number[];
  38844. /**
  38845. * Defines the list of key codes associated with the down action (decrease alpha)
  38846. */
  38847. keysDown: number[];
  38848. /**
  38849. * Defines the list of key codes associated with the left action (increase beta)
  38850. */
  38851. keysLeft: number[];
  38852. /**
  38853. * Defines the list of key codes associated with the right action (decrease beta)
  38854. */
  38855. keysRight: number[];
  38856. /**
  38857. * Defines the list of key codes associated with the reset action.
  38858. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  38859. */
  38860. keysReset: number[];
  38861. /**
  38862. * Defines the panning sensibility of the inputs.
  38863. * (How fast is the camera paning)
  38864. */
  38865. panningSensibility: number;
  38866. /**
  38867. * Defines the zooming sensibility of the inputs.
  38868. * (How fast is the camera zooming)
  38869. */
  38870. zoomingSensibility: number;
  38871. /**
  38872. * Defines wether maintaining the alt key down switch the movement mode from
  38873. * orientation to zoom.
  38874. */
  38875. useAltToZoom: boolean;
  38876. /**
  38877. * Rotation speed of the camera
  38878. */
  38879. angularSpeed: number;
  38880. private _keys;
  38881. private _ctrlPressed;
  38882. private _altPressed;
  38883. private _onCanvasBlurObserver;
  38884. private _onKeyboardObserver;
  38885. private _engine;
  38886. private _scene;
  38887. /**
  38888. * Attach the input controls to a specific dom element to get the input from.
  38889. * @param element Defines the element the controls should be listened from
  38890. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38891. */
  38892. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38893. /**
  38894. * Detach the current controls from the specified dom element.
  38895. * @param element Defines the element to stop listening the inputs from
  38896. */
  38897. detachControl(element: Nullable<HTMLElement>): void;
  38898. /**
  38899. * Update the current camera state depending on the inputs that have been used this frame.
  38900. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38901. */
  38902. checkInputs(): void;
  38903. /**
  38904. * Gets the class name of the current intput.
  38905. * @returns the class name
  38906. */
  38907. getClassName(): string;
  38908. /**
  38909. * Get the friendly name associated with the input class.
  38910. * @returns the input friendly name
  38911. */
  38912. getSimpleName(): string;
  38913. }
  38914. }
  38915. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  38916. import { Nullable } from "babylonjs/types";
  38917. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38918. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38919. /**
  38920. * Manage the mouse wheel inputs to control an arc rotate camera.
  38921. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38922. */
  38923. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  38924. /**
  38925. * Defines the camera the input is attached to.
  38926. */
  38927. camera: ArcRotateCamera;
  38928. /**
  38929. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38930. */
  38931. wheelPrecision: number;
  38932. /**
  38933. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38934. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38935. */
  38936. wheelDeltaPercentage: number;
  38937. private _wheel;
  38938. private _observer;
  38939. private computeDeltaFromMouseWheelLegacyEvent;
  38940. /**
  38941. * Attach the input controls to a specific dom element to get the input from.
  38942. * @param element Defines the element the controls should be listened from
  38943. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38944. */
  38945. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38946. /**
  38947. * Detach the current controls from the specified dom element.
  38948. * @param element Defines the element to stop listening the inputs from
  38949. */
  38950. detachControl(element: Nullable<HTMLElement>): void;
  38951. /**
  38952. * Gets the class name of the current intput.
  38953. * @returns the class name
  38954. */
  38955. getClassName(): string;
  38956. /**
  38957. * Get the friendly name associated with the input class.
  38958. * @returns the input friendly name
  38959. */
  38960. getSimpleName(): string;
  38961. }
  38962. }
  38963. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  38964. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38965. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38966. /**
  38967. * Default Inputs manager for the ArcRotateCamera.
  38968. * It groups all the default supported inputs for ease of use.
  38969. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38970. */
  38971. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  38972. /**
  38973. * Instantiates a new ArcRotateCameraInputsManager.
  38974. * @param camera Defines the camera the inputs belong to
  38975. */
  38976. constructor(camera: ArcRotateCamera);
  38977. /**
  38978. * Add mouse wheel input support to the input manager.
  38979. * @returns the current input manager
  38980. */
  38981. addMouseWheel(): ArcRotateCameraInputsManager;
  38982. /**
  38983. * Add pointers input support to the input manager.
  38984. * @returns the current input manager
  38985. */
  38986. addPointers(): ArcRotateCameraInputsManager;
  38987. /**
  38988. * Add keyboard input support to the input manager.
  38989. * @returns the current input manager
  38990. */
  38991. addKeyboard(): ArcRotateCameraInputsManager;
  38992. }
  38993. }
  38994. declare module "babylonjs/Cameras/arcRotateCamera" {
  38995. import { Observable } from "babylonjs/Misc/observable";
  38996. import { Nullable } from "babylonjs/types";
  38997. import { Scene } from "babylonjs/scene";
  38998. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  38999. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39000. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  39001. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  39002. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  39003. import { Camera } from "babylonjs/Cameras/camera";
  39004. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39005. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  39006. import { Collider } from "babylonjs/Collisions/collider";
  39007. /**
  39008. * This represents an orbital type of camera.
  39009. *
  39010. * 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.
  39011. * 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.
  39012. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  39013. */
  39014. export class ArcRotateCamera extends TargetCamera {
  39015. /**
  39016. * Defines the rotation angle of the camera along the longitudinal axis.
  39017. */
  39018. alpha: number;
  39019. /**
  39020. * Defines the rotation angle of the camera along the latitudinal axis.
  39021. */
  39022. beta: number;
  39023. /**
  39024. * Defines the radius of the camera from it s target point.
  39025. */
  39026. radius: number;
  39027. protected _target: Vector3;
  39028. protected _targetHost: Nullable<AbstractMesh>;
  39029. /**
  39030. * Defines the target point of the camera.
  39031. * The camera looks towards it form the radius distance.
  39032. */
  39033. target: Vector3;
  39034. /**
  39035. * Define the current local position of the camera in the scene
  39036. */
  39037. position: Vector3;
  39038. protected _upVector: Vector3;
  39039. protected _upToYMatrix: Matrix;
  39040. protected _YToUpMatrix: Matrix;
  39041. /**
  39042. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  39043. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  39044. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  39045. */
  39046. upVector: Vector3;
  39047. /**
  39048. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  39049. */
  39050. setMatUp(): void;
  39051. /**
  39052. * Current inertia value on the longitudinal axis.
  39053. * The bigger this number the longer it will take for the camera to stop.
  39054. */
  39055. inertialAlphaOffset: number;
  39056. /**
  39057. * Current inertia value on the latitudinal axis.
  39058. * The bigger this number the longer it will take for the camera to stop.
  39059. */
  39060. inertialBetaOffset: number;
  39061. /**
  39062. * Current inertia value on the radius axis.
  39063. * The bigger this number the longer it will take for the camera to stop.
  39064. */
  39065. inertialRadiusOffset: number;
  39066. /**
  39067. * Minimum allowed angle on the longitudinal axis.
  39068. * This can help limiting how the Camera is able to move in the scene.
  39069. */
  39070. lowerAlphaLimit: Nullable<number>;
  39071. /**
  39072. * Maximum allowed angle on the longitudinal axis.
  39073. * This can help limiting how the Camera is able to move in the scene.
  39074. */
  39075. upperAlphaLimit: Nullable<number>;
  39076. /**
  39077. * Minimum allowed angle on the latitudinal axis.
  39078. * This can help limiting how the Camera is able to move in the scene.
  39079. */
  39080. lowerBetaLimit: number;
  39081. /**
  39082. * Maximum allowed angle on the latitudinal axis.
  39083. * This can help limiting how the Camera is able to move in the scene.
  39084. */
  39085. upperBetaLimit: number;
  39086. /**
  39087. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  39088. * This can help limiting how the Camera is able to move in the scene.
  39089. */
  39090. lowerRadiusLimit: Nullable<number>;
  39091. /**
  39092. * Maximum allowed distance of the camera to the target (The camera can not get further).
  39093. * This can help limiting how the Camera is able to move in the scene.
  39094. */
  39095. upperRadiusLimit: Nullable<number>;
  39096. /**
  39097. * Defines the current inertia value used during panning of the camera along the X axis.
  39098. */
  39099. inertialPanningX: number;
  39100. /**
  39101. * Defines the current inertia value used during panning of the camera along the Y axis.
  39102. */
  39103. inertialPanningY: number;
  39104. /**
  39105. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  39106. * Basically if your fingers moves away from more than this distance you will be considered
  39107. * in pinch mode.
  39108. */
  39109. pinchToPanMaxDistance: number;
  39110. /**
  39111. * Defines the maximum distance the camera can pan.
  39112. * This could help keeping the cammera always in your scene.
  39113. */
  39114. panningDistanceLimit: Nullable<number>;
  39115. /**
  39116. * Defines the target of the camera before paning.
  39117. */
  39118. panningOriginTarget: Vector3;
  39119. /**
  39120. * Defines the value of the inertia used during panning.
  39121. * 0 would mean stop inertia and one would mean no decelleration at all.
  39122. */
  39123. panningInertia: number;
  39124. /**
  39125. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  39126. */
  39127. angularSensibilityX: number;
  39128. /**
  39129. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  39130. */
  39131. angularSensibilityY: number;
  39132. /**
  39133. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  39134. */
  39135. pinchPrecision: number;
  39136. /**
  39137. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  39138. * It will be used instead of pinchDeltaPrecision if different from 0.
  39139. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39140. */
  39141. pinchDeltaPercentage: number;
  39142. /**
  39143. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  39144. */
  39145. panningSensibility: number;
  39146. /**
  39147. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  39148. */
  39149. keysUp: number[];
  39150. /**
  39151. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  39152. */
  39153. keysDown: number[];
  39154. /**
  39155. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  39156. */
  39157. keysLeft: number[];
  39158. /**
  39159. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  39160. */
  39161. keysRight: number[];
  39162. /**
  39163. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39164. */
  39165. wheelPrecision: number;
  39166. /**
  39167. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  39168. * It will be used instead of pinchDeltaPrecision if different from 0.
  39169. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39170. */
  39171. wheelDeltaPercentage: number;
  39172. /**
  39173. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  39174. */
  39175. zoomOnFactor: number;
  39176. /**
  39177. * Defines a screen offset for the camera position.
  39178. */
  39179. targetScreenOffset: Vector2;
  39180. /**
  39181. * Allows the camera to be completely reversed.
  39182. * If false the camera can not arrive upside down.
  39183. */
  39184. allowUpsideDown: boolean;
  39185. /**
  39186. * Define if double tap/click is used to restore the previously saved state of the camera.
  39187. */
  39188. useInputToRestoreState: boolean;
  39189. /** @hidden */
  39190. _viewMatrix: Matrix;
  39191. /** @hidden */
  39192. _useCtrlForPanning: boolean;
  39193. /** @hidden */
  39194. _panningMouseButton: number;
  39195. /**
  39196. * Defines the input associated to the camera.
  39197. */
  39198. inputs: ArcRotateCameraInputsManager;
  39199. /** @hidden */
  39200. _reset: () => void;
  39201. /**
  39202. * Defines the allowed panning axis.
  39203. */
  39204. panningAxis: Vector3;
  39205. protected _localDirection: Vector3;
  39206. protected _transformedDirection: Vector3;
  39207. private _bouncingBehavior;
  39208. /**
  39209. * Gets the bouncing behavior of the camera if it has been enabled.
  39210. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39211. */
  39212. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  39213. /**
  39214. * Defines if the bouncing behavior of the camera is enabled on the camera.
  39215. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39216. */
  39217. useBouncingBehavior: boolean;
  39218. private _framingBehavior;
  39219. /**
  39220. * Gets the framing behavior of the camera if it has been enabled.
  39221. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39222. */
  39223. readonly framingBehavior: Nullable<FramingBehavior>;
  39224. /**
  39225. * Defines if the framing behavior of the camera is enabled on the camera.
  39226. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39227. */
  39228. useFramingBehavior: boolean;
  39229. private _autoRotationBehavior;
  39230. /**
  39231. * Gets the auto rotation behavior of the camera if it has been enabled.
  39232. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39233. */
  39234. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  39235. /**
  39236. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  39237. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39238. */
  39239. useAutoRotationBehavior: boolean;
  39240. /**
  39241. * Observable triggered when the mesh target has been changed on the camera.
  39242. */
  39243. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  39244. /**
  39245. * Event raised when the camera is colliding with a mesh.
  39246. */
  39247. onCollide: (collidedMesh: AbstractMesh) => void;
  39248. /**
  39249. * Defines whether the camera should check collision with the objects oh the scene.
  39250. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  39251. */
  39252. checkCollisions: boolean;
  39253. /**
  39254. * Defines the collision radius of the camera.
  39255. * This simulates a sphere around the camera.
  39256. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39257. */
  39258. collisionRadius: Vector3;
  39259. protected _collider: Collider;
  39260. protected _previousPosition: Vector3;
  39261. protected _collisionVelocity: Vector3;
  39262. protected _newPosition: Vector3;
  39263. protected _previousAlpha: number;
  39264. protected _previousBeta: number;
  39265. protected _previousRadius: number;
  39266. protected _collisionTriggered: boolean;
  39267. protected _targetBoundingCenter: Nullable<Vector3>;
  39268. private _computationVector;
  39269. /**
  39270. * Instantiates a new ArcRotateCamera in a given scene
  39271. * @param name Defines the name of the camera
  39272. * @param alpha Defines the camera rotation along the logitudinal axis
  39273. * @param beta Defines the camera rotation along the latitudinal axis
  39274. * @param radius Defines the camera distance from its target
  39275. * @param target Defines the camera target
  39276. * @param scene Defines the scene the camera belongs to
  39277. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  39278. */
  39279. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39280. /** @hidden */
  39281. _initCache(): void;
  39282. /** @hidden */
  39283. _updateCache(ignoreParentClass?: boolean): void;
  39284. protected _getTargetPosition(): Vector3;
  39285. private _storedAlpha;
  39286. private _storedBeta;
  39287. private _storedRadius;
  39288. private _storedTarget;
  39289. private _storedTargetScreenOffset;
  39290. /**
  39291. * Stores the current state of the camera (alpha, beta, radius and target)
  39292. * @returns the camera itself
  39293. */
  39294. storeState(): Camera;
  39295. /**
  39296. * @hidden
  39297. * Restored camera state. You must call storeState() first
  39298. */
  39299. _restoreStateValues(): boolean;
  39300. /** @hidden */
  39301. _isSynchronizedViewMatrix(): boolean;
  39302. /**
  39303. * Attached controls to the current camera.
  39304. * @param element Defines the element the controls should be listened from
  39305. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39306. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  39307. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  39308. */
  39309. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  39310. /**
  39311. * Detach the current controls from the camera.
  39312. * The camera will stop reacting to inputs.
  39313. * @param element Defines the element to stop listening the inputs from
  39314. */
  39315. detachControl(element: HTMLElement): void;
  39316. /** @hidden */
  39317. _checkInputs(): void;
  39318. protected _checkLimits(): void;
  39319. /**
  39320. * Rebuilds angles (alpha, beta) and radius from the give position and target
  39321. */
  39322. rebuildAnglesAndRadius(): void;
  39323. /**
  39324. * Use a position to define the current camera related information like alpha, beta and radius
  39325. * @param position Defines the position to set the camera at
  39326. */
  39327. setPosition(position: Vector3): void;
  39328. /**
  39329. * Defines the target the camera should look at.
  39330. * This will automatically adapt alpha beta and radius to fit within the new target.
  39331. * @param target Defines the new target as a Vector or a mesh
  39332. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  39333. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  39334. */
  39335. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  39336. /** @hidden */
  39337. _getViewMatrix(): Matrix;
  39338. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  39339. /**
  39340. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  39341. * @param meshes Defines the mesh to zoom on
  39342. * @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)
  39343. */
  39344. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  39345. /**
  39346. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  39347. * The target will be changed but the radius
  39348. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  39349. * @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)
  39350. */
  39351. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  39352. min: Vector3;
  39353. max: Vector3;
  39354. distance: number;
  39355. }, doNotUpdateMaxZ?: boolean): void;
  39356. /**
  39357. * @override
  39358. * Override Camera.createRigCamera
  39359. */
  39360. createRigCamera(name: string, cameraIndex: number): Camera;
  39361. /**
  39362. * @hidden
  39363. * @override
  39364. * Override Camera._updateRigCameras
  39365. */
  39366. _updateRigCameras(): void;
  39367. /**
  39368. * Destroy the camera and release the current resources hold by it.
  39369. */
  39370. dispose(): void;
  39371. /**
  39372. * Gets the current object class name.
  39373. * @return the class name
  39374. */
  39375. getClassName(): string;
  39376. }
  39377. }
  39378. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  39379. import { Behavior } from "babylonjs/Behaviors/behavior";
  39380. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39381. /**
  39382. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  39383. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39384. */
  39385. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  39386. /**
  39387. * Gets the name of the behavior.
  39388. */
  39389. readonly name: string;
  39390. private _zoomStopsAnimation;
  39391. private _idleRotationSpeed;
  39392. private _idleRotationWaitTime;
  39393. private _idleRotationSpinupTime;
  39394. /**
  39395. * Sets the flag that indicates if user zooming should stop animation.
  39396. */
  39397. /**
  39398. * Gets the flag that indicates if user zooming should stop animation.
  39399. */
  39400. zoomStopsAnimation: boolean;
  39401. /**
  39402. * Sets the default speed at which the camera rotates around the model.
  39403. */
  39404. /**
  39405. * Gets the default speed at which the camera rotates around the model.
  39406. */
  39407. idleRotationSpeed: number;
  39408. /**
  39409. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  39410. */
  39411. /**
  39412. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  39413. */
  39414. idleRotationWaitTime: number;
  39415. /**
  39416. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39417. */
  39418. /**
  39419. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39420. */
  39421. idleRotationSpinupTime: number;
  39422. /**
  39423. * Gets a value indicating if the camera is currently rotating because of this behavior
  39424. */
  39425. readonly rotationInProgress: boolean;
  39426. private _onPrePointerObservableObserver;
  39427. private _onAfterCheckInputsObserver;
  39428. private _attachedCamera;
  39429. private _isPointerDown;
  39430. private _lastFrameTime;
  39431. private _lastInteractionTime;
  39432. private _cameraRotationSpeed;
  39433. /**
  39434. * Initializes the behavior.
  39435. */
  39436. init(): void;
  39437. /**
  39438. * Attaches the behavior to its arc rotate camera.
  39439. * @param camera Defines the camera to attach the behavior to
  39440. */
  39441. attach(camera: ArcRotateCamera): void;
  39442. /**
  39443. * Detaches the behavior from its current arc rotate camera.
  39444. */
  39445. detach(): void;
  39446. /**
  39447. * Returns true if user is scrolling.
  39448. * @return true if user is scrolling.
  39449. */
  39450. private _userIsZooming;
  39451. private _lastFrameRadius;
  39452. private _shouldAnimationStopForInteraction;
  39453. /**
  39454. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39455. */
  39456. private _applyUserInteraction;
  39457. private _userIsMoving;
  39458. }
  39459. }
  39460. declare module "babylonjs/Behaviors/Cameras/index" {
  39461. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  39462. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  39463. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  39464. }
  39465. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  39466. import { Mesh } from "babylonjs/Meshes/mesh";
  39467. import { TransformNode } from "babylonjs/Meshes/transformNode";
  39468. import { Behavior } from "babylonjs/Behaviors/behavior";
  39469. /**
  39470. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  39471. */
  39472. export class AttachToBoxBehavior implements Behavior<Mesh> {
  39473. private ui;
  39474. /**
  39475. * The name of the behavior
  39476. */
  39477. name: string;
  39478. /**
  39479. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  39480. */
  39481. distanceAwayFromFace: number;
  39482. /**
  39483. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  39484. */
  39485. distanceAwayFromBottomOfFace: number;
  39486. private _faceVectors;
  39487. private _target;
  39488. private _scene;
  39489. private _onRenderObserver;
  39490. private _tmpMatrix;
  39491. private _tmpVector;
  39492. /**
  39493. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  39494. * @param ui The transform node that should be attched to the mesh
  39495. */
  39496. constructor(ui: TransformNode);
  39497. /**
  39498. * Initializes the behavior
  39499. */
  39500. init(): void;
  39501. private _closestFace;
  39502. private _zeroVector;
  39503. private _lookAtTmpMatrix;
  39504. private _lookAtToRef;
  39505. /**
  39506. * Attaches the AttachToBoxBehavior to the passed in mesh
  39507. * @param target The mesh that the specified node will be attached to
  39508. */
  39509. attach(target: Mesh): void;
  39510. /**
  39511. * Detaches the behavior from the mesh
  39512. */
  39513. detach(): void;
  39514. }
  39515. }
  39516. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  39517. import { Behavior } from "babylonjs/Behaviors/behavior";
  39518. import { Mesh } from "babylonjs/Meshes/mesh";
  39519. /**
  39520. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  39521. */
  39522. export class FadeInOutBehavior implements Behavior<Mesh> {
  39523. /**
  39524. * Time in milliseconds to delay before fading in (Default: 0)
  39525. */
  39526. delay: number;
  39527. /**
  39528. * Time in milliseconds for the mesh to fade in (Default: 300)
  39529. */
  39530. fadeInTime: number;
  39531. private _millisecondsPerFrame;
  39532. private _hovered;
  39533. private _hoverValue;
  39534. private _ownerNode;
  39535. /**
  39536. * Instatiates the FadeInOutBehavior
  39537. */
  39538. constructor();
  39539. /**
  39540. * The name of the behavior
  39541. */
  39542. readonly name: string;
  39543. /**
  39544. * Initializes the behavior
  39545. */
  39546. init(): void;
  39547. /**
  39548. * Attaches the fade behavior on the passed in mesh
  39549. * @param ownerNode The mesh that will be faded in/out once attached
  39550. */
  39551. attach(ownerNode: Mesh): void;
  39552. /**
  39553. * Detaches the behavior from the mesh
  39554. */
  39555. detach(): void;
  39556. /**
  39557. * Triggers the mesh to begin fading in or out
  39558. * @param value if the object should fade in or out (true to fade in)
  39559. */
  39560. fadeIn(value: boolean): void;
  39561. private _update;
  39562. private _setAllVisibility;
  39563. }
  39564. }
  39565. declare module "babylonjs/Misc/pivotTools" {
  39566. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39567. /**
  39568. * Class containing a set of static utilities functions for managing Pivots
  39569. * @hidden
  39570. */
  39571. export class PivotTools {
  39572. private static _PivotCached;
  39573. private static _OldPivotPoint;
  39574. private static _PivotTranslation;
  39575. private static _PivotTmpVector;
  39576. /** @hidden */
  39577. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  39578. /** @hidden */
  39579. static _RestorePivotPoint(mesh: AbstractMesh): void;
  39580. }
  39581. }
  39582. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  39583. import { Scene } from "babylonjs/scene";
  39584. import { Vector4 } from "babylonjs/Maths/math.vector";
  39585. import { Mesh } from "babylonjs/Meshes/mesh";
  39586. import { Nullable } from "babylonjs/types";
  39587. import { Plane } from "babylonjs/Maths/math.plane";
  39588. /**
  39589. * Class containing static functions to help procedurally build meshes
  39590. */
  39591. export class PlaneBuilder {
  39592. /**
  39593. * Creates a plane mesh
  39594. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  39595. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  39596. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  39597. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39598. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  39599. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39600. * @param name defines the name of the mesh
  39601. * @param options defines the options used to create the mesh
  39602. * @param scene defines the hosting scene
  39603. * @returns the plane mesh
  39604. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  39605. */
  39606. static CreatePlane(name: string, options: {
  39607. size?: number;
  39608. width?: number;
  39609. height?: number;
  39610. sideOrientation?: number;
  39611. frontUVs?: Vector4;
  39612. backUVs?: Vector4;
  39613. updatable?: boolean;
  39614. sourcePlane?: Plane;
  39615. }, scene?: Nullable<Scene>): Mesh;
  39616. }
  39617. }
  39618. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  39619. import { Behavior } from "babylonjs/Behaviors/behavior";
  39620. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39621. import { Observable } from "babylonjs/Misc/observable";
  39622. import { Vector3 } from "babylonjs/Maths/math.vector";
  39623. import { Ray } from "babylonjs/Culling/ray";
  39624. import "babylonjs/Meshes/Builders/planeBuilder";
  39625. /**
  39626. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  39627. */
  39628. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  39629. private static _AnyMouseID;
  39630. /**
  39631. * Abstract mesh the behavior is set on
  39632. */
  39633. attachedNode: AbstractMesh;
  39634. private _dragPlane;
  39635. private _scene;
  39636. private _pointerObserver;
  39637. private _beforeRenderObserver;
  39638. private static _planeScene;
  39639. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  39640. /**
  39641. * 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)
  39642. */
  39643. maxDragAngle: number;
  39644. /**
  39645. * @hidden
  39646. */
  39647. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  39648. /**
  39649. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39650. */
  39651. currentDraggingPointerID: number;
  39652. /**
  39653. * The last position where the pointer hit the drag plane in world space
  39654. */
  39655. lastDragPosition: Vector3;
  39656. /**
  39657. * If the behavior is currently in a dragging state
  39658. */
  39659. dragging: boolean;
  39660. /**
  39661. * 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)
  39662. */
  39663. dragDeltaRatio: number;
  39664. /**
  39665. * If the drag plane orientation should be updated during the dragging (Default: true)
  39666. */
  39667. updateDragPlane: boolean;
  39668. private _debugMode;
  39669. private _moving;
  39670. /**
  39671. * Fires each time the attached mesh is dragged with the pointer
  39672. * * delta between last drag position and current drag position in world space
  39673. * * dragDistance along the drag axis
  39674. * * dragPlaneNormal normal of the current drag plane used during the drag
  39675. * * dragPlanePoint in world space where the drag intersects the drag plane
  39676. */
  39677. onDragObservable: Observable<{
  39678. delta: Vector3;
  39679. dragPlanePoint: Vector3;
  39680. dragPlaneNormal: Vector3;
  39681. dragDistance: number;
  39682. pointerId: number;
  39683. }>;
  39684. /**
  39685. * Fires each time a drag begins (eg. mouse down on mesh)
  39686. */
  39687. onDragStartObservable: Observable<{
  39688. dragPlanePoint: Vector3;
  39689. pointerId: number;
  39690. }>;
  39691. /**
  39692. * Fires each time a drag ends (eg. mouse release after drag)
  39693. */
  39694. onDragEndObservable: Observable<{
  39695. dragPlanePoint: Vector3;
  39696. pointerId: number;
  39697. }>;
  39698. /**
  39699. * If the attached mesh should be moved when dragged
  39700. */
  39701. moveAttached: boolean;
  39702. /**
  39703. * If the drag behavior will react to drag events (Default: true)
  39704. */
  39705. enabled: boolean;
  39706. /**
  39707. * If pointer events should start and release the drag (Default: true)
  39708. */
  39709. startAndReleaseDragOnPointerEvents: boolean;
  39710. /**
  39711. * If camera controls should be detached during the drag
  39712. */
  39713. detachCameraControls: boolean;
  39714. /**
  39715. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  39716. */
  39717. useObjectOrienationForDragging: boolean;
  39718. private _options;
  39719. /**
  39720. * Gets the options used by the behavior
  39721. */
  39722. /**
  39723. * Sets the options used by the behavior
  39724. */
  39725. options: {
  39726. dragAxis?: Vector3;
  39727. dragPlaneNormal?: Vector3;
  39728. };
  39729. /**
  39730. * Creates a pointer drag behavior that can be attached to a mesh
  39731. * @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)
  39732. */
  39733. constructor(options?: {
  39734. dragAxis?: Vector3;
  39735. dragPlaneNormal?: Vector3;
  39736. });
  39737. /**
  39738. * Predicate to determine if it is valid to move the object to a new position when it is moved
  39739. */
  39740. validateDrag: (targetPosition: Vector3) => boolean;
  39741. /**
  39742. * The name of the behavior
  39743. */
  39744. readonly name: string;
  39745. /**
  39746. * Initializes the behavior
  39747. */
  39748. init(): void;
  39749. private _tmpVector;
  39750. private _alternatePickedPoint;
  39751. private _worldDragAxis;
  39752. private _targetPosition;
  39753. private _attachedElement;
  39754. /**
  39755. * Attaches the drag behavior the passed in mesh
  39756. * @param ownerNode The mesh that will be dragged around once attached
  39757. * @param predicate Predicate to use for pick filtering
  39758. */
  39759. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  39760. /**
  39761. * Force relase the drag action by code.
  39762. */
  39763. releaseDrag(): void;
  39764. private _startDragRay;
  39765. private _lastPointerRay;
  39766. /**
  39767. * Simulates the start of a pointer drag event on the behavior
  39768. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  39769. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  39770. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  39771. */
  39772. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  39773. private _startDrag;
  39774. private _dragDelta;
  39775. private _moveDrag;
  39776. private _pickWithRayOnDragPlane;
  39777. private _pointA;
  39778. private _pointB;
  39779. private _pointC;
  39780. private _lineA;
  39781. private _lineB;
  39782. private _localAxis;
  39783. private _lookAt;
  39784. private _updateDragPlanePosition;
  39785. /**
  39786. * Detaches the behavior from the mesh
  39787. */
  39788. detach(): void;
  39789. }
  39790. }
  39791. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  39792. import { Mesh } from "babylonjs/Meshes/mesh";
  39793. import { Behavior } from "babylonjs/Behaviors/behavior";
  39794. /**
  39795. * A behavior that when attached to a mesh will allow the mesh to be scaled
  39796. */
  39797. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  39798. private _dragBehaviorA;
  39799. private _dragBehaviorB;
  39800. private _startDistance;
  39801. private _initialScale;
  39802. private _targetScale;
  39803. private _ownerNode;
  39804. private _sceneRenderObserver;
  39805. /**
  39806. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  39807. */
  39808. constructor();
  39809. /**
  39810. * The name of the behavior
  39811. */
  39812. readonly name: string;
  39813. /**
  39814. * Initializes the behavior
  39815. */
  39816. init(): void;
  39817. private _getCurrentDistance;
  39818. /**
  39819. * Attaches the scale behavior the passed in mesh
  39820. * @param ownerNode The mesh that will be scaled around once attached
  39821. */
  39822. attach(ownerNode: Mesh): void;
  39823. /**
  39824. * Detaches the behavior from the mesh
  39825. */
  39826. detach(): void;
  39827. }
  39828. }
  39829. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  39830. import { Behavior } from "babylonjs/Behaviors/behavior";
  39831. import { Mesh } from "babylonjs/Meshes/mesh";
  39832. import { Observable } from "babylonjs/Misc/observable";
  39833. /**
  39834. * 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
  39835. */
  39836. export class SixDofDragBehavior implements Behavior<Mesh> {
  39837. private static _virtualScene;
  39838. private _ownerNode;
  39839. private _sceneRenderObserver;
  39840. private _scene;
  39841. private _targetPosition;
  39842. private _virtualOriginMesh;
  39843. private _virtualDragMesh;
  39844. private _pointerObserver;
  39845. private _moving;
  39846. private _startingOrientation;
  39847. /**
  39848. * 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)
  39849. */
  39850. private zDragFactor;
  39851. /**
  39852. * If the object should rotate to face the drag origin
  39853. */
  39854. rotateDraggedObject: boolean;
  39855. /**
  39856. * If the behavior is currently in a dragging state
  39857. */
  39858. dragging: boolean;
  39859. /**
  39860. * 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)
  39861. */
  39862. dragDeltaRatio: number;
  39863. /**
  39864. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39865. */
  39866. currentDraggingPointerID: number;
  39867. /**
  39868. * If camera controls should be detached during the drag
  39869. */
  39870. detachCameraControls: boolean;
  39871. /**
  39872. * Fires each time a drag starts
  39873. */
  39874. onDragStartObservable: Observable<{}>;
  39875. /**
  39876. * Fires each time a drag ends (eg. mouse release after drag)
  39877. */
  39878. onDragEndObservable: Observable<{}>;
  39879. /**
  39880. * 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
  39881. */
  39882. constructor();
  39883. /**
  39884. * The name of the behavior
  39885. */
  39886. readonly name: string;
  39887. /**
  39888. * Initializes the behavior
  39889. */
  39890. init(): void;
  39891. /**
  39892. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  39893. */
  39894. private readonly _pointerCamera;
  39895. /**
  39896. * Attaches the scale behavior the passed in mesh
  39897. * @param ownerNode The mesh that will be scaled around once attached
  39898. */
  39899. attach(ownerNode: Mesh): void;
  39900. /**
  39901. * Detaches the behavior from the mesh
  39902. */
  39903. detach(): void;
  39904. }
  39905. }
  39906. declare module "babylonjs/Behaviors/Meshes/index" {
  39907. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  39908. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  39909. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  39910. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  39911. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  39912. }
  39913. declare module "babylonjs/Behaviors/index" {
  39914. export * from "babylonjs/Behaviors/behavior";
  39915. export * from "babylonjs/Behaviors/Cameras/index";
  39916. export * from "babylonjs/Behaviors/Meshes/index";
  39917. }
  39918. declare module "babylonjs/Bones/boneIKController" {
  39919. import { Bone } from "babylonjs/Bones/bone";
  39920. import { Vector3 } from "babylonjs/Maths/math.vector";
  39921. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39922. import { Nullable } from "babylonjs/types";
  39923. /**
  39924. * Class used to apply inverse kinematics to bones
  39925. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  39926. */
  39927. export class BoneIKController {
  39928. private static _tmpVecs;
  39929. private static _tmpQuat;
  39930. private static _tmpMats;
  39931. /**
  39932. * Gets or sets the target mesh
  39933. */
  39934. targetMesh: AbstractMesh;
  39935. /** Gets or sets the mesh used as pole */
  39936. poleTargetMesh: AbstractMesh;
  39937. /**
  39938. * Gets or sets the bone used as pole
  39939. */
  39940. poleTargetBone: Nullable<Bone>;
  39941. /**
  39942. * Gets or sets the target position
  39943. */
  39944. targetPosition: Vector3;
  39945. /**
  39946. * Gets or sets the pole target position
  39947. */
  39948. poleTargetPosition: Vector3;
  39949. /**
  39950. * Gets or sets the pole target local offset
  39951. */
  39952. poleTargetLocalOffset: Vector3;
  39953. /**
  39954. * Gets or sets the pole angle
  39955. */
  39956. poleAngle: number;
  39957. /**
  39958. * Gets or sets the mesh associated with the controller
  39959. */
  39960. mesh: AbstractMesh;
  39961. /**
  39962. * 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)
  39963. */
  39964. slerpAmount: number;
  39965. private _bone1Quat;
  39966. private _bone1Mat;
  39967. private _bone2Ang;
  39968. private _bone1;
  39969. private _bone2;
  39970. private _bone1Length;
  39971. private _bone2Length;
  39972. private _maxAngle;
  39973. private _maxReach;
  39974. private _rightHandedSystem;
  39975. private _bendAxis;
  39976. private _slerping;
  39977. private _adjustRoll;
  39978. /**
  39979. * Gets or sets maximum allowed angle
  39980. */
  39981. maxAngle: number;
  39982. /**
  39983. * Creates a new BoneIKController
  39984. * @param mesh defines the mesh to control
  39985. * @param bone defines the bone to control
  39986. * @param options defines options to set up the controller
  39987. */
  39988. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  39989. targetMesh?: AbstractMesh;
  39990. poleTargetMesh?: AbstractMesh;
  39991. poleTargetBone?: Bone;
  39992. poleTargetLocalOffset?: Vector3;
  39993. poleAngle?: number;
  39994. bendAxis?: Vector3;
  39995. maxAngle?: number;
  39996. slerpAmount?: number;
  39997. });
  39998. private _setMaxAngle;
  39999. /**
  40000. * Force the controller to update the bones
  40001. */
  40002. update(): void;
  40003. }
  40004. }
  40005. declare module "babylonjs/Bones/boneLookController" {
  40006. import { Vector3 } from "babylonjs/Maths/math.vector";
  40007. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40008. import { Bone } from "babylonjs/Bones/bone";
  40009. import { Space } from "babylonjs/Maths/math.axis";
  40010. /**
  40011. * Class used to make a bone look toward a point in space
  40012. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  40013. */
  40014. export class BoneLookController {
  40015. private static _tmpVecs;
  40016. private static _tmpQuat;
  40017. private static _tmpMats;
  40018. /**
  40019. * The target Vector3 that the bone will look at
  40020. */
  40021. target: Vector3;
  40022. /**
  40023. * The mesh that the bone is attached to
  40024. */
  40025. mesh: AbstractMesh;
  40026. /**
  40027. * The bone that will be looking to the target
  40028. */
  40029. bone: Bone;
  40030. /**
  40031. * The up axis of the coordinate system that is used when the bone is rotated
  40032. */
  40033. upAxis: Vector3;
  40034. /**
  40035. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  40036. */
  40037. upAxisSpace: Space;
  40038. /**
  40039. * Used to make an adjustment to the yaw of the bone
  40040. */
  40041. adjustYaw: number;
  40042. /**
  40043. * Used to make an adjustment to the pitch of the bone
  40044. */
  40045. adjustPitch: number;
  40046. /**
  40047. * Used to make an adjustment to the roll of the bone
  40048. */
  40049. adjustRoll: number;
  40050. /**
  40051. * 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)
  40052. */
  40053. slerpAmount: number;
  40054. private _minYaw;
  40055. private _maxYaw;
  40056. private _minPitch;
  40057. private _maxPitch;
  40058. private _minYawSin;
  40059. private _minYawCos;
  40060. private _maxYawSin;
  40061. private _maxYawCos;
  40062. private _midYawConstraint;
  40063. private _minPitchTan;
  40064. private _maxPitchTan;
  40065. private _boneQuat;
  40066. private _slerping;
  40067. private _transformYawPitch;
  40068. private _transformYawPitchInv;
  40069. private _firstFrameSkipped;
  40070. private _yawRange;
  40071. private _fowardAxis;
  40072. /**
  40073. * Gets or sets the minimum yaw angle that the bone can look to
  40074. */
  40075. minYaw: number;
  40076. /**
  40077. * Gets or sets the maximum yaw angle that the bone can look to
  40078. */
  40079. maxYaw: number;
  40080. /**
  40081. * Gets or sets the minimum pitch angle that the bone can look to
  40082. */
  40083. minPitch: number;
  40084. /**
  40085. * Gets or sets the maximum pitch angle that the bone can look to
  40086. */
  40087. maxPitch: number;
  40088. /**
  40089. * Create a BoneLookController
  40090. * @param mesh the mesh that the bone belongs to
  40091. * @param bone the bone that will be looking to the target
  40092. * @param target the target Vector3 to look at
  40093. * @param options optional settings:
  40094. * * maxYaw: the maximum angle the bone will yaw to
  40095. * * minYaw: the minimum angle the bone will yaw to
  40096. * * maxPitch: the maximum angle the bone will pitch to
  40097. * * minPitch: the minimum angle the bone will yaw to
  40098. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  40099. * * upAxis: the up axis of the coordinate system
  40100. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  40101. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  40102. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  40103. * * adjustYaw: used to make an adjustment to the yaw of the bone
  40104. * * adjustPitch: used to make an adjustment to the pitch of the bone
  40105. * * adjustRoll: used to make an adjustment to the roll of the bone
  40106. **/
  40107. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  40108. maxYaw?: number;
  40109. minYaw?: number;
  40110. maxPitch?: number;
  40111. minPitch?: number;
  40112. slerpAmount?: number;
  40113. upAxis?: Vector3;
  40114. upAxisSpace?: Space;
  40115. yawAxis?: Vector3;
  40116. pitchAxis?: Vector3;
  40117. adjustYaw?: number;
  40118. adjustPitch?: number;
  40119. adjustRoll?: number;
  40120. });
  40121. /**
  40122. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  40123. */
  40124. update(): void;
  40125. private _getAngleDiff;
  40126. private _getAngleBetween;
  40127. private _isAngleBetween;
  40128. }
  40129. }
  40130. declare module "babylonjs/Bones/index" {
  40131. export * from "babylonjs/Bones/bone";
  40132. export * from "babylonjs/Bones/boneIKController";
  40133. export * from "babylonjs/Bones/boneLookController";
  40134. export * from "babylonjs/Bones/skeleton";
  40135. }
  40136. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  40137. import { Nullable } from "babylonjs/types";
  40138. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40139. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40140. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40141. /**
  40142. * Manage the gamepad inputs to control an arc rotate camera.
  40143. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40144. */
  40145. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  40146. /**
  40147. * Defines the camera the input is attached to.
  40148. */
  40149. camera: ArcRotateCamera;
  40150. /**
  40151. * Defines the gamepad the input is gathering event from.
  40152. */
  40153. gamepad: Nullable<Gamepad>;
  40154. /**
  40155. * Defines the gamepad rotation sensiblity.
  40156. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40157. */
  40158. gamepadRotationSensibility: number;
  40159. /**
  40160. * Defines the gamepad move sensiblity.
  40161. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40162. */
  40163. gamepadMoveSensibility: number;
  40164. private _yAxisScale;
  40165. /**
  40166. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40167. */
  40168. invertYAxis: boolean;
  40169. private _onGamepadConnectedObserver;
  40170. private _onGamepadDisconnectedObserver;
  40171. /**
  40172. * Attach the input controls to a specific dom element to get the input from.
  40173. * @param element Defines the element the controls should be listened from
  40174. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40175. */
  40176. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40177. /**
  40178. * Detach the current controls from the specified dom element.
  40179. * @param element Defines the element to stop listening the inputs from
  40180. */
  40181. detachControl(element: Nullable<HTMLElement>): void;
  40182. /**
  40183. * Update the current camera state depending on the inputs that have been used this frame.
  40184. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40185. */
  40186. checkInputs(): void;
  40187. /**
  40188. * Gets the class name of the current intput.
  40189. * @returns the class name
  40190. */
  40191. getClassName(): string;
  40192. /**
  40193. * Get the friendly name associated with the input class.
  40194. * @returns the input friendly name
  40195. */
  40196. getSimpleName(): string;
  40197. }
  40198. }
  40199. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  40200. import { Nullable } from "babylonjs/types";
  40201. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40202. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40203. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40204. interface ArcRotateCameraInputsManager {
  40205. /**
  40206. * Add orientation input support to the input manager.
  40207. * @returns the current input manager
  40208. */
  40209. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  40210. }
  40211. }
  40212. /**
  40213. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  40214. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40215. */
  40216. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  40217. /**
  40218. * Defines the camera the input is attached to.
  40219. */
  40220. camera: ArcRotateCamera;
  40221. /**
  40222. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  40223. */
  40224. alphaCorrection: number;
  40225. /**
  40226. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  40227. */
  40228. gammaCorrection: number;
  40229. private _alpha;
  40230. private _gamma;
  40231. private _dirty;
  40232. private _deviceOrientationHandler;
  40233. /**
  40234. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  40235. */
  40236. constructor();
  40237. /**
  40238. * Attach the input controls to a specific dom element to get the input from.
  40239. * @param element Defines the element the controls should be listened from
  40240. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40241. */
  40242. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40243. /** @hidden */
  40244. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  40245. /**
  40246. * Update the current camera state depending on the inputs that have been used this frame.
  40247. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40248. */
  40249. checkInputs(): void;
  40250. /**
  40251. * Detach the current controls from the specified dom element.
  40252. * @param element Defines the element to stop listening the inputs from
  40253. */
  40254. detachControl(element: Nullable<HTMLElement>): void;
  40255. /**
  40256. * Gets the class name of the current intput.
  40257. * @returns the class name
  40258. */
  40259. getClassName(): string;
  40260. /**
  40261. * Get the friendly name associated with the input class.
  40262. * @returns the input friendly name
  40263. */
  40264. getSimpleName(): string;
  40265. }
  40266. }
  40267. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  40268. import { Nullable } from "babylonjs/types";
  40269. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40270. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  40271. /**
  40272. * Listen to mouse events to control the camera.
  40273. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40274. */
  40275. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  40276. /**
  40277. * Defines the camera the input is attached to.
  40278. */
  40279. camera: FlyCamera;
  40280. /**
  40281. * Defines if touch is enabled. (Default is true.)
  40282. */
  40283. touchEnabled: boolean;
  40284. /**
  40285. * Defines the buttons associated with the input to handle camera rotation.
  40286. */
  40287. buttons: number[];
  40288. /**
  40289. * Assign buttons for Yaw control.
  40290. */
  40291. buttonsYaw: number[];
  40292. /**
  40293. * Assign buttons for Pitch control.
  40294. */
  40295. buttonsPitch: number[];
  40296. /**
  40297. * Assign buttons for Roll control.
  40298. */
  40299. buttonsRoll: number[];
  40300. /**
  40301. * Detect if any button is being pressed while mouse is moved.
  40302. * -1 = Mouse locked.
  40303. * 0 = Left button.
  40304. * 1 = Middle Button.
  40305. * 2 = Right Button.
  40306. */
  40307. activeButton: number;
  40308. /**
  40309. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  40310. * Higher values reduce its sensitivity.
  40311. */
  40312. angularSensibility: number;
  40313. private _mousemoveCallback;
  40314. private _observer;
  40315. private _rollObserver;
  40316. private previousPosition;
  40317. private noPreventDefault;
  40318. private element;
  40319. /**
  40320. * Listen to mouse events to control the camera.
  40321. * @param touchEnabled Define if touch is enabled. (Default is true.)
  40322. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40323. */
  40324. constructor(touchEnabled?: boolean);
  40325. /**
  40326. * Attach the mouse control to the HTML DOM element.
  40327. * @param element Defines the element that listens to the input events.
  40328. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  40329. */
  40330. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40331. /**
  40332. * Detach the current controls from the specified dom element.
  40333. * @param element Defines the element to stop listening the inputs from
  40334. */
  40335. detachControl(element: Nullable<HTMLElement>): void;
  40336. /**
  40337. * Gets the class name of the current input.
  40338. * @returns the class name.
  40339. */
  40340. getClassName(): string;
  40341. /**
  40342. * Get the friendly name associated with the input class.
  40343. * @returns the input's friendly name.
  40344. */
  40345. getSimpleName(): string;
  40346. private _pointerInput;
  40347. private _onMouseMove;
  40348. /**
  40349. * Rotate camera by mouse offset.
  40350. */
  40351. private rotateCamera;
  40352. }
  40353. }
  40354. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  40355. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  40356. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  40357. /**
  40358. * Default Inputs manager for the FlyCamera.
  40359. * It groups all the default supported inputs for ease of use.
  40360. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40361. */
  40362. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  40363. /**
  40364. * Instantiates a new FlyCameraInputsManager.
  40365. * @param camera Defines the camera the inputs belong to.
  40366. */
  40367. constructor(camera: FlyCamera);
  40368. /**
  40369. * Add keyboard input support to the input manager.
  40370. * @returns the new FlyCameraKeyboardMoveInput().
  40371. */
  40372. addKeyboard(): FlyCameraInputsManager;
  40373. /**
  40374. * Add mouse input support to the input manager.
  40375. * @param touchEnabled Enable touch screen support.
  40376. * @returns the new FlyCameraMouseInput().
  40377. */
  40378. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  40379. }
  40380. }
  40381. declare module "babylonjs/Cameras/flyCamera" {
  40382. import { Scene } from "babylonjs/scene";
  40383. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  40384. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40385. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  40386. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  40387. /**
  40388. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40389. * such as in a 3D Space Shooter or a Flight Simulator.
  40390. */
  40391. export class FlyCamera extends TargetCamera {
  40392. /**
  40393. * Define the collision ellipsoid of the camera.
  40394. * This is helpful for simulating a camera body, like a player's body.
  40395. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  40396. */
  40397. ellipsoid: Vector3;
  40398. /**
  40399. * Define an offset for the position of the ellipsoid around the camera.
  40400. * This can be helpful if the camera is attached away from the player's body center,
  40401. * such as at its head.
  40402. */
  40403. ellipsoidOffset: Vector3;
  40404. /**
  40405. * Enable or disable collisions of the camera with the rest of the scene objects.
  40406. */
  40407. checkCollisions: boolean;
  40408. /**
  40409. * Enable or disable gravity on the camera.
  40410. */
  40411. applyGravity: boolean;
  40412. /**
  40413. * Define the current direction the camera is moving to.
  40414. */
  40415. cameraDirection: Vector3;
  40416. /**
  40417. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  40418. * This overrides and empties cameraRotation.
  40419. */
  40420. rotationQuaternion: Quaternion;
  40421. /**
  40422. * Track Roll to maintain the wanted Rolling when looking around.
  40423. */
  40424. _trackRoll: number;
  40425. /**
  40426. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  40427. */
  40428. rollCorrect: number;
  40429. /**
  40430. * Mimic a banked turn, Rolling the camera when Yawing.
  40431. * It's recommended to use rollCorrect = 10 for faster banking correction.
  40432. */
  40433. bankedTurn: boolean;
  40434. /**
  40435. * Limit in radians for how much Roll banking will add. (Default: 90°)
  40436. */
  40437. bankedTurnLimit: number;
  40438. /**
  40439. * Value of 0 disables the banked Roll.
  40440. * Value of 1 is equal to the Yaw angle in radians.
  40441. */
  40442. bankedTurnMultiplier: number;
  40443. /**
  40444. * The inputs manager loads all the input sources, such as keyboard and mouse.
  40445. */
  40446. inputs: FlyCameraInputsManager;
  40447. /**
  40448. * Gets the input sensibility for mouse input.
  40449. * Higher values reduce sensitivity.
  40450. */
  40451. /**
  40452. * Sets the input sensibility for a mouse input.
  40453. * Higher values reduce sensitivity.
  40454. */
  40455. angularSensibility: number;
  40456. /**
  40457. * Get the keys for camera movement forward.
  40458. */
  40459. /**
  40460. * Set the keys for camera movement forward.
  40461. */
  40462. keysForward: number[];
  40463. /**
  40464. * Get the keys for camera movement backward.
  40465. */
  40466. keysBackward: number[];
  40467. /**
  40468. * Get the keys for camera movement up.
  40469. */
  40470. /**
  40471. * Set the keys for camera movement up.
  40472. */
  40473. keysUp: number[];
  40474. /**
  40475. * Get the keys for camera movement down.
  40476. */
  40477. /**
  40478. * Set the keys for camera movement down.
  40479. */
  40480. keysDown: number[];
  40481. /**
  40482. * Get the keys for camera movement left.
  40483. */
  40484. /**
  40485. * Set the keys for camera movement left.
  40486. */
  40487. keysLeft: number[];
  40488. /**
  40489. * Set the keys for camera movement right.
  40490. */
  40491. /**
  40492. * Set the keys for camera movement right.
  40493. */
  40494. keysRight: number[];
  40495. /**
  40496. * Event raised when the camera collides with a mesh in the scene.
  40497. */
  40498. onCollide: (collidedMesh: AbstractMesh) => void;
  40499. private _collider;
  40500. private _needMoveForGravity;
  40501. private _oldPosition;
  40502. private _diffPosition;
  40503. private _newPosition;
  40504. /** @hidden */
  40505. _localDirection: Vector3;
  40506. /** @hidden */
  40507. _transformedDirection: Vector3;
  40508. /**
  40509. * Instantiates a FlyCamera.
  40510. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40511. * such as in a 3D Space Shooter or a Flight Simulator.
  40512. * @param name Define the name of the camera in the scene.
  40513. * @param position Define the starting position of the camera in the scene.
  40514. * @param scene Define the scene the camera belongs to.
  40515. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  40516. */
  40517. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40518. /**
  40519. * Attach a control to the HTML DOM element.
  40520. * @param element Defines the element that listens to the input events.
  40521. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  40522. */
  40523. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40524. /**
  40525. * Detach a control from the HTML DOM element.
  40526. * The camera will stop reacting to that input.
  40527. * @param element Defines the element that listens to the input events.
  40528. */
  40529. detachControl(element: HTMLElement): void;
  40530. private _collisionMask;
  40531. /**
  40532. * Get the mask that the camera ignores in collision events.
  40533. */
  40534. /**
  40535. * Set the mask that the camera ignores in collision events.
  40536. */
  40537. collisionMask: number;
  40538. /** @hidden */
  40539. _collideWithWorld(displacement: Vector3): void;
  40540. /** @hidden */
  40541. private _onCollisionPositionChange;
  40542. /** @hidden */
  40543. _checkInputs(): void;
  40544. /** @hidden */
  40545. _decideIfNeedsToMove(): boolean;
  40546. /** @hidden */
  40547. _updatePosition(): void;
  40548. /**
  40549. * Restore the Roll to its target value at the rate specified.
  40550. * @param rate - Higher means slower restoring.
  40551. * @hidden
  40552. */
  40553. restoreRoll(rate: number): void;
  40554. /**
  40555. * Destroy the camera and release the current resources held by it.
  40556. */
  40557. dispose(): void;
  40558. /**
  40559. * Get the current object class name.
  40560. * @returns the class name.
  40561. */
  40562. getClassName(): string;
  40563. }
  40564. }
  40565. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  40566. import { Nullable } from "babylonjs/types";
  40567. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40568. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  40569. /**
  40570. * Listen to keyboard events to control the camera.
  40571. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40572. */
  40573. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  40574. /**
  40575. * Defines the camera the input is attached to.
  40576. */
  40577. camera: FlyCamera;
  40578. /**
  40579. * The list of keyboard keys used to control the forward move of the camera.
  40580. */
  40581. keysForward: number[];
  40582. /**
  40583. * The list of keyboard keys used to control the backward move of the camera.
  40584. */
  40585. keysBackward: number[];
  40586. /**
  40587. * The list of keyboard keys used to control the forward move of the camera.
  40588. */
  40589. keysUp: number[];
  40590. /**
  40591. * The list of keyboard keys used to control the backward move of the camera.
  40592. */
  40593. keysDown: number[];
  40594. /**
  40595. * The list of keyboard keys used to control the right strafe move of the camera.
  40596. */
  40597. keysRight: number[];
  40598. /**
  40599. * The list of keyboard keys used to control the left strafe move of the camera.
  40600. */
  40601. keysLeft: number[];
  40602. private _keys;
  40603. private _onCanvasBlurObserver;
  40604. private _onKeyboardObserver;
  40605. private _engine;
  40606. private _scene;
  40607. /**
  40608. * Attach the input controls to a specific dom element to get the input from.
  40609. * @param element Defines the element the controls should be listened from
  40610. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40611. */
  40612. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40613. /**
  40614. * Detach the current controls from the specified dom element.
  40615. * @param element Defines the element to stop listening the inputs from
  40616. */
  40617. detachControl(element: Nullable<HTMLElement>): void;
  40618. /**
  40619. * Gets the class name of the current intput.
  40620. * @returns the class name
  40621. */
  40622. getClassName(): string;
  40623. /** @hidden */
  40624. _onLostFocus(e: FocusEvent): void;
  40625. /**
  40626. * Get the friendly name associated with the input class.
  40627. * @returns the input friendly name
  40628. */
  40629. getSimpleName(): string;
  40630. /**
  40631. * Update the current camera state depending on the inputs that have been used this frame.
  40632. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40633. */
  40634. checkInputs(): void;
  40635. }
  40636. }
  40637. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  40638. import { Nullable } from "babylonjs/types";
  40639. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  40640. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40641. /**
  40642. * Manage the mouse wheel inputs to control a follow camera.
  40643. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40644. */
  40645. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  40646. /**
  40647. * Defines the camera the input is attached to.
  40648. */
  40649. camera: FollowCamera;
  40650. /**
  40651. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  40652. */
  40653. axisControlRadius: boolean;
  40654. /**
  40655. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  40656. */
  40657. axisControlHeight: boolean;
  40658. /**
  40659. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  40660. */
  40661. axisControlRotation: boolean;
  40662. /**
  40663. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  40664. * relation to mouseWheel events.
  40665. */
  40666. wheelPrecision: number;
  40667. /**
  40668. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  40669. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  40670. */
  40671. wheelDeltaPercentage: number;
  40672. private _wheel;
  40673. private _observer;
  40674. /**
  40675. * Attach the input controls to a specific dom element to get the input from.
  40676. * @param element Defines the element the controls should be listened from
  40677. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40678. */
  40679. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40680. /**
  40681. * Detach the current controls from the specified dom element.
  40682. * @param element Defines the element to stop listening the inputs from
  40683. */
  40684. detachControl(element: Nullable<HTMLElement>): void;
  40685. /**
  40686. * Gets the class name of the current intput.
  40687. * @returns the class name
  40688. */
  40689. getClassName(): string;
  40690. /**
  40691. * Get the friendly name associated with the input class.
  40692. * @returns the input friendly name
  40693. */
  40694. getSimpleName(): string;
  40695. }
  40696. }
  40697. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  40698. import { Nullable } from "babylonjs/types";
  40699. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  40700. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  40701. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  40702. /**
  40703. * Manage the pointers inputs to control an follow camera.
  40704. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40705. */
  40706. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  40707. /**
  40708. * Defines the camera the input is attached to.
  40709. */
  40710. camera: FollowCamera;
  40711. /**
  40712. * Gets the class name of the current input.
  40713. * @returns the class name
  40714. */
  40715. getClassName(): string;
  40716. /**
  40717. * Defines the pointer angular sensibility along the X axis or how fast is
  40718. * the camera rotating.
  40719. * A negative number will reverse the axis direction.
  40720. */
  40721. angularSensibilityX: number;
  40722. /**
  40723. * Defines the pointer angular sensibility along the Y axis or how fast is
  40724. * the camera rotating.
  40725. * A negative number will reverse the axis direction.
  40726. */
  40727. angularSensibilityY: number;
  40728. /**
  40729. * Defines the pointer pinch precision or how fast is the camera zooming.
  40730. * A negative number will reverse the axis direction.
  40731. */
  40732. pinchPrecision: number;
  40733. /**
  40734. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  40735. * from 0.
  40736. * It defines the percentage of current camera.radius to use as delta when
  40737. * pinch zoom is used.
  40738. */
  40739. pinchDeltaPercentage: number;
  40740. /**
  40741. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  40742. */
  40743. axisXControlRadius: boolean;
  40744. /**
  40745. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  40746. */
  40747. axisXControlHeight: boolean;
  40748. /**
  40749. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  40750. */
  40751. axisXControlRotation: boolean;
  40752. /**
  40753. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  40754. */
  40755. axisYControlRadius: boolean;
  40756. /**
  40757. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  40758. */
  40759. axisYControlHeight: boolean;
  40760. /**
  40761. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  40762. */
  40763. axisYControlRotation: boolean;
  40764. /**
  40765. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  40766. */
  40767. axisPinchControlRadius: boolean;
  40768. /**
  40769. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  40770. */
  40771. axisPinchControlHeight: boolean;
  40772. /**
  40773. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  40774. */
  40775. axisPinchControlRotation: boolean;
  40776. /**
  40777. * Log error messages if basic misconfiguration has occurred.
  40778. */
  40779. warningEnable: boolean;
  40780. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  40781. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  40782. private _warningCounter;
  40783. private _warning;
  40784. }
  40785. }
  40786. declare module "babylonjs/Cameras/followCameraInputsManager" {
  40787. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  40788. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  40789. /**
  40790. * Default Inputs manager for the FollowCamera.
  40791. * It groups all the default supported inputs for ease of use.
  40792. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40793. */
  40794. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  40795. /**
  40796. * Instantiates a new FollowCameraInputsManager.
  40797. * @param camera Defines the camera the inputs belong to
  40798. */
  40799. constructor(camera: FollowCamera);
  40800. /**
  40801. * Add keyboard input support to the input manager.
  40802. * @returns the current input manager
  40803. */
  40804. addKeyboard(): FollowCameraInputsManager;
  40805. /**
  40806. * Add mouse wheel input support to the input manager.
  40807. * @returns the current input manager
  40808. */
  40809. addMouseWheel(): FollowCameraInputsManager;
  40810. /**
  40811. * Add pointers input support to the input manager.
  40812. * @returns the current input manager
  40813. */
  40814. addPointers(): FollowCameraInputsManager;
  40815. /**
  40816. * Add orientation input support to the input manager.
  40817. * @returns the current input manager
  40818. */
  40819. addVRDeviceOrientation(): FollowCameraInputsManager;
  40820. }
  40821. }
  40822. declare module "babylonjs/Cameras/followCamera" {
  40823. import { Nullable } from "babylonjs/types";
  40824. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  40825. import { Scene } from "babylonjs/scene";
  40826. import { Vector3 } from "babylonjs/Maths/math.vector";
  40827. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40828. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  40829. /**
  40830. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  40831. * an arc rotate version arcFollowCamera are available.
  40832. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40833. */
  40834. export class FollowCamera extends TargetCamera {
  40835. /**
  40836. * Distance the follow camera should follow an object at
  40837. */
  40838. radius: number;
  40839. /**
  40840. * Minimum allowed distance of the camera to the axis of rotation
  40841. * (The camera can not get closer).
  40842. * This can help limiting how the Camera is able to move in the scene.
  40843. */
  40844. lowerRadiusLimit: Nullable<number>;
  40845. /**
  40846. * Maximum allowed distance of the camera to the axis of rotation
  40847. * (The camera can not get further).
  40848. * This can help limiting how the Camera is able to move in the scene.
  40849. */
  40850. upperRadiusLimit: Nullable<number>;
  40851. /**
  40852. * Define a rotation offset between the camera and the object it follows
  40853. */
  40854. rotationOffset: number;
  40855. /**
  40856. * Minimum allowed angle to camera position relative to target object.
  40857. * This can help limiting how the Camera is able to move in the scene.
  40858. */
  40859. lowerRotationOffsetLimit: Nullable<number>;
  40860. /**
  40861. * Maximum allowed angle to camera position relative to target object.
  40862. * This can help limiting how the Camera is able to move in the scene.
  40863. */
  40864. upperRotationOffsetLimit: Nullable<number>;
  40865. /**
  40866. * Define a height offset between the camera and the object it follows.
  40867. * It can help following an object from the top (like a car chaing a plane)
  40868. */
  40869. heightOffset: number;
  40870. /**
  40871. * Minimum allowed height of camera position relative to target object.
  40872. * This can help limiting how the Camera is able to move in the scene.
  40873. */
  40874. lowerHeightOffsetLimit: Nullable<number>;
  40875. /**
  40876. * Maximum allowed height of camera position relative to target object.
  40877. * This can help limiting how the Camera is able to move in the scene.
  40878. */
  40879. upperHeightOffsetLimit: Nullable<number>;
  40880. /**
  40881. * Define how fast the camera can accelerate to follow it s target.
  40882. */
  40883. cameraAcceleration: number;
  40884. /**
  40885. * Define the speed limit of the camera following an object.
  40886. */
  40887. maxCameraSpeed: number;
  40888. /**
  40889. * Define the target of the camera.
  40890. */
  40891. lockedTarget: Nullable<AbstractMesh>;
  40892. /**
  40893. * Defines the input associated with the camera.
  40894. */
  40895. inputs: FollowCameraInputsManager;
  40896. /**
  40897. * Instantiates the follow camera.
  40898. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40899. * @param name Define the name of the camera in the scene
  40900. * @param position Define the position of the camera
  40901. * @param scene Define the scene the camera belong to
  40902. * @param lockedTarget Define the target of the camera
  40903. */
  40904. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  40905. private _follow;
  40906. /**
  40907. * Attached controls to the current camera.
  40908. * @param element Defines the element the controls should be listened from
  40909. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40910. */
  40911. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40912. /**
  40913. * Detach the current controls from the camera.
  40914. * The camera will stop reacting to inputs.
  40915. * @param element Defines the element to stop listening the inputs from
  40916. */
  40917. detachControl(element: HTMLElement): void;
  40918. /** @hidden */
  40919. _checkInputs(): void;
  40920. private _checkLimits;
  40921. /**
  40922. * Gets the camera class name.
  40923. * @returns the class name
  40924. */
  40925. getClassName(): string;
  40926. }
  40927. /**
  40928. * Arc Rotate version of the follow camera.
  40929. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  40930. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40931. */
  40932. export class ArcFollowCamera extends TargetCamera {
  40933. /** The longitudinal angle of the camera */
  40934. alpha: number;
  40935. /** The latitudinal angle of the camera */
  40936. beta: number;
  40937. /** The radius of the camera from its target */
  40938. radius: number;
  40939. /** Define the camera target (the messh it should follow) */
  40940. target: Nullable<AbstractMesh>;
  40941. private _cartesianCoordinates;
  40942. /**
  40943. * Instantiates a new ArcFollowCamera
  40944. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40945. * @param name Define the name of the camera
  40946. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  40947. * @param beta Define the rotation angle of the camera around the elevation axis
  40948. * @param radius Define the radius of the camera from its target point
  40949. * @param target Define the target of the camera
  40950. * @param scene Define the scene the camera belongs to
  40951. */
  40952. constructor(name: string,
  40953. /** The longitudinal angle of the camera */
  40954. alpha: number,
  40955. /** The latitudinal angle of the camera */
  40956. beta: number,
  40957. /** The radius of the camera from its target */
  40958. radius: number,
  40959. /** Define the camera target (the messh it should follow) */
  40960. target: Nullable<AbstractMesh>, scene: Scene);
  40961. private _follow;
  40962. /** @hidden */
  40963. _checkInputs(): void;
  40964. /**
  40965. * Returns the class name of the object.
  40966. * It is mostly used internally for serialization purposes.
  40967. */
  40968. getClassName(): string;
  40969. }
  40970. }
  40971. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  40972. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40973. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  40974. import { Nullable } from "babylonjs/types";
  40975. /**
  40976. * Manage the keyboard inputs to control the movement of a follow camera.
  40977. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40978. */
  40979. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  40980. /**
  40981. * Defines the camera the input is attached to.
  40982. */
  40983. camera: FollowCamera;
  40984. /**
  40985. * Defines the list of key codes associated with the up action (increase heightOffset)
  40986. */
  40987. keysHeightOffsetIncr: number[];
  40988. /**
  40989. * Defines the list of key codes associated with the down action (decrease heightOffset)
  40990. */
  40991. keysHeightOffsetDecr: number[];
  40992. /**
  40993. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  40994. */
  40995. keysHeightOffsetModifierAlt: boolean;
  40996. /**
  40997. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  40998. */
  40999. keysHeightOffsetModifierCtrl: boolean;
  41000. /**
  41001. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  41002. */
  41003. keysHeightOffsetModifierShift: boolean;
  41004. /**
  41005. * Defines the list of key codes associated with the left action (increase rotationOffset)
  41006. */
  41007. keysRotationOffsetIncr: number[];
  41008. /**
  41009. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  41010. */
  41011. keysRotationOffsetDecr: number[];
  41012. /**
  41013. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  41014. */
  41015. keysRotationOffsetModifierAlt: boolean;
  41016. /**
  41017. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  41018. */
  41019. keysRotationOffsetModifierCtrl: boolean;
  41020. /**
  41021. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  41022. */
  41023. keysRotationOffsetModifierShift: boolean;
  41024. /**
  41025. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  41026. */
  41027. keysRadiusIncr: number[];
  41028. /**
  41029. * Defines the list of key codes associated with the zoom-out action (increase radius)
  41030. */
  41031. keysRadiusDecr: number[];
  41032. /**
  41033. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  41034. */
  41035. keysRadiusModifierAlt: boolean;
  41036. /**
  41037. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  41038. */
  41039. keysRadiusModifierCtrl: boolean;
  41040. /**
  41041. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  41042. */
  41043. keysRadiusModifierShift: boolean;
  41044. /**
  41045. * Defines the rate of change of heightOffset.
  41046. */
  41047. heightSensibility: number;
  41048. /**
  41049. * Defines the rate of change of rotationOffset.
  41050. */
  41051. rotationSensibility: number;
  41052. /**
  41053. * Defines the rate of change of radius.
  41054. */
  41055. radiusSensibility: number;
  41056. private _keys;
  41057. private _ctrlPressed;
  41058. private _altPressed;
  41059. private _shiftPressed;
  41060. private _onCanvasBlurObserver;
  41061. private _onKeyboardObserver;
  41062. private _engine;
  41063. private _scene;
  41064. /**
  41065. * Attach the input controls to a specific dom element to get the input from.
  41066. * @param element Defines the element the controls should be listened from
  41067. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41068. */
  41069. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41070. /**
  41071. * Detach the current controls from the specified dom element.
  41072. * @param element Defines the element to stop listening the inputs from
  41073. */
  41074. detachControl(element: Nullable<HTMLElement>): void;
  41075. /**
  41076. * Update the current camera state depending on the inputs that have been used this frame.
  41077. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41078. */
  41079. checkInputs(): void;
  41080. /**
  41081. * Gets the class name of the current input.
  41082. * @returns the class name
  41083. */
  41084. getClassName(): string;
  41085. /**
  41086. * Get the friendly name associated with the input class.
  41087. * @returns the input friendly name
  41088. */
  41089. getSimpleName(): string;
  41090. /**
  41091. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41092. * allow modification of the heightOffset value.
  41093. */
  41094. private _modifierHeightOffset;
  41095. /**
  41096. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41097. * allow modification of the rotationOffset value.
  41098. */
  41099. private _modifierRotationOffset;
  41100. /**
  41101. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41102. * allow modification of the radius value.
  41103. */
  41104. private _modifierRadius;
  41105. }
  41106. }
  41107. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  41108. import { Nullable } from "babylonjs/types";
  41109. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41110. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41111. import { Observable } from "babylonjs/Misc/observable";
  41112. module "babylonjs/Cameras/freeCameraInputsManager" {
  41113. interface FreeCameraInputsManager {
  41114. /**
  41115. * @hidden
  41116. */
  41117. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  41118. /**
  41119. * Add orientation input support to the input manager.
  41120. * @returns the current input manager
  41121. */
  41122. addDeviceOrientation(): FreeCameraInputsManager;
  41123. }
  41124. }
  41125. /**
  41126. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  41127. * Screen rotation is taken into account.
  41128. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41129. */
  41130. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  41131. private _camera;
  41132. private _screenOrientationAngle;
  41133. private _constantTranform;
  41134. private _screenQuaternion;
  41135. private _alpha;
  41136. private _beta;
  41137. private _gamma;
  41138. /**
  41139. * Can be used to detect if a device orientation sensor is available on a device
  41140. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  41141. * @returns a promise that will resolve on orientation change
  41142. */
  41143. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  41144. /**
  41145. * @hidden
  41146. */
  41147. _onDeviceOrientationChangedObservable: Observable<void>;
  41148. /**
  41149. * Instantiates a new input
  41150. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41151. */
  41152. constructor();
  41153. /**
  41154. * Define the camera controlled by the input.
  41155. */
  41156. camera: FreeCamera;
  41157. /**
  41158. * Attach the input controls to a specific dom element to get the input from.
  41159. * @param element Defines the element the controls should be listened from
  41160. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41161. */
  41162. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41163. private _orientationChanged;
  41164. private _deviceOrientation;
  41165. /**
  41166. * Detach the current controls from the specified dom element.
  41167. * @param element Defines the element to stop listening the inputs from
  41168. */
  41169. detachControl(element: Nullable<HTMLElement>): void;
  41170. /**
  41171. * Update the current camera state depending on the inputs that have been used this frame.
  41172. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41173. */
  41174. checkInputs(): void;
  41175. /**
  41176. * Gets the class name of the current intput.
  41177. * @returns the class name
  41178. */
  41179. getClassName(): string;
  41180. /**
  41181. * Get the friendly name associated with the input class.
  41182. * @returns the input friendly name
  41183. */
  41184. getSimpleName(): string;
  41185. }
  41186. }
  41187. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  41188. import { Nullable } from "babylonjs/types";
  41189. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41190. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41191. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41192. /**
  41193. * Manage the gamepad inputs to control a free camera.
  41194. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41195. */
  41196. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41197. /**
  41198. * Define the camera the input is attached to.
  41199. */
  41200. camera: FreeCamera;
  41201. /**
  41202. * Define the Gamepad controlling the input
  41203. */
  41204. gamepad: Nullable<Gamepad>;
  41205. /**
  41206. * Defines the gamepad rotation sensiblity.
  41207. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41208. */
  41209. gamepadAngularSensibility: number;
  41210. /**
  41211. * Defines the gamepad move sensiblity.
  41212. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41213. */
  41214. gamepadMoveSensibility: number;
  41215. private _yAxisScale;
  41216. /**
  41217. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41218. */
  41219. invertYAxis: boolean;
  41220. private _onGamepadConnectedObserver;
  41221. private _onGamepadDisconnectedObserver;
  41222. private _cameraTransform;
  41223. private _deltaTransform;
  41224. private _vector3;
  41225. private _vector2;
  41226. /**
  41227. * Attach the input controls to a specific dom element to get the input from.
  41228. * @param element Defines the element the controls should be listened from
  41229. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41230. */
  41231. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41232. /**
  41233. * Detach the current controls from the specified dom element.
  41234. * @param element Defines the element to stop listening the inputs from
  41235. */
  41236. detachControl(element: Nullable<HTMLElement>): void;
  41237. /**
  41238. * Update the current camera state depending on the inputs that have been used this frame.
  41239. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41240. */
  41241. checkInputs(): void;
  41242. /**
  41243. * Gets the class name of the current intput.
  41244. * @returns the class name
  41245. */
  41246. getClassName(): string;
  41247. /**
  41248. * Get the friendly name associated with the input class.
  41249. * @returns the input friendly name
  41250. */
  41251. getSimpleName(): string;
  41252. }
  41253. }
  41254. declare module "babylonjs/Misc/virtualJoystick" {
  41255. import { Nullable } from "babylonjs/types";
  41256. import { Vector3 } from "babylonjs/Maths/math.vector";
  41257. /**
  41258. * Defines the potential axis of a Joystick
  41259. */
  41260. export enum JoystickAxis {
  41261. /** X axis */
  41262. X = 0,
  41263. /** Y axis */
  41264. Y = 1,
  41265. /** Z axis */
  41266. Z = 2
  41267. }
  41268. /**
  41269. * Class used to define virtual joystick (used in touch mode)
  41270. */
  41271. export class VirtualJoystick {
  41272. /**
  41273. * Gets or sets a boolean indicating that left and right values must be inverted
  41274. */
  41275. reverseLeftRight: boolean;
  41276. /**
  41277. * Gets or sets a boolean indicating that up and down values must be inverted
  41278. */
  41279. reverseUpDown: boolean;
  41280. /**
  41281. * Gets the offset value for the position (ie. the change of the position value)
  41282. */
  41283. deltaPosition: Vector3;
  41284. /**
  41285. * Gets a boolean indicating if the virtual joystick was pressed
  41286. */
  41287. pressed: boolean;
  41288. /**
  41289. * Canvas the virtual joystick will render onto, default z-index of this is 5
  41290. */
  41291. static Canvas: Nullable<HTMLCanvasElement>;
  41292. private static _globalJoystickIndex;
  41293. private static vjCanvasContext;
  41294. private static vjCanvasWidth;
  41295. private static vjCanvasHeight;
  41296. private static halfWidth;
  41297. private _action;
  41298. private _axisTargetedByLeftAndRight;
  41299. private _axisTargetedByUpAndDown;
  41300. private _joystickSensibility;
  41301. private _inversedSensibility;
  41302. private _joystickPointerID;
  41303. private _joystickColor;
  41304. private _joystickPointerPos;
  41305. private _joystickPreviousPointerPos;
  41306. private _joystickPointerStartPos;
  41307. private _deltaJoystickVector;
  41308. private _leftJoystick;
  41309. private _touches;
  41310. private _onPointerDownHandlerRef;
  41311. private _onPointerMoveHandlerRef;
  41312. private _onPointerUpHandlerRef;
  41313. private _onResize;
  41314. /**
  41315. * Creates a new virtual joystick
  41316. * @param leftJoystick defines that the joystick is for left hand (false by default)
  41317. */
  41318. constructor(leftJoystick?: boolean);
  41319. /**
  41320. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  41321. * @param newJoystickSensibility defines the new sensibility
  41322. */
  41323. setJoystickSensibility(newJoystickSensibility: number): void;
  41324. private _onPointerDown;
  41325. private _onPointerMove;
  41326. private _onPointerUp;
  41327. /**
  41328. * Change the color of the virtual joystick
  41329. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  41330. */
  41331. setJoystickColor(newColor: string): void;
  41332. /**
  41333. * Defines a callback to call when the joystick is touched
  41334. * @param action defines the callback
  41335. */
  41336. setActionOnTouch(action: () => any): void;
  41337. /**
  41338. * Defines which axis you'd like to control for left & right
  41339. * @param axis defines the axis to use
  41340. */
  41341. setAxisForLeftRight(axis: JoystickAxis): void;
  41342. /**
  41343. * Defines which axis you'd like to control for up & down
  41344. * @param axis defines the axis to use
  41345. */
  41346. setAxisForUpDown(axis: JoystickAxis): void;
  41347. private _drawVirtualJoystick;
  41348. /**
  41349. * Release internal HTML canvas
  41350. */
  41351. releaseCanvas(): void;
  41352. }
  41353. }
  41354. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  41355. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  41356. import { Nullable } from "babylonjs/types";
  41357. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41358. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41359. module "babylonjs/Cameras/freeCameraInputsManager" {
  41360. interface FreeCameraInputsManager {
  41361. /**
  41362. * Add virtual joystick input support to the input manager.
  41363. * @returns the current input manager
  41364. */
  41365. addVirtualJoystick(): FreeCameraInputsManager;
  41366. }
  41367. }
  41368. /**
  41369. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  41370. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41371. */
  41372. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  41373. /**
  41374. * Defines the camera the input is attached to.
  41375. */
  41376. camera: FreeCamera;
  41377. private _leftjoystick;
  41378. private _rightjoystick;
  41379. /**
  41380. * Gets the left stick of the virtual joystick.
  41381. * @returns The virtual Joystick
  41382. */
  41383. getLeftJoystick(): VirtualJoystick;
  41384. /**
  41385. * Gets the right stick of the virtual joystick.
  41386. * @returns The virtual Joystick
  41387. */
  41388. getRightJoystick(): VirtualJoystick;
  41389. /**
  41390. * Update the current camera state depending on the inputs that have been used this frame.
  41391. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41392. */
  41393. checkInputs(): void;
  41394. /**
  41395. * Attach the input controls to a specific dom element to get the input from.
  41396. * @param element Defines the element the controls should be listened from
  41397. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41398. */
  41399. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41400. /**
  41401. * Detach the current controls from the specified dom element.
  41402. * @param element Defines the element to stop listening the inputs from
  41403. */
  41404. detachControl(element: Nullable<HTMLElement>): void;
  41405. /**
  41406. * Gets the class name of the current intput.
  41407. * @returns the class name
  41408. */
  41409. getClassName(): string;
  41410. /**
  41411. * Get the friendly name associated with the input class.
  41412. * @returns the input friendly name
  41413. */
  41414. getSimpleName(): string;
  41415. }
  41416. }
  41417. declare module "babylonjs/Cameras/Inputs/index" {
  41418. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  41419. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  41420. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  41421. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  41422. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  41423. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  41424. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  41425. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  41426. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  41427. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  41428. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  41429. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  41430. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  41431. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  41432. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  41433. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  41434. }
  41435. declare module "babylonjs/Cameras/touchCamera" {
  41436. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41437. import { Scene } from "babylonjs/scene";
  41438. import { Vector3 } from "babylonjs/Maths/math.vector";
  41439. /**
  41440. * This represents a FPS type of camera controlled by touch.
  41441. * This is like a universal camera minus the Gamepad controls.
  41442. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41443. */
  41444. export class TouchCamera extends FreeCamera {
  41445. /**
  41446. * Defines the touch sensibility for rotation.
  41447. * The higher the faster.
  41448. */
  41449. touchAngularSensibility: number;
  41450. /**
  41451. * Defines the touch sensibility for move.
  41452. * The higher the faster.
  41453. */
  41454. touchMoveSensibility: number;
  41455. /**
  41456. * Instantiates a new touch camera.
  41457. * This represents a FPS type of camera controlled by touch.
  41458. * This is like a universal camera minus the Gamepad controls.
  41459. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41460. * @param name Define the name of the camera in the scene
  41461. * @param position Define the start position of the camera in the scene
  41462. * @param scene Define the scene the camera belongs to
  41463. */
  41464. constructor(name: string, position: Vector3, scene: Scene);
  41465. /**
  41466. * Gets the current object class name.
  41467. * @return the class name
  41468. */
  41469. getClassName(): string;
  41470. /** @hidden */
  41471. _setupInputs(): void;
  41472. }
  41473. }
  41474. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  41475. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41476. import { Scene } from "babylonjs/scene";
  41477. import { Vector3 } from "babylonjs/Maths/math.vector";
  41478. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  41479. import { Axis } from "babylonjs/Maths/math.axis";
  41480. /**
  41481. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  41482. * being tilted forward or back and left or right.
  41483. */
  41484. export class DeviceOrientationCamera extends FreeCamera {
  41485. private _initialQuaternion;
  41486. private _quaternionCache;
  41487. private _tmpDragQuaternion;
  41488. private _disablePointerInputWhenUsingDeviceOrientation;
  41489. /**
  41490. * Creates a new device orientation camera
  41491. * @param name The name of the camera
  41492. * @param position The start position camera
  41493. * @param scene The scene the camera belongs to
  41494. */
  41495. constructor(name: string, position: Vector3, scene: Scene);
  41496. /**
  41497. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  41498. */
  41499. disablePointerInputWhenUsingDeviceOrientation: boolean;
  41500. private _dragFactor;
  41501. /**
  41502. * Enabled turning on the y axis when the orientation sensor is active
  41503. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  41504. */
  41505. enableHorizontalDragging(dragFactor?: number): void;
  41506. /**
  41507. * Gets the current instance class name ("DeviceOrientationCamera").
  41508. * This helps avoiding instanceof at run time.
  41509. * @returns the class name
  41510. */
  41511. getClassName(): string;
  41512. /**
  41513. * @hidden
  41514. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  41515. */
  41516. _checkInputs(): void;
  41517. /**
  41518. * Reset the camera to its default orientation on the specified axis only.
  41519. * @param axis The axis to reset
  41520. */
  41521. resetToCurrentRotation(axis?: Axis): void;
  41522. }
  41523. }
  41524. declare module "babylonjs/Gamepads/xboxGamepad" {
  41525. import { Observable } from "babylonjs/Misc/observable";
  41526. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41527. /**
  41528. * Defines supported buttons for XBox360 compatible gamepads
  41529. */
  41530. export enum Xbox360Button {
  41531. /** A */
  41532. A = 0,
  41533. /** B */
  41534. B = 1,
  41535. /** X */
  41536. X = 2,
  41537. /** Y */
  41538. Y = 3,
  41539. /** Start */
  41540. Start = 4,
  41541. /** Back */
  41542. Back = 5,
  41543. /** Left button */
  41544. LB = 6,
  41545. /** Right button */
  41546. RB = 7,
  41547. /** Left stick */
  41548. LeftStick = 8,
  41549. /** Right stick */
  41550. RightStick = 9
  41551. }
  41552. /** Defines values for XBox360 DPad */
  41553. export enum Xbox360Dpad {
  41554. /** Up */
  41555. Up = 0,
  41556. /** Down */
  41557. Down = 1,
  41558. /** Left */
  41559. Left = 2,
  41560. /** Right */
  41561. Right = 3
  41562. }
  41563. /**
  41564. * Defines a XBox360 gamepad
  41565. */
  41566. export class Xbox360Pad extends Gamepad {
  41567. private _leftTrigger;
  41568. private _rightTrigger;
  41569. private _onlefttriggerchanged;
  41570. private _onrighttriggerchanged;
  41571. private _onbuttondown;
  41572. private _onbuttonup;
  41573. private _ondpaddown;
  41574. private _ondpadup;
  41575. /** Observable raised when a button is pressed */
  41576. onButtonDownObservable: Observable<Xbox360Button>;
  41577. /** Observable raised when a button is released */
  41578. onButtonUpObservable: Observable<Xbox360Button>;
  41579. /** Observable raised when a pad is pressed */
  41580. onPadDownObservable: Observable<Xbox360Dpad>;
  41581. /** Observable raised when a pad is released */
  41582. onPadUpObservable: Observable<Xbox360Dpad>;
  41583. private _buttonA;
  41584. private _buttonB;
  41585. private _buttonX;
  41586. private _buttonY;
  41587. private _buttonBack;
  41588. private _buttonStart;
  41589. private _buttonLB;
  41590. private _buttonRB;
  41591. private _buttonLeftStick;
  41592. private _buttonRightStick;
  41593. private _dPadUp;
  41594. private _dPadDown;
  41595. private _dPadLeft;
  41596. private _dPadRight;
  41597. private _isXboxOnePad;
  41598. /**
  41599. * Creates a new XBox360 gamepad object
  41600. * @param id defines the id of this gamepad
  41601. * @param index defines its index
  41602. * @param gamepad defines the internal HTML gamepad object
  41603. * @param xboxOne defines if it is a XBox One gamepad
  41604. */
  41605. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  41606. /**
  41607. * Defines the callback to call when left trigger is pressed
  41608. * @param callback defines the callback to use
  41609. */
  41610. onlefttriggerchanged(callback: (value: number) => void): void;
  41611. /**
  41612. * Defines the callback to call when right trigger is pressed
  41613. * @param callback defines the callback to use
  41614. */
  41615. onrighttriggerchanged(callback: (value: number) => void): void;
  41616. /**
  41617. * Gets the left trigger value
  41618. */
  41619. /**
  41620. * Sets the left trigger value
  41621. */
  41622. leftTrigger: number;
  41623. /**
  41624. * Gets the right trigger value
  41625. */
  41626. /**
  41627. * Sets the right trigger value
  41628. */
  41629. rightTrigger: number;
  41630. /**
  41631. * Defines the callback to call when a button is pressed
  41632. * @param callback defines the callback to use
  41633. */
  41634. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  41635. /**
  41636. * Defines the callback to call when a button is released
  41637. * @param callback defines the callback to use
  41638. */
  41639. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  41640. /**
  41641. * Defines the callback to call when a pad is pressed
  41642. * @param callback defines the callback to use
  41643. */
  41644. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  41645. /**
  41646. * Defines the callback to call when a pad is released
  41647. * @param callback defines the callback to use
  41648. */
  41649. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  41650. private _setButtonValue;
  41651. private _setDPadValue;
  41652. /**
  41653. * Gets the value of the `A` button
  41654. */
  41655. /**
  41656. * Sets the value of the `A` button
  41657. */
  41658. buttonA: number;
  41659. /**
  41660. * Gets the value of the `B` button
  41661. */
  41662. /**
  41663. * Sets the value of the `B` button
  41664. */
  41665. buttonB: number;
  41666. /**
  41667. * Gets the value of the `X` button
  41668. */
  41669. /**
  41670. * Sets the value of the `X` button
  41671. */
  41672. buttonX: number;
  41673. /**
  41674. * Gets the value of the `Y` button
  41675. */
  41676. /**
  41677. * Sets the value of the `Y` button
  41678. */
  41679. buttonY: number;
  41680. /**
  41681. * Gets the value of the `Start` button
  41682. */
  41683. /**
  41684. * Sets the value of the `Start` button
  41685. */
  41686. buttonStart: number;
  41687. /**
  41688. * Gets the value of the `Back` button
  41689. */
  41690. /**
  41691. * Sets the value of the `Back` button
  41692. */
  41693. buttonBack: number;
  41694. /**
  41695. * Gets the value of the `Left` button
  41696. */
  41697. /**
  41698. * Sets the value of the `Left` button
  41699. */
  41700. buttonLB: number;
  41701. /**
  41702. * Gets the value of the `Right` button
  41703. */
  41704. /**
  41705. * Sets the value of the `Right` button
  41706. */
  41707. buttonRB: number;
  41708. /**
  41709. * Gets the value of the Left joystick
  41710. */
  41711. /**
  41712. * Sets the value of the Left joystick
  41713. */
  41714. buttonLeftStick: number;
  41715. /**
  41716. * Gets the value of the Right joystick
  41717. */
  41718. /**
  41719. * Sets the value of the Right joystick
  41720. */
  41721. buttonRightStick: number;
  41722. /**
  41723. * Gets the value of D-pad up
  41724. */
  41725. /**
  41726. * Sets the value of D-pad up
  41727. */
  41728. dPadUp: number;
  41729. /**
  41730. * Gets the value of D-pad down
  41731. */
  41732. /**
  41733. * Sets the value of D-pad down
  41734. */
  41735. dPadDown: number;
  41736. /**
  41737. * Gets the value of D-pad left
  41738. */
  41739. /**
  41740. * Sets the value of D-pad left
  41741. */
  41742. dPadLeft: number;
  41743. /**
  41744. * Gets the value of D-pad right
  41745. */
  41746. /**
  41747. * Sets the value of D-pad right
  41748. */
  41749. dPadRight: number;
  41750. /**
  41751. * Force the gamepad to synchronize with device values
  41752. */
  41753. update(): void;
  41754. /**
  41755. * Disposes the gamepad
  41756. */
  41757. dispose(): void;
  41758. }
  41759. }
  41760. declare module "babylonjs/Gamepads/dualShockGamepad" {
  41761. import { Observable } from "babylonjs/Misc/observable";
  41762. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41763. /**
  41764. * Defines supported buttons for DualShock compatible gamepads
  41765. */
  41766. export enum DualShockButton {
  41767. /** Cross */
  41768. Cross = 0,
  41769. /** Circle */
  41770. Circle = 1,
  41771. /** Square */
  41772. Square = 2,
  41773. /** Triangle */
  41774. Triangle = 3,
  41775. /** Options */
  41776. Options = 4,
  41777. /** Share */
  41778. Share = 5,
  41779. /** L1 */
  41780. L1 = 6,
  41781. /** R1 */
  41782. R1 = 7,
  41783. /** Left stick */
  41784. LeftStick = 8,
  41785. /** Right stick */
  41786. RightStick = 9
  41787. }
  41788. /** Defines values for DualShock DPad */
  41789. export enum DualShockDpad {
  41790. /** Up */
  41791. Up = 0,
  41792. /** Down */
  41793. Down = 1,
  41794. /** Left */
  41795. Left = 2,
  41796. /** Right */
  41797. Right = 3
  41798. }
  41799. /**
  41800. * Defines a DualShock gamepad
  41801. */
  41802. export class DualShockPad extends Gamepad {
  41803. private _leftTrigger;
  41804. private _rightTrigger;
  41805. private _onlefttriggerchanged;
  41806. private _onrighttriggerchanged;
  41807. private _onbuttondown;
  41808. private _onbuttonup;
  41809. private _ondpaddown;
  41810. private _ondpadup;
  41811. /** Observable raised when a button is pressed */
  41812. onButtonDownObservable: Observable<DualShockButton>;
  41813. /** Observable raised when a button is released */
  41814. onButtonUpObservable: Observable<DualShockButton>;
  41815. /** Observable raised when a pad is pressed */
  41816. onPadDownObservable: Observable<DualShockDpad>;
  41817. /** Observable raised when a pad is released */
  41818. onPadUpObservable: Observable<DualShockDpad>;
  41819. private _buttonCross;
  41820. private _buttonCircle;
  41821. private _buttonSquare;
  41822. private _buttonTriangle;
  41823. private _buttonShare;
  41824. private _buttonOptions;
  41825. private _buttonL1;
  41826. private _buttonR1;
  41827. private _buttonLeftStick;
  41828. private _buttonRightStick;
  41829. private _dPadUp;
  41830. private _dPadDown;
  41831. private _dPadLeft;
  41832. private _dPadRight;
  41833. /**
  41834. * Creates a new DualShock gamepad object
  41835. * @param id defines the id of this gamepad
  41836. * @param index defines its index
  41837. * @param gamepad defines the internal HTML gamepad object
  41838. */
  41839. constructor(id: string, index: number, gamepad: any);
  41840. /**
  41841. * Defines the callback to call when left trigger is pressed
  41842. * @param callback defines the callback to use
  41843. */
  41844. onlefttriggerchanged(callback: (value: number) => void): void;
  41845. /**
  41846. * Defines the callback to call when right trigger is pressed
  41847. * @param callback defines the callback to use
  41848. */
  41849. onrighttriggerchanged(callback: (value: number) => void): void;
  41850. /**
  41851. * Gets the left trigger value
  41852. */
  41853. /**
  41854. * Sets the left trigger value
  41855. */
  41856. leftTrigger: number;
  41857. /**
  41858. * Gets the right trigger value
  41859. */
  41860. /**
  41861. * Sets the right trigger value
  41862. */
  41863. rightTrigger: number;
  41864. /**
  41865. * Defines the callback to call when a button is pressed
  41866. * @param callback defines the callback to use
  41867. */
  41868. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  41869. /**
  41870. * Defines the callback to call when a button is released
  41871. * @param callback defines the callback to use
  41872. */
  41873. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  41874. /**
  41875. * Defines the callback to call when a pad is pressed
  41876. * @param callback defines the callback to use
  41877. */
  41878. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  41879. /**
  41880. * Defines the callback to call when a pad is released
  41881. * @param callback defines the callback to use
  41882. */
  41883. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  41884. private _setButtonValue;
  41885. private _setDPadValue;
  41886. /**
  41887. * Gets the value of the `Cross` button
  41888. */
  41889. /**
  41890. * Sets the value of the `Cross` button
  41891. */
  41892. buttonCross: number;
  41893. /**
  41894. * Gets the value of the `Circle` button
  41895. */
  41896. /**
  41897. * Sets the value of the `Circle` button
  41898. */
  41899. buttonCircle: number;
  41900. /**
  41901. * Gets the value of the `Square` button
  41902. */
  41903. /**
  41904. * Sets the value of the `Square` button
  41905. */
  41906. buttonSquare: number;
  41907. /**
  41908. * Gets the value of the `Triangle` button
  41909. */
  41910. /**
  41911. * Sets the value of the `Triangle` button
  41912. */
  41913. buttonTriangle: number;
  41914. /**
  41915. * Gets the value of the `Options` button
  41916. */
  41917. /**
  41918. * Sets the value of the `Options` button
  41919. */
  41920. buttonOptions: number;
  41921. /**
  41922. * Gets the value of the `Share` button
  41923. */
  41924. /**
  41925. * Sets the value of the `Share` button
  41926. */
  41927. buttonShare: number;
  41928. /**
  41929. * Gets the value of the `L1` button
  41930. */
  41931. /**
  41932. * Sets the value of the `L1` button
  41933. */
  41934. buttonL1: number;
  41935. /**
  41936. * Gets the value of the `R1` button
  41937. */
  41938. /**
  41939. * Sets the value of the `R1` button
  41940. */
  41941. buttonR1: number;
  41942. /**
  41943. * Gets the value of the Left joystick
  41944. */
  41945. /**
  41946. * Sets the value of the Left joystick
  41947. */
  41948. buttonLeftStick: number;
  41949. /**
  41950. * Gets the value of the Right joystick
  41951. */
  41952. /**
  41953. * Sets the value of the Right joystick
  41954. */
  41955. buttonRightStick: number;
  41956. /**
  41957. * Gets the value of D-pad up
  41958. */
  41959. /**
  41960. * Sets the value of D-pad up
  41961. */
  41962. dPadUp: number;
  41963. /**
  41964. * Gets the value of D-pad down
  41965. */
  41966. /**
  41967. * Sets the value of D-pad down
  41968. */
  41969. dPadDown: number;
  41970. /**
  41971. * Gets the value of D-pad left
  41972. */
  41973. /**
  41974. * Sets the value of D-pad left
  41975. */
  41976. dPadLeft: number;
  41977. /**
  41978. * Gets the value of D-pad right
  41979. */
  41980. /**
  41981. * Sets the value of D-pad right
  41982. */
  41983. dPadRight: number;
  41984. /**
  41985. * Force the gamepad to synchronize with device values
  41986. */
  41987. update(): void;
  41988. /**
  41989. * Disposes the gamepad
  41990. */
  41991. dispose(): void;
  41992. }
  41993. }
  41994. declare module "babylonjs/Gamepads/gamepadManager" {
  41995. import { Observable } from "babylonjs/Misc/observable";
  41996. import { Nullable } from "babylonjs/types";
  41997. import { Scene } from "babylonjs/scene";
  41998. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41999. /**
  42000. * Manager for handling gamepads
  42001. */
  42002. export class GamepadManager {
  42003. private _scene?;
  42004. private _babylonGamepads;
  42005. private _oneGamepadConnected;
  42006. /** @hidden */
  42007. _isMonitoring: boolean;
  42008. private _gamepadEventSupported;
  42009. private _gamepadSupport;
  42010. /**
  42011. * observable to be triggered when the gamepad controller has been connected
  42012. */
  42013. onGamepadConnectedObservable: Observable<Gamepad>;
  42014. /**
  42015. * observable to be triggered when the gamepad controller has been disconnected
  42016. */
  42017. onGamepadDisconnectedObservable: Observable<Gamepad>;
  42018. private _onGamepadConnectedEvent;
  42019. private _onGamepadDisconnectedEvent;
  42020. /**
  42021. * Initializes the gamepad manager
  42022. * @param _scene BabylonJS scene
  42023. */
  42024. constructor(_scene?: Scene | undefined);
  42025. /**
  42026. * The gamepads in the game pad manager
  42027. */
  42028. readonly gamepads: Gamepad[];
  42029. /**
  42030. * Get the gamepad controllers based on type
  42031. * @param type The type of gamepad controller
  42032. * @returns Nullable gamepad
  42033. */
  42034. getGamepadByType(type?: number): Nullable<Gamepad>;
  42035. /**
  42036. * Disposes the gamepad manager
  42037. */
  42038. dispose(): void;
  42039. private _addNewGamepad;
  42040. private _startMonitoringGamepads;
  42041. private _stopMonitoringGamepads;
  42042. /** @hidden */
  42043. _checkGamepadsStatus(): void;
  42044. private _updateGamepadObjects;
  42045. }
  42046. }
  42047. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  42048. import { Nullable } from "babylonjs/types";
  42049. import { Scene } from "babylonjs/scene";
  42050. import { ISceneComponent } from "babylonjs/sceneComponent";
  42051. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  42052. module "babylonjs/scene" {
  42053. interface Scene {
  42054. /** @hidden */
  42055. _gamepadManager: Nullable<GamepadManager>;
  42056. /**
  42057. * Gets the gamepad manager associated with the scene
  42058. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  42059. */
  42060. gamepadManager: GamepadManager;
  42061. }
  42062. }
  42063. module "babylonjs/Cameras/freeCameraInputsManager" {
  42064. /**
  42065. * Interface representing a free camera inputs manager
  42066. */
  42067. interface FreeCameraInputsManager {
  42068. /**
  42069. * Adds gamepad input support to the FreeCameraInputsManager.
  42070. * @returns the FreeCameraInputsManager
  42071. */
  42072. addGamepad(): FreeCameraInputsManager;
  42073. }
  42074. }
  42075. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  42076. /**
  42077. * Interface representing an arc rotate camera inputs manager
  42078. */
  42079. interface ArcRotateCameraInputsManager {
  42080. /**
  42081. * Adds gamepad input support to the ArcRotateCamera InputManager.
  42082. * @returns the camera inputs manager
  42083. */
  42084. addGamepad(): ArcRotateCameraInputsManager;
  42085. }
  42086. }
  42087. /**
  42088. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  42089. */
  42090. export class GamepadSystemSceneComponent implements ISceneComponent {
  42091. /**
  42092. * The component name helpfull to identify the component in the list of scene components.
  42093. */
  42094. readonly name: string;
  42095. /**
  42096. * The scene the component belongs to.
  42097. */
  42098. scene: Scene;
  42099. /**
  42100. * Creates a new instance of the component for the given scene
  42101. * @param scene Defines the scene to register the component in
  42102. */
  42103. constructor(scene: Scene);
  42104. /**
  42105. * Registers the component in a given scene
  42106. */
  42107. register(): void;
  42108. /**
  42109. * Rebuilds the elements related to this component in case of
  42110. * context lost for instance.
  42111. */
  42112. rebuild(): void;
  42113. /**
  42114. * Disposes the component and the associated ressources
  42115. */
  42116. dispose(): void;
  42117. private _beforeCameraUpdate;
  42118. }
  42119. }
  42120. declare module "babylonjs/Cameras/universalCamera" {
  42121. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  42122. import { Scene } from "babylonjs/scene";
  42123. import { Vector3 } from "babylonjs/Maths/math.vector";
  42124. import "babylonjs/Gamepads/gamepadSceneComponent";
  42125. /**
  42126. * 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,
  42127. * which still works and will still be found in many Playgrounds.
  42128. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42129. */
  42130. export class UniversalCamera extends TouchCamera {
  42131. /**
  42132. * Defines the gamepad rotation sensiblity.
  42133. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42134. */
  42135. gamepadAngularSensibility: number;
  42136. /**
  42137. * Defines the gamepad move sensiblity.
  42138. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42139. */
  42140. gamepadMoveSensibility: number;
  42141. /**
  42142. * 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,
  42143. * which still works and will still be found in many Playgrounds.
  42144. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42145. * @param name Define the name of the camera in the scene
  42146. * @param position Define the start position of the camera in the scene
  42147. * @param scene Define the scene the camera belongs to
  42148. */
  42149. constructor(name: string, position: Vector3, scene: Scene);
  42150. /**
  42151. * Gets the current object class name.
  42152. * @return the class name
  42153. */
  42154. getClassName(): string;
  42155. }
  42156. }
  42157. declare module "babylonjs/Cameras/gamepadCamera" {
  42158. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42159. import { Scene } from "babylonjs/scene";
  42160. import { Vector3 } from "babylonjs/Maths/math.vector";
  42161. /**
  42162. * This represents a FPS type of camera. This is only here for back compat purpose.
  42163. * Please use the UniversalCamera instead as both are identical.
  42164. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42165. */
  42166. export class GamepadCamera extends UniversalCamera {
  42167. /**
  42168. * Instantiates a new Gamepad Camera
  42169. * This represents a FPS type of camera. This is only here for back compat purpose.
  42170. * Please use the UniversalCamera instead as both are identical.
  42171. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42172. * @param name Define the name of the camera in the scene
  42173. * @param position Define the start position of the camera in the scene
  42174. * @param scene Define the scene the camera belongs to
  42175. */
  42176. constructor(name: string, position: Vector3, scene: Scene);
  42177. /**
  42178. * Gets the current object class name.
  42179. * @return the class name
  42180. */
  42181. getClassName(): string;
  42182. }
  42183. }
  42184. declare module "babylonjs/Shaders/pass.fragment" {
  42185. /** @hidden */
  42186. export var passPixelShader: {
  42187. name: string;
  42188. shader: string;
  42189. };
  42190. }
  42191. declare module "babylonjs/Shaders/passCube.fragment" {
  42192. /** @hidden */
  42193. export var passCubePixelShader: {
  42194. name: string;
  42195. shader: string;
  42196. };
  42197. }
  42198. declare module "babylonjs/PostProcesses/passPostProcess" {
  42199. import { Nullable } from "babylonjs/types";
  42200. import { Camera } from "babylonjs/Cameras/camera";
  42201. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42202. import { Engine } from "babylonjs/Engines/engine";
  42203. import "babylonjs/Shaders/pass.fragment";
  42204. import "babylonjs/Shaders/passCube.fragment";
  42205. /**
  42206. * PassPostProcess which produces an output the same as it's input
  42207. */
  42208. export class PassPostProcess extends PostProcess {
  42209. /**
  42210. * Creates the PassPostProcess
  42211. * @param name The name of the effect.
  42212. * @param options The required width/height ratio to downsize to before computing the render pass.
  42213. * @param camera The camera to apply the render pass to.
  42214. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42215. * @param engine The engine which the post process will be applied. (default: current engine)
  42216. * @param reusable If the post process can be reused on the same frame. (default: false)
  42217. * @param textureType The type of texture to be used when performing the post processing.
  42218. * @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)
  42219. */
  42220. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42221. }
  42222. /**
  42223. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  42224. */
  42225. export class PassCubePostProcess extends PostProcess {
  42226. private _face;
  42227. /**
  42228. * Gets or sets the cube face to display.
  42229. * * 0 is +X
  42230. * * 1 is -X
  42231. * * 2 is +Y
  42232. * * 3 is -Y
  42233. * * 4 is +Z
  42234. * * 5 is -Z
  42235. */
  42236. face: number;
  42237. /**
  42238. * Creates the PassCubePostProcess
  42239. * @param name The name of the effect.
  42240. * @param options The required width/height ratio to downsize to before computing the render pass.
  42241. * @param camera The camera to apply the render pass to.
  42242. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42243. * @param engine The engine which the post process will be applied. (default: current engine)
  42244. * @param reusable If the post process can be reused on the same frame. (default: false)
  42245. * @param textureType The type of texture to be used when performing the post processing.
  42246. * @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)
  42247. */
  42248. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42249. }
  42250. }
  42251. declare module "babylonjs/Shaders/anaglyph.fragment" {
  42252. /** @hidden */
  42253. export var anaglyphPixelShader: {
  42254. name: string;
  42255. shader: string;
  42256. };
  42257. }
  42258. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  42259. import { Engine } from "babylonjs/Engines/engine";
  42260. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42261. import { Camera } from "babylonjs/Cameras/camera";
  42262. import "babylonjs/Shaders/anaglyph.fragment";
  42263. /**
  42264. * Postprocess used to generate anaglyphic rendering
  42265. */
  42266. export class AnaglyphPostProcess extends PostProcess {
  42267. private _passedProcess;
  42268. /**
  42269. * Creates a new AnaglyphPostProcess
  42270. * @param name defines postprocess name
  42271. * @param options defines creation options or target ratio scale
  42272. * @param rigCameras defines cameras using this postprocess
  42273. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  42274. * @param engine defines hosting engine
  42275. * @param reusable defines if the postprocess will be reused multiple times per frame
  42276. */
  42277. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  42278. }
  42279. }
  42280. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  42281. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  42282. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42283. import { Scene } from "babylonjs/scene";
  42284. import { Vector3 } from "babylonjs/Maths/math.vector";
  42285. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42286. /**
  42287. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  42288. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42289. */
  42290. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  42291. /**
  42292. * Creates a new AnaglyphArcRotateCamera
  42293. * @param name defines camera name
  42294. * @param alpha defines alpha angle (in radians)
  42295. * @param beta defines beta angle (in radians)
  42296. * @param radius defines radius
  42297. * @param target defines camera target
  42298. * @param interaxialDistance defines distance between each color axis
  42299. * @param scene defines the hosting scene
  42300. */
  42301. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  42302. /**
  42303. * Gets camera class name
  42304. * @returns AnaglyphArcRotateCamera
  42305. */
  42306. getClassName(): string;
  42307. }
  42308. }
  42309. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  42310. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42311. import { Scene } from "babylonjs/scene";
  42312. import { Vector3 } from "babylonjs/Maths/math.vector";
  42313. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42314. /**
  42315. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  42316. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42317. */
  42318. export class AnaglyphFreeCamera extends FreeCamera {
  42319. /**
  42320. * Creates a new AnaglyphFreeCamera
  42321. * @param name defines camera name
  42322. * @param position defines initial position
  42323. * @param interaxialDistance defines distance between each color axis
  42324. * @param scene defines the hosting scene
  42325. */
  42326. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42327. /**
  42328. * Gets camera class name
  42329. * @returns AnaglyphFreeCamera
  42330. */
  42331. getClassName(): string;
  42332. }
  42333. }
  42334. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  42335. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  42336. import { Scene } from "babylonjs/scene";
  42337. import { Vector3 } from "babylonjs/Maths/math.vector";
  42338. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42339. /**
  42340. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  42341. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42342. */
  42343. export class AnaglyphGamepadCamera extends GamepadCamera {
  42344. /**
  42345. * Creates a new AnaglyphGamepadCamera
  42346. * @param name defines camera name
  42347. * @param position defines initial position
  42348. * @param interaxialDistance defines distance between each color axis
  42349. * @param scene defines the hosting scene
  42350. */
  42351. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42352. /**
  42353. * Gets camera class name
  42354. * @returns AnaglyphGamepadCamera
  42355. */
  42356. getClassName(): string;
  42357. }
  42358. }
  42359. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  42360. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42361. import { Scene } from "babylonjs/scene";
  42362. import { Vector3 } from "babylonjs/Maths/math.vector";
  42363. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42364. /**
  42365. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  42366. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42367. */
  42368. export class AnaglyphUniversalCamera extends UniversalCamera {
  42369. /**
  42370. * Creates a new AnaglyphUniversalCamera
  42371. * @param name defines camera name
  42372. * @param position defines initial position
  42373. * @param interaxialDistance defines distance between each color axis
  42374. * @param scene defines the hosting scene
  42375. */
  42376. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42377. /**
  42378. * Gets camera class name
  42379. * @returns AnaglyphUniversalCamera
  42380. */
  42381. getClassName(): string;
  42382. }
  42383. }
  42384. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  42385. /** @hidden */
  42386. export var stereoscopicInterlacePixelShader: {
  42387. name: string;
  42388. shader: string;
  42389. };
  42390. }
  42391. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  42392. import { Camera } from "babylonjs/Cameras/camera";
  42393. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  42394. import { Engine } from "babylonjs/Engines/engine";
  42395. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  42396. /**
  42397. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  42398. */
  42399. export class StereoscopicInterlacePostProcess extends PostProcess {
  42400. private _stepSize;
  42401. private _passedProcess;
  42402. /**
  42403. * Initializes a StereoscopicInterlacePostProcess
  42404. * @param name The name of the effect.
  42405. * @param rigCameras The rig cameras to be appled to the post process
  42406. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  42407. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42408. * @param engine The engine which the post process will be applied. (default: current engine)
  42409. * @param reusable If the post process can be reused on the same frame. (default: false)
  42410. */
  42411. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  42412. }
  42413. }
  42414. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  42415. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  42416. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42417. import { Scene } from "babylonjs/scene";
  42418. import { Vector3 } from "babylonjs/Maths/math.vector";
  42419. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42420. /**
  42421. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  42422. * @see http://doc.babylonjs.com/features/cameras
  42423. */
  42424. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  42425. /**
  42426. * Creates a new StereoscopicArcRotateCamera
  42427. * @param name defines camera name
  42428. * @param alpha defines alpha angle (in radians)
  42429. * @param beta defines beta angle (in radians)
  42430. * @param radius defines radius
  42431. * @param target defines camera target
  42432. * @param interaxialDistance defines distance between each color axis
  42433. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42434. * @param scene defines the hosting scene
  42435. */
  42436. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42437. /**
  42438. * Gets camera class name
  42439. * @returns StereoscopicArcRotateCamera
  42440. */
  42441. getClassName(): string;
  42442. }
  42443. }
  42444. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  42445. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42446. import { Scene } from "babylonjs/scene";
  42447. import { Vector3 } from "babylonjs/Maths/math.vector";
  42448. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42449. /**
  42450. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  42451. * @see http://doc.babylonjs.com/features/cameras
  42452. */
  42453. export class StereoscopicFreeCamera extends FreeCamera {
  42454. /**
  42455. * Creates a new StereoscopicFreeCamera
  42456. * @param name defines camera name
  42457. * @param position defines initial position
  42458. * @param interaxialDistance defines distance between each color axis
  42459. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42460. * @param scene defines the hosting scene
  42461. */
  42462. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42463. /**
  42464. * Gets camera class name
  42465. * @returns StereoscopicFreeCamera
  42466. */
  42467. getClassName(): string;
  42468. }
  42469. }
  42470. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  42471. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  42472. import { Scene } from "babylonjs/scene";
  42473. import { Vector3 } from "babylonjs/Maths/math.vector";
  42474. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42475. /**
  42476. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  42477. * @see http://doc.babylonjs.com/features/cameras
  42478. */
  42479. export class StereoscopicGamepadCamera extends GamepadCamera {
  42480. /**
  42481. * Creates a new StereoscopicGamepadCamera
  42482. * @param name defines camera name
  42483. * @param position defines initial position
  42484. * @param interaxialDistance defines distance between each color axis
  42485. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42486. * @param scene defines the hosting scene
  42487. */
  42488. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42489. /**
  42490. * Gets camera class name
  42491. * @returns StereoscopicGamepadCamera
  42492. */
  42493. getClassName(): string;
  42494. }
  42495. }
  42496. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  42497. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42498. import { Scene } from "babylonjs/scene";
  42499. import { Vector3 } from "babylonjs/Maths/math.vector";
  42500. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42501. /**
  42502. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  42503. * @see http://doc.babylonjs.com/features/cameras
  42504. */
  42505. export class StereoscopicUniversalCamera extends UniversalCamera {
  42506. /**
  42507. * Creates a new StereoscopicUniversalCamera
  42508. * @param name defines camera name
  42509. * @param position defines initial position
  42510. * @param interaxialDistance defines distance between each color axis
  42511. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42512. * @param scene defines the hosting scene
  42513. */
  42514. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42515. /**
  42516. * Gets camera class name
  42517. * @returns StereoscopicUniversalCamera
  42518. */
  42519. getClassName(): string;
  42520. }
  42521. }
  42522. declare module "babylonjs/Cameras/Stereoscopic/index" {
  42523. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  42524. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  42525. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  42526. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  42527. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  42528. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  42529. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  42530. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  42531. }
  42532. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  42533. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42534. import { Scene } from "babylonjs/scene";
  42535. import { Vector3 } from "babylonjs/Maths/math.vector";
  42536. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  42537. /**
  42538. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  42539. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  42540. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  42541. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  42542. */
  42543. export class VirtualJoysticksCamera extends FreeCamera {
  42544. /**
  42545. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  42546. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  42547. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  42548. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  42549. * @param name Define the name of the camera in the scene
  42550. * @param position Define the start position of the camera in the scene
  42551. * @param scene Define the scene the camera belongs to
  42552. */
  42553. constructor(name: string, position: Vector3, scene: Scene);
  42554. /**
  42555. * Gets the current object class name.
  42556. * @return the class name
  42557. */
  42558. getClassName(): string;
  42559. }
  42560. }
  42561. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  42562. import { Matrix } from "babylonjs/Maths/math.vector";
  42563. /**
  42564. * This represents all the required metrics to create a VR camera.
  42565. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  42566. */
  42567. export class VRCameraMetrics {
  42568. /**
  42569. * Define the horizontal resolution off the screen.
  42570. */
  42571. hResolution: number;
  42572. /**
  42573. * Define the vertical resolution off the screen.
  42574. */
  42575. vResolution: number;
  42576. /**
  42577. * Define the horizontal screen size.
  42578. */
  42579. hScreenSize: number;
  42580. /**
  42581. * Define the vertical screen size.
  42582. */
  42583. vScreenSize: number;
  42584. /**
  42585. * Define the vertical screen center position.
  42586. */
  42587. vScreenCenter: number;
  42588. /**
  42589. * Define the distance of the eyes to the screen.
  42590. */
  42591. eyeToScreenDistance: number;
  42592. /**
  42593. * Define the distance between both lenses
  42594. */
  42595. lensSeparationDistance: number;
  42596. /**
  42597. * Define the distance between both viewer's eyes.
  42598. */
  42599. interpupillaryDistance: number;
  42600. /**
  42601. * Define the distortion factor of the VR postprocess.
  42602. * Please, touch with care.
  42603. */
  42604. distortionK: number[];
  42605. /**
  42606. * Define the chromatic aberration correction factors for the VR post process.
  42607. */
  42608. chromaAbCorrection: number[];
  42609. /**
  42610. * Define the scale factor of the post process.
  42611. * The smaller the better but the slower.
  42612. */
  42613. postProcessScaleFactor: number;
  42614. /**
  42615. * Define an offset for the lens center.
  42616. */
  42617. lensCenterOffset: number;
  42618. /**
  42619. * Define if the current vr camera should compensate the distortion of the lense or not.
  42620. */
  42621. compensateDistortion: boolean;
  42622. /**
  42623. * Defines if multiview should be enabled when rendering (Default: false)
  42624. */
  42625. multiviewEnabled: boolean;
  42626. /**
  42627. * Gets the rendering aspect ratio based on the provided resolutions.
  42628. */
  42629. readonly aspectRatio: number;
  42630. /**
  42631. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  42632. */
  42633. readonly aspectRatioFov: number;
  42634. /**
  42635. * @hidden
  42636. */
  42637. readonly leftHMatrix: Matrix;
  42638. /**
  42639. * @hidden
  42640. */
  42641. readonly rightHMatrix: Matrix;
  42642. /**
  42643. * @hidden
  42644. */
  42645. readonly leftPreViewMatrix: Matrix;
  42646. /**
  42647. * @hidden
  42648. */
  42649. readonly rightPreViewMatrix: Matrix;
  42650. /**
  42651. * Get the default VRMetrics based on the most generic setup.
  42652. * @returns the default vr metrics
  42653. */
  42654. static GetDefault(): VRCameraMetrics;
  42655. }
  42656. }
  42657. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  42658. /** @hidden */
  42659. export var vrDistortionCorrectionPixelShader: {
  42660. name: string;
  42661. shader: string;
  42662. };
  42663. }
  42664. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  42665. import { Camera } from "babylonjs/Cameras/camera";
  42666. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42667. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  42668. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  42669. /**
  42670. * VRDistortionCorrectionPostProcess used for mobile VR
  42671. */
  42672. export class VRDistortionCorrectionPostProcess extends PostProcess {
  42673. private _isRightEye;
  42674. private _distortionFactors;
  42675. private _postProcessScaleFactor;
  42676. private _lensCenterOffset;
  42677. private _scaleIn;
  42678. private _scaleFactor;
  42679. private _lensCenter;
  42680. /**
  42681. * Initializes the VRDistortionCorrectionPostProcess
  42682. * @param name The name of the effect.
  42683. * @param camera The camera to apply the render pass to.
  42684. * @param isRightEye If this is for the right eye distortion
  42685. * @param vrMetrics All the required metrics for the VR camera
  42686. */
  42687. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  42688. }
  42689. }
  42690. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  42691. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  42692. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42693. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42694. import { Scene } from "babylonjs/scene";
  42695. import { Vector3 } from "babylonjs/Maths/math.vector";
  42696. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  42697. import "babylonjs/Cameras/RigModes/vrRigMode";
  42698. /**
  42699. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  42700. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42701. */
  42702. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  42703. /**
  42704. * Creates a new VRDeviceOrientationArcRotateCamera
  42705. * @param name defines camera name
  42706. * @param alpha defines the camera rotation along the logitudinal axis
  42707. * @param beta defines the camera rotation along the latitudinal axis
  42708. * @param radius defines the camera distance from its target
  42709. * @param target defines the camera target
  42710. * @param scene defines the scene the camera belongs to
  42711. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42712. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42713. */
  42714. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42715. /**
  42716. * Gets camera class name
  42717. * @returns VRDeviceOrientationArcRotateCamera
  42718. */
  42719. getClassName(): string;
  42720. }
  42721. }
  42722. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  42723. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  42724. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42725. import { Scene } from "babylonjs/scene";
  42726. import { Vector3 } from "babylonjs/Maths/math.vector";
  42727. import "babylonjs/Cameras/RigModes/vrRigMode";
  42728. /**
  42729. * Camera used to simulate VR rendering (based on FreeCamera)
  42730. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42731. */
  42732. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  42733. /**
  42734. * Creates a new VRDeviceOrientationFreeCamera
  42735. * @param name defines camera name
  42736. * @param position defines the start position of the camera
  42737. * @param scene defines the scene the camera belongs to
  42738. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42739. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42740. */
  42741. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42742. /**
  42743. * Gets camera class name
  42744. * @returns VRDeviceOrientationFreeCamera
  42745. */
  42746. getClassName(): string;
  42747. }
  42748. }
  42749. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  42750. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42751. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42752. import { Scene } from "babylonjs/scene";
  42753. import { Vector3 } from "babylonjs/Maths/math.vector";
  42754. import "babylonjs/Gamepads/gamepadSceneComponent";
  42755. /**
  42756. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  42757. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42758. */
  42759. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  42760. /**
  42761. * Creates a new VRDeviceOrientationGamepadCamera
  42762. * @param name defines camera name
  42763. * @param position defines the start position of the camera
  42764. * @param scene defines the scene the camera belongs to
  42765. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42766. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42767. */
  42768. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42769. /**
  42770. * Gets camera class name
  42771. * @returns VRDeviceOrientationGamepadCamera
  42772. */
  42773. getClassName(): string;
  42774. }
  42775. }
  42776. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  42777. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  42778. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  42779. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  42780. /** @hidden */
  42781. export var imageProcessingPixelShader: {
  42782. name: string;
  42783. shader: string;
  42784. };
  42785. }
  42786. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  42787. import { Nullable } from "babylonjs/types";
  42788. import { Color4 } from "babylonjs/Maths/math.color";
  42789. import { Camera } from "babylonjs/Cameras/camera";
  42790. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42791. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  42792. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  42793. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42794. import { Engine } from "babylonjs/Engines/engine";
  42795. import "babylonjs/Shaders/imageProcessing.fragment";
  42796. import "babylonjs/Shaders/postprocess.vertex";
  42797. /**
  42798. * ImageProcessingPostProcess
  42799. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42800. */
  42801. export class ImageProcessingPostProcess extends PostProcess {
  42802. /**
  42803. * Default configuration related to image processing available in the PBR Material.
  42804. */
  42805. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42806. /**
  42807. * Gets the image processing configuration used either in this material.
  42808. */
  42809. /**
  42810. * Sets the Default image processing configuration used either in the this material.
  42811. *
  42812. * If sets to null, the scene one is in use.
  42813. */
  42814. imageProcessingConfiguration: ImageProcessingConfiguration;
  42815. /**
  42816. * Keep track of the image processing observer to allow dispose and replace.
  42817. */
  42818. private _imageProcessingObserver;
  42819. /**
  42820. * Attaches a new image processing configuration to the PBR Material.
  42821. * @param configuration
  42822. */
  42823. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42824. /**
  42825. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42826. */
  42827. /**
  42828. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42829. */
  42830. colorCurves: Nullable<ColorCurves>;
  42831. /**
  42832. * Gets wether the color curves effect is enabled.
  42833. */
  42834. /**
  42835. * Sets wether the color curves effect is enabled.
  42836. */
  42837. colorCurvesEnabled: boolean;
  42838. /**
  42839. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42840. */
  42841. /**
  42842. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42843. */
  42844. colorGradingTexture: Nullable<BaseTexture>;
  42845. /**
  42846. * Gets wether the color grading effect is enabled.
  42847. */
  42848. /**
  42849. * Gets wether the color grading effect is enabled.
  42850. */
  42851. colorGradingEnabled: boolean;
  42852. /**
  42853. * Gets exposure used in the effect.
  42854. */
  42855. /**
  42856. * Sets exposure used in the effect.
  42857. */
  42858. exposure: number;
  42859. /**
  42860. * Gets wether tonemapping is enabled or not.
  42861. */
  42862. /**
  42863. * Sets wether tonemapping is enabled or not
  42864. */
  42865. toneMappingEnabled: boolean;
  42866. /**
  42867. * Gets the type of tone mapping effect.
  42868. */
  42869. /**
  42870. * Sets the type of tone mapping effect.
  42871. */
  42872. toneMappingType: number;
  42873. /**
  42874. * Gets contrast used in the effect.
  42875. */
  42876. /**
  42877. * Sets contrast used in the effect.
  42878. */
  42879. contrast: number;
  42880. /**
  42881. * Gets Vignette stretch size.
  42882. */
  42883. /**
  42884. * Sets Vignette stretch size.
  42885. */
  42886. vignetteStretch: number;
  42887. /**
  42888. * Gets Vignette centre X Offset.
  42889. */
  42890. /**
  42891. * Sets Vignette centre X Offset.
  42892. */
  42893. vignetteCentreX: number;
  42894. /**
  42895. * Gets Vignette centre Y Offset.
  42896. */
  42897. /**
  42898. * Sets Vignette centre Y Offset.
  42899. */
  42900. vignetteCentreY: number;
  42901. /**
  42902. * Gets Vignette weight or intensity of the vignette effect.
  42903. */
  42904. /**
  42905. * Sets Vignette weight or intensity of the vignette effect.
  42906. */
  42907. vignetteWeight: number;
  42908. /**
  42909. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42910. * if vignetteEnabled is set to true.
  42911. */
  42912. /**
  42913. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42914. * if vignetteEnabled is set to true.
  42915. */
  42916. vignetteColor: Color4;
  42917. /**
  42918. * Gets Camera field of view used by the Vignette effect.
  42919. */
  42920. /**
  42921. * Sets Camera field of view used by the Vignette effect.
  42922. */
  42923. vignetteCameraFov: number;
  42924. /**
  42925. * Gets the vignette blend mode allowing different kind of effect.
  42926. */
  42927. /**
  42928. * Sets the vignette blend mode allowing different kind of effect.
  42929. */
  42930. vignetteBlendMode: number;
  42931. /**
  42932. * Gets wether the vignette effect is enabled.
  42933. */
  42934. /**
  42935. * Sets wether the vignette effect is enabled.
  42936. */
  42937. vignetteEnabled: boolean;
  42938. private _fromLinearSpace;
  42939. /**
  42940. * Gets wether the input of the processing is in Gamma or Linear Space.
  42941. */
  42942. /**
  42943. * Sets wether the input of the processing is in Gamma or Linear Space.
  42944. */
  42945. fromLinearSpace: boolean;
  42946. /**
  42947. * Defines cache preventing GC.
  42948. */
  42949. private _defines;
  42950. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42951. /**
  42952. * "ImageProcessingPostProcess"
  42953. * @returns "ImageProcessingPostProcess"
  42954. */
  42955. getClassName(): string;
  42956. protected _updateParameters(): void;
  42957. dispose(camera?: Camera): void;
  42958. }
  42959. }
  42960. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  42961. import { Scene } from "babylonjs/scene";
  42962. import { Color3 } from "babylonjs/Maths/math.color";
  42963. import { Mesh } from "babylonjs/Meshes/mesh";
  42964. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  42965. import { Nullable } from "babylonjs/types";
  42966. /**
  42967. * Class containing static functions to help procedurally build meshes
  42968. */
  42969. export class GroundBuilder {
  42970. /**
  42971. * Creates a ground mesh
  42972. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42973. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42974. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42975. * @param name defines the name of the mesh
  42976. * @param options defines the options used to create the mesh
  42977. * @param scene defines the hosting scene
  42978. * @returns the ground mesh
  42979. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42980. */
  42981. static CreateGround(name: string, options: {
  42982. width?: number;
  42983. height?: number;
  42984. subdivisions?: number;
  42985. subdivisionsX?: number;
  42986. subdivisionsY?: number;
  42987. updatable?: boolean;
  42988. }, scene: any): Mesh;
  42989. /**
  42990. * Creates a tiled ground mesh
  42991. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42992. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42993. * * 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
  42994. * * 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
  42995. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42996. * @param name defines the name of the mesh
  42997. * @param options defines the options used to create the mesh
  42998. * @param scene defines the hosting scene
  42999. * @returns the tiled ground mesh
  43000. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  43001. */
  43002. static CreateTiledGround(name: string, options: {
  43003. xmin: number;
  43004. zmin: number;
  43005. xmax: number;
  43006. zmax: number;
  43007. subdivisions?: {
  43008. w: number;
  43009. h: number;
  43010. };
  43011. precision?: {
  43012. w: number;
  43013. h: number;
  43014. };
  43015. updatable?: boolean;
  43016. }, scene?: Nullable<Scene>): Mesh;
  43017. /**
  43018. * Creates a ground mesh from a height map
  43019. * * The parameter `url` sets the URL of the height map image resource.
  43020. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  43021. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  43022. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  43023. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  43024. * * 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.
  43025. * * 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).
  43026. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  43027. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43028. * @param name defines the name of the mesh
  43029. * @param url defines the url to the height map
  43030. * @param options defines the options used to create the mesh
  43031. * @param scene defines the hosting scene
  43032. * @returns the ground mesh
  43033. * @see https://doc.babylonjs.com/babylon101/height_map
  43034. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  43035. */
  43036. static CreateGroundFromHeightMap(name: string, url: string, options: {
  43037. width?: number;
  43038. height?: number;
  43039. subdivisions?: number;
  43040. minHeight?: number;
  43041. maxHeight?: number;
  43042. colorFilter?: Color3;
  43043. alphaFilter?: number;
  43044. updatable?: boolean;
  43045. onReady?: (mesh: GroundMesh) => void;
  43046. }, scene?: Nullable<Scene>): GroundMesh;
  43047. }
  43048. }
  43049. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  43050. import { Vector4 } from "babylonjs/Maths/math.vector";
  43051. import { Mesh } from "babylonjs/Meshes/mesh";
  43052. /**
  43053. * Class containing static functions to help procedurally build meshes
  43054. */
  43055. export class TorusBuilder {
  43056. /**
  43057. * Creates a torus mesh
  43058. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  43059. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  43060. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  43061. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43062. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43063. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43064. * @param name defines the name of the mesh
  43065. * @param options defines the options used to create the mesh
  43066. * @param scene defines the hosting scene
  43067. * @returns the torus mesh
  43068. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  43069. */
  43070. static CreateTorus(name: string, options: {
  43071. diameter?: number;
  43072. thickness?: number;
  43073. tessellation?: number;
  43074. updatable?: boolean;
  43075. sideOrientation?: number;
  43076. frontUVs?: Vector4;
  43077. backUVs?: Vector4;
  43078. }, scene: any): Mesh;
  43079. }
  43080. }
  43081. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  43082. import { Vector4 } from "babylonjs/Maths/math.vector";
  43083. import { Color4 } from "babylonjs/Maths/math.color";
  43084. import { Mesh } from "babylonjs/Meshes/mesh";
  43085. /**
  43086. * Class containing static functions to help procedurally build meshes
  43087. */
  43088. export class CylinderBuilder {
  43089. /**
  43090. * Creates a cylinder or a cone mesh
  43091. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  43092. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  43093. * * 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.
  43094. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  43095. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  43096. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  43097. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  43098. * * 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).
  43099. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  43100. * * 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).
  43101. * * 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
  43102. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  43103. * * 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
  43104. * * 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.
  43105. * * If `enclose` is false, a ring surface is one element.
  43106. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  43107. * * 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
  43108. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43109. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43110. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43111. * @param name defines the name of the mesh
  43112. * @param options defines the options used to create the mesh
  43113. * @param scene defines the hosting scene
  43114. * @returns the cylinder mesh
  43115. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  43116. */
  43117. static CreateCylinder(name: string, options: {
  43118. height?: number;
  43119. diameterTop?: number;
  43120. diameterBottom?: number;
  43121. diameter?: number;
  43122. tessellation?: number;
  43123. subdivisions?: number;
  43124. arc?: number;
  43125. faceColors?: Color4[];
  43126. faceUV?: Vector4[];
  43127. updatable?: boolean;
  43128. hasRings?: boolean;
  43129. enclose?: boolean;
  43130. cap?: number;
  43131. sideOrientation?: number;
  43132. frontUVs?: Vector4;
  43133. backUVs?: Vector4;
  43134. }, scene: any): Mesh;
  43135. }
  43136. }
  43137. declare module "babylonjs/Cameras/XR/webXRTypes" {
  43138. import { Nullable } from "babylonjs/types";
  43139. import { IDisposable } from "babylonjs/scene";
  43140. /**
  43141. * States of the webXR experience
  43142. */
  43143. export enum WebXRState {
  43144. /**
  43145. * Transitioning to being in XR mode
  43146. */
  43147. ENTERING_XR = 0,
  43148. /**
  43149. * Transitioning to non XR mode
  43150. */
  43151. EXITING_XR = 1,
  43152. /**
  43153. * In XR mode and presenting
  43154. */
  43155. IN_XR = 2,
  43156. /**
  43157. * Not entered XR mode
  43158. */
  43159. NOT_IN_XR = 3
  43160. }
  43161. /**
  43162. * Abstraction of the XR render target
  43163. */
  43164. export interface WebXRRenderTarget extends IDisposable {
  43165. /**
  43166. * xrpresent context of the canvas which can be used to display/mirror xr content
  43167. */
  43168. canvasContext: WebGLRenderingContext;
  43169. /**
  43170. * xr layer for the canvas
  43171. */
  43172. xrLayer: Nullable<XRWebGLLayer>;
  43173. /**
  43174. * Initializes the xr layer for the session
  43175. * @param xrSession xr session
  43176. * @returns a promise that will resolve once the XR Layer has been created
  43177. */
  43178. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  43179. }
  43180. }
  43181. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  43182. import { Nullable } from "babylonjs/types";
  43183. import { Observable } from "babylonjs/Misc/observable";
  43184. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  43185. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43186. /**
  43187. * COnfiguration object for WebXR output canvas
  43188. */
  43189. export class WebXRManagedOutputCanvasOptions {
  43190. /**
  43191. * Options for this XR Layer output
  43192. */
  43193. canvasOptions: XRWebGLLayerOptions;
  43194. /**
  43195. * CSS styling for a newly created canvas (if not provided)
  43196. */
  43197. newCanvasCssStyle?: string;
  43198. /**
  43199. * Get the default values of the configuration object
  43200. * @returns default values of this configuration object
  43201. */
  43202. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  43203. }
  43204. /**
  43205. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  43206. */
  43207. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  43208. private configuration;
  43209. private _engine;
  43210. private _canvas;
  43211. /**
  43212. * xrpresent context of the canvas which can be used to display/mirror xr content
  43213. */
  43214. canvasContext: WebGLRenderingContext;
  43215. /**
  43216. * xr layer for the canvas
  43217. */
  43218. xrLayer: Nullable<XRWebGLLayer>;
  43219. /**
  43220. * Initializes the xr layer for the session
  43221. * @param xrSession xr session
  43222. * @returns a promise that will resolve once the XR Layer has been created
  43223. */
  43224. initializeXRLayerAsync(xrSession: any): any;
  43225. /**
  43226. * Initializes the canvas to be added/removed upon entering/exiting xr
  43227. * @param engine the Babylon engine
  43228. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  43229. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  43230. * @param configuration optional configuration for this canvas output. defaults will be used if not provided
  43231. */
  43232. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>, configuration?: WebXRManagedOutputCanvasOptions);
  43233. /**
  43234. * Disposes of the object
  43235. */
  43236. dispose(): void;
  43237. private _setManagedOutputCanvas;
  43238. private _addCanvas;
  43239. private _removeCanvas;
  43240. }
  43241. }
  43242. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  43243. import { Observable } from "babylonjs/Misc/observable";
  43244. import { Nullable } from "babylonjs/types";
  43245. import { IDisposable, Scene } from "babylonjs/scene";
  43246. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43247. import { WebXRRenderTarget, WebXRState } from "babylonjs/Cameras/XR/webXRTypes";
  43248. import { WebXRManagedOutputCanvasOptions } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43249. /**
  43250. * Manages an XRSession to work with Babylon's engine
  43251. * @see https://doc.babylonjs.com/how_to/webxr
  43252. */
  43253. export class WebXRSessionManager implements IDisposable {
  43254. /** The scene which the session should be created for */
  43255. scene: Scene;
  43256. /**
  43257. * Fires every time a new xrFrame arrives which can be used to update the camera
  43258. */
  43259. onXRFrameObservable: Observable<XRFrame>;
  43260. /**
  43261. * Fires when the xr session is ended either by the device or manually done
  43262. */
  43263. onXRSessionEnded: Observable<any>;
  43264. /**
  43265. * Fires when the xr session is ended either by the device or manually done
  43266. */
  43267. onXRSessionInit: Observable<XRSession>;
  43268. /**
  43269. * Underlying xr session
  43270. */
  43271. session: XRSession;
  43272. /**
  43273. * Type of reference space used when creating the session
  43274. */
  43275. referenceSpace: XRReferenceSpace;
  43276. /**
  43277. * Current XR frame
  43278. */
  43279. currentFrame: Nullable<XRFrame>;
  43280. private _xrNavigator;
  43281. private baseLayer;
  43282. private _rttProvider;
  43283. private _sessionEnded;
  43284. /**
  43285. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  43286. * @param scene The scene which the session should be created for
  43287. */
  43288. constructor(
  43289. /** The scene which the session should be created for */
  43290. scene: Scene);
  43291. /**
  43292. * Initializes the manager
  43293. * After initialization enterXR can be called to start an XR session
  43294. * @returns Promise which resolves after it is initialized
  43295. */
  43296. initializeAsync(): Promise<void>;
  43297. /**
  43298. * Initializes an xr session
  43299. * @param xrSessionMode mode to initialize
  43300. * @param optionalFeatures defines optional values to pass to the session builder
  43301. * @returns a promise which will resolve once the session has been initialized
  43302. */
  43303. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): Promise<XRSession>;
  43304. /**
  43305. * Sets the reference space on the xr session
  43306. * @param referenceSpace space to set
  43307. * @returns a promise that will resolve once the reference space has been set
  43308. */
  43309. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  43310. /**
  43311. * Updates the render state of the session
  43312. * @param state state to set
  43313. * @returns a promise that resolves once the render state has been updated
  43314. */
  43315. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  43316. /**
  43317. * Starts rendering to the xr layer
  43318. * @returns a promise that will resolve once rendering has started
  43319. */
  43320. startRenderingToXRAsync(): Promise<void>;
  43321. /**
  43322. * Gets the correct render target texture to be rendered this frame for this eye
  43323. * @param eye the eye for which to get the render target
  43324. * @returns the render target for the specified eye
  43325. */
  43326. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  43327. /**
  43328. * Stops the xrSession and restores the renderloop
  43329. * @returns Promise which resolves after it exits XR
  43330. */
  43331. exitXRAsync(): Promise<void>;
  43332. /**
  43333. * Checks if a session would be supported for the creation options specified
  43334. * @param sessionMode session mode to check if supported eg. immersive-vr
  43335. * @returns true if supported
  43336. */
  43337. supportsSessionAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43338. /**
  43339. * Creates a WebXRRenderTarget object for the XR session
  43340. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  43341. * @param options optional options to provide when creating a new render target
  43342. * @returns a WebXR render target to which the session can render
  43343. */
  43344. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>, options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  43345. /**
  43346. * @hidden
  43347. * Converts the render layer of xrSession to a render target
  43348. * @param session session to create render target for
  43349. * @param scene scene the new render target should be created for
  43350. * @param baseLayer the webgl layer to create the render target for
  43351. */
  43352. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  43353. /**
  43354. * Disposes of the session manager
  43355. */
  43356. dispose(): void;
  43357. /**
  43358. * Gets a promise returning true when fullfiled if the given session mode is supported
  43359. * @param sessionMode defines the session to test
  43360. * @returns a promise
  43361. */
  43362. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43363. }
  43364. }
  43365. declare module "babylonjs/Cameras/XR/webXRCamera" {
  43366. import { Scene } from "babylonjs/scene";
  43367. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43368. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43369. /**
  43370. * WebXR Camera which holds the views for the xrSession
  43371. * @see https://doc.babylonjs.com/how_to/webxr
  43372. */
  43373. export class WebXRCamera extends FreeCamera {
  43374. /**
  43375. * Is the camera in debug mode. Used when using an emulator
  43376. */
  43377. debugMode: boolean;
  43378. /**
  43379. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43380. * @param name the name of the camera
  43381. * @param scene the scene to add the camera to
  43382. */
  43383. constructor(name: string, scene: Scene);
  43384. private _updateNumberOfRigCameras;
  43385. /** @hidden */
  43386. _updateForDualEyeDebugging(): void;
  43387. /**
  43388. * Updates the cameras position from the current pose information of the XR session
  43389. * @param xrSessionManager the session containing pose information
  43390. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  43391. */
  43392. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  43393. }
  43394. }
  43395. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  43396. import { Observable } from "babylonjs/Misc/observable";
  43397. import { IDisposable, Scene } from "babylonjs/scene";
  43398. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  43399. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43400. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43401. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  43402. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43403. /**
  43404. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  43405. * @see https://doc.babylonjs.com/how_to/webxr
  43406. */
  43407. export class WebXRExperienceHelper implements IDisposable {
  43408. private scene;
  43409. /**
  43410. * 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
  43411. */
  43412. container: AbstractMesh;
  43413. /**
  43414. * Camera used to render xr content
  43415. */
  43416. camera: WebXRCamera;
  43417. /**
  43418. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43419. */
  43420. state: WebXRState;
  43421. private _setState;
  43422. private static _TmpVector;
  43423. /**
  43424. * Fires when the state of the experience helper has changed
  43425. */
  43426. onStateChangedObservable: Observable<WebXRState>;
  43427. /** Session manager used to keep track of xr session */
  43428. sessionManager: WebXRSessionManager;
  43429. private _nonVRCamera;
  43430. private _originalSceneAutoClear;
  43431. private _supported;
  43432. /**
  43433. * Creates the experience helper
  43434. * @param scene the scene to attach the experience helper to
  43435. * @returns a promise for the experience helper
  43436. */
  43437. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43438. /**
  43439. * Creates a WebXRExperienceHelper
  43440. * @param scene The scene the helper should be created in
  43441. */
  43442. private constructor();
  43443. /**
  43444. * Exits XR mode and returns the scene to its original state
  43445. * @returns promise that resolves after xr mode has exited
  43446. */
  43447. exitXRAsync(): Promise<void>;
  43448. /**
  43449. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43450. * @param sessionMode options for the XR session
  43451. * @param referenceSpaceType frame of reference of the XR session
  43452. * @param renderTarget the output canvas that will be used to enter XR mode
  43453. * @returns promise that resolves after xr mode has entered
  43454. */
  43455. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): Promise<WebXRSessionManager>;
  43456. /**
  43457. * Updates the global position of the camera by moving the camera's container
  43458. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  43459. * @param position The desired global position of the camera
  43460. */
  43461. setPositionOfCameraUsingContainer(position: Vector3): void;
  43462. /**
  43463. * Rotates the xr camera by rotating the camera's container around the camera's position
  43464. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  43465. * @param rotation the desired quaternion rotation to apply to the camera
  43466. */
  43467. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  43468. /**
  43469. * Disposes of the experience helper
  43470. */
  43471. dispose(): void;
  43472. }
  43473. }
  43474. declare module "babylonjs/Cameras/XR/webXRController" {
  43475. import { Nullable } from "babylonjs/types";
  43476. import { Observable } from "babylonjs/Misc/observable";
  43477. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43478. import { Ray } from "babylonjs/Culling/ray";
  43479. import { Scene } from "babylonjs/scene";
  43480. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43481. /**
  43482. * Represents an XR input
  43483. */
  43484. export class WebXRController {
  43485. private scene;
  43486. /** The underlying input source for the controller */
  43487. inputSource: XRInputSource;
  43488. private parentContainer;
  43489. /**
  43490. * 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
  43491. */
  43492. grip?: AbstractMesh;
  43493. /**
  43494. * Pointer which can be used to select objects or attach a visible laser to
  43495. */
  43496. pointer: AbstractMesh;
  43497. private _gamepadMode;
  43498. /**
  43499. * If available, this is the gamepad object related to this controller.
  43500. * Using this object it is possible to get click events and trackpad changes of the
  43501. * webxr controller that is currently being used.
  43502. */
  43503. gamepadController?: WebVRController;
  43504. /**
  43505. * Event that fires when the controller is removed/disposed
  43506. */
  43507. onDisposeObservable: Observable<{}>;
  43508. private _tmpQuaternion;
  43509. private _tmpVector;
  43510. /**
  43511. * Creates the controller
  43512. * @see https://doc.babylonjs.com/how_to/webxr
  43513. * @param scene the scene which the controller should be associated to
  43514. * @param inputSource the underlying input source for the controller
  43515. * @param parentContainer parent that the controller meshes should be children of
  43516. */
  43517. constructor(scene: Scene,
  43518. /** The underlying input source for the controller */
  43519. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  43520. /**
  43521. * Updates the controller pose based on the given XRFrame
  43522. * @param xrFrame xr frame to update the pose with
  43523. * @param referenceSpace reference space to use
  43524. */
  43525. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  43526. /**
  43527. * Gets a world space ray coming from the controller
  43528. * @param result the resulting ray
  43529. */
  43530. getWorldPointerRayToRef(result: Ray): void;
  43531. /**
  43532. * Get the scene associated with this controller
  43533. * @returns the scene object
  43534. */
  43535. getScene(): Scene;
  43536. /**
  43537. * Disposes of the object
  43538. */
  43539. dispose(): void;
  43540. }
  43541. }
  43542. declare module "babylonjs/Cameras/XR/webXRInput" {
  43543. import { Observable } from "babylonjs/Misc/observable";
  43544. import { IDisposable } from "babylonjs/scene";
  43545. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43546. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  43547. /**
  43548. * XR input used to track XR inputs such as controllers/rays
  43549. */
  43550. export class WebXRInput implements IDisposable {
  43551. /**
  43552. * Base experience the input listens to
  43553. */
  43554. baseExperience: WebXRExperienceHelper;
  43555. /**
  43556. * XR controllers being tracked
  43557. */
  43558. controllers: Array<WebXRController>;
  43559. private _frameObserver;
  43560. private _stateObserver;
  43561. /**
  43562. * Event when a controller has been connected/added
  43563. */
  43564. onControllerAddedObservable: Observable<WebXRController>;
  43565. /**
  43566. * Event when a controller has been removed/disconnected
  43567. */
  43568. onControllerRemovedObservable: Observable<WebXRController>;
  43569. /**
  43570. * Initializes the WebXRInput
  43571. * @param baseExperience experience helper which the input should be created for
  43572. */
  43573. constructor(
  43574. /**
  43575. * Base experience the input listens to
  43576. */
  43577. baseExperience: WebXRExperienceHelper);
  43578. private _onInputSourcesChange;
  43579. private _addAndRemoveControllers;
  43580. /**
  43581. * Disposes of the object
  43582. */
  43583. dispose(): void;
  43584. }
  43585. }
  43586. declare module "babylonjs/Loading/sceneLoader" {
  43587. import { Observable } from "babylonjs/Misc/observable";
  43588. import { Nullable } from "babylonjs/types";
  43589. import { Scene } from "babylonjs/scene";
  43590. import { Engine } from "babylonjs/Engines/engine";
  43591. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43592. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43593. import { AssetContainer } from "babylonjs/assetContainer";
  43594. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43595. import { Skeleton } from "babylonjs/Bones/skeleton";
  43596. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  43597. import { WebRequest } from "babylonjs/Misc/webRequest";
  43598. /**
  43599. * Class used to represent data loading progression
  43600. */
  43601. export class SceneLoaderProgressEvent {
  43602. /** defines if data length to load can be evaluated */
  43603. readonly lengthComputable: boolean;
  43604. /** defines the loaded data length */
  43605. readonly loaded: number;
  43606. /** defines the data length to load */
  43607. readonly total: number;
  43608. /**
  43609. * Create a new progress event
  43610. * @param lengthComputable defines if data length to load can be evaluated
  43611. * @param loaded defines the loaded data length
  43612. * @param total defines the data length to load
  43613. */
  43614. constructor(
  43615. /** defines if data length to load can be evaluated */
  43616. lengthComputable: boolean,
  43617. /** defines the loaded data length */
  43618. loaded: number,
  43619. /** defines the data length to load */
  43620. total: number);
  43621. /**
  43622. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43623. * @param event defines the source event
  43624. * @returns a new SceneLoaderProgressEvent
  43625. */
  43626. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43627. }
  43628. /**
  43629. * Interface used by SceneLoader plugins to define supported file extensions
  43630. */
  43631. export interface ISceneLoaderPluginExtensions {
  43632. /**
  43633. * Defines the list of supported extensions
  43634. */
  43635. [extension: string]: {
  43636. isBinary: boolean;
  43637. };
  43638. }
  43639. /**
  43640. * Interface used by SceneLoader plugin factory
  43641. */
  43642. export interface ISceneLoaderPluginFactory {
  43643. /**
  43644. * Defines the name of the factory
  43645. */
  43646. name: string;
  43647. /**
  43648. * Function called to create a new plugin
  43649. * @return the new plugin
  43650. */
  43651. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43652. /**
  43653. * The callback that returns true if the data can be directly loaded.
  43654. * @param data string containing the file data
  43655. * @returns if the data can be loaded directly
  43656. */
  43657. canDirectLoad?(data: string): boolean;
  43658. }
  43659. /**
  43660. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  43661. */
  43662. export interface ISceneLoaderPluginBase {
  43663. /**
  43664. * The friendly name of this plugin.
  43665. */
  43666. name: string;
  43667. /**
  43668. * The file extensions supported by this plugin.
  43669. */
  43670. extensions: string | ISceneLoaderPluginExtensions;
  43671. /**
  43672. * The callback called when loading from a url.
  43673. * @param scene scene loading this url
  43674. * @param url url to load
  43675. * @param onSuccess callback called when the file successfully loads
  43676. * @param onProgress callback called while file is loading (if the server supports this mode)
  43677. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43678. * @param onError callback called when the file fails to load
  43679. * @returns a file request object
  43680. */
  43681. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43682. /**
  43683. * The callback called when loading from a file object.
  43684. * @param scene scene loading this file
  43685. * @param file defines the file to load
  43686. * @param onSuccess defines the callback to call when data is loaded
  43687. * @param onProgress defines the callback to call during loading process
  43688. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43689. * @param onError defines the callback to call when an error occurs
  43690. * @returns a file request object
  43691. */
  43692. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43693. /**
  43694. * The callback that returns true if the data can be directly loaded.
  43695. * @param data string containing the file data
  43696. * @returns if the data can be loaded directly
  43697. */
  43698. canDirectLoad?(data: string): boolean;
  43699. /**
  43700. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  43701. * @param scene scene loading this data
  43702. * @param data string containing the data
  43703. * @returns data to pass to the plugin
  43704. */
  43705. directLoad?(scene: Scene, data: string): any;
  43706. /**
  43707. * The callback that allows custom handling of the root url based on the response url.
  43708. * @param rootUrl the original root url
  43709. * @param responseURL the response url if available
  43710. * @returns the new root url
  43711. */
  43712. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  43713. }
  43714. /**
  43715. * Interface used to define a SceneLoader plugin
  43716. */
  43717. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  43718. /**
  43719. * Import meshes into a scene.
  43720. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43721. * @param scene The scene to import into
  43722. * @param data The data to import
  43723. * @param rootUrl The root url for scene and resources
  43724. * @param meshes The meshes array to import into
  43725. * @param particleSystems The particle systems array to import into
  43726. * @param skeletons The skeletons array to import into
  43727. * @param onError The callback when import fails
  43728. * @returns True if successful or false otherwise
  43729. */
  43730. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43731. /**
  43732. * Load into a scene.
  43733. * @param scene The scene to load into
  43734. * @param data The data to import
  43735. * @param rootUrl The root url for scene and resources
  43736. * @param onError The callback when import fails
  43737. * @returns True if successful or false otherwise
  43738. */
  43739. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43740. /**
  43741. * Load into an asset container.
  43742. * @param scene The scene to load into
  43743. * @param data The data to import
  43744. * @param rootUrl The root url for scene and resources
  43745. * @param onError The callback when import fails
  43746. * @returns The loaded asset container
  43747. */
  43748. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43749. }
  43750. /**
  43751. * Interface used to define an async SceneLoader plugin
  43752. */
  43753. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  43754. /**
  43755. * Import meshes into a scene.
  43756. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43757. * @param scene The scene to import into
  43758. * @param data The data to import
  43759. * @param rootUrl The root url for scene and resources
  43760. * @param onProgress The callback when the load progresses
  43761. * @param fileName Defines the name of the file to load
  43762. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43763. */
  43764. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43765. meshes: AbstractMesh[];
  43766. particleSystems: IParticleSystem[];
  43767. skeletons: Skeleton[];
  43768. animationGroups: AnimationGroup[];
  43769. }>;
  43770. /**
  43771. * Load into a scene.
  43772. * @param scene The scene to load into
  43773. * @param data The data to import
  43774. * @param rootUrl The root url for scene and resources
  43775. * @param onProgress The callback when the load progresses
  43776. * @param fileName Defines the name of the file to load
  43777. * @returns Nothing
  43778. */
  43779. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43780. /**
  43781. * Load into an asset container.
  43782. * @param scene The scene to load into
  43783. * @param data The data to import
  43784. * @param rootUrl The root url for scene and resources
  43785. * @param onProgress The callback when the load progresses
  43786. * @param fileName Defines the name of the file to load
  43787. * @returns The loaded asset container
  43788. */
  43789. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43790. }
  43791. /**
  43792. * Class used to load scene from various file formats using registered plugins
  43793. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43794. */
  43795. export class SceneLoader {
  43796. /**
  43797. * No logging while loading
  43798. */
  43799. static readonly NO_LOGGING: number;
  43800. /**
  43801. * Minimal logging while loading
  43802. */
  43803. static readonly MINIMAL_LOGGING: number;
  43804. /**
  43805. * Summary logging while loading
  43806. */
  43807. static readonly SUMMARY_LOGGING: number;
  43808. /**
  43809. * Detailled logging while loading
  43810. */
  43811. static readonly DETAILED_LOGGING: number;
  43812. /**
  43813. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43814. */
  43815. static ForceFullSceneLoadingForIncremental: boolean;
  43816. /**
  43817. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43818. */
  43819. static ShowLoadingScreen: boolean;
  43820. /**
  43821. * Defines the current logging level (while loading the scene)
  43822. * @ignorenaming
  43823. */
  43824. static loggingLevel: number;
  43825. /**
  43826. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43827. */
  43828. static CleanBoneMatrixWeights: boolean;
  43829. /**
  43830. * Event raised when a plugin is used to load a scene
  43831. */
  43832. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43833. private static _registeredPlugins;
  43834. private static _getDefaultPlugin;
  43835. private static _getPluginForExtension;
  43836. private static _getPluginForDirectLoad;
  43837. private static _getPluginForFilename;
  43838. private static _getDirectLoad;
  43839. private static _loadData;
  43840. private static _getFileInfo;
  43841. /**
  43842. * Gets a plugin that can load the given extension
  43843. * @param extension defines the extension to load
  43844. * @returns a plugin or null if none works
  43845. */
  43846. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43847. /**
  43848. * Gets a boolean indicating that the given extension can be loaded
  43849. * @param extension defines the extension to load
  43850. * @returns true if the extension is supported
  43851. */
  43852. static IsPluginForExtensionAvailable(extension: string): boolean;
  43853. /**
  43854. * Adds a new plugin to the list of registered plugins
  43855. * @param plugin defines the plugin to add
  43856. */
  43857. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43858. /**
  43859. * Import meshes into a scene
  43860. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43861. * @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)
  43862. * @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)
  43863. * @param scene the instance of BABYLON.Scene to append to
  43864. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43865. * @param onProgress a callback with a progress event for each file being loaded
  43866. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43867. * @param pluginExtension the extension used to determine the plugin
  43868. * @returns The loaded plugin
  43869. */
  43870. 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>;
  43871. /**
  43872. * Import meshes into a scene
  43873. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43874. * @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)
  43875. * @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)
  43876. * @param scene the instance of BABYLON.Scene to append to
  43877. * @param onProgress a callback with a progress event for each file being loaded
  43878. * @param pluginExtension the extension used to determine the plugin
  43879. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43880. */
  43881. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43882. meshes: AbstractMesh[];
  43883. particleSystems: IParticleSystem[];
  43884. skeletons: Skeleton[];
  43885. animationGroups: AnimationGroup[];
  43886. }>;
  43887. /**
  43888. * Load a scene
  43889. * @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)
  43890. * @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)
  43891. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43892. * @param onSuccess a callback with the scene when import succeeds
  43893. * @param onProgress a callback with a progress event for each file being loaded
  43894. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43895. * @param pluginExtension the extension used to determine the plugin
  43896. * @returns The loaded plugin
  43897. */
  43898. 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>;
  43899. /**
  43900. * Load a scene
  43901. * @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)
  43902. * @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)
  43903. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43904. * @param onProgress a callback with a progress event for each file being loaded
  43905. * @param pluginExtension the extension used to determine the plugin
  43906. * @returns The loaded scene
  43907. */
  43908. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43909. /**
  43910. * Append a scene
  43911. * @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)
  43912. * @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)
  43913. * @param scene is the instance of BABYLON.Scene to append to
  43914. * @param onSuccess a callback with the scene when import succeeds
  43915. * @param onProgress a callback with a progress event for each file being loaded
  43916. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43917. * @param pluginExtension the extension used to determine the plugin
  43918. * @returns The loaded plugin
  43919. */
  43920. 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>;
  43921. /**
  43922. * Append a scene
  43923. * @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)
  43924. * @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)
  43925. * @param scene is the instance of BABYLON.Scene to append to
  43926. * @param onProgress a callback with a progress event for each file being loaded
  43927. * @param pluginExtension the extension used to determine the plugin
  43928. * @returns The given scene
  43929. */
  43930. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43931. /**
  43932. * Load a scene into an asset container
  43933. * @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)
  43934. * @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)
  43935. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43936. * @param onSuccess a callback with the scene when import succeeds
  43937. * @param onProgress a callback with a progress event for each file being loaded
  43938. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43939. * @param pluginExtension the extension used to determine the plugin
  43940. * @returns The loaded plugin
  43941. */
  43942. 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>;
  43943. /**
  43944. * Load a scene into an asset container
  43945. * @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)
  43946. * @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)
  43947. * @param scene is the instance of Scene to append to
  43948. * @param onProgress a callback with a progress event for each file being loaded
  43949. * @param pluginExtension the extension used to determine the plugin
  43950. * @returns The loaded asset container
  43951. */
  43952. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43953. }
  43954. }
  43955. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43956. import { Scene } from "babylonjs/scene";
  43957. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43958. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43959. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43960. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43961. /**
  43962. * Generic Controller
  43963. */
  43964. export class GenericController extends WebVRController {
  43965. /**
  43966. * Base Url for the controller model.
  43967. */
  43968. static readonly MODEL_BASE_URL: string;
  43969. /**
  43970. * File name for the controller model.
  43971. */
  43972. static readonly MODEL_FILENAME: string;
  43973. /**
  43974. * Creates a new GenericController from a gamepad
  43975. * @param vrGamepad the gamepad that the controller should be created from
  43976. */
  43977. constructor(vrGamepad: any);
  43978. /**
  43979. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43980. * @param scene scene in which to add meshes
  43981. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43982. */
  43983. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43984. /**
  43985. * Called once for each button that changed state since the last frame
  43986. * @param buttonIdx Which button index changed
  43987. * @param state New state of the button
  43988. * @param changes Which properties on the state changed since last frame
  43989. */
  43990. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43991. }
  43992. }
  43993. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43994. import { Observable } from "babylonjs/Misc/observable";
  43995. import { Scene } from "babylonjs/scene";
  43996. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43997. import { Ray } from "babylonjs/Culling/ray";
  43998. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43999. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44000. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44001. /**
  44002. * Defines the WindowsMotionController object that the state of the windows motion controller
  44003. */
  44004. export class WindowsMotionController extends WebVRController {
  44005. /**
  44006. * The base url used to load the left and right controller models
  44007. */
  44008. static MODEL_BASE_URL: string;
  44009. /**
  44010. * The name of the left controller model file
  44011. */
  44012. static MODEL_LEFT_FILENAME: string;
  44013. /**
  44014. * The name of the right controller model file
  44015. */
  44016. static MODEL_RIGHT_FILENAME: string;
  44017. /**
  44018. * The controller name prefix for this controller type
  44019. */
  44020. static readonly GAMEPAD_ID_PREFIX: string;
  44021. /**
  44022. * The controller id pattern for this controller type
  44023. */
  44024. private static readonly GAMEPAD_ID_PATTERN;
  44025. private _loadedMeshInfo;
  44026. protected readonly _mapping: {
  44027. buttons: string[];
  44028. buttonMeshNames: {
  44029. 'trigger': string;
  44030. 'menu': string;
  44031. 'grip': string;
  44032. 'thumbstick': string;
  44033. 'trackpad': string;
  44034. };
  44035. buttonObservableNames: {
  44036. 'trigger': string;
  44037. 'menu': string;
  44038. 'grip': string;
  44039. 'thumbstick': string;
  44040. 'trackpad': string;
  44041. };
  44042. axisMeshNames: string[];
  44043. pointingPoseMeshName: string;
  44044. };
  44045. /**
  44046. * Fired when the trackpad on this controller is clicked
  44047. */
  44048. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44049. /**
  44050. * Fired when the trackpad on this controller is modified
  44051. */
  44052. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44053. /**
  44054. * The current x and y values of this controller's trackpad
  44055. */
  44056. trackpad: StickValues;
  44057. /**
  44058. * Creates a new WindowsMotionController from a gamepad
  44059. * @param vrGamepad the gamepad that the controller should be created from
  44060. */
  44061. constructor(vrGamepad: any);
  44062. /**
  44063. * Fired when the trigger on this controller is modified
  44064. */
  44065. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44066. /**
  44067. * Fired when the menu button on this controller is modified
  44068. */
  44069. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44070. /**
  44071. * Fired when the grip button on this controller is modified
  44072. */
  44073. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44074. /**
  44075. * Fired when the thumbstick button on this controller is modified
  44076. */
  44077. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44078. /**
  44079. * Fired when the touchpad button on this controller is modified
  44080. */
  44081. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44082. /**
  44083. * Fired when the touchpad values on this controller are modified
  44084. */
  44085. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  44086. protected _updateTrackpad(): void;
  44087. /**
  44088. * Called once per frame by the engine.
  44089. */
  44090. update(): void;
  44091. /**
  44092. * Called once for each button that changed state since the last frame
  44093. * @param buttonIdx Which button index changed
  44094. * @param state New state of the button
  44095. * @param changes Which properties on the state changed since last frame
  44096. */
  44097. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44098. /**
  44099. * Moves the buttons on the controller mesh based on their current state
  44100. * @param buttonName the name of the button to move
  44101. * @param buttonValue the value of the button which determines the buttons new position
  44102. */
  44103. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44104. /**
  44105. * Moves the axis on the controller mesh based on its current state
  44106. * @param axis the index of the axis
  44107. * @param axisValue the value of the axis which determines the meshes new position
  44108. * @hidden
  44109. */
  44110. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44111. /**
  44112. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44113. * @param scene scene in which to add meshes
  44114. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44115. */
  44116. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44117. /**
  44118. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44119. * can be transformed by button presses and axes values, based on this._mapping.
  44120. *
  44121. * @param scene scene in which the meshes exist
  44122. * @param meshes list of meshes that make up the controller model to process
  44123. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44124. */
  44125. private processModel;
  44126. private createMeshInfo;
  44127. /**
  44128. * Gets the ray of the controller in the direction the controller is pointing
  44129. * @param length the length the resulting ray should be
  44130. * @returns a ray in the direction the controller is pointing
  44131. */
  44132. getForwardRay(length?: number): Ray;
  44133. /**
  44134. * Disposes of the controller
  44135. */
  44136. dispose(): void;
  44137. }
  44138. /**
  44139. * This class represents a new windows motion controller in XR.
  44140. */
  44141. export class XRWindowsMotionController extends WindowsMotionController {
  44142. /**
  44143. * Changing the original WIndowsMotionController mapping to fir the new mapping
  44144. */
  44145. protected readonly _mapping: {
  44146. buttons: string[];
  44147. buttonMeshNames: {
  44148. 'trigger': string;
  44149. 'menu': string;
  44150. 'grip': string;
  44151. 'thumbstick': string;
  44152. 'trackpad': string;
  44153. };
  44154. buttonObservableNames: {
  44155. 'trigger': string;
  44156. 'menu': string;
  44157. 'grip': string;
  44158. 'thumbstick': string;
  44159. 'trackpad': string;
  44160. };
  44161. axisMeshNames: string[];
  44162. pointingPoseMeshName: string;
  44163. };
  44164. /**
  44165. * Construct a new XR-Based windows motion controller
  44166. *
  44167. * @param gamepadInfo the gamepad object from the browser
  44168. */
  44169. constructor(gamepadInfo: any);
  44170. /**
  44171. * holds the thumbstick values (X,Y)
  44172. */
  44173. thumbstickValues: StickValues;
  44174. /**
  44175. * Fired when the thumbstick on this controller is clicked
  44176. */
  44177. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  44178. /**
  44179. * Fired when the thumbstick on this controller is modified
  44180. */
  44181. onThumbstickValuesChangedObservable: Observable<StickValues>;
  44182. /**
  44183. * Fired when the touchpad button on this controller is modified
  44184. */
  44185. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44186. /**
  44187. * Fired when the touchpad values on this controller are modified
  44188. */
  44189. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44190. /**
  44191. * Fired when the thumbstick button on this controller is modified
  44192. * here to prevent breaking changes
  44193. */
  44194. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44195. /**
  44196. * updating the thumbstick(!) and not the trackpad.
  44197. * This is named this way due to the difference between WebVR and XR and to avoid
  44198. * changing the parent class.
  44199. */
  44200. protected _updateTrackpad(): void;
  44201. /**
  44202. * Disposes the class with joy
  44203. */
  44204. dispose(): void;
  44205. }
  44206. }
  44207. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  44208. import { Observable } from "babylonjs/Misc/observable";
  44209. import { Scene } from "babylonjs/scene";
  44210. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44211. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44212. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44213. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44214. /**
  44215. * Oculus Touch Controller
  44216. */
  44217. export class OculusTouchController extends WebVRController {
  44218. /**
  44219. * Base Url for the controller model.
  44220. */
  44221. static MODEL_BASE_URL: string;
  44222. /**
  44223. * File name for the left controller model.
  44224. */
  44225. static MODEL_LEFT_FILENAME: string;
  44226. /**
  44227. * File name for the right controller model.
  44228. */
  44229. static MODEL_RIGHT_FILENAME: string;
  44230. /**
  44231. * Base Url for the Quest controller model.
  44232. */
  44233. static QUEST_MODEL_BASE_URL: string;
  44234. /**
  44235. * @hidden
  44236. * If the controllers are running on a device that needs the updated Quest controller models
  44237. */
  44238. static _IsQuest: boolean;
  44239. /**
  44240. * Fired when the secondary trigger on this controller is modified
  44241. */
  44242. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  44243. /**
  44244. * Fired when the thumb rest on this controller is modified
  44245. */
  44246. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  44247. /**
  44248. * Creates a new OculusTouchController from a gamepad
  44249. * @param vrGamepad the gamepad that the controller should be created from
  44250. */
  44251. constructor(vrGamepad: any);
  44252. /**
  44253. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44254. * @param scene scene in which to add meshes
  44255. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44256. */
  44257. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44258. /**
  44259. * Fired when the A button on this controller is modified
  44260. */
  44261. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44262. /**
  44263. * Fired when the B button on this controller is modified
  44264. */
  44265. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44266. /**
  44267. * Fired when the X button on this controller is modified
  44268. */
  44269. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44270. /**
  44271. * Fired when the Y button on this controller is modified
  44272. */
  44273. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44274. /**
  44275. * Called once for each button that changed state since the last frame
  44276. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  44277. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  44278. * 2) secondary trigger (same)
  44279. * 3) A (right) X (left), touch, pressed = value
  44280. * 4) B / Y
  44281. * 5) thumb rest
  44282. * @param buttonIdx Which button index changed
  44283. * @param state New state of the button
  44284. * @param changes Which properties on the state changed since last frame
  44285. */
  44286. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44287. }
  44288. }
  44289. declare module "babylonjs/Gamepads/Controllers/viveController" {
  44290. import { Scene } from "babylonjs/scene";
  44291. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44292. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44293. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44294. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44295. import { Observable } from "babylonjs/Misc/observable";
  44296. /**
  44297. * Vive Controller
  44298. */
  44299. export class ViveController extends WebVRController {
  44300. /**
  44301. * Base Url for the controller model.
  44302. */
  44303. static MODEL_BASE_URL: string;
  44304. /**
  44305. * File name for the controller model.
  44306. */
  44307. static MODEL_FILENAME: string;
  44308. /**
  44309. * Creates a new ViveController from a gamepad
  44310. * @param vrGamepad the gamepad that the controller should be created from
  44311. */
  44312. constructor(vrGamepad: any);
  44313. /**
  44314. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44315. * @param scene scene in which to add meshes
  44316. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44317. */
  44318. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44319. /**
  44320. * Fired when the left button on this controller is modified
  44321. */
  44322. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44323. /**
  44324. * Fired when the right button on this controller is modified
  44325. */
  44326. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44327. /**
  44328. * Fired when the menu button on this controller is modified
  44329. */
  44330. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44331. /**
  44332. * Called once for each button that changed state since the last frame
  44333. * Vive mapping:
  44334. * 0: touchpad
  44335. * 1: trigger
  44336. * 2: left AND right buttons
  44337. * 3: menu button
  44338. * @param buttonIdx Which button index changed
  44339. * @param state New state of the button
  44340. * @param changes Which properties on the state changed since last frame
  44341. */
  44342. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44343. }
  44344. }
  44345. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  44346. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  44347. import { Observable } from "babylonjs/Misc/observable";
  44348. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  44349. /**
  44350. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  44351. */
  44352. export class WebXRControllerModelLoader {
  44353. /**
  44354. * an observable that triggers when a new model (the mesh itself) was initialized.
  44355. * To know when the mesh was loaded use the controller's own modelLoaded() method
  44356. */
  44357. onControllerModelLoaded: Observable<WebXRController>;
  44358. /**
  44359. * Creates the WebXRControllerModelLoader
  44360. * @param input xr input that creates the controllers
  44361. */
  44362. constructor(input: WebXRInput);
  44363. }
  44364. }
  44365. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  44366. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  44367. /**
  44368. * Handles pointer input automatically for the pointer of XR controllers
  44369. */
  44370. export class WebXRControllerPointerSelection {
  44371. private static _idCounter;
  44372. private _tmpRay;
  44373. /**
  44374. * Creates a WebXRControllerPointerSelection
  44375. * @param input input manager to setup pointer selection
  44376. */
  44377. constructor(input: WebXRInput);
  44378. private _convertNormalToDirectionOfRay;
  44379. private _updatePointerDistance;
  44380. }
  44381. }
  44382. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  44383. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44384. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  44385. /**
  44386. * Enables teleportation
  44387. */
  44388. export class WebXRControllerTeleportation {
  44389. private _teleportationFillColor;
  44390. private _teleportationBorderColor;
  44391. private _tmpRay;
  44392. private _tmpVector;
  44393. /**
  44394. * Creates a WebXRControllerTeleportation
  44395. * @param input input manager to add teleportation to
  44396. * @param floorMeshes floormeshes which can be teleported to
  44397. */
  44398. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  44399. }
  44400. }
  44401. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  44402. import { Nullable } from "babylonjs/types";
  44403. import { Observable } from "babylonjs/Misc/observable";
  44404. import { IDisposable, Scene } from "babylonjs/scene";
  44405. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  44406. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  44407. /**
  44408. * Button which can be used to enter a different mode of XR
  44409. */
  44410. export class WebXREnterExitUIButton {
  44411. /** button element */
  44412. element: HTMLElement;
  44413. /** XR initialization options for the button */
  44414. sessionMode: XRSessionMode;
  44415. /** Reference space type */
  44416. referenceSpaceType: XRReferenceSpaceType;
  44417. /**
  44418. * Creates a WebXREnterExitUIButton
  44419. * @param element button element
  44420. * @param sessionMode XR initialization session mode
  44421. * @param referenceSpaceType the type of reference space to be used
  44422. */
  44423. constructor(
  44424. /** button element */
  44425. element: HTMLElement,
  44426. /** XR initialization options for the button */
  44427. sessionMode: XRSessionMode,
  44428. /** Reference space type */
  44429. referenceSpaceType: XRReferenceSpaceType);
  44430. /**
  44431. * Overwritable function which can be used to update the button's visuals when the state changes
  44432. * @param activeButton the current active button in the UI
  44433. */
  44434. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  44435. }
  44436. /**
  44437. * Options to create the webXR UI
  44438. */
  44439. export class WebXREnterExitUIOptions {
  44440. /**
  44441. * Context to enter xr with
  44442. */
  44443. renderTarget?: Nullable<WebXRRenderTarget>;
  44444. /**
  44445. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  44446. */
  44447. customButtons?: Array<WebXREnterExitUIButton>;
  44448. /**
  44449. * A session mode to use when creating the default button.
  44450. * Default is immersive-vr
  44451. */
  44452. sessionMode?: XRSessionMode;
  44453. /**
  44454. * A reference space type to use when creating the default button.
  44455. * Default is local-floor
  44456. */
  44457. referenceSpaceType?: XRReferenceSpaceType;
  44458. }
  44459. /**
  44460. * UI to allow the user to enter/exit XR mode
  44461. */
  44462. export class WebXREnterExitUI implements IDisposable {
  44463. private scene;
  44464. /** version of the options passed to this UI */
  44465. options: WebXREnterExitUIOptions;
  44466. private _overlay;
  44467. private _buttons;
  44468. private _activeButton;
  44469. /**
  44470. * Fired every time the active button is changed.
  44471. *
  44472. * When xr is entered via a button that launches xr that button will be the callback parameter
  44473. *
  44474. * When exiting xr the callback parameter will be null)
  44475. */
  44476. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  44477. /**
  44478. * Creates UI to allow the user to enter/exit XR mode
  44479. * @param scene the scene to add the ui to
  44480. * @param helper the xr experience helper to enter/exit xr with
  44481. * @param options options to configure the UI
  44482. * @returns the created ui
  44483. */
  44484. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  44485. /**
  44486. *
  44487. * @param scene babylon scene object to use
  44488. * @param options (read-only) version of the options passed to this UI
  44489. */
  44490. private constructor();
  44491. private _updateButtons;
  44492. /**
  44493. * Disposes of the object
  44494. */
  44495. dispose(): void;
  44496. }
  44497. }
  44498. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  44499. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  44500. import { Scene } from "babylonjs/scene";
  44501. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  44502. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  44503. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  44504. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  44505. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  44506. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/Cameras/XR/webXREnterExitUI";
  44507. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44508. import { WebXRManagedOutputCanvasOptions } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  44509. /**
  44510. * Options for the default xr helper
  44511. */
  44512. export class WebXRDefaultExperienceOptions {
  44513. /**
  44514. * Floor meshes that should be used for teleporting
  44515. */
  44516. floorMeshes: Array<AbstractMesh>;
  44517. /**
  44518. * Enable or disable default UI to enter XR
  44519. */
  44520. disableDefaultUI?: boolean;
  44521. /**
  44522. * optional configuration for the output canvas
  44523. */
  44524. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  44525. /**
  44526. * optional UI options. This can be used among other to change session mode and reference space type
  44527. */
  44528. uiOptions?: WebXREnterExitUIOptions;
  44529. }
  44530. /**
  44531. * Default experience which provides a similar setup to the previous webVRExperience
  44532. */
  44533. export class WebXRDefaultExperience {
  44534. /**
  44535. * Base experience
  44536. */
  44537. baseExperience: WebXRExperienceHelper;
  44538. /**
  44539. * Input experience extension
  44540. */
  44541. input: WebXRInput;
  44542. /**
  44543. * Loads the controller models
  44544. */
  44545. controllerModelLoader: WebXRControllerModelLoader;
  44546. /**
  44547. * Enables laser pointer and selection
  44548. */
  44549. pointerSelection: WebXRControllerPointerSelection;
  44550. /**
  44551. * Enables teleportation
  44552. */
  44553. teleportation: WebXRControllerTeleportation;
  44554. /**
  44555. * Enables ui for entering/exiting xr
  44556. */
  44557. enterExitUI: WebXREnterExitUI;
  44558. /**
  44559. * Default target xr should render to
  44560. */
  44561. renderTarget: WebXRRenderTarget;
  44562. /**
  44563. * Creates the default xr experience
  44564. * @param scene scene
  44565. * @param options options for basic configuration
  44566. * @returns resulting WebXRDefaultExperience
  44567. */
  44568. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  44569. private constructor();
  44570. /**
  44571. * DIsposes of the experience helper
  44572. */
  44573. dispose(): void;
  44574. }
  44575. }
  44576. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  44577. import { Observable } from "babylonjs/Misc/observable";
  44578. import { Nullable } from "babylonjs/types";
  44579. import { Camera } from "babylonjs/Cameras/camera";
  44580. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  44581. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  44582. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  44583. import { Scene } from "babylonjs/scene";
  44584. import { Vector3 } from "babylonjs/Maths/math.vector";
  44585. import { Color3 } from "babylonjs/Maths/math.color";
  44586. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44587. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44588. import { Mesh } from "babylonjs/Meshes/mesh";
  44589. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  44590. import { EasingFunction } from "babylonjs/Animations/easing";
  44591. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  44592. import "babylonjs/Meshes/Builders/groundBuilder";
  44593. import "babylonjs/Meshes/Builders/torusBuilder";
  44594. import "babylonjs/Meshes/Builders/cylinderBuilder";
  44595. import "babylonjs/Gamepads/gamepadSceneComponent";
  44596. import "babylonjs/Animations/animatable";
  44597. import { WebXRDefaultExperience } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  44598. /**
  44599. * Options to modify the vr teleportation behavior.
  44600. */
  44601. export interface VRTeleportationOptions {
  44602. /**
  44603. * The name of the mesh which should be used as the teleportation floor. (default: null)
  44604. */
  44605. floorMeshName?: string;
  44606. /**
  44607. * A list of meshes to be used as the teleportation floor. (default: empty)
  44608. */
  44609. floorMeshes?: Mesh[];
  44610. /**
  44611. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  44612. */
  44613. teleportationMode?: number;
  44614. /**
  44615. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  44616. */
  44617. teleportationTime?: number;
  44618. /**
  44619. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  44620. */
  44621. teleportationSpeed?: number;
  44622. /**
  44623. * The easing function used in the animation or null for Linear. (default CircleEase)
  44624. */
  44625. easingFunction?: EasingFunction;
  44626. }
  44627. /**
  44628. * Options to modify the vr experience helper's behavior.
  44629. */
  44630. export interface VRExperienceHelperOptions extends WebVROptions {
  44631. /**
  44632. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  44633. */
  44634. createDeviceOrientationCamera?: boolean;
  44635. /**
  44636. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  44637. */
  44638. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  44639. /**
  44640. * Uses the main button on the controller to toggle the laser casted. (default: true)
  44641. */
  44642. laserToggle?: boolean;
  44643. /**
  44644. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  44645. */
  44646. floorMeshes?: Mesh[];
  44647. /**
  44648. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  44649. */
  44650. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  44651. /**
  44652. * Defines if WebXR should be used instead of WebVR (if available)
  44653. */
  44654. useXR?: boolean;
  44655. }
  44656. /**
  44657. * Event containing information after VR has been entered
  44658. */
  44659. export class OnAfterEnteringVRObservableEvent {
  44660. /**
  44661. * If entering vr was successful
  44662. */
  44663. success: boolean;
  44664. }
  44665. /**
  44666. * Helps to quickly add VR support to an existing scene.
  44667. * See http://doc.babylonjs.com/how_to/webvr_helper
  44668. */
  44669. export class VRExperienceHelper {
  44670. /** Options to modify the vr experience helper's behavior. */
  44671. webVROptions: VRExperienceHelperOptions;
  44672. private _scene;
  44673. private _position;
  44674. private _btnVR;
  44675. private _btnVRDisplayed;
  44676. private _webVRsupported;
  44677. private _webVRready;
  44678. private _webVRrequesting;
  44679. private _webVRpresenting;
  44680. private _hasEnteredVR;
  44681. private _fullscreenVRpresenting;
  44682. private _inputElement;
  44683. private _webVRCamera;
  44684. private _vrDeviceOrientationCamera;
  44685. private _deviceOrientationCamera;
  44686. private _existingCamera;
  44687. private _onKeyDown;
  44688. private _onVrDisplayPresentChange;
  44689. private _onVRDisplayChanged;
  44690. private _onVRRequestPresentStart;
  44691. private _onVRRequestPresentComplete;
  44692. /**
  44693. * Gets or sets a boolean indicating that gaze can be enabled even if pointer lock is not engage (useful on iOS where fullscreen mode and pointer lock are not supported)
  44694. */
  44695. enableGazeEvenWhenNoPointerLock: boolean;
  44696. /**
  44697. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  44698. */
  44699. exitVROnDoubleTap: boolean;
  44700. /**
  44701. * Observable raised right before entering VR.
  44702. */
  44703. onEnteringVRObservable: Observable<VRExperienceHelper>;
  44704. /**
  44705. * Observable raised when entering VR has completed.
  44706. */
  44707. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  44708. /**
  44709. * Observable raised when exiting VR.
  44710. */
  44711. onExitingVRObservable: Observable<VRExperienceHelper>;
  44712. /**
  44713. * Observable raised when controller mesh is loaded.
  44714. */
  44715. onControllerMeshLoadedObservable: Observable<WebVRController>;
  44716. /** Return this.onEnteringVRObservable
  44717. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  44718. */
  44719. readonly onEnteringVR: Observable<VRExperienceHelper>;
  44720. /** Return this.onExitingVRObservable
  44721. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  44722. */
  44723. readonly onExitingVR: Observable<VRExperienceHelper>;
  44724. /** Return this.onControllerMeshLoadedObservable
  44725. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  44726. */
  44727. readonly onControllerMeshLoaded: Observable<WebVRController>;
  44728. private _rayLength;
  44729. private _useCustomVRButton;
  44730. private _teleportationRequested;
  44731. private _teleportActive;
  44732. private _floorMeshName;
  44733. private _floorMeshesCollection;
  44734. private _teleportationMode;
  44735. private _teleportationTime;
  44736. private _teleportationSpeed;
  44737. private _teleportationEasing;
  44738. private _rotationAllowed;
  44739. private _teleportBackwardsVector;
  44740. private _teleportationTarget;
  44741. private _isDefaultTeleportationTarget;
  44742. private _postProcessMove;
  44743. private _teleportationFillColor;
  44744. private _teleportationBorderColor;
  44745. private _rotationAngle;
  44746. private _haloCenter;
  44747. private _cameraGazer;
  44748. private _padSensibilityUp;
  44749. private _padSensibilityDown;
  44750. private _leftController;
  44751. private _rightController;
  44752. /**
  44753. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  44754. */
  44755. onNewMeshSelected: Observable<AbstractMesh>;
  44756. /**
  44757. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  44758. * This observable will provide the mesh and the controller used to select the mesh
  44759. */
  44760. onMeshSelectedWithController: Observable<{
  44761. mesh: AbstractMesh;
  44762. controller: WebVRController;
  44763. }>;
  44764. /**
  44765. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  44766. */
  44767. onNewMeshPicked: Observable<PickingInfo>;
  44768. private _circleEase;
  44769. /**
  44770. * Observable raised before camera teleportation
  44771. */
  44772. onBeforeCameraTeleport: Observable<Vector3>;
  44773. /**
  44774. * Observable raised after camera teleportation
  44775. */
  44776. onAfterCameraTeleport: Observable<Vector3>;
  44777. /**
  44778. * Observable raised when current selected mesh gets unselected
  44779. */
  44780. onSelectedMeshUnselected: Observable<AbstractMesh>;
  44781. private _raySelectionPredicate;
  44782. /**
  44783. * To be optionaly changed by user to define custom ray selection
  44784. */
  44785. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  44786. /**
  44787. * To be optionaly changed by user to define custom selection logic (after ray selection)
  44788. */
  44789. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  44790. /**
  44791. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  44792. */
  44793. teleportationEnabled: boolean;
  44794. private _defaultHeight;
  44795. private _teleportationInitialized;
  44796. private _interactionsEnabled;
  44797. private _interactionsRequested;
  44798. private _displayGaze;
  44799. private _displayLaserPointer;
  44800. /**
  44801. * The mesh used to display where the user is going to teleport.
  44802. */
  44803. /**
  44804. * Sets the mesh to be used to display where the user is going to teleport.
  44805. */
  44806. teleportationTarget: Mesh;
  44807. /**
  44808. * 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
  44809. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  44810. * See http://doc.babylonjs.com/resources/baking_transformations
  44811. */
  44812. gazeTrackerMesh: Mesh;
  44813. /**
  44814. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  44815. */
  44816. updateGazeTrackerScale: boolean;
  44817. /**
  44818. * If the gaze trackers color should be updated when selecting meshes
  44819. */
  44820. updateGazeTrackerColor: boolean;
  44821. /**
  44822. * If the controller laser color should be updated when selecting meshes
  44823. */
  44824. updateControllerLaserColor: boolean;
  44825. /**
  44826. * The gaze tracking mesh corresponding to the left controller
  44827. */
  44828. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  44829. /**
  44830. * The gaze tracking mesh corresponding to the right controller
  44831. */
  44832. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  44833. /**
  44834. * If the ray of the gaze should be displayed.
  44835. */
  44836. /**
  44837. * Sets if the ray of the gaze should be displayed.
  44838. */
  44839. displayGaze: boolean;
  44840. /**
  44841. * If the ray of the LaserPointer should be displayed.
  44842. */
  44843. /**
  44844. * Sets if the ray of the LaserPointer should be displayed.
  44845. */
  44846. displayLaserPointer: boolean;
  44847. /**
  44848. * The deviceOrientationCamera used as the camera when not in VR.
  44849. */
  44850. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  44851. /**
  44852. * Based on the current WebVR support, returns the current VR camera used.
  44853. */
  44854. readonly currentVRCamera: Nullable<Camera>;
  44855. /**
  44856. * The webVRCamera which is used when in VR.
  44857. */
  44858. readonly webVRCamera: WebVRFreeCamera;
  44859. /**
  44860. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  44861. */
  44862. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  44863. /**
  44864. * The html button that is used to trigger entering into VR.
  44865. */
  44866. readonly vrButton: Nullable<HTMLButtonElement>;
  44867. private readonly _teleportationRequestInitiated;
  44868. /**
  44869. * Defines wether or not Pointer lock should be requested when switching to
  44870. * full screen.
  44871. */
  44872. requestPointerLockOnFullScreen: boolean;
  44873. /**
  44874. * If asking to force XR, this will be populated with the default xr experience
  44875. */
  44876. xr: WebXRDefaultExperience;
  44877. /**
  44878. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  44879. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  44880. */
  44881. xrTestDone: boolean;
  44882. /**
  44883. * Instantiates a VRExperienceHelper.
  44884. * Helps to quickly add VR support to an existing scene.
  44885. * @param scene The scene the VRExperienceHelper belongs to.
  44886. * @param webVROptions Options to modify the vr experience helper's behavior.
  44887. */
  44888. constructor(scene: Scene,
  44889. /** Options to modify the vr experience helper's behavior. */
  44890. webVROptions?: VRExperienceHelperOptions);
  44891. private completeVRInit;
  44892. private _onDefaultMeshLoaded;
  44893. private _onResize;
  44894. private _onFullscreenChange;
  44895. /**
  44896. * Gets a value indicating if we are currently in VR mode.
  44897. */
  44898. readonly isInVRMode: boolean;
  44899. private onVrDisplayPresentChange;
  44900. private onVRDisplayChanged;
  44901. private moveButtonToBottomRight;
  44902. private displayVRButton;
  44903. private updateButtonVisibility;
  44904. private _cachedAngularSensibility;
  44905. /**
  44906. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  44907. * Otherwise, will use the fullscreen API.
  44908. */
  44909. enterVR(): void;
  44910. /**
  44911. * Attempt to exit VR, or fullscreen.
  44912. */
  44913. exitVR(): void;
  44914. /**
  44915. * The position of the vr experience helper.
  44916. */
  44917. /**
  44918. * Sets the position of the vr experience helper.
  44919. */
  44920. position: Vector3;
  44921. /**
  44922. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  44923. */
  44924. enableInteractions(): void;
  44925. private readonly _noControllerIsActive;
  44926. private beforeRender;
  44927. private _isTeleportationFloor;
  44928. /**
  44929. * Adds a floor mesh to be used for teleportation.
  44930. * @param floorMesh the mesh to be used for teleportation.
  44931. */
  44932. addFloorMesh(floorMesh: Mesh): void;
  44933. /**
  44934. * Removes a floor mesh from being used for teleportation.
  44935. * @param floorMesh the mesh to be removed.
  44936. */
  44937. removeFloorMesh(floorMesh: Mesh): void;
  44938. /**
  44939. * Enables interactions and teleportation using the VR controllers and gaze.
  44940. * @param vrTeleportationOptions options to modify teleportation behavior.
  44941. */
  44942. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  44943. private _onNewGamepadConnected;
  44944. private _tryEnableInteractionOnController;
  44945. private _onNewGamepadDisconnected;
  44946. private _enableInteractionOnController;
  44947. private _checkTeleportWithRay;
  44948. private _checkRotate;
  44949. private _checkTeleportBackwards;
  44950. private _enableTeleportationOnController;
  44951. private _createTeleportationCircles;
  44952. private _displayTeleportationTarget;
  44953. private _hideTeleportationTarget;
  44954. private _rotateCamera;
  44955. private _moveTeleportationSelectorTo;
  44956. private _workingVector;
  44957. private _workingQuaternion;
  44958. private _workingMatrix;
  44959. /**
  44960. * Time Constant Teleportation Mode
  44961. */
  44962. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  44963. /**
  44964. * Speed Constant Teleportation Mode
  44965. */
  44966. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  44967. /**
  44968. * Teleports the users feet to the desired location
  44969. * @param location The location where the user's feet should be placed
  44970. */
  44971. teleportCamera(location: Vector3): void;
  44972. private _convertNormalToDirectionOfRay;
  44973. private _castRayAndSelectObject;
  44974. private _notifySelectedMeshUnselected;
  44975. /**
  44976. * Sets the color of the laser ray from the vr controllers.
  44977. * @param color new color for the ray.
  44978. */
  44979. changeLaserColor(color: Color3): void;
  44980. /**
  44981. * Sets the color of the ray from the vr headsets gaze.
  44982. * @param color new color for the ray.
  44983. */
  44984. changeGazeColor(color: Color3): void;
  44985. /**
  44986. * Exits VR and disposes of the vr experience helper
  44987. */
  44988. dispose(): void;
  44989. /**
  44990. * Gets the name of the VRExperienceHelper class
  44991. * @returns "VRExperienceHelper"
  44992. */
  44993. getClassName(): string;
  44994. }
  44995. }
  44996. declare module "babylonjs/Cameras/VR/index" {
  44997. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  44998. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  44999. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  45000. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  45001. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  45002. export * from "babylonjs/Cameras/VR/webVRCamera";
  45003. }
  45004. declare module "babylonjs/Cameras/XR/index" {
  45005. export * from "babylonjs/Cameras/XR/webXRCamera";
  45006. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  45007. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  45008. export * from "babylonjs/Cameras/XR/webXRInput";
  45009. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  45010. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  45011. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  45012. export * from "babylonjs/Cameras/XR/webXRController";
  45013. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  45014. export * from "babylonjs/Cameras/XR/webXRTypes";
  45015. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  45016. export * from "babylonjs/Cameras/XR/webXRDefaultExperience";
  45017. }
  45018. declare module "babylonjs/Cameras/RigModes/index" {
  45019. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  45020. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  45021. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  45022. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  45023. }
  45024. declare module "babylonjs/Cameras/index" {
  45025. export * from "babylonjs/Cameras/Inputs/index";
  45026. export * from "babylonjs/Cameras/cameraInputsManager";
  45027. export * from "babylonjs/Cameras/camera";
  45028. export * from "babylonjs/Cameras/targetCamera";
  45029. export * from "babylonjs/Cameras/freeCamera";
  45030. export * from "babylonjs/Cameras/freeCameraInputsManager";
  45031. export * from "babylonjs/Cameras/touchCamera";
  45032. export * from "babylonjs/Cameras/arcRotateCamera";
  45033. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  45034. export * from "babylonjs/Cameras/deviceOrientationCamera";
  45035. export * from "babylonjs/Cameras/flyCamera";
  45036. export * from "babylonjs/Cameras/flyCameraInputsManager";
  45037. export * from "babylonjs/Cameras/followCamera";
  45038. export * from "babylonjs/Cameras/followCameraInputsManager";
  45039. export * from "babylonjs/Cameras/gamepadCamera";
  45040. export * from "babylonjs/Cameras/Stereoscopic/index";
  45041. export * from "babylonjs/Cameras/universalCamera";
  45042. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  45043. export * from "babylonjs/Cameras/VR/index";
  45044. export * from "babylonjs/Cameras/XR/index";
  45045. export * from "babylonjs/Cameras/RigModes/index";
  45046. }
  45047. declare module "babylonjs/Collisions/index" {
  45048. export * from "babylonjs/Collisions/collider";
  45049. export * from "babylonjs/Collisions/collisionCoordinator";
  45050. export * from "babylonjs/Collisions/pickingInfo";
  45051. export * from "babylonjs/Collisions/intersectionInfo";
  45052. export * from "babylonjs/Collisions/meshCollisionData";
  45053. }
  45054. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  45055. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  45056. import { Vector3 } from "babylonjs/Maths/math.vector";
  45057. import { Ray } from "babylonjs/Culling/ray";
  45058. import { Plane } from "babylonjs/Maths/math.plane";
  45059. /**
  45060. * Contains an array of blocks representing the octree
  45061. */
  45062. export interface IOctreeContainer<T> {
  45063. /**
  45064. * Blocks within the octree
  45065. */
  45066. blocks: Array<OctreeBlock<T>>;
  45067. }
  45068. /**
  45069. * Class used to store a cell in an octree
  45070. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45071. */
  45072. export class OctreeBlock<T> {
  45073. /**
  45074. * Gets the content of the current block
  45075. */
  45076. entries: T[];
  45077. /**
  45078. * Gets the list of block children
  45079. */
  45080. blocks: Array<OctreeBlock<T>>;
  45081. private _depth;
  45082. private _maxDepth;
  45083. private _capacity;
  45084. private _minPoint;
  45085. private _maxPoint;
  45086. private _boundingVectors;
  45087. private _creationFunc;
  45088. /**
  45089. * Creates a new block
  45090. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  45091. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  45092. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45093. * @param depth defines the current depth of this block in the octree
  45094. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  45095. * @param creationFunc defines a callback to call when an element is added to the block
  45096. */
  45097. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  45098. /**
  45099. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45100. */
  45101. readonly capacity: number;
  45102. /**
  45103. * Gets the minimum vector (in world space) of the block's bounding box
  45104. */
  45105. readonly minPoint: Vector3;
  45106. /**
  45107. * Gets the maximum vector (in world space) of the block's bounding box
  45108. */
  45109. readonly maxPoint: Vector3;
  45110. /**
  45111. * Add a new element to this block
  45112. * @param entry defines the element to add
  45113. */
  45114. addEntry(entry: T): void;
  45115. /**
  45116. * Remove an element from this block
  45117. * @param entry defines the element to remove
  45118. */
  45119. removeEntry(entry: T): void;
  45120. /**
  45121. * Add an array of elements to this block
  45122. * @param entries defines the array of elements to add
  45123. */
  45124. addEntries(entries: T[]): void;
  45125. /**
  45126. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  45127. * @param frustumPlanes defines the frustum planes to test
  45128. * @param selection defines the array to store current content if selection is positive
  45129. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45130. */
  45131. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45132. /**
  45133. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  45134. * @param sphereCenter defines the bounding sphere center
  45135. * @param sphereRadius defines the bounding sphere radius
  45136. * @param selection defines the array to store current content if selection is positive
  45137. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45138. */
  45139. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45140. /**
  45141. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  45142. * @param ray defines the ray to test with
  45143. * @param selection defines the array to store current content if selection is positive
  45144. */
  45145. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  45146. /**
  45147. * Subdivide the content into child blocks (this block will then be empty)
  45148. */
  45149. createInnerBlocks(): void;
  45150. /**
  45151. * @hidden
  45152. */
  45153. 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;
  45154. }
  45155. }
  45156. declare module "babylonjs/Culling/Octrees/octree" {
  45157. import { SmartArray } from "babylonjs/Misc/smartArray";
  45158. import { Vector3 } from "babylonjs/Maths/math.vector";
  45159. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45160. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45161. import { Ray } from "babylonjs/Culling/ray";
  45162. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  45163. import { Plane } from "babylonjs/Maths/math.plane";
  45164. /**
  45165. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  45166. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45167. */
  45168. export class Octree<T> {
  45169. /** 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.) */
  45170. maxDepth: number;
  45171. /**
  45172. * Blocks within the octree containing objects
  45173. */
  45174. blocks: Array<OctreeBlock<T>>;
  45175. /**
  45176. * Content stored in the octree
  45177. */
  45178. dynamicContent: T[];
  45179. private _maxBlockCapacity;
  45180. private _selectionContent;
  45181. private _creationFunc;
  45182. /**
  45183. * Creates a octree
  45184. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45185. * @param creationFunc function to be used to instatiate the octree
  45186. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  45187. * @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.)
  45188. */
  45189. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  45190. /** 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.) */
  45191. maxDepth?: number);
  45192. /**
  45193. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  45194. * @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);
  45195. * @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);
  45196. * @param entries meshes to be added to the octree blocks
  45197. */
  45198. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  45199. /**
  45200. * Adds a mesh to the octree
  45201. * @param entry Mesh to add to the octree
  45202. */
  45203. addMesh(entry: T): void;
  45204. /**
  45205. * Remove an element from the octree
  45206. * @param entry defines the element to remove
  45207. */
  45208. removeMesh(entry: T): void;
  45209. /**
  45210. * Selects an array of meshes within the frustum
  45211. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  45212. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  45213. * @returns array of meshes within the frustum
  45214. */
  45215. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  45216. /**
  45217. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  45218. * @param sphereCenter defines the bounding sphere center
  45219. * @param sphereRadius defines the bounding sphere radius
  45220. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45221. * @returns an array of objects that intersect the sphere
  45222. */
  45223. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  45224. /**
  45225. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  45226. * @param ray defines the ray to test with
  45227. * @returns array of intersected objects
  45228. */
  45229. intersectsRay(ray: Ray): SmartArray<T>;
  45230. /**
  45231. * Adds a mesh into the octree block if it intersects the block
  45232. */
  45233. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  45234. /**
  45235. * Adds a submesh into the octree block if it intersects the block
  45236. */
  45237. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  45238. }
  45239. }
  45240. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  45241. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  45242. import { Scene } from "babylonjs/scene";
  45243. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45244. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45245. import { Ray } from "babylonjs/Culling/ray";
  45246. import { Octree } from "babylonjs/Culling/Octrees/octree";
  45247. import { Collider } from "babylonjs/Collisions/collider";
  45248. module "babylonjs/scene" {
  45249. interface Scene {
  45250. /**
  45251. * @hidden
  45252. * Backing Filed
  45253. */
  45254. _selectionOctree: Octree<AbstractMesh>;
  45255. /**
  45256. * Gets the octree used to boost mesh selection (picking)
  45257. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45258. */
  45259. selectionOctree: Octree<AbstractMesh>;
  45260. /**
  45261. * Creates or updates the octree used to boost selection (picking)
  45262. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45263. * @param maxCapacity defines the maximum capacity per leaf
  45264. * @param maxDepth defines the maximum depth of the octree
  45265. * @returns an octree of AbstractMesh
  45266. */
  45267. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  45268. }
  45269. }
  45270. module "babylonjs/Meshes/abstractMesh" {
  45271. interface AbstractMesh {
  45272. /**
  45273. * @hidden
  45274. * Backing Field
  45275. */
  45276. _submeshesOctree: Octree<SubMesh>;
  45277. /**
  45278. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  45279. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  45280. * @param maxCapacity defines the maximum size of each block (64 by default)
  45281. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  45282. * @returns the new octree
  45283. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  45284. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45285. */
  45286. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  45287. }
  45288. }
  45289. /**
  45290. * Defines the octree scene component responsible to manage any octrees
  45291. * in a given scene.
  45292. */
  45293. export class OctreeSceneComponent {
  45294. /**
  45295. * The component name help to identify the component in the list of scene components.
  45296. */
  45297. readonly name: string;
  45298. /**
  45299. * The scene the component belongs to.
  45300. */
  45301. scene: Scene;
  45302. /**
  45303. * Indicates if the meshes have been checked to make sure they are isEnabled()
  45304. */
  45305. readonly checksIsEnabled: boolean;
  45306. /**
  45307. * Creates a new instance of the component for the given scene
  45308. * @param scene Defines the scene to register the component in
  45309. */
  45310. constructor(scene: Scene);
  45311. /**
  45312. * Registers the component in a given scene
  45313. */
  45314. register(): void;
  45315. /**
  45316. * Return the list of active meshes
  45317. * @returns the list of active meshes
  45318. */
  45319. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  45320. /**
  45321. * Return the list of active sub meshes
  45322. * @param mesh The mesh to get the candidates sub meshes from
  45323. * @returns the list of active sub meshes
  45324. */
  45325. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  45326. private _tempRay;
  45327. /**
  45328. * Return the list of sub meshes intersecting with a given local ray
  45329. * @param mesh defines the mesh to find the submesh for
  45330. * @param localRay defines the ray in local space
  45331. * @returns the list of intersecting sub meshes
  45332. */
  45333. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  45334. /**
  45335. * Return the list of sub meshes colliding with a collider
  45336. * @param mesh defines the mesh to find the submesh for
  45337. * @param collider defines the collider to evaluate the collision against
  45338. * @returns the list of colliding sub meshes
  45339. */
  45340. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  45341. /**
  45342. * Rebuilds the elements related to this component in case of
  45343. * context lost for instance.
  45344. */
  45345. rebuild(): void;
  45346. /**
  45347. * Disposes the component and the associated ressources.
  45348. */
  45349. dispose(): void;
  45350. }
  45351. }
  45352. declare module "babylonjs/Culling/Octrees/index" {
  45353. export * from "babylonjs/Culling/Octrees/octree";
  45354. export * from "babylonjs/Culling/Octrees/octreeBlock";
  45355. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  45356. }
  45357. declare module "babylonjs/Culling/index" {
  45358. export * from "babylonjs/Culling/boundingBox";
  45359. export * from "babylonjs/Culling/boundingInfo";
  45360. export * from "babylonjs/Culling/boundingSphere";
  45361. export * from "babylonjs/Culling/Octrees/index";
  45362. export * from "babylonjs/Culling/ray";
  45363. }
  45364. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  45365. import { IDisposable, Scene } from "babylonjs/scene";
  45366. import { Nullable } from "babylonjs/types";
  45367. import { Observable } from "babylonjs/Misc/observable";
  45368. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45369. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  45370. import { Camera } from "babylonjs/Cameras/camera";
  45371. /**
  45372. * Renders a layer on top of an existing scene
  45373. */
  45374. export class UtilityLayerRenderer implements IDisposable {
  45375. /** the original scene that will be rendered on top of */
  45376. originalScene: Scene;
  45377. private _pointerCaptures;
  45378. private _lastPointerEvents;
  45379. private static _DefaultUtilityLayer;
  45380. private static _DefaultKeepDepthUtilityLayer;
  45381. private _sharedGizmoLight;
  45382. private _renderCamera;
  45383. /**
  45384. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  45385. * @returns the camera that is used when rendering the utility layer
  45386. */
  45387. getRenderCamera(): Nullable<Camera>;
  45388. /**
  45389. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  45390. * @param cam the camera that should be used when rendering the utility layer
  45391. */
  45392. setRenderCamera(cam: Nullable<Camera>): void;
  45393. /**
  45394. * @hidden
  45395. * Light which used by gizmos to get light shading
  45396. */
  45397. _getSharedGizmoLight(): HemisphericLight;
  45398. /**
  45399. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  45400. */
  45401. pickUtilitySceneFirst: boolean;
  45402. /**
  45403. * 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)
  45404. */
  45405. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  45406. /**
  45407. * 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)
  45408. */
  45409. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  45410. /**
  45411. * The scene that is rendered on top of the original scene
  45412. */
  45413. utilityLayerScene: Scene;
  45414. /**
  45415. * If the utility layer should automatically be rendered on top of existing scene
  45416. */
  45417. shouldRender: boolean;
  45418. /**
  45419. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  45420. */
  45421. onlyCheckPointerDownEvents: boolean;
  45422. /**
  45423. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  45424. */
  45425. processAllEvents: boolean;
  45426. /**
  45427. * Observable raised when the pointer move from the utility layer scene to the main scene
  45428. */
  45429. onPointerOutObservable: Observable<number>;
  45430. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  45431. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  45432. private _afterRenderObserver;
  45433. private _sceneDisposeObserver;
  45434. private _originalPointerObserver;
  45435. /**
  45436. * Instantiates a UtilityLayerRenderer
  45437. * @param originalScene the original scene that will be rendered on top of
  45438. * @param handleEvents boolean indicating if the utility layer should handle events
  45439. */
  45440. constructor(
  45441. /** the original scene that will be rendered on top of */
  45442. originalScene: Scene, handleEvents?: boolean);
  45443. private _notifyObservers;
  45444. /**
  45445. * Renders the utility layers scene on top of the original scene
  45446. */
  45447. render(): void;
  45448. /**
  45449. * Disposes of the renderer
  45450. */
  45451. dispose(): void;
  45452. private _updateCamera;
  45453. }
  45454. }
  45455. declare module "babylonjs/Gizmos/gizmo" {
  45456. import { Nullable } from "babylonjs/types";
  45457. import { IDisposable } from "babylonjs/scene";
  45458. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45459. import { Mesh } from "babylonjs/Meshes/mesh";
  45460. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45461. /**
  45462. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  45463. */
  45464. export class Gizmo implements IDisposable {
  45465. /** The utility layer the gizmo will be added to */
  45466. gizmoLayer: UtilityLayerRenderer;
  45467. /**
  45468. * The root mesh of the gizmo
  45469. */
  45470. _rootMesh: Mesh;
  45471. private _attachedMesh;
  45472. /**
  45473. * Ratio for the scale of the gizmo (Default: 1)
  45474. */
  45475. scaleRatio: number;
  45476. /**
  45477. * If a custom mesh has been set (Default: false)
  45478. */
  45479. protected _customMeshSet: boolean;
  45480. /**
  45481. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  45482. * * When set, interactions will be enabled
  45483. */
  45484. attachedMesh: Nullable<AbstractMesh>;
  45485. /**
  45486. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  45487. * @param mesh The mesh to replace the default mesh of the gizmo
  45488. */
  45489. setCustomMesh(mesh: Mesh): void;
  45490. /**
  45491. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  45492. */
  45493. updateGizmoRotationToMatchAttachedMesh: boolean;
  45494. /**
  45495. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  45496. */
  45497. updateGizmoPositionToMatchAttachedMesh: boolean;
  45498. /**
  45499. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  45500. */
  45501. updateScale: boolean;
  45502. protected _interactionsEnabled: boolean;
  45503. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45504. private _beforeRenderObserver;
  45505. private _tempVector;
  45506. /**
  45507. * Creates a gizmo
  45508. * @param gizmoLayer The utility layer the gizmo will be added to
  45509. */
  45510. constructor(
  45511. /** The utility layer the gizmo will be added to */
  45512. gizmoLayer?: UtilityLayerRenderer);
  45513. /**
  45514. * Updates the gizmo to match the attached mesh's position/rotation
  45515. */
  45516. protected _update(): void;
  45517. /**
  45518. * Disposes of the gizmo
  45519. */
  45520. dispose(): void;
  45521. }
  45522. }
  45523. declare module "babylonjs/Gizmos/planeDragGizmo" {
  45524. import { Observable } from "babylonjs/Misc/observable";
  45525. import { Nullable } from "babylonjs/types";
  45526. import { Vector3 } from "babylonjs/Maths/math.vector";
  45527. import { Color3 } from "babylonjs/Maths/math.color";
  45528. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45529. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45530. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45531. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45532. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45533. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  45534. import { Scene } from "babylonjs/scene";
  45535. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  45536. /**
  45537. * Single plane drag gizmo
  45538. */
  45539. export class PlaneDragGizmo extends Gizmo {
  45540. /**
  45541. * Drag behavior responsible for the gizmos dragging interactions
  45542. */
  45543. dragBehavior: PointerDragBehavior;
  45544. private _pointerObserver;
  45545. /**
  45546. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45547. */
  45548. snapDistance: number;
  45549. /**
  45550. * Event that fires each time the gizmo snaps to a new location.
  45551. * * snapDistance is the the change in distance
  45552. */
  45553. onSnapObservable: Observable<{
  45554. snapDistance: number;
  45555. }>;
  45556. private _plane;
  45557. private _coloredMaterial;
  45558. private _hoverMaterial;
  45559. private _isEnabled;
  45560. private _parent;
  45561. /** @hidden */
  45562. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  45563. /** @hidden */
  45564. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45565. /**
  45566. * Creates a PlaneDragGizmo
  45567. * @param gizmoLayer The utility layer the gizmo will be added to
  45568. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  45569. * @param color The color of the gizmo
  45570. */
  45571. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45572. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45573. /**
  45574. * If the gizmo is enabled
  45575. */
  45576. isEnabled: boolean;
  45577. /**
  45578. * Disposes of the gizmo
  45579. */
  45580. dispose(): void;
  45581. }
  45582. }
  45583. declare module "babylonjs/Gizmos/positionGizmo" {
  45584. import { Observable } from "babylonjs/Misc/observable";
  45585. import { Nullable } from "babylonjs/types";
  45586. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45587. import { Mesh } from "babylonjs/Meshes/mesh";
  45588. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45589. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  45590. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  45591. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45592. /**
  45593. * Gizmo that enables dragging a mesh along 3 axis
  45594. */
  45595. export class PositionGizmo extends Gizmo {
  45596. /**
  45597. * Internal gizmo used for interactions on the x axis
  45598. */
  45599. xGizmo: AxisDragGizmo;
  45600. /**
  45601. * Internal gizmo used for interactions on the y axis
  45602. */
  45603. yGizmo: AxisDragGizmo;
  45604. /**
  45605. * Internal gizmo used for interactions on the z axis
  45606. */
  45607. zGizmo: AxisDragGizmo;
  45608. /**
  45609. * Internal gizmo used for interactions on the yz plane
  45610. */
  45611. xPlaneGizmo: PlaneDragGizmo;
  45612. /**
  45613. * Internal gizmo used for interactions on the xz plane
  45614. */
  45615. yPlaneGizmo: PlaneDragGizmo;
  45616. /**
  45617. * Internal gizmo used for interactions on the xy plane
  45618. */
  45619. zPlaneGizmo: PlaneDragGizmo;
  45620. /**
  45621. * private variables
  45622. */
  45623. private _meshAttached;
  45624. private _updateGizmoRotationToMatchAttachedMesh;
  45625. private _snapDistance;
  45626. private _scaleRatio;
  45627. /** Fires an event when any of it's sub gizmos are dragged */
  45628. onDragStartObservable: Observable<unknown>;
  45629. /** Fires an event when any of it's sub gizmos are released from dragging */
  45630. onDragEndObservable: Observable<unknown>;
  45631. /**
  45632. * If set to true, planar drag is enabled
  45633. */
  45634. private _planarGizmoEnabled;
  45635. attachedMesh: Nullable<AbstractMesh>;
  45636. /**
  45637. * Creates a PositionGizmo
  45638. * @param gizmoLayer The utility layer the gizmo will be added to
  45639. */
  45640. constructor(gizmoLayer?: UtilityLayerRenderer);
  45641. /**
  45642. * If the planar drag gizmo is enabled
  45643. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  45644. */
  45645. planarGizmoEnabled: boolean;
  45646. updateGizmoRotationToMatchAttachedMesh: boolean;
  45647. /**
  45648. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45649. */
  45650. snapDistance: number;
  45651. /**
  45652. * Ratio for the scale of the gizmo (Default: 1)
  45653. */
  45654. scaleRatio: number;
  45655. /**
  45656. * Disposes of the gizmo
  45657. */
  45658. dispose(): void;
  45659. /**
  45660. * CustomMeshes are not supported by this gizmo
  45661. * @param mesh The mesh to replace the default mesh of the gizmo
  45662. */
  45663. setCustomMesh(mesh: Mesh): void;
  45664. }
  45665. }
  45666. declare module "babylonjs/Gizmos/axisDragGizmo" {
  45667. import { Observable } from "babylonjs/Misc/observable";
  45668. import { Nullable } from "babylonjs/types";
  45669. import { Vector3 } from "babylonjs/Maths/math.vector";
  45670. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45671. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45672. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45673. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45674. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45675. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  45676. import { Scene } from "babylonjs/scene";
  45677. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  45678. import { Color3 } from "babylonjs/Maths/math.color";
  45679. /**
  45680. * Single axis drag gizmo
  45681. */
  45682. export class AxisDragGizmo extends Gizmo {
  45683. /**
  45684. * Drag behavior responsible for the gizmos dragging interactions
  45685. */
  45686. dragBehavior: PointerDragBehavior;
  45687. private _pointerObserver;
  45688. /**
  45689. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45690. */
  45691. snapDistance: number;
  45692. /**
  45693. * Event that fires each time the gizmo snaps to a new location.
  45694. * * snapDistance is the the change in distance
  45695. */
  45696. onSnapObservable: Observable<{
  45697. snapDistance: number;
  45698. }>;
  45699. private _isEnabled;
  45700. private _parent;
  45701. private _arrow;
  45702. private _coloredMaterial;
  45703. private _hoverMaterial;
  45704. /** @hidden */
  45705. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  45706. /** @hidden */
  45707. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45708. /**
  45709. * Creates an AxisDragGizmo
  45710. * @param gizmoLayer The utility layer the gizmo will be added to
  45711. * @param dragAxis The axis which the gizmo will be able to drag on
  45712. * @param color The color of the gizmo
  45713. */
  45714. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45715. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45716. /**
  45717. * If the gizmo is enabled
  45718. */
  45719. isEnabled: boolean;
  45720. /**
  45721. * Disposes of the gizmo
  45722. */
  45723. dispose(): void;
  45724. }
  45725. }
  45726. declare module "babylonjs/Debug/axesViewer" {
  45727. import { Vector3 } from "babylonjs/Maths/math.vector";
  45728. import { Nullable } from "babylonjs/types";
  45729. import { Scene } from "babylonjs/scene";
  45730. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45731. /**
  45732. * The Axes viewer will show 3 axes in a specific point in space
  45733. */
  45734. export class AxesViewer {
  45735. private _xAxis;
  45736. private _yAxis;
  45737. private _zAxis;
  45738. private _scaleLinesFactor;
  45739. private _instanced;
  45740. /**
  45741. * Gets the hosting scene
  45742. */
  45743. scene: Scene;
  45744. /**
  45745. * Gets or sets a number used to scale line length
  45746. */
  45747. scaleLines: number;
  45748. /** Gets the node hierarchy used to render x-axis */
  45749. readonly xAxis: TransformNode;
  45750. /** Gets the node hierarchy used to render y-axis */
  45751. readonly yAxis: TransformNode;
  45752. /** Gets the node hierarchy used to render z-axis */
  45753. readonly zAxis: TransformNode;
  45754. /**
  45755. * Creates a new AxesViewer
  45756. * @param scene defines the hosting scene
  45757. * @param scaleLines defines a number used to scale line length (1 by default)
  45758. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  45759. * @param xAxis defines the node hierarchy used to render the x-axis
  45760. * @param yAxis defines the node hierarchy used to render the y-axis
  45761. * @param zAxis defines the node hierarchy used to render the z-axis
  45762. */
  45763. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  45764. /**
  45765. * Force the viewer to update
  45766. * @param position defines the position of the viewer
  45767. * @param xaxis defines the x axis of the viewer
  45768. * @param yaxis defines the y axis of the viewer
  45769. * @param zaxis defines the z axis of the viewer
  45770. */
  45771. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  45772. /**
  45773. * Creates an instance of this axes viewer.
  45774. * @returns a new axes viewer with instanced meshes
  45775. */
  45776. createInstance(): AxesViewer;
  45777. /** Releases resources */
  45778. dispose(): void;
  45779. private static _SetRenderingGroupId;
  45780. }
  45781. }
  45782. declare module "babylonjs/Debug/boneAxesViewer" {
  45783. import { Nullable } from "babylonjs/types";
  45784. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  45785. import { Vector3 } from "babylonjs/Maths/math.vector";
  45786. import { Mesh } from "babylonjs/Meshes/mesh";
  45787. import { Bone } from "babylonjs/Bones/bone";
  45788. import { Scene } from "babylonjs/scene";
  45789. /**
  45790. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  45791. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  45792. */
  45793. export class BoneAxesViewer extends AxesViewer {
  45794. /**
  45795. * Gets or sets the target mesh where to display the axes viewer
  45796. */
  45797. mesh: Nullable<Mesh>;
  45798. /**
  45799. * Gets or sets the target bone where to display the axes viewer
  45800. */
  45801. bone: Nullable<Bone>;
  45802. /** Gets current position */
  45803. pos: Vector3;
  45804. /** Gets direction of X axis */
  45805. xaxis: Vector3;
  45806. /** Gets direction of Y axis */
  45807. yaxis: Vector3;
  45808. /** Gets direction of Z axis */
  45809. zaxis: Vector3;
  45810. /**
  45811. * Creates a new BoneAxesViewer
  45812. * @param scene defines the hosting scene
  45813. * @param bone defines the target bone
  45814. * @param mesh defines the target mesh
  45815. * @param scaleLines defines a scaling factor for line length (1 by default)
  45816. */
  45817. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  45818. /**
  45819. * Force the viewer to update
  45820. */
  45821. update(): void;
  45822. /** Releases resources */
  45823. dispose(): void;
  45824. }
  45825. }
  45826. declare module "babylonjs/Debug/debugLayer" {
  45827. import { Scene } from "babylonjs/scene";
  45828. /**
  45829. * Interface used to define scene explorer extensibility option
  45830. */
  45831. export interface IExplorerExtensibilityOption {
  45832. /**
  45833. * Define the option label
  45834. */
  45835. label: string;
  45836. /**
  45837. * Defines the action to execute on click
  45838. */
  45839. action: (entity: any) => void;
  45840. }
  45841. /**
  45842. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  45843. */
  45844. export interface IExplorerExtensibilityGroup {
  45845. /**
  45846. * Defines a predicate to test if a given type mut be extended
  45847. */
  45848. predicate: (entity: any) => boolean;
  45849. /**
  45850. * Gets the list of options added to a type
  45851. */
  45852. entries: IExplorerExtensibilityOption[];
  45853. }
  45854. /**
  45855. * Interface used to define the options to use to create the Inspector
  45856. */
  45857. export interface IInspectorOptions {
  45858. /**
  45859. * Display in overlay mode (default: false)
  45860. */
  45861. overlay?: boolean;
  45862. /**
  45863. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  45864. */
  45865. globalRoot?: HTMLElement;
  45866. /**
  45867. * Display the Scene explorer
  45868. */
  45869. showExplorer?: boolean;
  45870. /**
  45871. * Display the property inspector
  45872. */
  45873. showInspector?: boolean;
  45874. /**
  45875. * Display in embed mode (both panes on the right)
  45876. */
  45877. embedMode?: boolean;
  45878. /**
  45879. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  45880. */
  45881. handleResize?: boolean;
  45882. /**
  45883. * Allow the panes to popup (default: true)
  45884. */
  45885. enablePopup?: boolean;
  45886. /**
  45887. * Allow the panes to be closed by users (default: true)
  45888. */
  45889. enableClose?: boolean;
  45890. /**
  45891. * Optional list of extensibility entries
  45892. */
  45893. explorerExtensibility?: IExplorerExtensibilityGroup[];
  45894. /**
  45895. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  45896. */
  45897. inspectorURL?: string;
  45898. /**
  45899. * Optional initial tab (default to DebugLayerTab.Properties)
  45900. */
  45901. initialTab?: DebugLayerTab;
  45902. }
  45903. module "babylonjs/scene" {
  45904. interface Scene {
  45905. /**
  45906. * @hidden
  45907. * Backing field
  45908. */
  45909. _debugLayer: DebugLayer;
  45910. /**
  45911. * Gets the debug layer (aka Inspector) associated with the scene
  45912. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45913. */
  45914. debugLayer: DebugLayer;
  45915. }
  45916. }
  45917. /**
  45918. * Enum of inspector action tab
  45919. */
  45920. export enum DebugLayerTab {
  45921. /**
  45922. * Properties tag (default)
  45923. */
  45924. Properties = 0,
  45925. /**
  45926. * Debug tab
  45927. */
  45928. Debug = 1,
  45929. /**
  45930. * Statistics tab
  45931. */
  45932. Statistics = 2,
  45933. /**
  45934. * Tools tab
  45935. */
  45936. Tools = 3,
  45937. /**
  45938. * Settings tab
  45939. */
  45940. Settings = 4
  45941. }
  45942. /**
  45943. * The debug layer (aka Inspector) is the go to tool in order to better understand
  45944. * what is happening in your scene
  45945. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45946. */
  45947. export class DebugLayer {
  45948. /**
  45949. * Define the url to get the inspector script from.
  45950. * By default it uses the babylonjs CDN.
  45951. * @ignoreNaming
  45952. */
  45953. static InspectorURL: string;
  45954. private _scene;
  45955. private BJSINSPECTOR;
  45956. private _onPropertyChangedObservable?;
  45957. /**
  45958. * Observable triggered when a property is changed through the inspector.
  45959. */
  45960. readonly onPropertyChangedObservable: any;
  45961. /**
  45962. * Instantiates a new debug layer.
  45963. * The debug layer (aka Inspector) is the go to tool in order to better understand
  45964. * what is happening in your scene
  45965. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45966. * @param scene Defines the scene to inspect
  45967. */
  45968. constructor(scene: Scene);
  45969. /** Creates the inspector window. */
  45970. private _createInspector;
  45971. /**
  45972. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  45973. * @param entity defines the entity to select
  45974. * @param lineContainerTitle defines the specific block to highlight
  45975. */
  45976. select(entity: any, lineContainerTitle?: string): void;
  45977. /** Get the inspector from bundle or global */
  45978. private _getGlobalInspector;
  45979. /**
  45980. * Get if the inspector is visible or not.
  45981. * @returns true if visible otherwise, false
  45982. */
  45983. isVisible(): boolean;
  45984. /**
  45985. * Hide the inspector and close its window.
  45986. */
  45987. hide(): void;
  45988. /**
  45989. * Launch the debugLayer.
  45990. * @param config Define the configuration of the inspector
  45991. * @return a promise fulfilled when the debug layer is visible
  45992. */
  45993. show(config?: IInspectorOptions): Promise<DebugLayer>;
  45994. }
  45995. }
  45996. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  45997. import { Nullable } from "babylonjs/types";
  45998. import { Scene } from "babylonjs/scene";
  45999. import { Vector4 } from "babylonjs/Maths/math.vector";
  46000. import { Color4 } from "babylonjs/Maths/math.color";
  46001. import { Mesh } from "babylonjs/Meshes/mesh";
  46002. /**
  46003. * Class containing static functions to help procedurally build meshes
  46004. */
  46005. export class BoxBuilder {
  46006. /**
  46007. * Creates a box mesh
  46008. * * The parameter `size` sets the size (float) of each box side (default 1)
  46009. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  46010. * * 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)
  46011. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  46012. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46013. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  46014. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46015. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  46016. * @param name defines the name of the mesh
  46017. * @param options defines the options used to create the mesh
  46018. * @param scene defines the hosting scene
  46019. * @returns the box mesh
  46020. */
  46021. static CreateBox(name: string, options: {
  46022. size?: number;
  46023. width?: number;
  46024. height?: number;
  46025. depth?: number;
  46026. faceUV?: Vector4[];
  46027. faceColors?: Color4[];
  46028. sideOrientation?: number;
  46029. frontUVs?: Vector4;
  46030. backUVs?: Vector4;
  46031. wrap?: boolean;
  46032. topBaseAt?: number;
  46033. bottomBaseAt?: number;
  46034. updatable?: boolean;
  46035. }, scene?: Nullable<Scene>): Mesh;
  46036. }
  46037. }
  46038. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  46039. import { Vector4 } from "babylonjs/Maths/math.vector";
  46040. import { Mesh } from "babylonjs/Meshes/mesh";
  46041. import { Scene } from "babylonjs/scene";
  46042. import { Nullable } from "babylonjs/types";
  46043. /**
  46044. * Class containing static functions to help procedurally build meshes
  46045. */
  46046. export class SphereBuilder {
  46047. /**
  46048. * Creates a sphere mesh
  46049. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  46050. * * 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`)
  46051. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  46052. * * 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
  46053. * * 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)
  46054. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46055. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  46056. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46057. * @param name defines the name of the mesh
  46058. * @param options defines the options used to create the mesh
  46059. * @param scene defines the hosting scene
  46060. * @returns the sphere mesh
  46061. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  46062. */
  46063. static CreateSphere(name: string, options: {
  46064. segments?: number;
  46065. diameter?: number;
  46066. diameterX?: number;
  46067. diameterY?: number;
  46068. diameterZ?: number;
  46069. arc?: number;
  46070. slice?: number;
  46071. sideOrientation?: number;
  46072. frontUVs?: Vector4;
  46073. backUVs?: Vector4;
  46074. updatable?: boolean;
  46075. }, scene?: Nullable<Scene>): Mesh;
  46076. }
  46077. }
  46078. declare module "babylonjs/Debug/physicsViewer" {
  46079. import { Nullable } from "babylonjs/types";
  46080. import { Scene } from "babylonjs/scene";
  46081. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46082. import { Mesh } from "babylonjs/Meshes/mesh";
  46083. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  46084. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  46085. /**
  46086. * Used to show the physics impostor around the specific mesh
  46087. */
  46088. export class PhysicsViewer {
  46089. /** @hidden */
  46090. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  46091. /** @hidden */
  46092. protected _meshes: Array<Nullable<AbstractMesh>>;
  46093. /** @hidden */
  46094. protected _scene: Nullable<Scene>;
  46095. /** @hidden */
  46096. protected _numMeshes: number;
  46097. /** @hidden */
  46098. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  46099. private _renderFunction;
  46100. private _utilityLayer;
  46101. private _debugBoxMesh;
  46102. private _debugSphereMesh;
  46103. private _debugCylinderMesh;
  46104. private _debugMaterial;
  46105. private _debugMeshMeshes;
  46106. /**
  46107. * Creates a new PhysicsViewer
  46108. * @param scene defines the hosting scene
  46109. */
  46110. constructor(scene: Scene);
  46111. /** @hidden */
  46112. protected _updateDebugMeshes(): void;
  46113. /**
  46114. * Renders a specified physic impostor
  46115. * @param impostor defines the impostor to render
  46116. * @param targetMesh defines the mesh represented by the impostor
  46117. * @returns the new debug mesh used to render the impostor
  46118. */
  46119. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  46120. /**
  46121. * Hides a specified physic impostor
  46122. * @param impostor defines the impostor to hide
  46123. */
  46124. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  46125. private _getDebugMaterial;
  46126. private _getDebugBoxMesh;
  46127. private _getDebugSphereMesh;
  46128. private _getDebugCylinderMesh;
  46129. private _getDebugMeshMesh;
  46130. private _getDebugMesh;
  46131. /** Releases all resources */
  46132. dispose(): void;
  46133. }
  46134. }
  46135. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  46136. import { Vector3 } from "babylonjs/Maths/math.vector";
  46137. import { Color4 } from "babylonjs/Maths/math.color";
  46138. import { Nullable } from "babylonjs/types";
  46139. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  46140. import { Scene } from "babylonjs/scene";
  46141. /**
  46142. * Class containing static functions to help procedurally build meshes
  46143. */
  46144. export class LinesBuilder {
  46145. /**
  46146. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  46147. * * 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
  46148. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  46149. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  46150. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  46151. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  46152. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46153. * * 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
  46154. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  46155. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46156. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  46157. * @param name defines the name of the new line system
  46158. * @param options defines the options used to create the line system
  46159. * @param scene defines the hosting scene
  46160. * @returns a new line system mesh
  46161. */
  46162. static CreateLineSystem(name: string, options: {
  46163. lines: Vector3[][];
  46164. updatable?: boolean;
  46165. instance?: Nullable<LinesMesh>;
  46166. colors?: Nullable<Color4[][]>;
  46167. useVertexAlpha?: boolean;
  46168. }, scene: Nullable<Scene>): LinesMesh;
  46169. /**
  46170. * Creates a line mesh
  46171. * 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
  46172. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46173. * * The parameter `points` is an array successive Vector3
  46174. * * 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
  46175. * * The optional parameter `colors` is an array of successive Color4, one per line point
  46176. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  46177. * * When updating an instance, remember that only point positions can change, not the number of points
  46178. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46179. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  46180. * @param name defines the name of the new line system
  46181. * @param options defines the options used to create the line system
  46182. * @param scene defines the hosting scene
  46183. * @returns a new line mesh
  46184. */
  46185. static CreateLines(name: string, options: {
  46186. points: Vector3[];
  46187. updatable?: boolean;
  46188. instance?: Nullable<LinesMesh>;
  46189. colors?: Color4[];
  46190. useVertexAlpha?: boolean;
  46191. }, scene?: Nullable<Scene>): LinesMesh;
  46192. /**
  46193. * Creates a dashed line mesh
  46194. * * 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
  46195. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46196. * * The parameter `points` is an array successive Vector3
  46197. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  46198. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  46199. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  46200. * * 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
  46201. * * When updating an instance, remember that only point positions can change, not the number of points
  46202. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46203. * @param name defines the name of the mesh
  46204. * @param options defines the options used to create the mesh
  46205. * @param scene defines the hosting scene
  46206. * @returns the dashed line mesh
  46207. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  46208. */
  46209. static CreateDashedLines(name: string, options: {
  46210. points: Vector3[];
  46211. dashSize?: number;
  46212. gapSize?: number;
  46213. dashNb?: number;
  46214. updatable?: boolean;
  46215. instance?: LinesMesh;
  46216. }, scene?: Nullable<Scene>): LinesMesh;
  46217. }
  46218. }
  46219. declare module "babylonjs/Debug/rayHelper" {
  46220. import { Nullable } from "babylonjs/types";
  46221. import { Ray } from "babylonjs/Culling/ray";
  46222. import { Vector3 } from "babylonjs/Maths/math.vector";
  46223. import { Color3 } from "babylonjs/Maths/math.color";
  46224. import { Scene } from "babylonjs/scene";
  46225. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46226. import "babylonjs/Meshes/Builders/linesBuilder";
  46227. /**
  46228. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46229. * in order to better appreciate the issue one might have.
  46230. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46231. */
  46232. export class RayHelper {
  46233. /**
  46234. * Defines the ray we are currently tryin to visualize.
  46235. */
  46236. ray: Nullable<Ray>;
  46237. private _renderPoints;
  46238. private _renderLine;
  46239. private _renderFunction;
  46240. private _scene;
  46241. private _updateToMeshFunction;
  46242. private _attachedToMesh;
  46243. private _meshSpaceDirection;
  46244. private _meshSpaceOrigin;
  46245. /**
  46246. * Helper function to create a colored helper in a scene in one line.
  46247. * @param ray Defines the ray we are currently tryin to visualize
  46248. * @param scene Defines the scene the ray is used in
  46249. * @param color Defines the color we want to see the ray in
  46250. * @returns The newly created ray helper.
  46251. */
  46252. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  46253. /**
  46254. * Instantiate a new ray helper.
  46255. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46256. * in order to better appreciate the issue one might have.
  46257. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46258. * @param ray Defines the ray we are currently tryin to visualize
  46259. */
  46260. constructor(ray: Ray);
  46261. /**
  46262. * Shows the ray we are willing to debug.
  46263. * @param scene Defines the scene the ray needs to be rendered in
  46264. * @param color Defines the color the ray needs to be rendered in
  46265. */
  46266. show(scene: Scene, color?: Color3): void;
  46267. /**
  46268. * Hides the ray we are debugging.
  46269. */
  46270. hide(): void;
  46271. private _render;
  46272. /**
  46273. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  46274. * @param mesh Defines the mesh we want the helper attached to
  46275. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  46276. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  46277. * @param length Defines the length of the ray
  46278. */
  46279. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  46280. /**
  46281. * Detach the ray helper from the mesh it has previously been attached to.
  46282. */
  46283. detachFromMesh(): void;
  46284. private _updateToMesh;
  46285. /**
  46286. * Dispose the helper and release its associated resources.
  46287. */
  46288. dispose(): void;
  46289. }
  46290. }
  46291. declare module "babylonjs/Debug/skeletonViewer" {
  46292. import { Color3 } from "babylonjs/Maths/math.color";
  46293. import { Scene } from "babylonjs/scene";
  46294. import { Nullable } from "babylonjs/types";
  46295. import { Skeleton } from "babylonjs/Bones/skeleton";
  46296. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46297. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  46298. /**
  46299. * Class used to render a debug view of a given skeleton
  46300. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  46301. */
  46302. export class SkeletonViewer {
  46303. /** defines the skeleton to render */
  46304. skeleton: Skeleton;
  46305. /** defines the mesh attached to the skeleton */
  46306. mesh: AbstractMesh;
  46307. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46308. autoUpdateBonesMatrices: boolean;
  46309. /** defines the rendering group id to use with the viewer */
  46310. renderingGroupId: number;
  46311. /** Gets or sets the color used to render the skeleton */
  46312. color: Color3;
  46313. private _scene;
  46314. private _debugLines;
  46315. private _debugMesh;
  46316. private _isEnabled;
  46317. private _renderFunction;
  46318. private _utilityLayer;
  46319. /**
  46320. * Returns the mesh used to render the bones
  46321. */
  46322. readonly debugMesh: Nullable<LinesMesh>;
  46323. /**
  46324. * Creates a new SkeletonViewer
  46325. * @param skeleton defines the skeleton to render
  46326. * @param mesh defines the mesh attached to the skeleton
  46327. * @param scene defines the hosting scene
  46328. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  46329. * @param renderingGroupId defines the rendering group id to use with the viewer
  46330. */
  46331. constructor(
  46332. /** defines the skeleton to render */
  46333. skeleton: Skeleton,
  46334. /** defines the mesh attached to the skeleton */
  46335. mesh: AbstractMesh, scene: Scene,
  46336. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46337. autoUpdateBonesMatrices?: boolean,
  46338. /** defines the rendering group id to use with the viewer */
  46339. renderingGroupId?: number);
  46340. /** Gets or sets a boolean indicating if the viewer is enabled */
  46341. isEnabled: boolean;
  46342. private _getBonePosition;
  46343. private _getLinesForBonesWithLength;
  46344. private _getLinesForBonesNoLength;
  46345. /** Update the viewer to sync with current skeleton state */
  46346. update(): void;
  46347. /** Release associated resources */
  46348. dispose(): void;
  46349. }
  46350. }
  46351. declare module "babylonjs/Debug/index" {
  46352. export * from "babylonjs/Debug/axesViewer";
  46353. export * from "babylonjs/Debug/boneAxesViewer";
  46354. export * from "babylonjs/Debug/debugLayer";
  46355. export * from "babylonjs/Debug/physicsViewer";
  46356. export * from "babylonjs/Debug/rayHelper";
  46357. export * from "babylonjs/Debug/skeletonViewer";
  46358. }
  46359. declare module "babylonjs/Engines/nullEngine" {
  46360. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  46361. import { Scene } from "babylonjs/scene";
  46362. import { Engine } from "babylonjs/Engines/engine";
  46363. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  46364. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  46365. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46366. import { Effect } from "babylonjs/Materials/effect";
  46367. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  46368. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46369. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  46370. /**
  46371. * Options to create the null engine
  46372. */
  46373. export class NullEngineOptions {
  46374. /**
  46375. * Render width (Default: 512)
  46376. */
  46377. renderWidth: number;
  46378. /**
  46379. * Render height (Default: 256)
  46380. */
  46381. renderHeight: number;
  46382. /**
  46383. * Texture size (Default: 512)
  46384. */
  46385. textureSize: number;
  46386. /**
  46387. * If delta time between frames should be constant
  46388. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46389. */
  46390. deterministicLockstep: boolean;
  46391. /**
  46392. * Maximum about of steps between frames (Default: 4)
  46393. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46394. */
  46395. lockstepMaxSteps: number;
  46396. }
  46397. /**
  46398. * The null engine class provides support for headless version of babylon.js.
  46399. * This can be used in server side scenario or for testing purposes
  46400. */
  46401. export class NullEngine extends Engine {
  46402. private _options;
  46403. /**
  46404. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  46405. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46406. * @returns true if engine is in deterministic lock step mode
  46407. */
  46408. isDeterministicLockStep(): boolean;
  46409. /**
  46410. * Gets the max steps when engine is running in deterministic lock step
  46411. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46412. * @returns the max steps
  46413. */
  46414. getLockstepMaxSteps(): number;
  46415. /**
  46416. * Gets the current hardware scaling level.
  46417. * By default the hardware scaling level is computed from the window device ratio.
  46418. * 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.
  46419. * @returns a number indicating the current hardware scaling level
  46420. */
  46421. getHardwareScalingLevel(): number;
  46422. constructor(options?: NullEngineOptions);
  46423. /**
  46424. * Creates a vertex buffer
  46425. * @param vertices the data for the vertex buffer
  46426. * @returns the new WebGL static buffer
  46427. */
  46428. createVertexBuffer(vertices: FloatArray): DataBuffer;
  46429. /**
  46430. * Creates a new index buffer
  46431. * @param indices defines the content of the index buffer
  46432. * @param updatable defines if the index buffer must be updatable
  46433. * @returns a new webGL buffer
  46434. */
  46435. createIndexBuffer(indices: IndicesArray): DataBuffer;
  46436. /**
  46437. * Clear the current render buffer or the current render target (if any is set up)
  46438. * @param color defines the color to use
  46439. * @param backBuffer defines if the back buffer must be cleared
  46440. * @param depth defines if the depth buffer must be cleared
  46441. * @param stencil defines if the stencil buffer must be cleared
  46442. */
  46443. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46444. /**
  46445. * Gets the current render width
  46446. * @param useScreen defines if screen size must be used (or the current render target if any)
  46447. * @returns a number defining the current render width
  46448. */
  46449. getRenderWidth(useScreen?: boolean): number;
  46450. /**
  46451. * Gets the current render height
  46452. * @param useScreen defines if screen size must be used (or the current render target if any)
  46453. * @returns a number defining the current render height
  46454. */
  46455. getRenderHeight(useScreen?: boolean): number;
  46456. /**
  46457. * Set the WebGL's viewport
  46458. * @param viewport defines the viewport element to be used
  46459. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  46460. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  46461. */
  46462. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  46463. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  46464. /**
  46465. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  46466. * @param pipelineContext defines the pipeline context to use
  46467. * @param uniformsNames defines the list of uniform names
  46468. * @returns an array of webGL uniform locations
  46469. */
  46470. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  46471. /**
  46472. * Gets the lsit of active attributes for a given webGL program
  46473. * @param pipelineContext defines the pipeline context to use
  46474. * @param attributesNames defines the list of attribute names to get
  46475. * @returns an array of indices indicating the offset of each attribute
  46476. */
  46477. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46478. /**
  46479. * Binds an effect to the webGL context
  46480. * @param effect defines the effect to bind
  46481. */
  46482. bindSamplers(effect: Effect): void;
  46483. /**
  46484. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  46485. * @param effect defines the effect to activate
  46486. */
  46487. enableEffect(effect: Effect): void;
  46488. /**
  46489. * Set various states to the webGL context
  46490. * @param culling defines backface culling state
  46491. * @param zOffset defines the value to apply to zOffset (0 by default)
  46492. * @param force defines if states must be applied even if cache is up to date
  46493. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  46494. */
  46495. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46496. /**
  46497. * Set the value of an uniform to an array of int32
  46498. * @param uniform defines the webGL uniform location where to store the value
  46499. * @param array defines the array of int32 to store
  46500. */
  46501. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46502. /**
  46503. * Set the value of an uniform to an array of int32 (stored as vec2)
  46504. * @param uniform defines the webGL uniform location where to store the value
  46505. * @param array defines the array of int32 to store
  46506. */
  46507. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46508. /**
  46509. * Set the value of an uniform to an array of int32 (stored as vec3)
  46510. * @param uniform defines the webGL uniform location where to store the value
  46511. * @param array defines the array of int32 to store
  46512. */
  46513. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46514. /**
  46515. * Set the value of an uniform to an array of int32 (stored as vec4)
  46516. * @param uniform defines the webGL uniform location where to store the value
  46517. * @param array defines the array of int32 to store
  46518. */
  46519. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46520. /**
  46521. * Set the value of an uniform to an array of float32
  46522. * @param uniform defines the webGL uniform location where to store the value
  46523. * @param array defines the array of float32 to store
  46524. */
  46525. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46526. /**
  46527. * Set the value of an uniform to an array of float32 (stored as vec2)
  46528. * @param uniform defines the webGL uniform location where to store the value
  46529. * @param array defines the array of float32 to store
  46530. */
  46531. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46532. /**
  46533. * Set the value of an uniform to an array of float32 (stored as vec3)
  46534. * @param uniform defines the webGL uniform location where to store the value
  46535. * @param array defines the array of float32 to store
  46536. */
  46537. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  46538. /**
  46539. * Set the value of an uniform to an array of float32 (stored as vec4)
  46540. * @param uniform defines the webGL uniform location where to store the value
  46541. * @param array defines the array of float32 to store
  46542. */
  46543. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  46544. /**
  46545. * Set the value of an uniform to an array of number
  46546. * @param uniform defines the webGL uniform location where to store the value
  46547. * @param array defines the array of number to store
  46548. */
  46549. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  46550. /**
  46551. * Set the value of an uniform to an array of number (stored as vec2)
  46552. * @param uniform defines the webGL uniform location where to store the value
  46553. * @param array defines the array of number to store
  46554. */
  46555. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  46556. /**
  46557. * Set the value of an uniform to an array of number (stored as vec3)
  46558. * @param uniform defines the webGL uniform location where to store the value
  46559. * @param array defines the array of number to store
  46560. */
  46561. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  46562. /**
  46563. * Set the value of an uniform to an array of number (stored as vec4)
  46564. * @param uniform defines the webGL uniform location where to store the value
  46565. * @param array defines the array of number to store
  46566. */
  46567. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  46568. /**
  46569. * Set the value of an uniform to an array of float32 (stored as matrices)
  46570. * @param uniform defines the webGL uniform location where to store the value
  46571. * @param matrices defines the array of float32 to store
  46572. */
  46573. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  46574. /**
  46575. * Set the value of an uniform to a matrix (3x3)
  46576. * @param uniform defines the webGL uniform location where to store the value
  46577. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  46578. */
  46579. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46580. /**
  46581. * Set the value of an uniform to a matrix (2x2)
  46582. * @param uniform defines the webGL uniform location where to store the value
  46583. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  46584. */
  46585. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46586. /**
  46587. * Set the value of an uniform to a number (float)
  46588. * @param uniform defines the webGL uniform location where to store the value
  46589. * @param value defines the float number to store
  46590. */
  46591. setFloat(uniform: WebGLUniformLocation, value: number): void;
  46592. /**
  46593. * Set the value of an uniform to a vec2
  46594. * @param uniform defines the webGL uniform location where to store the value
  46595. * @param x defines the 1st component of the value
  46596. * @param y defines the 2nd component of the value
  46597. */
  46598. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  46599. /**
  46600. * Set the value of an uniform to a vec3
  46601. * @param uniform defines the webGL uniform location where to store the value
  46602. * @param x defines the 1st component of the value
  46603. * @param y defines the 2nd component of the value
  46604. * @param z defines the 3rd component of the value
  46605. */
  46606. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  46607. /**
  46608. * Set the value of an uniform to a boolean
  46609. * @param uniform defines the webGL uniform location where to store the value
  46610. * @param bool defines the boolean to store
  46611. */
  46612. setBool(uniform: WebGLUniformLocation, bool: number): void;
  46613. /**
  46614. * Set the value of an uniform to a vec4
  46615. * @param uniform defines the webGL uniform location where to store the value
  46616. * @param x defines the 1st component of the value
  46617. * @param y defines the 2nd component of the value
  46618. * @param z defines the 3rd component of the value
  46619. * @param w defines the 4th component of the value
  46620. */
  46621. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  46622. /**
  46623. * Sets the current alpha mode
  46624. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  46625. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46626. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46627. */
  46628. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46629. /**
  46630. * Bind webGl buffers directly to the webGL context
  46631. * @param vertexBuffers defines the vertex buffer to bind
  46632. * @param indexBuffer defines the index buffer to bind
  46633. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  46634. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  46635. * @param effect defines the effect associated with the vertex buffer
  46636. */
  46637. bindBuffers(vertexBuffers: {
  46638. [key: string]: VertexBuffer;
  46639. }, indexBuffer: DataBuffer, effect: Effect): void;
  46640. /**
  46641. * Force the entire cache to be cleared
  46642. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  46643. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  46644. */
  46645. wipeCaches(bruteForce?: boolean): void;
  46646. /**
  46647. * Send a draw order
  46648. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  46649. * @param indexStart defines the starting index
  46650. * @param indexCount defines the number of index to draw
  46651. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46652. */
  46653. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  46654. /**
  46655. * Draw a list of indexed primitives
  46656. * @param fillMode defines the primitive to use
  46657. * @param indexStart defines the starting index
  46658. * @param indexCount defines the number of index to draw
  46659. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46660. */
  46661. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46662. /**
  46663. * Draw a list of unindexed primitives
  46664. * @param fillMode defines the primitive to use
  46665. * @param verticesStart defines the index of first vertex to draw
  46666. * @param verticesCount defines the count of vertices to draw
  46667. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46668. */
  46669. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46670. /** @hidden */
  46671. _createTexture(): WebGLTexture;
  46672. /** @hidden */
  46673. _releaseTexture(texture: InternalTexture): void;
  46674. /**
  46675. * Usually called from Texture.ts.
  46676. * Passed information to create a WebGLTexture
  46677. * @param urlArg defines a value which contains one of the following:
  46678. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46679. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46680. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46681. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46682. * @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)
  46683. * @param scene needed for loading to the correct scene
  46684. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  46685. * @param onLoad optional callback to be called upon successful completion
  46686. * @param onError optional callback to be called upon failure
  46687. * @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
  46688. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46689. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46690. * @param forcedExtension defines the extension to use to pick the right loader
  46691. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  46692. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46693. */
  46694. 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;
  46695. /**
  46696. * Creates a new render target texture
  46697. * @param size defines the size of the texture
  46698. * @param options defines the options used to create the texture
  46699. * @returns a new render target texture stored in an InternalTexture
  46700. */
  46701. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46702. /**
  46703. * Update the sampling mode of a given texture
  46704. * @param samplingMode defines the required sampling mode
  46705. * @param texture defines the texture to update
  46706. */
  46707. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46708. /**
  46709. * Binds the frame buffer to the specified texture.
  46710. * @param texture The texture to render to or null for the default canvas
  46711. * @param faceIndex The face of the texture to render to in case of cube texture
  46712. * @param requiredWidth The width of the target to render to
  46713. * @param requiredHeight The height of the target to render to
  46714. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  46715. * @param depthStencilTexture The depth stencil texture to use to render
  46716. * @param lodLevel defines le lod level to bind to the frame buffer
  46717. */
  46718. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46719. /**
  46720. * Unbind the current render target texture from the webGL context
  46721. * @param texture defines the render target texture to unbind
  46722. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46723. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46724. */
  46725. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46726. /**
  46727. * Creates a dynamic vertex buffer
  46728. * @param vertices the data for the dynamic vertex buffer
  46729. * @returns the new WebGL dynamic buffer
  46730. */
  46731. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  46732. /**
  46733. * Update the content of a dynamic texture
  46734. * @param texture defines the texture to update
  46735. * @param canvas defines the canvas containing the source
  46736. * @param invertY defines if data must be stored with Y axis inverted
  46737. * @param premulAlpha defines if alpha is stored as premultiplied
  46738. * @param format defines the format of the data
  46739. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  46740. */
  46741. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  46742. /**
  46743. * Gets a boolean indicating if all created effects are ready
  46744. * @returns true if all effects are ready
  46745. */
  46746. areAllEffectsReady(): boolean;
  46747. /**
  46748. * @hidden
  46749. * Get the current error code of the webGL context
  46750. * @returns the error code
  46751. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  46752. */
  46753. getError(): number;
  46754. /** @hidden */
  46755. _getUnpackAlignement(): number;
  46756. /** @hidden */
  46757. _unpackFlipY(value: boolean): void;
  46758. /**
  46759. * Update a dynamic index buffer
  46760. * @param indexBuffer defines the target index buffer
  46761. * @param indices defines the data to update
  46762. * @param offset defines the offset in the target index buffer where update should start
  46763. */
  46764. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  46765. /**
  46766. * Updates a dynamic vertex buffer.
  46767. * @param vertexBuffer the vertex buffer to update
  46768. * @param vertices the data used to update the vertex buffer
  46769. * @param byteOffset the byte offset of the data (optional)
  46770. * @param byteLength the byte length of the data (optional)
  46771. */
  46772. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  46773. /** @hidden */
  46774. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  46775. /** @hidden */
  46776. _bindTexture(channel: number, texture: InternalTexture): void;
  46777. protected _deleteBuffer(buffer: WebGLBuffer): void;
  46778. /**
  46779. * 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
  46780. */
  46781. releaseEffects(): void;
  46782. displayLoadingUI(): void;
  46783. hideLoadingUI(): void;
  46784. /** @hidden */
  46785. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46786. /** @hidden */
  46787. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46788. /** @hidden */
  46789. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46790. /** @hidden */
  46791. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46792. }
  46793. }
  46794. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  46795. import { Nullable, int } from "babylonjs/types";
  46796. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  46797. /** @hidden */
  46798. export class _OcclusionDataStorage {
  46799. /** @hidden */
  46800. occlusionInternalRetryCounter: number;
  46801. /** @hidden */
  46802. isOcclusionQueryInProgress: boolean;
  46803. /** @hidden */
  46804. isOccluded: boolean;
  46805. /** @hidden */
  46806. occlusionRetryCount: number;
  46807. /** @hidden */
  46808. occlusionType: number;
  46809. /** @hidden */
  46810. occlusionQueryAlgorithmType: number;
  46811. }
  46812. module "babylonjs/Engines/engine" {
  46813. interface Engine {
  46814. /**
  46815. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  46816. * @return the new query
  46817. */
  46818. createQuery(): WebGLQuery;
  46819. /**
  46820. * Delete and release a webGL query
  46821. * @param query defines the query to delete
  46822. * @return the current engine
  46823. */
  46824. deleteQuery(query: WebGLQuery): Engine;
  46825. /**
  46826. * Check if a given query has resolved and got its value
  46827. * @param query defines the query to check
  46828. * @returns true if the query got its value
  46829. */
  46830. isQueryResultAvailable(query: WebGLQuery): boolean;
  46831. /**
  46832. * Gets the value of a given query
  46833. * @param query defines the query to check
  46834. * @returns the value of the query
  46835. */
  46836. getQueryResult(query: WebGLQuery): number;
  46837. /**
  46838. * Initiates an occlusion query
  46839. * @param algorithmType defines the algorithm to use
  46840. * @param query defines the query to use
  46841. * @returns the current engine
  46842. * @see http://doc.babylonjs.com/features/occlusionquery
  46843. */
  46844. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  46845. /**
  46846. * Ends an occlusion query
  46847. * @see http://doc.babylonjs.com/features/occlusionquery
  46848. * @param algorithmType defines the algorithm to use
  46849. * @returns the current engine
  46850. */
  46851. endOcclusionQuery(algorithmType: number): Engine;
  46852. /**
  46853. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  46854. * Please note that only one query can be issued at a time
  46855. * @returns a time token used to track the time span
  46856. */
  46857. startTimeQuery(): Nullable<_TimeToken>;
  46858. /**
  46859. * Ends a time query
  46860. * @param token defines the token used to measure the time span
  46861. * @returns the time spent (in ns)
  46862. */
  46863. endTimeQuery(token: _TimeToken): int;
  46864. /** @hidden */
  46865. _currentNonTimestampToken: Nullable<_TimeToken>;
  46866. /** @hidden */
  46867. _createTimeQuery(): WebGLQuery;
  46868. /** @hidden */
  46869. _deleteTimeQuery(query: WebGLQuery): void;
  46870. /** @hidden */
  46871. _getGlAlgorithmType(algorithmType: number): number;
  46872. /** @hidden */
  46873. _getTimeQueryResult(query: WebGLQuery): any;
  46874. /** @hidden */
  46875. _getTimeQueryAvailability(query: WebGLQuery): any;
  46876. }
  46877. }
  46878. module "babylonjs/Meshes/abstractMesh" {
  46879. interface AbstractMesh {
  46880. /**
  46881. * Backing filed
  46882. * @hidden
  46883. */
  46884. __occlusionDataStorage: _OcclusionDataStorage;
  46885. /**
  46886. * Access property
  46887. * @hidden
  46888. */
  46889. _occlusionDataStorage: _OcclusionDataStorage;
  46890. /**
  46891. * 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.
  46892. * The default value is -1 which means don't break the query and wait till the result
  46893. * @see http://doc.babylonjs.com/features/occlusionquery
  46894. */
  46895. occlusionRetryCount: number;
  46896. /**
  46897. * 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:
  46898. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  46899. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  46900. * * 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.
  46901. * @see http://doc.babylonjs.com/features/occlusionquery
  46902. */
  46903. occlusionType: number;
  46904. /**
  46905. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  46906. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  46907. * * 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.
  46908. * @see http://doc.babylonjs.com/features/occlusionquery
  46909. */
  46910. occlusionQueryAlgorithmType: number;
  46911. /**
  46912. * 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
  46913. * @see http://doc.babylonjs.com/features/occlusionquery
  46914. */
  46915. isOccluded: boolean;
  46916. /**
  46917. * Flag to check the progress status of the query
  46918. * @see http://doc.babylonjs.com/features/occlusionquery
  46919. */
  46920. isOcclusionQueryInProgress: boolean;
  46921. }
  46922. }
  46923. }
  46924. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  46925. import { Nullable } from "babylonjs/types";
  46926. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46927. /** @hidden */
  46928. export var _forceTransformFeedbackToBundle: boolean;
  46929. module "babylonjs/Engines/engine" {
  46930. interface Engine {
  46931. /**
  46932. * Creates a webGL transform feedback object
  46933. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  46934. * @returns the webGL transform feedback object
  46935. */
  46936. createTransformFeedback(): WebGLTransformFeedback;
  46937. /**
  46938. * Delete a webGL transform feedback object
  46939. * @param value defines the webGL transform feedback object to delete
  46940. */
  46941. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  46942. /**
  46943. * Bind a webGL transform feedback object to the webgl context
  46944. * @param value defines the webGL transform feedback object to bind
  46945. */
  46946. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  46947. /**
  46948. * Begins a transform feedback operation
  46949. * @param usePoints defines if points or triangles must be used
  46950. */
  46951. beginTransformFeedback(usePoints: boolean): void;
  46952. /**
  46953. * Ends a transform feedback operation
  46954. */
  46955. endTransformFeedback(): void;
  46956. /**
  46957. * Specify the varyings to use with transform feedback
  46958. * @param program defines the associated webGL program
  46959. * @param value defines the list of strings representing the varying names
  46960. */
  46961. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  46962. /**
  46963. * Bind a webGL buffer for a transform feedback operation
  46964. * @param value defines the webGL buffer to bind
  46965. */
  46966. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  46967. }
  46968. }
  46969. }
  46970. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  46971. import { Scene } from "babylonjs/scene";
  46972. import { Engine } from "babylonjs/Engines/engine";
  46973. import { Texture } from "babylonjs/Materials/Textures/texture";
  46974. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  46975. import "babylonjs/Engines/Extensions/engine.multiRender";
  46976. /**
  46977. * Creation options of the multi render target texture.
  46978. */
  46979. export interface IMultiRenderTargetOptions {
  46980. /**
  46981. * Define if the texture needs to create mip maps after render.
  46982. */
  46983. generateMipMaps?: boolean;
  46984. /**
  46985. * Define the types of all the draw buffers we want to create
  46986. */
  46987. types?: number[];
  46988. /**
  46989. * Define the sampling modes of all the draw buffers we want to create
  46990. */
  46991. samplingModes?: number[];
  46992. /**
  46993. * Define if a depth buffer is required
  46994. */
  46995. generateDepthBuffer?: boolean;
  46996. /**
  46997. * Define if a stencil buffer is required
  46998. */
  46999. generateStencilBuffer?: boolean;
  47000. /**
  47001. * Define if a depth texture is required instead of a depth buffer
  47002. */
  47003. generateDepthTexture?: boolean;
  47004. /**
  47005. * Define the number of desired draw buffers
  47006. */
  47007. textureCount?: number;
  47008. /**
  47009. * Define if aspect ratio should be adapted to the texture or stay the scene one
  47010. */
  47011. doNotChangeAspectRatio?: boolean;
  47012. /**
  47013. * Define the default type of the buffers we are creating
  47014. */
  47015. defaultType?: number;
  47016. }
  47017. /**
  47018. * A multi render target, like a render target provides the ability to render to a texture.
  47019. * Unlike the render target, it can render to several draw buffers in one draw.
  47020. * This is specially interesting in deferred rendering or for any effects requiring more than
  47021. * just one color from a single pass.
  47022. */
  47023. export class MultiRenderTarget extends RenderTargetTexture {
  47024. private _internalTextures;
  47025. private _textures;
  47026. private _multiRenderTargetOptions;
  47027. /**
  47028. * Get if draw buffers are currently supported by the used hardware and browser.
  47029. */
  47030. readonly isSupported: boolean;
  47031. /**
  47032. * Get the list of textures generated by the multi render target.
  47033. */
  47034. readonly textures: Texture[];
  47035. /**
  47036. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  47037. */
  47038. readonly depthTexture: Texture;
  47039. /**
  47040. * Set the wrapping mode on U of all the textures we are rendering to.
  47041. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47042. */
  47043. wrapU: number;
  47044. /**
  47045. * Set the wrapping mode on V of all the textures we are rendering to.
  47046. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47047. */
  47048. wrapV: number;
  47049. /**
  47050. * Instantiate a new multi render target texture.
  47051. * A multi render target, like a render target provides the ability to render to a texture.
  47052. * Unlike the render target, it can render to several draw buffers in one draw.
  47053. * This is specially interesting in deferred rendering or for any effects requiring more than
  47054. * just one color from a single pass.
  47055. * @param name Define the name of the texture
  47056. * @param size Define the size of the buffers to render to
  47057. * @param count Define the number of target we are rendering into
  47058. * @param scene Define the scene the texture belongs to
  47059. * @param options Define the options used to create the multi render target
  47060. */
  47061. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  47062. /** @hidden */
  47063. _rebuild(): void;
  47064. private _createInternalTextures;
  47065. private _createTextures;
  47066. /**
  47067. * Define the number of samples used if MSAA is enabled.
  47068. */
  47069. samples: number;
  47070. /**
  47071. * Resize all the textures in the multi render target.
  47072. * Be carrefull as it will recreate all the data in the new texture.
  47073. * @param size Define the new size
  47074. */
  47075. resize(size: any): void;
  47076. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47077. /**
  47078. * Dispose the render targets and their associated resources
  47079. */
  47080. dispose(): void;
  47081. /**
  47082. * Release all the underlying texture used as draw buffers.
  47083. */
  47084. releaseInternalTextures(): void;
  47085. }
  47086. }
  47087. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  47088. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47089. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  47090. import { Nullable } from "babylonjs/types";
  47091. module "babylonjs/Engines/thinEngine" {
  47092. interface ThinEngine {
  47093. /**
  47094. * Unbind a list of render target textures from the webGL context
  47095. * This is used only when drawBuffer extension or webGL2 are active
  47096. * @param textures defines the render target textures to unbind
  47097. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47098. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47099. */
  47100. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  47101. /**
  47102. * Create a multi render target texture
  47103. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  47104. * @param size defines the size of the texture
  47105. * @param options defines the creation options
  47106. * @returns the cube texture as an InternalTexture
  47107. */
  47108. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  47109. /**
  47110. * Update the sample count for a given multiple render target texture
  47111. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  47112. * @param textures defines the textures to update
  47113. * @param samples defines the sample count to set
  47114. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  47115. */
  47116. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  47117. }
  47118. }
  47119. }
  47120. declare module "babylonjs/Engines/Extensions/engine.views" {
  47121. import { Camera } from "babylonjs/Cameras/camera";
  47122. import { Nullable } from "babylonjs/types";
  47123. /**
  47124. * Class used to define an additional view for the engine
  47125. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47126. */
  47127. export class EngineView {
  47128. /** Defines the canvas where to render the view */
  47129. target: HTMLCanvasElement;
  47130. /** Defines an optional camera used to render the view (will use active camera else) */
  47131. camera?: Camera;
  47132. }
  47133. module "babylonjs/Engines/engine" {
  47134. interface Engine {
  47135. /**
  47136. * Gets or sets the HTML element to use for attaching events
  47137. */
  47138. inputElement: Nullable<HTMLElement>;
  47139. /**
  47140. * Gets the current engine view
  47141. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47142. */
  47143. activeView: Nullable<EngineView>;
  47144. /** Gets or sets the list of views */
  47145. views: EngineView[];
  47146. /**
  47147. * Register a new child canvas
  47148. * @param canvas defines the canvas to register
  47149. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  47150. * @returns the associated view
  47151. */
  47152. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  47153. /**
  47154. * Remove a registered child canvas
  47155. * @param canvas defines the canvas to remove
  47156. * @returns the current engine
  47157. */
  47158. unRegisterView(canvas: HTMLCanvasElement): Engine;
  47159. }
  47160. }
  47161. }
  47162. declare module "babylonjs/Engines/Extensions/index" {
  47163. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  47164. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  47165. export * from "babylonjs/Engines/Extensions/engine.multiview";
  47166. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  47167. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  47168. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  47169. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  47170. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  47171. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  47172. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  47173. export * from "babylonjs/Engines/Extensions/engine.webVR";
  47174. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  47175. export * from "babylonjs/Engines/Extensions/engine.views";
  47176. }
  47177. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  47178. import { Nullable } from "babylonjs/types";
  47179. /**
  47180. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  47181. */
  47182. export interface CubeMapInfo {
  47183. /**
  47184. * The pixel array for the front face.
  47185. * This is stored in format, left to right, up to down format.
  47186. */
  47187. front: Nullable<ArrayBufferView>;
  47188. /**
  47189. * The pixel array for the back face.
  47190. * This is stored in format, left to right, up to down format.
  47191. */
  47192. back: Nullable<ArrayBufferView>;
  47193. /**
  47194. * The pixel array for the left face.
  47195. * This is stored in format, left to right, up to down format.
  47196. */
  47197. left: Nullable<ArrayBufferView>;
  47198. /**
  47199. * The pixel array for the right face.
  47200. * This is stored in format, left to right, up to down format.
  47201. */
  47202. right: Nullable<ArrayBufferView>;
  47203. /**
  47204. * The pixel array for the up face.
  47205. * This is stored in format, left to right, up to down format.
  47206. */
  47207. up: Nullable<ArrayBufferView>;
  47208. /**
  47209. * The pixel array for the down face.
  47210. * This is stored in format, left to right, up to down format.
  47211. */
  47212. down: Nullable<ArrayBufferView>;
  47213. /**
  47214. * The size of the cubemap stored.
  47215. *
  47216. * Each faces will be size * size pixels.
  47217. */
  47218. size: number;
  47219. /**
  47220. * The format of the texture.
  47221. *
  47222. * RGBA, RGB.
  47223. */
  47224. format: number;
  47225. /**
  47226. * The type of the texture data.
  47227. *
  47228. * UNSIGNED_INT, FLOAT.
  47229. */
  47230. type: number;
  47231. /**
  47232. * Specifies whether the texture is in gamma space.
  47233. */
  47234. gammaSpace: boolean;
  47235. }
  47236. /**
  47237. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  47238. */
  47239. export class PanoramaToCubeMapTools {
  47240. private static FACE_FRONT;
  47241. private static FACE_BACK;
  47242. private static FACE_RIGHT;
  47243. private static FACE_LEFT;
  47244. private static FACE_DOWN;
  47245. private static FACE_UP;
  47246. /**
  47247. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  47248. *
  47249. * @param float32Array The source data.
  47250. * @param inputWidth The width of the input panorama.
  47251. * @param inputHeight The height of the input panorama.
  47252. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  47253. * @return The cubemap data
  47254. */
  47255. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  47256. private static CreateCubemapTexture;
  47257. private static CalcProjectionSpherical;
  47258. }
  47259. }
  47260. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  47261. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47262. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47263. import { Nullable } from "babylonjs/types";
  47264. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  47265. /**
  47266. * Helper class dealing with the extraction of spherical polynomial dataArray
  47267. * from a cube map.
  47268. */
  47269. export class CubeMapToSphericalPolynomialTools {
  47270. private static FileFaces;
  47271. /**
  47272. * Converts a texture to the according Spherical Polynomial data.
  47273. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47274. *
  47275. * @param texture The texture to extract the information from.
  47276. * @return The Spherical Polynomial data.
  47277. */
  47278. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  47279. /**
  47280. * Converts a cubemap to the according Spherical Polynomial data.
  47281. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47282. *
  47283. * @param cubeInfo The Cube map to extract the information from.
  47284. * @return The Spherical Polynomial data.
  47285. */
  47286. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  47287. }
  47288. }
  47289. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  47290. import { Nullable } from "babylonjs/types";
  47291. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47292. module "babylonjs/Materials/Textures/baseTexture" {
  47293. interface BaseTexture {
  47294. /**
  47295. * Get the polynomial representation of the texture data.
  47296. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  47297. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  47298. */
  47299. sphericalPolynomial: Nullable<SphericalPolynomial>;
  47300. }
  47301. }
  47302. }
  47303. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  47304. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47305. /** @hidden */
  47306. export var rgbdEncodePixelShader: {
  47307. name: string;
  47308. shader: string;
  47309. };
  47310. }
  47311. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  47312. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47313. /** @hidden */
  47314. export var rgbdDecodePixelShader: {
  47315. name: string;
  47316. shader: string;
  47317. };
  47318. }
  47319. declare module "babylonjs/Misc/environmentTextureTools" {
  47320. import { Nullable } from "babylonjs/types";
  47321. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47322. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47323. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  47324. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  47325. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  47326. import "babylonjs/Shaders/rgbdEncode.fragment";
  47327. import "babylonjs/Shaders/rgbdDecode.fragment";
  47328. /**
  47329. * Raw texture data and descriptor sufficient for WebGL texture upload
  47330. */
  47331. export interface EnvironmentTextureInfo {
  47332. /**
  47333. * Version of the environment map
  47334. */
  47335. version: number;
  47336. /**
  47337. * Width of image
  47338. */
  47339. width: number;
  47340. /**
  47341. * Irradiance information stored in the file.
  47342. */
  47343. irradiance: any;
  47344. /**
  47345. * Specular information stored in the file.
  47346. */
  47347. specular: any;
  47348. }
  47349. /**
  47350. * Defines One Image in the file. It requires only the position in the file
  47351. * as well as the length.
  47352. */
  47353. interface BufferImageData {
  47354. /**
  47355. * Length of the image data.
  47356. */
  47357. length: number;
  47358. /**
  47359. * Position of the data from the null terminator delimiting the end of the JSON.
  47360. */
  47361. position: number;
  47362. }
  47363. /**
  47364. * Defines the specular data enclosed in the file.
  47365. * This corresponds to the version 1 of the data.
  47366. */
  47367. export interface EnvironmentTextureSpecularInfoV1 {
  47368. /**
  47369. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  47370. */
  47371. specularDataPosition?: number;
  47372. /**
  47373. * This contains all the images data needed to reconstruct the cubemap.
  47374. */
  47375. mipmaps: Array<BufferImageData>;
  47376. /**
  47377. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  47378. */
  47379. lodGenerationScale: number;
  47380. }
  47381. /**
  47382. * Sets of helpers addressing the serialization and deserialization of environment texture
  47383. * stored in a BabylonJS env file.
  47384. * Those files are usually stored as .env files.
  47385. */
  47386. export class EnvironmentTextureTools {
  47387. /**
  47388. * Magic number identifying the env file.
  47389. */
  47390. private static _MagicBytes;
  47391. /**
  47392. * Gets the environment info from an env file.
  47393. * @param data The array buffer containing the .env bytes.
  47394. * @returns the environment file info (the json header) if successfully parsed.
  47395. */
  47396. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  47397. /**
  47398. * Creates an environment texture from a loaded cube texture.
  47399. * @param texture defines the cube texture to convert in env file
  47400. * @return a promise containing the environment data if succesfull.
  47401. */
  47402. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47403. /**
  47404. * Creates a JSON representation of the spherical data.
  47405. * @param texture defines the texture containing the polynomials
  47406. * @return the JSON representation of the spherical info
  47407. */
  47408. private static _CreateEnvTextureIrradiance;
  47409. /**
  47410. * Creates the ArrayBufferViews used for initializing environment texture image data.
  47411. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  47412. * @param info parameters that determine what views will be created for accessing the underlying buffer
  47413. * @return the views described by info providing access to the underlying buffer
  47414. */
  47415. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  47416. /**
  47417. * Uploads the texture info contained in the env file to the GPU.
  47418. * @param texture defines the internal texture to upload to
  47419. * @param arrayBuffer defines the buffer cotaining the data to load
  47420. * @param info defines the texture info retrieved through the GetEnvInfo method
  47421. * @returns a promise
  47422. */
  47423. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  47424. private static _OnImageReadyAsync;
  47425. /**
  47426. * Uploads the levels of image data to the GPU.
  47427. * @param texture defines the internal texture to upload to
  47428. * @param imageData defines the array buffer views of image data [mipmap][face]
  47429. * @returns a promise
  47430. */
  47431. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47432. /**
  47433. * Uploads spherical polynomials information to the texture.
  47434. * @param texture defines the texture we are trying to upload the information to
  47435. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47436. */
  47437. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47438. /** @hidden */
  47439. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47440. }
  47441. }
  47442. declare module "babylonjs/Maths/math.vertexFormat" {
  47443. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  47444. /**
  47445. * Contains position and normal vectors for a vertex
  47446. */
  47447. export class PositionNormalVertex {
  47448. /** the position of the vertex (defaut: 0,0,0) */
  47449. position: Vector3;
  47450. /** the normal of the vertex (defaut: 0,1,0) */
  47451. normal: Vector3;
  47452. /**
  47453. * Creates a PositionNormalVertex
  47454. * @param position the position of the vertex (defaut: 0,0,0)
  47455. * @param normal the normal of the vertex (defaut: 0,1,0)
  47456. */
  47457. constructor(
  47458. /** the position of the vertex (defaut: 0,0,0) */
  47459. position?: Vector3,
  47460. /** the normal of the vertex (defaut: 0,1,0) */
  47461. normal?: Vector3);
  47462. /**
  47463. * Clones the PositionNormalVertex
  47464. * @returns the cloned PositionNormalVertex
  47465. */
  47466. clone(): PositionNormalVertex;
  47467. }
  47468. /**
  47469. * Contains position, normal and uv vectors for a vertex
  47470. */
  47471. export class PositionNormalTextureVertex {
  47472. /** the position of the vertex (defaut: 0,0,0) */
  47473. position: Vector3;
  47474. /** the normal of the vertex (defaut: 0,1,0) */
  47475. normal: Vector3;
  47476. /** the uv of the vertex (default: 0,0) */
  47477. uv: Vector2;
  47478. /**
  47479. * Creates a PositionNormalTextureVertex
  47480. * @param position the position of the vertex (defaut: 0,0,0)
  47481. * @param normal the normal of the vertex (defaut: 0,1,0)
  47482. * @param uv the uv of the vertex (default: 0,0)
  47483. */
  47484. constructor(
  47485. /** the position of the vertex (defaut: 0,0,0) */
  47486. position?: Vector3,
  47487. /** the normal of the vertex (defaut: 0,1,0) */
  47488. normal?: Vector3,
  47489. /** the uv of the vertex (default: 0,0) */
  47490. uv?: Vector2);
  47491. /**
  47492. * Clones the PositionNormalTextureVertex
  47493. * @returns the cloned PositionNormalTextureVertex
  47494. */
  47495. clone(): PositionNormalTextureVertex;
  47496. }
  47497. }
  47498. declare module "babylonjs/Maths/math" {
  47499. export * from "babylonjs/Maths/math.axis";
  47500. export * from "babylonjs/Maths/math.color";
  47501. export * from "babylonjs/Maths/math.constants";
  47502. export * from "babylonjs/Maths/math.frustum";
  47503. export * from "babylonjs/Maths/math.path";
  47504. export * from "babylonjs/Maths/math.plane";
  47505. export * from "babylonjs/Maths/math.size";
  47506. export * from "babylonjs/Maths/math.vector";
  47507. export * from "babylonjs/Maths/math.vertexFormat";
  47508. export * from "babylonjs/Maths/math.viewport";
  47509. }
  47510. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  47511. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  47512. /** @hidden */
  47513. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  47514. private _genericAttributeLocation;
  47515. private _varyingLocationCount;
  47516. private _varyingLocationMap;
  47517. private _replacements;
  47518. private _textureCount;
  47519. private _uniforms;
  47520. lineProcessor(line: string): string;
  47521. attributeProcessor(attribute: string): string;
  47522. varyingProcessor(varying: string, isFragment: boolean): string;
  47523. uniformProcessor(uniform: string): string;
  47524. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  47525. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  47526. }
  47527. }
  47528. declare module "babylonjs/Engines/nativeEngine" {
  47529. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  47530. import { Engine } from "babylonjs/Engines/engine";
  47531. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  47532. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47533. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47534. import { Effect } from "babylonjs/Materials/effect";
  47535. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  47536. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  47537. import { IColor4Like } from "babylonjs/Maths/math.like";
  47538. import { Scene } from "babylonjs/scene";
  47539. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  47540. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  47541. /**
  47542. * Container for accessors for natively-stored mesh data buffers.
  47543. */
  47544. class NativeDataBuffer extends DataBuffer {
  47545. /**
  47546. * Accessor value used to identify/retrieve a natively-stored index buffer.
  47547. */
  47548. nativeIndexBuffer?: any;
  47549. /**
  47550. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  47551. */
  47552. nativeVertexBuffer?: any;
  47553. }
  47554. /** @hidden */
  47555. class NativeTexture extends InternalTexture {
  47556. getInternalTexture(): InternalTexture;
  47557. getViewCount(): number;
  47558. }
  47559. /** @hidden */
  47560. export class NativeEngine extends Engine {
  47561. private readonly _native;
  47562. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  47563. private readonly INVALID_HANDLE;
  47564. getHardwareScalingLevel(): number;
  47565. constructor();
  47566. /**
  47567. * Can be used to override the current requestAnimationFrame requester.
  47568. * @hidden
  47569. */
  47570. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  47571. /**
  47572. * Override default engine behavior.
  47573. * @param color
  47574. * @param backBuffer
  47575. * @param depth
  47576. * @param stencil
  47577. */
  47578. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  47579. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  47580. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  47581. createVertexBuffer(data: DataArray): NativeDataBuffer;
  47582. recordVertexArrayObject(vertexBuffers: {
  47583. [key: string]: VertexBuffer;
  47584. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  47585. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47586. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47587. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  47588. /**
  47589. * Draw a list of indexed primitives
  47590. * @param fillMode defines the primitive to use
  47591. * @param indexStart defines the starting index
  47592. * @param indexCount defines the number of index to draw
  47593. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47594. */
  47595. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47596. /**
  47597. * Draw a list of unindexed primitives
  47598. * @param fillMode defines the primitive to use
  47599. * @param verticesStart defines the index of first vertex to draw
  47600. * @param verticesCount defines the count of vertices to draw
  47601. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47602. */
  47603. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47604. createPipelineContext(): IPipelineContext;
  47605. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  47606. /** @hidden */
  47607. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  47608. /** @hidden */
  47609. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  47610. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47611. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47612. protected _setProgram(program: WebGLProgram): void;
  47613. _releaseEffect(effect: Effect): void;
  47614. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  47615. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  47616. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  47617. bindSamplers(effect: Effect): void;
  47618. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  47619. getRenderWidth(useScreen?: boolean): number;
  47620. getRenderHeight(useScreen?: boolean): number;
  47621. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  47622. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  47623. /**
  47624. * Set the z offset to apply to current rendering
  47625. * @param value defines the offset to apply
  47626. */
  47627. setZOffset(value: number): void;
  47628. /**
  47629. * Gets the current value of the zOffset
  47630. * @returns the current zOffset state
  47631. */
  47632. getZOffset(): number;
  47633. /**
  47634. * Enable or disable depth buffering
  47635. * @param enable defines the state to set
  47636. */
  47637. setDepthBuffer(enable: boolean): void;
  47638. /**
  47639. * Gets a boolean indicating if depth writing is enabled
  47640. * @returns the current depth writing state
  47641. */
  47642. getDepthWrite(): boolean;
  47643. /**
  47644. * Enable or disable depth writing
  47645. * @param enable defines the state to set
  47646. */
  47647. setDepthWrite(enable: boolean): void;
  47648. /**
  47649. * Enable or disable color writing
  47650. * @param enable defines the state to set
  47651. */
  47652. setColorWrite(enable: boolean): void;
  47653. /**
  47654. * Gets a boolean indicating if color writing is enabled
  47655. * @returns the current color writing state
  47656. */
  47657. getColorWrite(): boolean;
  47658. /**
  47659. * Sets alpha constants used by some alpha blending modes
  47660. * @param r defines the red component
  47661. * @param g defines the green component
  47662. * @param b defines the blue component
  47663. * @param a defines the alpha component
  47664. */
  47665. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  47666. /**
  47667. * Sets the current alpha mode
  47668. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  47669. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47670. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47671. */
  47672. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47673. /**
  47674. * Gets the current alpha mode
  47675. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47676. * @returns the current alpha mode
  47677. */
  47678. getAlphaMode(): number;
  47679. setInt(uniform: WebGLUniformLocation, int: number): void;
  47680. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  47681. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  47682. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  47683. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  47684. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  47685. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  47686. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  47687. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  47688. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  47689. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  47690. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  47691. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  47692. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  47693. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47694. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47695. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47696. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47697. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47698. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47699. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  47700. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  47701. wipeCaches(bruteForce?: boolean): void;
  47702. _createTexture(): WebGLTexture;
  47703. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  47704. /**
  47705. * Usually called from BABYLON.Texture.ts.
  47706. * Passed information to create a WebGLTexture
  47707. * @param urlArg defines a value which contains one of the following:
  47708. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47709. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47710. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47711. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47712. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  47713. * @param scene needed for loading to the correct scene
  47714. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  47715. * @param onLoad optional callback to be called upon successful completion
  47716. * @param onError optional callback to be called upon failure
  47717. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  47718. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47719. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47720. * @param forcedExtension defines the extension to use to pick the right loader
  47721. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47722. */
  47723. 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 | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>): InternalTexture;
  47724. /**
  47725. * Creates a cube texture
  47726. * @param rootUrl defines the url where the files to load is located
  47727. * @param scene defines the current scene
  47728. * @param files defines the list of files to load (1 per face)
  47729. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  47730. * @param onLoad defines an optional callback raised when the texture is loaded
  47731. * @param onError defines an optional callback raised if there is an issue to load the texture
  47732. * @param format defines the format of the data
  47733. * @param forcedExtension defines the extension to use to pick the right loader
  47734. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  47735. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  47736. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  47737. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  47738. * @returns the cube texture as an InternalTexture
  47739. */
  47740. 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, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>): InternalTexture;
  47741. private _getSamplingFilter;
  47742. private static _GetNativeTextureFormat;
  47743. createRenderTargetTexture(size: number | {
  47744. width: number;
  47745. height: number;
  47746. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  47747. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47748. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47749. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47750. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  47751. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  47752. /**
  47753. * Updates a dynamic vertex buffer.
  47754. * @param vertexBuffer the vertex buffer to update
  47755. * @param data the data used to update the vertex buffer
  47756. * @param byteOffset the byte offset of the data (optional)
  47757. * @param byteLength the byte length of the data (optional)
  47758. */
  47759. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  47760. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  47761. private _updateAnisotropicLevel;
  47762. private _getAddressMode;
  47763. /** @hidden */
  47764. _bindTexture(channel: number, texture: InternalTexture): void;
  47765. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  47766. releaseEffects(): void;
  47767. /** @hidden */
  47768. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47769. /** @hidden */
  47770. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47771. /** @hidden */
  47772. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47773. /** @hidden */
  47774. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47775. }
  47776. }
  47777. declare module "babylonjs/Engines/index" {
  47778. export * from "babylonjs/Engines/constants";
  47779. export * from "babylonjs/Engines/engineCapabilities";
  47780. export * from "babylonjs/Engines/instancingAttributeInfo";
  47781. export * from "babylonjs/Engines/thinEngine";
  47782. export * from "babylonjs/Engines/engine";
  47783. export * from "babylonjs/Engines/engineStore";
  47784. export * from "babylonjs/Engines/nullEngine";
  47785. export * from "babylonjs/Engines/Extensions/index";
  47786. export * from "babylonjs/Engines/IPipelineContext";
  47787. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  47788. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  47789. export * from "babylonjs/Engines/nativeEngine";
  47790. }
  47791. declare module "babylonjs/Events/clipboardEvents" {
  47792. /**
  47793. * Gather the list of clipboard event types as constants.
  47794. */
  47795. export class ClipboardEventTypes {
  47796. /**
  47797. * The clipboard event is fired when a copy command is active (pressed).
  47798. */
  47799. static readonly COPY: number;
  47800. /**
  47801. * The clipboard event is fired when a cut command is active (pressed).
  47802. */
  47803. static readonly CUT: number;
  47804. /**
  47805. * The clipboard event is fired when a paste command is active (pressed).
  47806. */
  47807. static readonly PASTE: number;
  47808. }
  47809. /**
  47810. * This class is used to store clipboard related info for the onClipboardObservable event.
  47811. */
  47812. export class ClipboardInfo {
  47813. /**
  47814. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47815. */
  47816. type: number;
  47817. /**
  47818. * Defines the related dom event
  47819. */
  47820. event: ClipboardEvent;
  47821. /**
  47822. *Creates an instance of ClipboardInfo.
  47823. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  47824. * @param event Defines the related dom event
  47825. */
  47826. constructor(
  47827. /**
  47828. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47829. */
  47830. type: number,
  47831. /**
  47832. * Defines the related dom event
  47833. */
  47834. event: ClipboardEvent);
  47835. /**
  47836. * Get the clipboard event's type from the keycode.
  47837. * @param keyCode Defines the keyCode for the current keyboard event.
  47838. * @return {number}
  47839. */
  47840. static GetTypeFromCharacter(keyCode: number): number;
  47841. }
  47842. }
  47843. declare module "babylonjs/Events/index" {
  47844. export * from "babylonjs/Events/keyboardEvents";
  47845. export * from "babylonjs/Events/pointerEvents";
  47846. export * from "babylonjs/Events/clipboardEvents";
  47847. }
  47848. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  47849. import { Scene } from "babylonjs/scene";
  47850. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47851. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  47852. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  47853. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  47854. /**
  47855. * Google Daydream controller
  47856. */
  47857. export class DaydreamController extends WebVRController {
  47858. /**
  47859. * Base Url for the controller model.
  47860. */
  47861. static MODEL_BASE_URL: string;
  47862. /**
  47863. * File name for the controller model.
  47864. */
  47865. static MODEL_FILENAME: string;
  47866. /**
  47867. * Gamepad Id prefix used to identify Daydream Controller.
  47868. */
  47869. static readonly GAMEPAD_ID_PREFIX: string;
  47870. /**
  47871. * Creates a new DaydreamController from a gamepad
  47872. * @param vrGamepad the gamepad that the controller should be created from
  47873. */
  47874. constructor(vrGamepad: any);
  47875. /**
  47876. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47877. * @param scene scene in which to add meshes
  47878. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47879. */
  47880. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47881. /**
  47882. * Called once for each button that changed state since the last frame
  47883. * @param buttonIdx Which button index changed
  47884. * @param state New state of the button
  47885. * @param changes Which properties on the state changed since last frame
  47886. */
  47887. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47888. }
  47889. }
  47890. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  47891. import { Scene } from "babylonjs/scene";
  47892. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47893. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  47894. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  47895. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  47896. /**
  47897. * Gear VR Controller
  47898. */
  47899. export class GearVRController extends WebVRController {
  47900. /**
  47901. * Base Url for the controller model.
  47902. */
  47903. static MODEL_BASE_URL: string;
  47904. /**
  47905. * File name for the controller model.
  47906. */
  47907. static MODEL_FILENAME: string;
  47908. /**
  47909. * Gamepad Id prefix used to identify this controller.
  47910. */
  47911. static readonly GAMEPAD_ID_PREFIX: string;
  47912. private readonly _buttonIndexToObservableNameMap;
  47913. /**
  47914. * Creates a new GearVRController from a gamepad
  47915. * @param vrGamepad the gamepad that the controller should be created from
  47916. */
  47917. constructor(vrGamepad: any);
  47918. /**
  47919. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47920. * @param scene scene in which to add meshes
  47921. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47922. */
  47923. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47924. /**
  47925. * Called once for each button that changed state since the last frame
  47926. * @param buttonIdx Which button index changed
  47927. * @param state New state of the button
  47928. * @param changes Which properties on the state changed since last frame
  47929. */
  47930. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47931. }
  47932. }
  47933. declare module "babylonjs/Gamepads/Controllers/index" {
  47934. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  47935. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  47936. export * from "babylonjs/Gamepads/Controllers/genericController";
  47937. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  47938. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  47939. export * from "babylonjs/Gamepads/Controllers/viveController";
  47940. export * from "babylonjs/Gamepads/Controllers/webVRController";
  47941. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  47942. }
  47943. declare module "babylonjs/Gamepads/index" {
  47944. export * from "babylonjs/Gamepads/Controllers/index";
  47945. export * from "babylonjs/Gamepads/gamepad";
  47946. export * from "babylonjs/Gamepads/gamepadManager";
  47947. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  47948. export * from "babylonjs/Gamepads/xboxGamepad";
  47949. export * from "babylonjs/Gamepads/dualShockGamepad";
  47950. }
  47951. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  47952. import { Scene } from "babylonjs/scene";
  47953. import { Vector4 } from "babylonjs/Maths/math.vector";
  47954. import { Color4 } from "babylonjs/Maths/math.color";
  47955. import { Mesh } from "babylonjs/Meshes/mesh";
  47956. import { Nullable } from "babylonjs/types";
  47957. /**
  47958. * Class containing static functions to help procedurally build meshes
  47959. */
  47960. export class PolyhedronBuilder {
  47961. /**
  47962. * Creates a polyhedron mesh
  47963. * * 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
  47964. * * The parameter `size` (positive float, default 1) sets the polygon size
  47965. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  47966. * * 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`
  47967. * * 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
  47968. * * 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)`)
  47969. * * 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
  47970. * * 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
  47971. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47972. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47973. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47974. * @param name defines the name of the mesh
  47975. * @param options defines the options used to create the mesh
  47976. * @param scene defines the hosting scene
  47977. * @returns the polyhedron mesh
  47978. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  47979. */
  47980. static CreatePolyhedron(name: string, options: {
  47981. type?: number;
  47982. size?: number;
  47983. sizeX?: number;
  47984. sizeY?: number;
  47985. sizeZ?: number;
  47986. custom?: any;
  47987. faceUV?: Vector4[];
  47988. faceColors?: Color4[];
  47989. flat?: boolean;
  47990. updatable?: boolean;
  47991. sideOrientation?: number;
  47992. frontUVs?: Vector4;
  47993. backUVs?: Vector4;
  47994. }, scene?: Nullable<Scene>): Mesh;
  47995. }
  47996. }
  47997. declare module "babylonjs/Gizmos/scaleGizmo" {
  47998. import { Observable } from "babylonjs/Misc/observable";
  47999. import { Nullable } from "babylonjs/types";
  48000. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48001. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48002. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  48003. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48004. /**
  48005. * Gizmo that enables scaling a mesh along 3 axis
  48006. */
  48007. export class ScaleGizmo extends Gizmo {
  48008. /**
  48009. * Internal gizmo used for interactions on the x axis
  48010. */
  48011. xGizmo: AxisScaleGizmo;
  48012. /**
  48013. * Internal gizmo used for interactions on the y axis
  48014. */
  48015. yGizmo: AxisScaleGizmo;
  48016. /**
  48017. * Internal gizmo used for interactions on the z axis
  48018. */
  48019. zGizmo: AxisScaleGizmo;
  48020. /**
  48021. * Internal gizmo used to scale all axis equally
  48022. */
  48023. uniformScaleGizmo: AxisScaleGizmo;
  48024. private _meshAttached;
  48025. private _updateGizmoRotationToMatchAttachedMesh;
  48026. private _snapDistance;
  48027. private _scaleRatio;
  48028. private _uniformScalingMesh;
  48029. private _octahedron;
  48030. private _sensitivity;
  48031. /** Fires an event when any of it's sub gizmos are dragged */
  48032. onDragStartObservable: Observable<unknown>;
  48033. /** Fires an event when any of it's sub gizmos are released from dragging */
  48034. onDragEndObservable: Observable<unknown>;
  48035. attachedMesh: Nullable<AbstractMesh>;
  48036. /**
  48037. * Creates a ScaleGizmo
  48038. * @param gizmoLayer The utility layer the gizmo will be added to
  48039. */
  48040. constructor(gizmoLayer?: UtilityLayerRenderer);
  48041. updateGizmoRotationToMatchAttachedMesh: boolean;
  48042. /**
  48043. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48044. */
  48045. snapDistance: number;
  48046. /**
  48047. * Ratio for the scale of the gizmo (Default: 1)
  48048. */
  48049. scaleRatio: number;
  48050. /**
  48051. * Sensitivity factor for dragging (Default: 1)
  48052. */
  48053. sensitivity: number;
  48054. /**
  48055. * Disposes of the gizmo
  48056. */
  48057. dispose(): void;
  48058. }
  48059. }
  48060. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  48061. import { Observable } from "babylonjs/Misc/observable";
  48062. import { Nullable } from "babylonjs/types";
  48063. import { Vector3 } from "babylonjs/Maths/math.vector";
  48064. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48065. import { Mesh } from "babylonjs/Meshes/mesh";
  48066. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  48067. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48068. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48069. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  48070. import { Color3 } from "babylonjs/Maths/math.color";
  48071. /**
  48072. * Single axis scale gizmo
  48073. */
  48074. export class AxisScaleGizmo extends Gizmo {
  48075. /**
  48076. * Drag behavior responsible for the gizmos dragging interactions
  48077. */
  48078. dragBehavior: PointerDragBehavior;
  48079. private _pointerObserver;
  48080. /**
  48081. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48082. */
  48083. snapDistance: number;
  48084. /**
  48085. * Event that fires each time the gizmo snaps to a new location.
  48086. * * snapDistance is the the change in distance
  48087. */
  48088. onSnapObservable: Observable<{
  48089. snapDistance: number;
  48090. }>;
  48091. /**
  48092. * If the scaling operation should be done on all axis (default: false)
  48093. */
  48094. uniformScaling: boolean;
  48095. /**
  48096. * Custom sensitivity value for the drag strength
  48097. */
  48098. sensitivity: number;
  48099. private _isEnabled;
  48100. private _parent;
  48101. private _arrow;
  48102. private _coloredMaterial;
  48103. private _hoverMaterial;
  48104. /**
  48105. * Creates an AxisScaleGizmo
  48106. * @param gizmoLayer The utility layer the gizmo will be added to
  48107. * @param dragAxis The axis which the gizmo will be able to scale on
  48108. * @param color The color of the gizmo
  48109. */
  48110. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  48111. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48112. /**
  48113. * If the gizmo is enabled
  48114. */
  48115. isEnabled: boolean;
  48116. /**
  48117. * Disposes of the gizmo
  48118. */
  48119. dispose(): void;
  48120. /**
  48121. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  48122. * @param mesh The mesh to replace the default mesh of the gizmo
  48123. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  48124. */
  48125. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  48126. }
  48127. }
  48128. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  48129. import { Observable } from "babylonjs/Misc/observable";
  48130. import { Nullable } from "babylonjs/types";
  48131. import { Vector3 } from "babylonjs/Maths/math.vector";
  48132. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48133. import { Mesh } from "babylonjs/Meshes/mesh";
  48134. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48135. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48136. import { Color3 } from "babylonjs/Maths/math.color";
  48137. import "babylonjs/Meshes/Builders/boxBuilder";
  48138. /**
  48139. * Bounding box gizmo
  48140. */
  48141. export class BoundingBoxGizmo extends Gizmo {
  48142. private _lineBoundingBox;
  48143. private _rotateSpheresParent;
  48144. private _scaleBoxesParent;
  48145. private _boundingDimensions;
  48146. private _renderObserver;
  48147. private _pointerObserver;
  48148. private _scaleDragSpeed;
  48149. private _tmpQuaternion;
  48150. private _tmpVector;
  48151. private _tmpRotationMatrix;
  48152. /**
  48153. * 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)
  48154. */
  48155. ignoreChildren: boolean;
  48156. /**
  48157. * 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)
  48158. */
  48159. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  48160. /**
  48161. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  48162. */
  48163. rotationSphereSize: number;
  48164. /**
  48165. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  48166. */
  48167. scaleBoxSize: number;
  48168. /**
  48169. * 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)
  48170. */
  48171. fixedDragMeshScreenSize: boolean;
  48172. /**
  48173. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  48174. */
  48175. fixedDragMeshScreenSizeDistanceFactor: number;
  48176. /**
  48177. * Fired when a rotation sphere or scale box is dragged
  48178. */
  48179. onDragStartObservable: Observable<{}>;
  48180. /**
  48181. * Fired when a scale box is dragged
  48182. */
  48183. onScaleBoxDragObservable: Observable<{}>;
  48184. /**
  48185. * Fired when a scale box drag is ended
  48186. */
  48187. onScaleBoxDragEndObservable: Observable<{}>;
  48188. /**
  48189. * Fired when a rotation sphere is dragged
  48190. */
  48191. onRotationSphereDragObservable: Observable<{}>;
  48192. /**
  48193. * Fired when a rotation sphere drag is ended
  48194. */
  48195. onRotationSphereDragEndObservable: Observable<{}>;
  48196. /**
  48197. * 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)
  48198. */
  48199. scalePivot: Nullable<Vector3>;
  48200. /**
  48201. * Mesh used as a pivot to rotate the attached mesh
  48202. */
  48203. private _anchorMesh;
  48204. private _existingMeshScale;
  48205. private _dragMesh;
  48206. private pointerDragBehavior;
  48207. private coloredMaterial;
  48208. private hoverColoredMaterial;
  48209. /**
  48210. * Sets the color of the bounding box gizmo
  48211. * @param color the color to set
  48212. */
  48213. setColor(color: Color3): void;
  48214. /**
  48215. * Creates an BoundingBoxGizmo
  48216. * @param gizmoLayer The utility layer the gizmo will be added to
  48217. * @param color The color of the gizmo
  48218. */
  48219. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  48220. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48221. private _selectNode;
  48222. /**
  48223. * Updates the bounding box information for the Gizmo
  48224. */
  48225. updateBoundingBox(): void;
  48226. private _updateRotationSpheres;
  48227. private _updateScaleBoxes;
  48228. /**
  48229. * Enables rotation on the specified axis and disables rotation on the others
  48230. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  48231. */
  48232. setEnabledRotationAxis(axis: string): void;
  48233. /**
  48234. * Enables/disables scaling
  48235. * @param enable if scaling should be enabled
  48236. */
  48237. setEnabledScaling(enable: boolean): void;
  48238. private _updateDummy;
  48239. /**
  48240. * Enables a pointer drag behavior on the bounding box of the gizmo
  48241. */
  48242. enableDragBehavior(): void;
  48243. /**
  48244. * Disposes of the gizmo
  48245. */
  48246. dispose(): void;
  48247. /**
  48248. * 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)
  48249. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  48250. * @returns the bounding box mesh with the passed in mesh as a child
  48251. */
  48252. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  48253. /**
  48254. * CustomMeshes are not supported by this gizmo
  48255. * @param mesh The mesh to replace the default mesh of the gizmo
  48256. */
  48257. setCustomMesh(mesh: Mesh): void;
  48258. }
  48259. }
  48260. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  48261. import { Observable } from "babylonjs/Misc/observable";
  48262. import { Nullable } from "babylonjs/types";
  48263. import { Vector3 } from "babylonjs/Maths/math.vector";
  48264. import { Color3 } from "babylonjs/Maths/math.color";
  48265. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48266. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  48267. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48268. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48269. import "babylonjs/Meshes/Builders/linesBuilder";
  48270. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  48271. /**
  48272. * Single plane rotation gizmo
  48273. */
  48274. export class PlaneRotationGizmo extends Gizmo {
  48275. /**
  48276. * Drag behavior responsible for the gizmos dragging interactions
  48277. */
  48278. dragBehavior: PointerDragBehavior;
  48279. private _pointerObserver;
  48280. /**
  48281. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  48282. */
  48283. snapDistance: number;
  48284. /**
  48285. * Event that fires each time the gizmo snaps to a new location.
  48286. * * snapDistance is the the change in distance
  48287. */
  48288. onSnapObservable: Observable<{
  48289. snapDistance: number;
  48290. }>;
  48291. private _isEnabled;
  48292. private _parent;
  48293. /**
  48294. * Creates a PlaneRotationGizmo
  48295. * @param gizmoLayer The utility layer the gizmo will be added to
  48296. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  48297. * @param color The color of the gizmo
  48298. * @param tessellation Amount of tessellation to be used when creating rotation circles
  48299. * @param useEulerRotation Use and update Euler angle instead of quaternion
  48300. */
  48301. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  48302. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48303. /**
  48304. * If the gizmo is enabled
  48305. */
  48306. isEnabled: boolean;
  48307. /**
  48308. * Disposes of the gizmo
  48309. */
  48310. dispose(): void;
  48311. }
  48312. }
  48313. declare module "babylonjs/Gizmos/rotationGizmo" {
  48314. import { Observable } from "babylonjs/Misc/observable";
  48315. import { Nullable } from "babylonjs/types";
  48316. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48317. import { Mesh } from "babylonjs/Meshes/mesh";
  48318. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48319. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  48320. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48321. /**
  48322. * Gizmo that enables rotating a mesh along 3 axis
  48323. */
  48324. export class RotationGizmo extends Gizmo {
  48325. /**
  48326. * Internal gizmo used for interactions on the x axis
  48327. */
  48328. xGizmo: PlaneRotationGizmo;
  48329. /**
  48330. * Internal gizmo used for interactions on the y axis
  48331. */
  48332. yGizmo: PlaneRotationGizmo;
  48333. /**
  48334. * Internal gizmo used for interactions on the z axis
  48335. */
  48336. zGizmo: PlaneRotationGizmo;
  48337. /** Fires an event when any of it's sub gizmos are dragged */
  48338. onDragStartObservable: Observable<unknown>;
  48339. /** Fires an event when any of it's sub gizmos are released from dragging */
  48340. onDragEndObservable: Observable<unknown>;
  48341. private _meshAttached;
  48342. attachedMesh: Nullable<AbstractMesh>;
  48343. /**
  48344. * Creates a RotationGizmo
  48345. * @param gizmoLayer The utility layer the gizmo will be added to
  48346. * @param tessellation Amount of tessellation to be used when creating rotation circles
  48347. * @param useEulerRotation Use and update Euler angle instead of quaternion
  48348. */
  48349. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  48350. updateGizmoRotationToMatchAttachedMesh: boolean;
  48351. /**
  48352. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48353. */
  48354. snapDistance: number;
  48355. /**
  48356. * Ratio for the scale of the gizmo (Default: 1)
  48357. */
  48358. scaleRatio: number;
  48359. /**
  48360. * Disposes of the gizmo
  48361. */
  48362. dispose(): void;
  48363. /**
  48364. * CustomMeshes are not supported by this gizmo
  48365. * @param mesh The mesh to replace the default mesh of the gizmo
  48366. */
  48367. setCustomMesh(mesh: Mesh): void;
  48368. }
  48369. }
  48370. declare module "babylonjs/Gizmos/gizmoManager" {
  48371. import { Observable } from "babylonjs/Misc/observable";
  48372. import { Nullable } from "babylonjs/types";
  48373. import { Scene, IDisposable } from "babylonjs/scene";
  48374. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48375. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48376. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  48377. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  48378. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  48379. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  48380. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  48381. /**
  48382. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  48383. */
  48384. export class GizmoManager implements IDisposable {
  48385. private scene;
  48386. /**
  48387. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  48388. */
  48389. gizmos: {
  48390. positionGizmo: Nullable<PositionGizmo>;
  48391. rotationGizmo: Nullable<RotationGizmo>;
  48392. scaleGizmo: Nullable<ScaleGizmo>;
  48393. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  48394. };
  48395. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  48396. clearGizmoOnEmptyPointerEvent: boolean;
  48397. /** Fires an event when the manager is attached to a mesh */
  48398. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  48399. private _gizmosEnabled;
  48400. private _pointerObserver;
  48401. private _attachedMesh;
  48402. private _boundingBoxColor;
  48403. private _defaultUtilityLayer;
  48404. private _defaultKeepDepthUtilityLayer;
  48405. /**
  48406. * When bounding box gizmo is enabled, this can be used to track drag/end events
  48407. */
  48408. boundingBoxDragBehavior: SixDofDragBehavior;
  48409. /**
  48410. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  48411. */
  48412. attachableMeshes: Nullable<Array<AbstractMesh>>;
  48413. /**
  48414. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  48415. */
  48416. usePointerToAttachGizmos: boolean;
  48417. /**
  48418. * Utility layer that the bounding box gizmo belongs to
  48419. */
  48420. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  48421. /**
  48422. * Utility layer that all gizmos besides bounding box belong to
  48423. */
  48424. readonly utilityLayer: UtilityLayerRenderer;
  48425. /**
  48426. * Instatiates a gizmo manager
  48427. * @param scene the scene to overlay the gizmos on top of
  48428. */
  48429. constructor(scene: Scene);
  48430. /**
  48431. * Attaches a set of gizmos to the specified mesh
  48432. * @param mesh The mesh the gizmo's should be attached to
  48433. */
  48434. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  48435. /**
  48436. * If the position gizmo is enabled
  48437. */
  48438. positionGizmoEnabled: boolean;
  48439. /**
  48440. * If the rotation gizmo is enabled
  48441. */
  48442. rotationGizmoEnabled: boolean;
  48443. /**
  48444. * If the scale gizmo is enabled
  48445. */
  48446. scaleGizmoEnabled: boolean;
  48447. /**
  48448. * If the boundingBox gizmo is enabled
  48449. */
  48450. boundingBoxGizmoEnabled: boolean;
  48451. /**
  48452. * Disposes of the gizmo manager
  48453. */
  48454. dispose(): void;
  48455. }
  48456. }
  48457. declare module "babylonjs/Lights/directionalLight" {
  48458. import { Camera } from "babylonjs/Cameras/camera";
  48459. import { Scene } from "babylonjs/scene";
  48460. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  48461. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48462. import { Light } from "babylonjs/Lights/light";
  48463. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48464. import { Effect } from "babylonjs/Materials/effect";
  48465. /**
  48466. * A directional light is defined by a direction (what a surprise!).
  48467. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  48468. * 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.
  48469. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48470. */
  48471. export class DirectionalLight extends ShadowLight {
  48472. private _shadowFrustumSize;
  48473. /**
  48474. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  48475. */
  48476. /**
  48477. * Specifies a fix frustum size for the shadow generation.
  48478. */
  48479. shadowFrustumSize: number;
  48480. private _shadowOrthoScale;
  48481. /**
  48482. * Gets the shadow projection scale against the optimal computed one.
  48483. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48484. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48485. */
  48486. /**
  48487. * Sets the shadow projection scale against the optimal computed one.
  48488. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48489. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48490. */
  48491. shadowOrthoScale: number;
  48492. /**
  48493. * Automatically compute the projection matrix to best fit (including all the casters)
  48494. * on each frame.
  48495. */
  48496. autoUpdateExtends: boolean;
  48497. private _orthoLeft;
  48498. private _orthoRight;
  48499. private _orthoTop;
  48500. private _orthoBottom;
  48501. /**
  48502. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  48503. * The directional light is emitted from everywhere in the given direction.
  48504. * It can cast shadows.
  48505. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48506. * @param name The friendly name of the light
  48507. * @param direction The direction of the light
  48508. * @param scene The scene the light belongs to
  48509. */
  48510. constructor(name: string, direction: Vector3, scene: Scene);
  48511. /**
  48512. * Returns the string "DirectionalLight".
  48513. * @return The class name
  48514. */
  48515. getClassName(): string;
  48516. /**
  48517. * Returns the integer 1.
  48518. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48519. */
  48520. getTypeID(): number;
  48521. /**
  48522. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  48523. * Returns the DirectionalLight Shadow projection matrix.
  48524. */
  48525. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48526. /**
  48527. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  48528. * Returns the DirectionalLight Shadow projection matrix.
  48529. */
  48530. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  48531. /**
  48532. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  48533. * Returns the DirectionalLight Shadow projection matrix.
  48534. */
  48535. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48536. protected _buildUniformLayout(): void;
  48537. /**
  48538. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  48539. * @param effect The effect to update
  48540. * @param lightIndex The index of the light in the effect to update
  48541. * @returns The directional light
  48542. */
  48543. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  48544. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  48545. /**
  48546. * Gets the minZ used for shadow according to both the scene and the light.
  48547. *
  48548. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48549. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48550. * @param activeCamera The camera we are returning the min for
  48551. * @returns the depth min z
  48552. */
  48553. getDepthMinZ(activeCamera: Camera): number;
  48554. /**
  48555. * Gets the maxZ used for shadow according to both the scene and the light.
  48556. *
  48557. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48558. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48559. * @param activeCamera The camera we are returning the max for
  48560. * @returns the depth max z
  48561. */
  48562. getDepthMaxZ(activeCamera: Camera): number;
  48563. /**
  48564. * Prepares the list of defines specific to the light type.
  48565. * @param defines the list of defines
  48566. * @param lightIndex defines the index of the light for the effect
  48567. */
  48568. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48569. }
  48570. }
  48571. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  48572. import { Mesh } from "babylonjs/Meshes/mesh";
  48573. /**
  48574. * Class containing static functions to help procedurally build meshes
  48575. */
  48576. export class HemisphereBuilder {
  48577. /**
  48578. * Creates a hemisphere mesh
  48579. * @param name defines the name of the mesh
  48580. * @param options defines the options used to create the mesh
  48581. * @param scene defines the hosting scene
  48582. * @returns the hemisphere mesh
  48583. */
  48584. static CreateHemisphere(name: string, options: {
  48585. segments?: number;
  48586. diameter?: number;
  48587. sideOrientation?: number;
  48588. }, scene: any): Mesh;
  48589. }
  48590. }
  48591. declare module "babylonjs/Lights/spotLight" {
  48592. import { Nullable } from "babylonjs/types";
  48593. import { Scene } from "babylonjs/scene";
  48594. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  48595. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48596. import { Effect } from "babylonjs/Materials/effect";
  48597. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48598. import { Light } from "babylonjs/Lights/light";
  48599. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48600. /**
  48601. * A spot light is defined by a position, a direction, an angle, and an exponent.
  48602. * These values define a cone of light starting from the position, emitting toward the direction.
  48603. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  48604. * and the exponent defines the speed of the decay of the light with distance (reach).
  48605. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48606. */
  48607. export class SpotLight extends ShadowLight {
  48608. private _angle;
  48609. private _innerAngle;
  48610. private _cosHalfAngle;
  48611. private _lightAngleScale;
  48612. private _lightAngleOffset;
  48613. /**
  48614. * Gets the cone angle of the spot light in Radians.
  48615. */
  48616. /**
  48617. * Sets the cone angle of the spot light in Radians.
  48618. */
  48619. angle: number;
  48620. /**
  48621. * Only used in gltf falloff mode, this defines the angle where
  48622. * the directional falloff will start before cutting at angle which could be seen
  48623. * as outer angle.
  48624. */
  48625. /**
  48626. * Only used in gltf falloff mode, this defines the angle where
  48627. * the directional falloff will start before cutting at angle which could be seen
  48628. * as outer angle.
  48629. */
  48630. innerAngle: number;
  48631. private _shadowAngleScale;
  48632. /**
  48633. * Allows scaling the angle of the light for shadow generation only.
  48634. */
  48635. /**
  48636. * Allows scaling the angle of the light for shadow generation only.
  48637. */
  48638. shadowAngleScale: number;
  48639. /**
  48640. * The light decay speed with the distance from the emission spot.
  48641. */
  48642. exponent: number;
  48643. private _projectionTextureMatrix;
  48644. /**
  48645. * Allows reading the projecton texture
  48646. */
  48647. readonly projectionTextureMatrix: Matrix;
  48648. protected _projectionTextureLightNear: number;
  48649. /**
  48650. * Gets the near clip of the Spotlight for texture projection.
  48651. */
  48652. /**
  48653. * Sets the near clip of the Spotlight for texture projection.
  48654. */
  48655. projectionTextureLightNear: number;
  48656. protected _projectionTextureLightFar: number;
  48657. /**
  48658. * Gets the far clip of the Spotlight for texture projection.
  48659. */
  48660. /**
  48661. * Sets the far clip of the Spotlight for texture projection.
  48662. */
  48663. projectionTextureLightFar: number;
  48664. protected _projectionTextureUpDirection: Vector3;
  48665. /**
  48666. * Gets the Up vector of the Spotlight for texture projection.
  48667. */
  48668. /**
  48669. * Sets the Up vector of the Spotlight for texture projection.
  48670. */
  48671. projectionTextureUpDirection: Vector3;
  48672. private _projectionTexture;
  48673. /**
  48674. * Gets the projection texture of the light.
  48675. */
  48676. /**
  48677. * Sets the projection texture of the light.
  48678. */
  48679. projectionTexture: Nullable<BaseTexture>;
  48680. private _projectionTextureViewLightDirty;
  48681. private _projectionTextureProjectionLightDirty;
  48682. private _projectionTextureDirty;
  48683. private _projectionTextureViewTargetVector;
  48684. private _projectionTextureViewLightMatrix;
  48685. private _projectionTextureProjectionLightMatrix;
  48686. private _projectionTextureScalingMatrix;
  48687. /**
  48688. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  48689. * It can cast shadows.
  48690. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48691. * @param name The light friendly name
  48692. * @param position The position of the spot light in the scene
  48693. * @param direction The direction of the light in the scene
  48694. * @param angle The cone angle of the light in Radians
  48695. * @param exponent The light decay speed with the distance from the emission spot
  48696. * @param scene The scene the lights belongs to
  48697. */
  48698. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  48699. /**
  48700. * Returns the string "SpotLight".
  48701. * @returns the class name
  48702. */
  48703. getClassName(): string;
  48704. /**
  48705. * Returns the integer 2.
  48706. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48707. */
  48708. getTypeID(): number;
  48709. /**
  48710. * Overrides the direction setter to recompute the projection texture view light Matrix.
  48711. */
  48712. protected _setDirection(value: Vector3): void;
  48713. /**
  48714. * Overrides the position setter to recompute the projection texture view light Matrix.
  48715. */
  48716. protected _setPosition(value: Vector3): void;
  48717. /**
  48718. * 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.
  48719. * Returns the SpotLight.
  48720. */
  48721. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48722. protected _computeProjectionTextureViewLightMatrix(): void;
  48723. protected _computeProjectionTextureProjectionLightMatrix(): void;
  48724. /**
  48725. * Main function for light texture projection matrix computing.
  48726. */
  48727. protected _computeProjectionTextureMatrix(): void;
  48728. protected _buildUniformLayout(): void;
  48729. private _computeAngleValues;
  48730. /**
  48731. * Sets the passed Effect "effect" with the Light textures.
  48732. * @param effect The effect to update
  48733. * @param lightIndex The index of the light in the effect to update
  48734. * @returns The light
  48735. */
  48736. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  48737. /**
  48738. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  48739. * @param effect The effect to update
  48740. * @param lightIndex The index of the light in the effect to update
  48741. * @returns The spot light
  48742. */
  48743. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  48744. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  48745. /**
  48746. * Disposes the light and the associated resources.
  48747. */
  48748. dispose(): void;
  48749. /**
  48750. * Prepares the list of defines specific to the light type.
  48751. * @param defines the list of defines
  48752. * @param lightIndex defines the index of the light for the effect
  48753. */
  48754. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48755. }
  48756. }
  48757. declare module "babylonjs/Gizmos/lightGizmo" {
  48758. import { Nullable } from "babylonjs/types";
  48759. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48760. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48761. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  48762. import { Light } from "babylonjs/Lights/light";
  48763. /**
  48764. * Gizmo that enables viewing a light
  48765. */
  48766. export class LightGizmo extends Gizmo {
  48767. private _lightMesh;
  48768. private _material;
  48769. private _cachedPosition;
  48770. private _cachedForward;
  48771. private _attachedMeshParent;
  48772. /**
  48773. * Creates a LightGizmo
  48774. * @param gizmoLayer The utility layer the gizmo will be added to
  48775. */
  48776. constructor(gizmoLayer?: UtilityLayerRenderer);
  48777. private _light;
  48778. /**
  48779. * The light that the gizmo is attached to
  48780. */
  48781. light: Nullable<Light>;
  48782. /**
  48783. * Gets the material used to render the light gizmo
  48784. */
  48785. readonly material: StandardMaterial;
  48786. /**
  48787. * @hidden
  48788. * Updates the gizmo to match the attached mesh's position/rotation
  48789. */
  48790. protected _update(): void;
  48791. private static _Scale;
  48792. /**
  48793. * Creates the lines for a light mesh
  48794. */
  48795. private static _CreateLightLines;
  48796. /**
  48797. * Disposes of the light gizmo
  48798. */
  48799. dispose(): void;
  48800. private static _CreateHemisphericLightMesh;
  48801. private static _CreatePointLightMesh;
  48802. private static _CreateSpotLightMesh;
  48803. private static _CreateDirectionalLightMesh;
  48804. }
  48805. }
  48806. declare module "babylonjs/Gizmos/index" {
  48807. export * from "babylonjs/Gizmos/axisDragGizmo";
  48808. export * from "babylonjs/Gizmos/axisScaleGizmo";
  48809. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  48810. export * from "babylonjs/Gizmos/gizmo";
  48811. export * from "babylonjs/Gizmos/gizmoManager";
  48812. export * from "babylonjs/Gizmos/planeRotationGizmo";
  48813. export * from "babylonjs/Gizmos/positionGizmo";
  48814. export * from "babylonjs/Gizmos/rotationGizmo";
  48815. export * from "babylonjs/Gizmos/scaleGizmo";
  48816. export * from "babylonjs/Gizmos/lightGizmo";
  48817. export * from "babylonjs/Gizmos/planeDragGizmo";
  48818. }
  48819. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  48820. /** @hidden */
  48821. export var backgroundFragmentDeclaration: {
  48822. name: string;
  48823. shader: string;
  48824. };
  48825. }
  48826. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  48827. /** @hidden */
  48828. export var backgroundUboDeclaration: {
  48829. name: string;
  48830. shader: string;
  48831. };
  48832. }
  48833. declare module "babylonjs/Shaders/background.fragment" {
  48834. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  48835. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  48836. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  48837. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  48838. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48839. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48840. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48841. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  48842. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  48843. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  48844. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  48845. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  48846. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  48847. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  48848. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  48849. /** @hidden */
  48850. export var backgroundPixelShader: {
  48851. name: string;
  48852. shader: string;
  48853. };
  48854. }
  48855. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  48856. /** @hidden */
  48857. export var backgroundVertexDeclaration: {
  48858. name: string;
  48859. shader: string;
  48860. };
  48861. }
  48862. declare module "babylonjs/Shaders/background.vertex" {
  48863. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  48864. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  48865. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48866. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  48867. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  48868. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  48869. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  48870. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48871. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48872. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  48873. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  48874. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  48875. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  48876. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  48877. /** @hidden */
  48878. export var backgroundVertexShader: {
  48879. name: string;
  48880. shader: string;
  48881. };
  48882. }
  48883. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  48884. import { Nullable, int, float } from "babylonjs/types";
  48885. import { Scene } from "babylonjs/scene";
  48886. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  48887. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48888. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48889. import { Mesh } from "babylonjs/Meshes/mesh";
  48890. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  48891. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  48892. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  48893. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48894. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  48895. import { Color3 } from "babylonjs/Maths/math.color";
  48896. import "babylonjs/Shaders/background.fragment";
  48897. import "babylonjs/Shaders/background.vertex";
  48898. /**
  48899. * Background material used to create an efficient environement around your scene.
  48900. */
  48901. export class BackgroundMaterial extends PushMaterial {
  48902. /**
  48903. * Standard reflectance value at parallel view angle.
  48904. */
  48905. static StandardReflectance0: number;
  48906. /**
  48907. * Standard reflectance value at grazing angle.
  48908. */
  48909. static StandardReflectance90: number;
  48910. protected _primaryColor: Color3;
  48911. /**
  48912. * Key light Color (multiply against the environement texture)
  48913. */
  48914. primaryColor: Color3;
  48915. protected __perceptualColor: Nullable<Color3>;
  48916. /**
  48917. * Experimental Internal Use Only.
  48918. *
  48919. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  48920. * This acts as a helper to set the primary color to a more "human friendly" value.
  48921. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  48922. * output color as close as possible from the chosen value.
  48923. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  48924. * part of lighting setup.)
  48925. */
  48926. _perceptualColor: Nullable<Color3>;
  48927. protected _primaryColorShadowLevel: float;
  48928. /**
  48929. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  48930. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  48931. */
  48932. primaryColorShadowLevel: float;
  48933. protected _primaryColorHighlightLevel: float;
  48934. /**
  48935. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  48936. * The primary color is used at the level chosen to define what the white area would look.
  48937. */
  48938. primaryColorHighlightLevel: float;
  48939. protected _reflectionTexture: Nullable<BaseTexture>;
  48940. /**
  48941. * Reflection Texture used in the material.
  48942. * Should be author in a specific way for the best result (refer to the documentation).
  48943. */
  48944. reflectionTexture: Nullable<BaseTexture>;
  48945. protected _reflectionBlur: float;
  48946. /**
  48947. * Reflection Texture level of blur.
  48948. *
  48949. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  48950. * texture twice.
  48951. */
  48952. reflectionBlur: float;
  48953. protected _diffuseTexture: Nullable<BaseTexture>;
  48954. /**
  48955. * Diffuse Texture used in the material.
  48956. * Should be author in a specific way for the best result (refer to the documentation).
  48957. */
  48958. diffuseTexture: Nullable<BaseTexture>;
  48959. protected _shadowLights: Nullable<IShadowLight[]>;
  48960. /**
  48961. * Specify the list of lights casting shadow on the material.
  48962. * All scene shadow lights will be included if null.
  48963. */
  48964. shadowLights: Nullable<IShadowLight[]>;
  48965. protected _shadowLevel: float;
  48966. /**
  48967. * Helps adjusting the shadow to a softer level if required.
  48968. * 0 means black shadows and 1 means no shadows.
  48969. */
  48970. shadowLevel: float;
  48971. protected _sceneCenter: Vector3;
  48972. /**
  48973. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  48974. * It is usually zero but might be interesting to modify according to your setup.
  48975. */
  48976. sceneCenter: Vector3;
  48977. protected _opacityFresnel: boolean;
  48978. /**
  48979. * This helps specifying that the material is falling off to the sky box at grazing angle.
  48980. * This helps ensuring a nice transition when the camera goes under the ground.
  48981. */
  48982. opacityFresnel: boolean;
  48983. protected _reflectionFresnel: boolean;
  48984. /**
  48985. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  48986. * This helps adding a mirror texture on the ground.
  48987. */
  48988. reflectionFresnel: boolean;
  48989. protected _reflectionFalloffDistance: number;
  48990. /**
  48991. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  48992. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  48993. */
  48994. reflectionFalloffDistance: number;
  48995. protected _reflectionAmount: number;
  48996. /**
  48997. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  48998. */
  48999. reflectionAmount: number;
  49000. protected _reflectionReflectance0: number;
  49001. /**
  49002. * This specifies the weight of the reflection at grazing angle.
  49003. */
  49004. reflectionReflectance0: number;
  49005. protected _reflectionReflectance90: number;
  49006. /**
  49007. * This specifies the weight of the reflection at a perpendicular point of view.
  49008. */
  49009. reflectionReflectance90: number;
  49010. /**
  49011. * Sets the reflection reflectance fresnel values according to the default standard
  49012. * empirically know to work well :-)
  49013. */
  49014. reflectionStandardFresnelWeight: number;
  49015. protected _useRGBColor: boolean;
  49016. /**
  49017. * Helps to directly use the maps channels instead of their level.
  49018. */
  49019. useRGBColor: boolean;
  49020. protected _enableNoise: boolean;
  49021. /**
  49022. * This helps reducing the banding effect that could occur on the background.
  49023. */
  49024. enableNoise: boolean;
  49025. /**
  49026. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49027. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  49028. * Recommended to be keep at 1.0 except for special cases.
  49029. */
  49030. fovMultiplier: number;
  49031. private _fovMultiplier;
  49032. /**
  49033. * Enable the FOV adjustment feature controlled by fovMultiplier.
  49034. */
  49035. useEquirectangularFOV: boolean;
  49036. private _maxSimultaneousLights;
  49037. /**
  49038. * Number of Simultaneous lights allowed on the material.
  49039. */
  49040. maxSimultaneousLights: int;
  49041. /**
  49042. * Default configuration related to image processing available in the Background Material.
  49043. */
  49044. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49045. /**
  49046. * Keep track of the image processing observer to allow dispose and replace.
  49047. */
  49048. private _imageProcessingObserver;
  49049. /**
  49050. * Attaches a new image processing configuration to the PBR Material.
  49051. * @param configuration (if null the scene configuration will be use)
  49052. */
  49053. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49054. /**
  49055. * Gets the image processing configuration used either in this material.
  49056. */
  49057. /**
  49058. * Sets the Default image processing configuration used either in the this material.
  49059. *
  49060. * If sets to null, the scene one is in use.
  49061. */
  49062. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  49063. /**
  49064. * Gets wether the color curves effect is enabled.
  49065. */
  49066. /**
  49067. * Sets wether the color curves effect is enabled.
  49068. */
  49069. cameraColorCurvesEnabled: boolean;
  49070. /**
  49071. * Gets wether the color grading effect is enabled.
  49072. */
  49073. /**
  49074. * Gets wether the color grading effect is enabled.
  49075. */
  49076. cameraColorGradingEnabled: boolean;
  49077. /**
  49078. * Gets wether tonemapping is enabled or not.
  49079. */
  49080. /**
  49081. * Sets wether tonemapping is enabled or not
  49082. */
  49083. cameraToneMappingEnabled: boolean;
  49084. /**
  49085. * The camera exposure used on this material.
  49086. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49087. * This corresponds to a photographic exposure.
  49088. */
  49089. /**
  49090. * The camera exposure used on this material.
  49091. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49092. * This corresponds to a photographic exposure.
  49093. */
  49094. cameraExposure: float;
  49095. /**
  49096. * Gets The camera contrast used on this material.
  49097. */
  49098. /**
  49099. * Sets The camera contrast used on this material.
  49100. */
  49101. cameraContrast: float;
  49102. /**
  49103. * Gets the Color Grading 2D Lookup Texture.
  49104. */
  49105. /**
  49106. * Sets the Color Grading 2D Lookup Texture.
  49107. */
  49108. cameraColorGradingTexture: Nullable<BaseTexture>;
  49109. /**
  49110. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49111. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49112. * 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;
  49113. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49114. */
  49115. /**
  49116. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49117. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49118. * 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;
  49119. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49120. */
  49121. cameraColorCurves: Nullable<ColorCurves>;
  49122. /**
  49123. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  49124. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  49125. */
  49126. switchToBGR: boolean;
  49127. private _renderTargets;
  49128. private _reflectionControls;
  49129. private _white;
  49130. private _primaryShadowColor;
  49131. private _primaryHighlightColor;
  49132. /**
  49133. * Instantiates a Background Material in the given scene
  49134. * @param name The friendly name of the material
  49135. * @param scene The scene to add the material to
  49136. */
  49137. constructor(name: string, scene: Scene);
  49138. /**
  49139. * Gets a boolean indicating that current material needs to register RTT
  49140. */
  49141. readonly hasRenderTargetTextures: boolean;
  49142. /**
  49143. * The entire material has been created in order to prevent overdraw.
  49144. * @returns false
  49145. */
  49146. needAlphaTesting(): boolean;
  49147. /**
  49148. * The entire material has been created in order to prevent overdraw.
  49149. * @returns true if blending is enable
  49150. */
  49151. needAlphaBlending(): boolean;
  49152. /**
  49153. * Checks wether the material is ready to be rendered for a given mesh.
  49154. * @param mesh The mesh to render
  49155. * @param subMesh The submesh to check against
  49156. * @param useInstances Specify wether or not the material is used with instances
  49157. * @returns true if all the dependencies are ready (Textures, Effects...)
  49158. */
  49159. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  49160. /**
  49161. * Compute the primary color according to the chosen perceptual color.
  49162. */
  49163. private _computePrimaryColorFromPerceptualColor;
  49164. /**
  49165. * Compute the highlights and shadow colors according to their chosen levels.
  49166. */
  49167. private _computePrimaryColors;
  49168. /**
  49169. * Build the uniform buffer used in the material.
  49170. */
  49171. buildUniformLayout(): void;
  49172. /**
  49173. * Unbind the material.
  49174. */
  49175. unbind(): void;
  49176. /**
  49177. * Bind only the world matrix to the material.
  49178. * @param world The world matrix to bind.
  49179. */
  49180. bindOnlyWorldMatrix(world: Matrix): void;
  49181. /**
  49182. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  49183. * @param world The world matrix to bind.
  49184. * @param subMesh The submesh to bind for.
  49185. */
  49186. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  49187. /**
  49188. * Checks to see if a texture is used in the material.
  49189. * @param texture - Base texture to use.
  49190. * @returns - Boolean specifying if a texture is used in the material.
  49191. */
  49192. hasTexture(texture: BaseTexture): boolean;
  49193. /**
  49194. * Dispose the material.
  49195. * @param forceDisposeEffect Force disposal of the associated effect.
  49196. * @param forceDisposeTextures Force disposal of the associated textures.
  49197. */
  49198. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  49199. /**
  49200. * Clones the material.
  49201. * @param name The cloned name.
  49202. * @returns The cloned material.
  49203. */
  49204. clone(name: string): BackgroundMaterial;
  49205. /**
  49206. * Serializes the current material to its JSON representation.
  49207. * @returns The JSON representation.
  49208. */
  49209. serialize(): any;
  49210. /**
  49211. * Gets the class name of the material
  49212. * @returns "BackgroundMaterial"
  49213. */
  49214. getClassName(): string;
  49215. /**
  49216. * Parse a JSON input to create back a background material.
  49217. * @param source The JSON data to parse
  49218. * @param scene The scene to create the parsed material in
  49219. * @param rootUrl The root url of the assets the material depends upon
  49220. * @returns the instantiated BackgroundMaterial.
  49221. */
  49222. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  49223. }
  49224. }
  49225. declare module "babylonjs/Helpers/environmentHelper" {
  49226. import { Observable } from "babylonjs/Misc/observable";
  49227. import { Nullable } from "babylonjs/types";
  49228. import { Scene } from "babylonjs/scene";
  49229. import { Vector3 } from "babylonjs/Maths/math.vector";
  49230. import { Color3 } from "babylonjs/Maths/math.color";
  49231. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49232. import { Mesh } from "babylonjs/Meshes/mesh";
  49233. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49234. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  49235. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  49236. import "babylonjs/Meshes/Builders/planeBuilder";
  49237. import "babylonjs/Meshes/Builders/boxBuilder";
  49238. /**
  49239. * Represents the different options available during the creation of
  49240. * a Environment helper.
  49241. *
  49242. * This can control the default ground, skybox and image processing setup of your scene.
  49243. */
  49244. export interface IEnvironmentHelperOptions {
  49245. /**
  49246. * Specifies wether or not to create a ground.
  49247. * True by default.
  49248. */
  49249. createGround: boolean;
  49250. /**
  49251. * Specifies the ground size.
  49252. * 15 by default.
  49253. */
  49254. groundSize: number;
  49255. /**
  49256. * The texture used on the ground for the main color.
  49257. * Comes from the BabylonJS CDN by default.
  49258. *
  49259. * Remarks: Can be either a texture or a url.
  49260. */
  49261. groundTexture: string | BaseTexture;
  49262. /**
  49263. * The color mixed in the ground texture by default.
  49264. * BabylonJS clearColor by default.
  49265. */
  49266. groundColor: Color3;
  49267. /**
  49268. * Specifies the ground opacity.
  49269. * 1 by default.
  49270. */
  49271. groundOpacity: number;
  49272. /**
  49273. * Enables the ground to receive shadows.
  49274. * True by default.
  49275. */
  49276. enableGroundShadow: boolean;
  49277. /**
  49278. * Helps preventing the shadow to be fully black on the ground.
  49279. * 0.5 by default.
  49280. */
  49281. groundShadowLevel: number;
  49282. /**
  49283. * Creates a mirror texture attach to the ground.
  49284. * false by default.
  49285. */
  49286. enableGroundMirror: boolean;
  49287. /**
  49288. * Specifies the ground mirror size ratio.
  49289. * 0.3 by default as the default kernel is 64.
  49290. */
  49291. groundMirrorSizeRatio: number;
  49292. /**
  49293. * Specifies the ground mirror blur kernel size.
  49294. * 64 by default.
  49295. */
  49296. groundMirrorBlurKernel: number;
  49297. /**
  49298. * Specifies the ground mirror visibility amount.
  49299. * 1 by default
  49300. */
  49301. groundMirrorAmount: number;
  49302. /**
  49303. * Specifies the ground mirror reflectance weight.
  49304. * This uses the standard weight of the background material to setup the fresnel effect
  49305. * of the mirror.
  49306. * 1 by default.
  49307. */
  49308. groundMirrorFresnelWeight: number;
  49309. /**
  49310. * Specifies the ground mirror Falloff distance.
  49311. * This can helps reducing the size of the reflection.
  49312. * 0 by Default.
  49313. */
  49314. groundMirrorFallOffDistance: number;
  49315. /**
  49316. * Specifies the ground mirror texture type.
  49317. * Unsigned Int by Default.
  49318. */
  49319. groundMirrorTextureType: number;
  49320. /**
  49321. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  49322. * the shown objects.
  49323. */
  49324. groundYBias: number;
  49325. /**
  49326. * Specifies wether or not to create a skybox.
  49327. * True by default.
  49328. */
  49329. createSkybox: boolean;
  49330. /**
  49331. * Specifies the skybox size.
  49332. * 20 by default.
  49333. */
  49334. skyboxSize: number;
  49335. /**
  49336. * The texture used on the skybox for the main color.
  49337. * Comes from the BabylonJS CDN by default.
  49338. *
  49339. * Remarks: Can be either a texture or a url.
  49340. */
  49341. skyboxTexture: string | BaseTexture;
  49342. /**
  49343. * The color mixed in the skybox texture by default.
  49344. * BabylonJS clearColor by default.
  49345. */
  49346. skyboxColor: Color3;
  49347. /**
  49348. * The background rotation around the Y axis of the scene.
  49349. * This helps aligning the key lights of your scene with the background.
  49350. * 0 by default.
  49351. */
  49352. backgroundYRotation: number;
  49353. /**
  49354. * Compute automatically the size of the elements to best fit with the scene.
  49355. */
  49356. sizeAuto: boolean;
  49357. /**
  49358. * Default position of the rootMesh if autoSize is not true.
  49359. */
  49360. rootPosition: Vector3;
  49361. /**
  49362. * Sets up the image processing in the scene.
  49363. * true by default.
  49364. */
  49365. setupImageProcessing: boolean;
  49366. /**
  49367. * The texture used as your environment texture in the scene.
  49368. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  49369. *
  49370. * Remarks: Can be either a texture or a url.
  49371. */
  49372. environmentTexture: string | BaseTexture;
  49373. /**
  49374. * The value of the exposure to apply to the scene.
  49375. * 0.6 by default if setupImageProcessing is true.
  49376. */
  49377. cameraExposure: number;
  49378. /**
  49379. * The value of the contrast to apply to the scene.
  49380. * 1.6 by default if setupImageProcessing is true.
  49381. */
  49382. cameraContrast: number;
  49383. /**
  49384. * Specifies wether or not tonemapping should be enabled in the scene.
  49385. * true by default if setupImageProcessing is true.
  49386. */
  49387. toneMappingEnabled: boolean;
  49388. }
  49389. /**
  49390. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  49391. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  49392. * It also helps with the default setup of your imageProcessing configuration.
  49393. */
  49394. export class EnvironmentHelper {
  49395. /**
  49396. * Default ground texture URL.
  49397. */
  49398. private static _groundTextureCDNUrl;
  49399. /**
  49400. * Default skybox texture URL.
  49401. */
  49402. private static _skyboxTextureCDNUrl;
  49403. /**
  49404. * Default environment texture URL.
  49405. */
  49406. private static _environmentTextureCDNUrl;
  49407. /**
  49408. * Creates the default options for the helper.
  49409. */
  49410. private static _getDefaultOptions;
  49411. private _rootMesh;
  49412. /**
  49413. * Gets the root mesh created by the helper.
  49414. */
  49415. readonly rootMesh: Mesh;
  49416. private _skybox;
  49417. /**
  49418. * Gets the skybox created by the helper.
  49419. */
  49420. readonly skybox: Nullable<Mesh>;
  49421. private _skyboxTexture;
  49422. /**
  49423. * Gets the skybox texture created by the helper.
  49424. */
  49425. readonly skyboxTexture: Nullable<BaseTexture>;
  49426. private _skyboxMaterial;
  49427. /**
  49428. * Gets the skybox material created by the helper.
  49429. */
  49430. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  49431. private _ground;
  49432. /**
  49433. * Gets the ground mesh created by the helper.
  49434. */
  49435. readonly ground: Nullable<Mesh>;
  49436. private _groundTexture;
  49437. /**
  49438. * Gets the ground texture created by the helper.
  49439. */
  49440. readonly groundTexture: Nullable<BaseTexture>;
  49441. private _groundMirror;
  49442. /**
  49443. * Gets the ground mirror created by the helper.
  49444. */
  49445. readonly groundMirror: Nullable<MirrorTexture>;
  49446. /**
  49447. * Gets the ground mirror render list to helps pushing the meshes
  49448. * you wish in the ground reflection.
  49449. */
  49450. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  49451. private _groundMaterial;
  49452. /**
  49453. * Gets the ground material created by the helper.
  49454. */
  49455. readonly groundMaterial: Nullable<BackgroundMaterial>;
  49456. /**
  49457. * Stores the creation options.
  49458. */
  49459. private readonly _scene;
  49460. private _options;
  49461. /**
  49462. * This observable will be notified with any error during the creation of the environment,
  49463. * mainly texture creation errors.
  49464. */
  49465. onErrorObservable: Observable<{
  49466. message?: string;
  49467. exception?: any;
  49468. }>;
  49469. /**
  49470. * constructor
  49471. * @param options Defines the options we want to customize the helper
  49472. * @param scene The scene to add the material to
  49473. */
  49474. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  49475. /**
  49476. * Updates the background according to the new options
  49477. * @param options
  49478. */
  49479. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  49480. /**
  49481. * Sets the primary color of all the available elements.
  49482. * @param color the main color to affect to the ground and the background
  49483. */
  49484. setMainColor(color: Color3): void;
  49485. /**
  49486. * Setup the image processing according to the specified options.
  49487. */
  49488. private _setupImageProcessing;
  49489. /**
  49490. * Setup the environment texture according to the specified options.
  49491. */
  49492. private _setupEnvironmentTexture;
  49493. /**
  49494. * Setup the background according to the specified options.
  49495. */
  49496. private _setupBackground;
  49497. /**
  49498. * Get the scene sizes according to the setup.
  49499. */
  49500. private _getSceneSize;
  49501. /**
  49502. * Setup the ground according to the specified options.
  49503. */
  49504. private _setupGround;
  49505. /**
  49506. * Setup the ground material according to the specified options.
  49507. */
  49508. private _setupGroundMaterial;
  49509. /**
  49510. * Setup the ground diffuse texture according to the specified options.
  49511. */
  49512. private _setupGroundDiffuseTexture;
  49513. /**
  49514. * Setup the ground mirror texture according to the specified options.
  49515. */
  49516. private _setupGroundMirrorTexture;
  49517. /**
  49518. * Setup the ground to receive the mirror texture.
  49519. */
  49520. private _setupMirrorInGroundMaterial;
  49521. /**
  49522. * Setup the skybox according to the specified options.
  49523. */
  49524. private _setupSkybox;
  49525. /**
  49526. * Setup the skybox material according to the specified options.
  49527. */
  49528. private _setupSkyboxMaterial;
  49529. /**
  49530. * Setup the skybox reflection texture according to the specified options.
  49531. */
  49532. private _setupSkyboxReflectionTexture;
  49533. private _errorHandler;
  49534. /**
  49535. * Dispose all the elements created by the Helper.
  49536. */
  49537. dispose(): void;
  49538. }
  49539. }
  49540. declare module "babylonjs/Helpers/photoDome" {
  49541. import { Observable } from "babylonjs/Misc/observable";
  49542. import { Nullable } from "babylonjs/types";
  49543. import { Scene } from "babylonjs/scene";
  49544. import { TransformNode } from "babylonjs/Meshes/transformNode";
  49545. import { Mesh } from "babylonjs/Meshes/mesh";
  49546. import { Texture } from "babylonjs/Materials/Textures/texture";
  49547. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  49548. import "babylonjs/Meshes/Builders/sphereBuilder";
  49549. /**
  49550. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  49551. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  49552. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  49553. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  49554. */
  49555. export class PhotoDome extends TransformNode {
  49556. /**
  49557. * Define the image as a Monoscopic panoramic 360 image.
  49558. */
  49559. static readonly MODE_MONOSCOPIC: number;
  49560. /**
  49561. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  49562. */
  49563. static readonly MODE_TOPBOTTOM: number;
  49564. /**
  49565. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  49566. */
  49567. static readonly MODE_SIDEBYSIDE: number;
  49568. private _useDirectMapping;
  49569. /**
  49570. * The texture being displayed on the sphere
  49571. */
  49572. protected _photoTexture: Texture;
  49573. /**
  49574. * Gets or sets the texture being displayed on the sphere
  49575. */
  49576. photoTexture: Texture;
  49577. /**
  49578. * Observable raised when an error occured while loading the 360 image
  49579. */
  49580. onLoadErrorObservable: Observable<string>;
  49581. /**
  49582. * The skybox material
  49583. */
  49584. protected _material: BackgroundMaterial;
  49585. /**
  49586. * The surface used for the skybox
  49587. */
  49588. protected _mesh: Mesh;
  49589. /**
  49590. * Gets the mesh used for the skybox.
  49591. */
  49592. readonly mesh: Mesh;
  49593. /**
  49594. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49595. * Also see the options.resolution property.
  49596. */
  49597. fovMultiplier: number;
  49598. private _imageMode;
  49599. /**
  49600. * Gets or set the current video mode for the video. It can be:
  49601. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  49602. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  49603. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  49604. */
  49605. imageMode: number;
  49606. /**
  49607. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  49608. * @param name Element's name, child elements will append suffixes for their own names.
  49609. * @param urlsOfPhoto defines the url of the photo to display
  49610. * @param options defines an object containing optional or exposed sub element properties
  49611. * @param onError defines a callback called when an error occured while loading the texture
  49612. */
  49613. constructor(name: string, urlOfPhoto: string, options: {
  49614. resolution?: number;
  49615. size?: number;
  49616. useDirectMapping?: boolean;
  49617. faceForward?: boolean;
  49618. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  49619. private _onBeforeCameraRenderObserver;
  49620. private _changeImageMode;
  49621. /**
  49622. * Releases resources associated with this node.
  49623. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  49624. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  49625. */
  49626. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  49627. }
  49628. }
  49629. declare module "babylonjs/Misc/rgbdTextureTools" {
  49630. import "babylonjs/Shaders/rgbdDecode.fragment";
  49631. import "babylonjs/Engines/Extensions/engine.renderTarget";
  49632. import { Texture } from "babylonjs/Materials/Textures/texture";
  49633. /**
  49634. * Class used to host RGBD texture specific utilities
  49635. */
  49636. export class RGBDTextureTools {
  49637. /**
  49638. * Expand the RGBD Texture from RGBD to Half Float if possible.
  49639. * @param texture the texture to expand.
  49640. */
  49641. static ExpandRGBDTexture(texture: Texture): void;
  49642. }
  49643. }
  49644. declare module "babylonjs/Misc/brdfTextureTools" {
  49645. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49646. import { Scene } from "babylonjs/scene";
  49647. /**
  49648. * Class used to host texture specific utilities
  49649. */
  49650. export class BRDFTextureTools {
  49651. /**
  49652. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  49653. * @param scene defines the hosting scene
  49654. * @returns the environment BRDF texture
  49655. */
  49656. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  49657. private static _environmentBRDFBase64Texture;
  49658. }
  49659. }
  49660. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  49661. import { Nullable } from "babylonjs/types";
  49662. import { Color3 } from "babylonjs/Maths/math.color";
  49663. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49664. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49665. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49666. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49667. import { Engine } from "babylonjs/Engines/engine";
  49668. import { Scene } from "babylonjs/scene";
  49669. /**
  49670. * @hidden
  49671. */
  49672. export interface IMaterialClearCoatDefines {
  49673. CLEARCOAT: boolean;
  49674. CLEARCOAT_DEFAULTIOR: boolean;
  49675. CLEARCOAT_TEXTURE: boolean;
  49676. CLEARCOAT_TEXTUREDIRECTUV: number;
  49677. CLEARCOAT_BUMP: boolean;
  49678. CLEARCOAT_BUMPDIRECTUV: number;
  49679. CLEARCOAT_TINT: boolean;
  49680. CLEARCOAT_TINT_TEXTURE: boolean;
  49681. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49682. /** @hidden */
  49683. _areTexturesDirty: boolean;
  49684. }
  49685. /**
  49686. * Define the code related to the clear coat parameters of the pbr material.
  49687. */
  49688. export class PBRClearCoatConfiguration {
  49689. /**
  49690. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  49691. * The default fits with a polyurethane material.
  49692. */
  49693. private static readonly _DefaultIndexOfRefraction;
  49694. private _isEnabled;
  49695. /**
  49696. * Defines if the clear coat is enabled in the material.
  49697. */
  49698. isEnabled: boolean;
  49699. /**
  49700. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  49701. */
  49702. intensity: number;
  49703. /**
  49704. * Defines the clear coat layer roughness.
  49705. */
  49706. roughness: number;
  49707. private _indexOfRefraction;
  49708. /**
  49709. * Defines the index of refraction of the clear coat.
  49710. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  49711. * The default fits with a polyurethane material.
  49712. * Changing the default value is more performance intensive.
  49713. */
  49714. indexOfRefraction: number;
  49715. private _texture;
  49716. /**
  49717. * Stores the clear coat values in a texture.
  49718. */
  49719. texture: Nullable<BaseTexture>;
  49720. private _bumpTexture;
  49721. /**
  49722. * Define the clear coat specific bump texture.
  49723. */
  49724. bumpTexture: Nullable<BaseTexture>;
  49725. private _isTintEnabled;
  49726. /**
  49727. * Defines if the clear coat tint is enabled in the material.
  49728. */
  49729. isTintEnabled: boolean;
  49730. /**
  49731. * Defines the clear coat tint of the material.
  49732. * This is only use if tint is enabled
  49733. */
  49734. tintColor: Color3;
  49735. /**
  49736. * Defines the distance at which the tint color should be found in the
  49737. * clear coat media.
  49738. * This is only use if tint is enabled
  49739. */
  49740. tintColorAtDistance: number;
  49741. /**
  49742. * Defines the clear coat layer thickness.
  49743. * This is only use if tint is enabled
  49744. */
  49745. tintThickness: number;
  49746. private _tintTexture;
  49747. /**
  49748. * Stores the clear tint values in a texture.
  49749. * rgb is tint
  49750. * a is a thickness factor
  49751. */
  49752. tintTexture: Nullable<BaseTexture>;
  49753. /** @hidden */
  49754. private _internalMarkAllSubMeshesAsTexturesDirty;
  49755. /** @hidden */
  49756. _markAllSubMeshesAsTexturesDirty(): void;
  49757. /**
  49758. * Instantiate a new istance of clear coat configuration.
  49759. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49760. */
  49761. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49762. /**
  49763. * Gets wehter the submesh is ready to be used or not.
  49764. * @param defines the list of "defines" to update.
  49765. * @param scene defines the scene the material belongs to.
  49766. * @param engine defines the engine the material belongs to.
  49767. * @param disableBumpMap defines wether the material disables bump or not.
  49768. * @returns - boolean indicating that the submesh is ready or not.
  49769. */
  49770. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  49771. /**
  49772. * Checks to see if a texture is used in the material.
  49773. * @param defines the list of "defines" to update.
  49774. * @param scene defines the scene to the material belongs to.
  49775. */
  49776. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  49777. /**
  49778. * Binds the material data.
  49779. * @param uniformBuffer defines the Uniform buffer to fill in.
  49780. * @param scene defines the scene the material belongs to.
  49781. * @param engine defines the engine the material belongs to.
  49782. * @param disableBumpMap defines wether the material disables bump or not.
  49783. * @param isFrozen defines wether the material is frozen or not.
  49784. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  49785. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  49786. */
  49787. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  49788. /**
  49789. * Checks to see if a texture is used in the material.
  49790. * @param texture - Base texture to use.
  49791. * @returns - Boolean specifying if a texture is used in the material.
  49792. */
  49793. hasTexture(texture: BaseTexture): boolean;
  49794. /**
  49795. * Returns an array of the actively used textures.
  49796. * @param activeTextures Array of BaseTextures
  49797. */
  49798. getActiveTextures(activeTextures: BaseTexture[]): void;
  49799. /**
  49800. * Returns the animatable textures.
  49801. * @param animatables Array of animatable textures.
  49802. */
  49803. getAnimatables(animatables: IAnimatable[]): void;
  49804. /**
  49805. * Disposes the resources of the material.
  49806. * @param forceDisposeTextures - Forces the disposal of all textures.
  49807. */
  49808. dispose(forceDisposeTextures?: boolean): void;
  49809. /**
  49810. * Get the current class name of the texture useful for serialization or dynamic coding.
  49811. * @returns "PBRClearCoatConfiguration"
  49812. */
  49813. getClassName(): string;
  49814. /**
  49815. * Add fallbacks to the effect fallbacks list.
  49816. * @param defines defines the Base texture to use.
  49817. * @param fallbacks defines the current fallback list.
  49818. * @param currentRank defines the current fallback rank.
  49819. * @returns the new fallback rank.
  49820. */
  49821. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49822. /**
  49823. * Add the required uniforms to the current list.
  49824. * @param uniforms defines the current uniform list.
  49825. */
  49826. static AddUniforms(uniforms: string[]): void;
  49827. /**
  49828. * Add the required samplers to the current list.
  49829. * @param samplers defines the current sampler list.
  49830. */
  49831. static AddSamplers(samplers: string[]): void;
  49832. /**
  49833. * Add the required uniforms to the current buffer.
  49834. * @param uniformBuffer defines the current uniform buffer.
  49835. */
  49836. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49837. /**
  49838. * Makes a duplicate of the current configuration into another one.
  49839. * @param clearCoatConfiguration define the config where to copy the info
  49840. */
  49841. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  49842. /**
  49843. * Serializes this clear coat configuration.
  49844. * @returns - An object with the serialized config.
  49845. */
  49846. serialize(): any;
  49847. /**
  49848. * Parses a anisotropy Configuration from a serialized object.
  49849. * @param source - Serialized object.
  49850. * @param scene Defines the scene we are parsing for
  49851. * @param rootUrl Defines the rootUrl to load from
  49852. */
  49853. parse(source: any, scene: Scene, rootUrl: string): void;
  49854. }
  49855. }
  49856. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  49857. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49858. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49859. import { Vector2 } from "babylonjs/Maths/math.vector";
  49860. import { Scene } from "babylonjs/scene";
  49861. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49862. import { Nullable } from "babylonjs/types";
  49863. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49864. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49865. /**
  49866. * @hidden
  49867. */
  49868. export interface IMaterialAnisotropicDefines {
  49869. ANISOTROPIC: boolean;
  49870. ANISOTROPIC_TEXTURE: boolean;
  49871. ANISOTROPIC_TEXTUREDIRECTUV: number;
  49872. MAINUV1: boolean;
  49873. _areTexturesDirty: boolean;
  49874. _needUVs: boolean;
  49875. }
  49876. /**
  49877. * Define the code related to the anisotropic parameters of the pbr material.
  49878. */
  49879. export class PBRAnisotropicConfiguration {
  49880. private _isEnabled;
  49881. /**
  49882. * Defines if the anisotropy is enabled in the material.
  49883. */
  49884. isEnabled: boolean;
  49885. /**
  49886. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  49887. */
  49888. intensity: number;
  49889. /**
  49890. * Defines if the effect is along the tangents, bitangents or in between.
  49891. * By default, the effect is "strectching" the highlights along the tangents.
  49892. */
  49893. direction: Vector2;
  49894. private _texture;
  49895. /**
  49896. * Stores the anisotropy values in a texture.
  49897. * rg is direction (like normal from -1 to 1)
  49898. * b is a intensity
  49899. */
  49900. texture: Nullable<BaseTexture>;
  49901. /** @hidden */
  49902. private _internalMarkAllSubMeshesAsTexturesDirty;
  49903. /** @hidden */
  49904. _markAllSubMeshesAsTexturesDirty(): void;
  49905. /**
  49906. * Instantiate a new istance of anisotropy configuration.
  49907. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49908. */
  49909. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49910. /**
  49911. * Specifies that the submesh is ready to be used.
  49912. * @param defines the list of "defines" to update.
  49913. * @param scene defines the scene the material belongs to.
  49914. * @returns - boolean indicating that the submesh is ready or not.
  49915. */
  49916. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  49917. /**
  49918. * Checks to see if a texture is used in the material.
  49919. * @param defines the list of "defines" to update.
  49920. * @param mesh the mesh we are preparing the defines for.
  49921. * @param scene defines the scene the material belongs to.
  49922. */
  49923. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  49924. /**
  49925. * Binds the material data.
  49926. * @param uniformBuffer defines the Uniform buffer to fill in.
  49927. * @param scene defines the scene the material belongs to.
  49928. * @param isFrozen defines wether the material is frozen or not.
  49929. */
  49930. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  49931. /**
  49932. * Checks to see if a texture is used in the material.
  49933. * @param texture - Base texture to use.
  49934. * @returns - Boolean specifying if a texture is used in the material.
  49935. */
  49936. hasTexture(texture: BaseTexture): boolean;
  49937. /**
  49938. * Returns an array of the actively used textures.
  49939. * @param activeTextures Array of BaseTextures
  49940. */
  49941. getActiveTextures(activeTextures: BaseTexture[]): void;
  49942. /**
  49943. * Returns the animatable textures.
  49944. * @param animatables Array of animatable textures.
  49945. */
  49946. getAnimatables(animatables: IAnimatable[]): void;
  49947. /**
  49948. * Disposes the resources of the material.
  49949. * @param forceDisposeTextures - Forces the disposal of all textures.
  49950. */
  49951. dispose(forceDisposeTextures?: boolean): void;
  49952. /**
  49953. * Get the current class name of the texture useful for serialization or dynamic coding.
  49954. * @returns "PBRAnisotropicConfiguration"
  49955. */
  49956. getClassName(): string;
  49957. /**
  49958. * Add fallbacks to the effect fallbacks list.
  49959. * @param defines defines the Base texture to use.
  49960. * @param fallbacks defines the current fallback list.
  49961. * @param currentRank defines the current fallback rank.
  49962. * @returns the new fallback rank.
  49963. */
  49964. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49965. /**
  49966. * Add the required uniforms to the current list.
  49967. * @param uniforms defines the current uniform list.
  49968. */
  49969. static AddUniforms(uniforms: string[]): void;
  49970. /**
  49971. * Add the required uniforms to the current buffer.
  49972. * @param uniformBuffer defines the current uniform buffer.
  49973. */
  49974. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49975. /**
  49976. * Add the required samplers to the current list.
  49977. * @param samplers defines the current sampler list.
  49978. */
  49979. static AddSamplers(samplers: string[]): void;
  49980. /**
  49981. * Makes a duplicate of the current configuration into another one.
  49982. * @param anisotropicConfiguration define the config where to copy the info
  49983. */
  49984. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  49985. /**
  49986. * Serializes this anisotropy configuration.
  49987. * @returns - An object with the serialized config.
  49988. */
  49989. serialize(): any;
  49990. /**
  49991. * Parses a anisotropy Configuration from a serialized object.
  49992. * @param source - Serialized object.
  49993. * @param scene Defines the scene we are parsing for
  49994. * @param rootUrl Defines the rootUrl to load from
  49995. */
  49996. parse(source: any, scene: Scene, rootUrl: string): void;
  49997. }
  49998. }
  49999. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  50000. import { Scene } from "babylonjs/scene";
  50001. /**
  50002. * @hidden
  50003. */
  50004. export interface IMaterialBRDFDefines {
  50005. BRDF_V_HEIGHT_CORRELATED: boolean;
  50006. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50007. SPHERICAL_HARMONICS: boolean;
  50008. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50009. /** @hidden */
  50010. _areMiscDirty: boolean;
  50011. }
  50012. /**
  50013. * Define the code related to the BRDF parameters of the pbr material.
  50014. */
  50015. export class PBRBRDFConfiguration {
  50016. /**
  50017. * Default value used for the energy conservation.
  50018. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50019. */
  50020. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  50021. /**
  50022. * Default value used for the Smith Visibility Height Correlated mode.
  50023. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50024. */
  50025. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  50026. /**
  50027. * Default value used for the IBL diffuse part.
  50028. * This can help switching back to the polynomials mode globally which is a tiny bit
  50029. * less GPU intensive at the drawback of a lower quality.
  50030. */
  50031. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  50032. /**
  50033. * Default value used for activating energy conservation for the specular workflow.
  50034. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50035. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50036. */
  50037. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  50038. private _useEnergyConservation;
  50039. /**
  50040. * Defines if the material uses energy conservation.
  50041. */
  50042. useEnergyConservation: boolean;
  50043. private _useSmithVisibilityHeightCorrelated;
  50044. /**
  50045. * LEGACY Mode set to false
  50046. * Defines if the material uses height smith correlated visibility term.
  50047. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  50048. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  50049. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  50050. * Not relying on height correlated will also disable energy conservation.
  50051. */
  50052. useSmithVisibilityHeightCorrelated: boolean;
  50053. private _useSphericalHarmonics;
  50054. /**
  50055. * LEGACY Mode set to false
  50056. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  50057. * diffuse part of the IBL.
  50058. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  50059. * to the ground truth.
  50060. */
  50061. useSphericalHarmonics: boolean;
  50062. private _useSpecularGlossinessInputEnergyConservation;
  50063. /**
  50064. * Defines if the material uses energy conservation, when the specular workflow is active.
  50065. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50066. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50067. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  50068. */
  50069. useSpecularGlossinessInputEnergyConservation: boolean;
  50070. /** @hidden */
  50071. private _internalMarkAllSubMeshesAsMiscDirty;
  50072. /** @hidden */
  50073. _markAllSubMeshesAsMiscDirty(): void;
  50074. /**
  50075. * Instantiate a new istance of clear coat configuration.
  50076. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  50077. */
  50078. constructor(markAllSubMeshesAsMiscDirty: () => void);
  50079. /**
  50080. * Checks to see if a texture is used in the material.
  50081. * @param defines the list of "defines" to update.
  50082. */
  50083. prepareDefines(defines: IMaterialBRDFDefines): void;
  50084. /**
  50085. * Get the current class name of the texture useful for serialization or dynamic coding.
  50086. * @returns "PBRClearCoatConfiguration"
  50087. */
  50088. getClassName(): string;
  50089. /**
  50090. * Makes a duplicate of the current configuration into another one.
  50091. * @param brdfConfiguration define the config where to copy the info
  50092. */
  50093. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  50094. /**
  50095. * Serializes this BRDF configuration.
  50096. * @returns - An object with the serialized config.
  50097. */
  50098. serialize(): any;
  50099. /**
  50100. * Parses a anisotropy Configuration from a serialized object.
  50101. * @param source - Serialized object.
  50102. * @param scene Defines the scene we are parsing for
  50103. * @param rootUrl Defines the rootUrl to load from
  50104. */
  50105. parse(source: any, scene: Scene, rootUrl: string): void;
  50106. }
  50107. }
  50108. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  50109. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  50110. import { Color3 } from "babylonjs/Maths/math.color";
  50111. import { Scene } from "babylonjs/scene";
  50112. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50113. import { Nullable } from "babylonjs/types";
  50114. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  50115. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  50116. /**
  50117. * @hidden
  50118. */
  50119. export interface IMaterialSheenDefines {
  50120. SHEEN: boolean;
  50121. SHEEN_TEXTURE: boolean;
  50122. SHEEN_TEXTUREDIRECTUV: number;
  50123. SHEEN_LINKWITHALBEDO: boolean;
  50124. /** @hidden */
  50125. _areTexturesDirty: boolean;
  50126. }
  50127. /**
  50128. * Define the code related to the Sheen parameters of the pbr material.
  50129. */
  50130. export class PBRSheenConfiguration {
  50131. private _isEnabled;
  50132. /**
  50133. * Defines if the material uses sheen.
  50134. */
  50135. isEnabled: boolean;
  50136. private _linkSheenWithAlbedo;
  50137. /**
  50138. * Defines if the sheen is linked to the sheen color.
  50139. */
  50140. linkSheenWithAlbedo: boolean;
  50141. /**
  50142. * Defines the sheen intensity.
  50143. */
  50144. intensity: number;
  50145. /**
  50146. * Defines the sheen color.
  50147. */
  50148. color: Color3;
  50149. private _texture;
  50150. /**
  50151. * Stores the sheen tint values in a texture.
  50152. * rgb is tint
  50153. * a is a intensity
  50154. */
  50155. texture: Nullable<BaseTexture>;
  50156. /** @hidden */
  50157. private _internalMarkAllSubMeshesAsTexturesDirty;
  50158. /** @hidden */
  50159. _markAllSubMeshesAsTexturesDirty(): void;
  50160. /**
  50161. * Instantiate a new istance of clear coat configuration.
  50162. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50163. */
  50164. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50165. /**
  50166. * Specifies that the submesh is ready to be used.
  50167. * @param defines the list of "defines" to update.
  50168. * @param scene defines the scene the material belongs to.
  50169. * @returns - boolean indicating that the submesh is ready or not.
  50170. */
  50171. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  50172. /**
  50173. * Checks to see if a texture is used in the material.
  50174. * @param defines the list of "defines" to update.
  50175. * @param scene defines the scene the material belongs to.
  50176. */
  50177. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  50178. /**
  50179. * Binds the material data.
  50180. * @param uniformBuffer defines the Uniform buffer to fill in.
  50181. * @param scene defines the scene the material belongs to.
  50182. * @param isFrozen defines wether the material is frozen or not.
  50183. */
  50184. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50185. /**
  50186. * Checks to see if a texture is used in the material.
  50187. * @param texture - Base texture to use.
  50188. * @returns - Boolean specifying if a texture is used in the material.
  50189. */
  50190. hasTexture(texture: BaseTexture): boolean;
  50191. /**
  50192. * Returns an array of the actively used textures.
  50193. * @param activeTextures Array of BaseTextures
  50194. */
  50195. getActiveTextures(activeTextures: BaseTexture[]): void;
  50196. /**
  50197. * Returns the animatable textures.
  50198. * @param animatables Array of animatable textures.
  50199. */
  50200. getAnimatables(animatables: IAnimatable[]): void;
  50201. /**
  50202. * Disposes the resources of the material.
  50203. * @param forceDisposeTextures - Forces the disposal of all textures.
  50204. */
  50205. dispose(forceDisposeTextures?: boolean): void;
  50206. /**
  50207. * Get the current class name of the texture useful for serialization or dynamic coding.
  50208. * @returns "PBRSheenConfiguration"
  50209. */
  50210. getClassName(): string;
  50211. /**
  50212. * Add fallbacks to the effect fallbacks list.
  50213. * @param defines defines the Base texture to use.
  50214. * @param fallbacks defines the current fallback list.
  50215. * @param currentRank defines the current fallback rank.
  50216. * @returns the new fallback rank.
  50217. */
  50218. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50219. /**
  50220. * Add the required uniforms to the current list.
  50221. * @param uniforms defines the current uniform list.
  50222. */
  50223. static AddUniforms(uniforms: string[]): void;
  50224. /**
  50225. * Add the required uniforms to the current buffer.
  50226. * @param uniformBuffer defines the current uniform buffer.
  50227. */
  50228. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50229. /**
  50230. * Add the required samplers to the current list.
  50231. * @param samplers defines the current sampler list.
  50232. */
  50233. static AddSamplers(samplers: string[]): void;
  50234. /**
  50235. * Makes a duplicate of the current configuration into another one.
  50236. * @param sheenConfiguration define the config where to copy the info
  50237. */
  50238. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  50239. /**
  50240. * Serializes this BRDF configuration.
  50241. * @returns - An object with the serialized config.
  50242. */
  50243. serialize(): any;
  50244. /**
  50245. * Parses a anisotropy Configuration from a serialized object.
  50246. * @param source - Serialized object.
  50247. * @param scene Defines the scene we are parsing for
  50248. * @param rootUrl Defines the rootUrl to load from
  50249. */
  50250. parse(source: any, scene: Scene, rootUrl: string): void;
  50251. }
  50252. }
  50253. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  50254. import { Nullable } from "babylonjs/types";
  50255. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  50256. import { Color3 } from "babylonjs/Maths/math.color";
  50257. import { SmartArray } from "babylonjs/Misc/smartArray";
  50258. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50259. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50260. import { Effect } from "babylonjs/Materials/effect";
  50261. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  50262. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  50263. import { Engine } from "babylonjs/Engines/engine";
  50264. import { Scene } from "babylonjs/scene";
  50265. /**
  50266. * @hidden
  50267. */
  50268. export interface IMaterialSubSurfaceDefines {
  50269. SUBSURFACE: boolean;
  50270. SS_REFRACTION: boolean;
  50271. SS_TRANSLUCENCY: boolean;
  50272. SS_SCATERRING: boolean;
  50273. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50274. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50275. SS_REFRACTIONMAP_3D: boolean;
  50276. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50277. SS_LODINREFRACTIONALPHA: boolean;
  50278. SS_GAMMAREFRACTION: boolean;
  50279. SS_RGBDREFRACTION: boolean;
  50280. SS_LINEARSPECULARREFRACTION: boolean;
  50281. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50282. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50283. /** @hidden */
  50284. _areTexturesDirty: boolean;
  50285. }
  50286. /**
  50287. * Define the code related to the sub surface parameters of the pbr material.
  50288. */
  50289. export class PBRSubSurfaceConfiguration {
  50290. private _isRefractionEnabled;
  50291. /**
  50292. * Defines if the refraction is enabled in the material.
  50293. */
  50294. isRefractionEnabled: boolean;
  50295. private _isTranslucencyEnabled;
  50296. /**
  50297. * Defines if the translucency is enabled in the material.
  50298. */
  50299. isTranslucencyEnabled: boolean;
  50300. private _isScatteringEnabled;
  50301. /**
  50302. * Defines the refraction intensity of the material.
  50303. * The refraction when enabled replaces the Diffuse part of the material.
  50304. * The intensity helps transitionning between diffuse and refraction.
  50305. */
  50306. refractionIntensity: number;
  50307. /**
  50308. * Defines the translucency intensity of the material.
  50309. * When translucency has been enabled, this defines how much of the "translucency"
  50310. * is addded to the diffuse part of the material.
  50311. */
  50312. translucencyIntensity: number;
  50313. /**
  50314. * Defines the scattering intensity of the material.
  50315. * When scattering has been enabled, this defines how much of the "scattered light"
  50316. * is addded to the diffuse part of the material.
  50317. */
  50318. scatteringIntensity: number;
  50319. private _thicknessTexture;
  50320. /**
  50321. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  50322. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  50323. * 0 would mean minimumThickness
  50324. * 1 would mean maximumThickness
  50325. * The other channels might be use as a mask to vary the different effects intensity.
  50326. */
  50327. thicknessTexture: Nullable<BaseTexture>;
  50328. private _refractionTexture;
  50329. /**
  50330. * Defines the texture to use for refraction.
  50331. */
  50332. refractionTexture: Nullable<BaseTexture>;
  50333. private _indexOfRefraction;
  50334. /**
  50335. * Defines the index of refraction used in the material.
  50336. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  50337. */
  50338. indexOfRefraction: number;
  50339. private _invertRefractionY;
  50340. /**
  50341. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50342. */
  50343. invertRefractionY: boolean;
  50344. private _linkRefractionWithTransparency;
  50345. /**
  50346. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50347. * Materials half opaque for instance using refraction could benefit from this control.
  50348. */
  50349. linkRefractionWithTransparency: boolean;
  50350. /**
  50351. * Defines the minimum thickness stored in the thickness map.
  50352. * If no thickness map is defined, this value will be used to simulate thickness.
  50353. */
  50354. minimumThickness: number;
  50355. /**
  50356. * Defines the maximum thickness stored in the thickness map.
  50357. */
  50358. maximumThickness: number;
  50359. /**
  50360. * Defines the volume tint of the material.
  50361. * This is used for both translucency and scattering.
  50362. */
  50363. tintColor: Color3;
  50364. /**
  50365. * Defines the distance at which the tint color should be found in the media.
  50366. * This is used for refraction only.
  50367. */
  50368. tintColorAtDistance: number;
  50369. /**
  50370. * Defines how far each channel transmit through the media.
  50371. * It is defined as a color to simplify it selection.
  50372. */
  50373. diffusionDistance: Color3;
  50374. private _useMaskFromThicknessTexture;
  50375. /**
  50376. * Stores the intensity of the different subsurface effects in the thickness texture.
  50377. * * the green channel is the translucency intensity.
  50378. * * the blue channel is the scattering intensity.
  50379. * * the alpha channel is the refraction intensity.
  50380. */
  50381. useMaskFromThicknessTexture: boolean;
  50382. /** @hidden */
  50383. private _internalMarkAllSubMeshesAsTexturesDirty;
  50384. /** @hidden */
  50385. _markAllSubMeshesAsTexturesDirty(): void;
  50386. /**
  50387. * Instantiate a new istance of sub surface configuration.
  50388. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50389. */
  50390. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50391. /**
  50392. * Gets wehter the submesh is ready to be used or not.
  50393. * @param defines the list of "defines" to update.
  50394. * @param scene defines the scene the material belongs to.
  50395. * @returns - boolean indicating that the submesh is ready or not.
  50396. */
  50397. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  50398. /**
  50399. * Checks to see if a texture is used in the material.
  50400. * @param defines the list of "defines" to update.
  50401. * @param scene defines the scene to the material belongs to.
  50402. */
  50403. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  50404. /**
  50405. * Binds the material data.
  50406. * @param uniformBuffer defines the Uniform buffer to fill in.
  50407. * @param scene defines the scene the material belongs to.
  50408. * @param engine defines the engine the material belongs to.
  50409. * @param isFrozen defines wether the material is frozen or not.
  50410. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  50411. */
  50412. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  50413. /**
  50414. * Unbinds the material from the mesh.
  50415. * @param activeEffect defines the effect that should be unbound from.
  50416. * @returns true if unbound, otherwise false
  50417. */
  50418. unbind(activeEffect: Effect): boolean;
  50419. /**
  50420. * Returns the texture used for refraction or null if none is used.
  50421. * @param scene defines the scene the material belongs to.
  50422. * @returns - Refraction texture if present. If no refraction texture and refraction
  50423. * is linked with transparency, returns environment texture. Otherwise, returns null.
  50424. */
  50425. private _getRefractionTexture;
  50426. /**
  50427. * Returns true if alpha blending should be disabled.
  50428. */
  50429. readonly disableAlphaBlending: boolean;
  50430. /**
  50431. * Fills the list of render target textures.
  50432. * @param renderTargets the list of render targets to update
  50433. */
  50434. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  50435. /**
  50436. * Checks to see if a texture is used in the material.
  50437. * @param texture - Base texture to use.
  50438. * @returns - Boolean specifying if a texture is used in the material.
  50439. */
  50440. hasTexture(texture: BaseTexture): boolean;
  50441. /**
  50442. * Gets a boolean indicating that current material needs to register RTT
  50443. * @returns true if this uses a render target otherwise false.
  50444. */
  50445. hasRenderTargetTextures(): boolean;
  50446. /**
  50447. * Returns an array of the actively used textures.
  50448. * @param activeTextures Array of BaseTextures
  50449. */
  50450. getActiveTextures(activeTextures: BaseTexture[]): void;
  50451. /**
  50452. * Returns the animatable textures.
  50453. * @param animatables Array of animatable textures.
  50454. */
  50455. getAnimatables(animatables: IAnimatable[]): void;
  50456. /**
  50457. * Disposes the resources of the material.
  50458. * @param forceDisposeTextures - Forces the disposal of all textures.
  50459. */
  50460. dispose(forceDisposeTextures?: boolean): void;
  50461. /**
  50462. * Get the current class name of the texture useful for serialization or dynamic coding.
  50463. * @returns "PBRSubSurfaceConfiguration"
  50464. */
  50465. getClassName(): string;
  50466. /**
  50467. * Add fallbacks to the effect fallbacks list.
  50468. * @param defines defines the Base texture to use.
  50469. * @param fallbacks defines the current fallback list.
  50470. * @param currentRank defines the current fallback rank.
  50471. * @returns the new fallback rank.
  50472. */
  50473. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50474. /**
  50475. * Add the required uniforms to the current list.
  50476. * @param uniforms defines the current uniform list.
  50477. */
  50478. static AddUniforms(uniforms: string[]): void;
  50479. /**
  50480. * Add the required samplers to the current list.
  50481. * @param samplers defines the current sampler list.
  50482. */
  50483. static AddSamplers(samplers: string[]): void;
  50484. /**
  50485. * Add the required uniforms to the current buffer.
  50486. * @param uniformBuffer defines the current uniform buffer.
  50487. */
  50488. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50489. /**
  50490. * Makes a duplicate of the current configuration into another one.
  50491. * @param configuration define the config where to copy the info
  50492. */
  50493. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  50494. /**
  50495. * Serializes this Sub Surface configuration.
  50496. * @returns - An object with the serialized config.
  50497. */
  50498. serialize(): any;
  50499. /**
  50500. * Parses a anisotropy Configuration from a serialized object.
  50501. * @param source - Serialized object.
  50502. * @param scene Defines the scene we are parsing for
  50503. * @param rootUrl Defines the rootUrl to load from
  50504. */
  50505. parse(source: any, scene: Scene, rootUrl: string): void;
  50506. }
  50507. }
  50508. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  50509. /** @hidden */
  50510. export var pbrFragmentDeclaration: {
  50511. name: string;
  50512. shader: string;
  50513. };
  50514. }
  50515. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  50516. /** @hidden */
  50517. export var pbrUboDeclaration: {
  50518. name: string;
  50519. shader: string;
  50520. };
  50521. }
  50522. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  50523. /** @hidden */
  50524. export var pbrFragmentExtraDeclaration: {
  50525. name: string;
  50526. shader: string;
  50527. };
  50528. }
  50529. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  50530. /** @hidden */
  50531. export var pbrFragmentSamplersDeclaration: {
  50532. name: string;
  50533. shader: string;
  50534. };
  50535. }
  50536. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  50537. /** @hidden */
  50538. export var pbrHelperFunctions: {
  50539. name: string;
  50540. shader: string;
  50541. };
  50542. }
  50543. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  50544. /** @hidden */
  50545. export var harmonicsFunctions: {
  50546. name: string;
  50547. shader: string;
  50548. };
  50549. }
  50550. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  50551. /** @hidden */
  50552. export var pbrDirectLightingSetupFunctions: {
  50553. name: string;
  50554. shader: string;
  50555. };
  50556. }
  50557. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  50558. /** @hidden */
  50559. export var pbrDirectLightingFalloffFunctions: {
  50560. name: string;
  50561. shader: string;
  50562. };
  50563. }
  50564. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  50565. /** @hidden */
  50566. export var pbrBRDFFunctions: {
  50567. name: string;
  50568. shader: string;
  50569. };
  50570. }
  50571. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  50572. /** @hidden */
  50573. export var pbrDirectLightingFunctions: {
  50574. name: string;
  50575. shader: string;
  50576. };
  50577. }
  50578. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  50579. /** @hidden */
  50580. export var pbrIBLFunctions: {
  50581. name: string;
  50582. shader: string;
  50583. };
  50584. }
  50585. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  50586. /** @hidden */
  50587. export var pbrDebug: {
  50588. name: string;
  50589. shader: string;
  50590. };
  50591. }
  50592. declare module "babylonjs/Shaders/pbr.fragment" {
  50593. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  50594. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  50595. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  50596. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  50597. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  50598. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  50599. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  50600. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  50601. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  50602. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  50603. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  50604. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  50605. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  50606. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  50607. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  50608. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  50609. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  50610. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  50611. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  50612. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  50613. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  50614. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  50615. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  50616. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  50617. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  50618. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  50619. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  50620. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  50621. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  50622. /** @hidden */
  50623. export var pbrPixelShader: {
  50624. name: string;
  50625. shader: string;
  50626. };
  50627. }
  50628. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  50629. /** @hidden */
  50630. export var pbrVertexDeclaration: {
  50631. name: string;
  50632. shader: string;
  50633. };
  50634. }
  50635. declare module "babylonjs/Shaders/pbr.vertex" {
  50636. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  50637. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  50638. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  50639. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  50640. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  50641. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  50642. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  50643. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  50644. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  50645. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  50646. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  50647. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  50648. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  50649. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  50650. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  50651. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  50652. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  50653. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  50654. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  50655. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  50656. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  50657. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  50658. /** @hidden */
  50659. export var pbrVertexShader: {
  50660. name: string;
  50661. shader: string;
  50662. };
  50663. }
  50664. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  50665. import { Nullable } from "babylonjs/types";
  50666. import { Scene } from "babylonjs/scene";
  50667. import { Matrix } from "babylonjs/Maths/math.vector";
  50668. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50669. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50670. import { Mesh } from "babylonjs/Meshes/mesh";
  50671. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  50672. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  50673. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  50674. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  50675. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  50676. import { Color3 } from "babylonjs/Maths/math.color";
  50677. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  50678. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  50679. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  50680. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  50681. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50682. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  50683. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  50684. import "babylonjs/Shaders/pbr.fragment";
  50685. import "babylonjs/Shaders/pbr.vertex";
  50686. /**
  50687. * Manages the defines for the PBR Material.
  50688. * @hidden
  50689. */
  50690. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  50691. PBR: boolean;
  50692. MAINUV1: boolean;
  50693. MAINUV2: boolean;
  50694. UV1: boolean;
  50695. UV2: boolean;
  50696. ALBEDO: boolean;
  50697. ALBEDODIRECTUV: number;
  50698. VERTEXCOLOR: boolean;
  50699. AMBIENT: boolean;
  50700. AMBIENTDIRECTUV: number;
  50701. AMBIENTINGRAYSCALE: boolean;
  50702. OPACITY: boolean;
  50703. VERTEXALPHA: boolean;
  50704. OPACITYDIRECTUV: number;
  50705. OPACITYRGB: boolean;
  50706. ALPHATEST: boolean;
  50707. DEPTHPREPASS: boolean;
  50708. ALPHABLEND: boolean;
  50709. ALPHAFROMALBEDO: boolean;
  50710. ALPHATESTVALUE: string;
  50711. SPECULAROVERALPHA: boolean;
  50712. RADIANCEOVERALPHA: boolean;
  50713. ALPHAFRESNEL: boolean;
  50714. LINEARALPHAFRESNEL: boolean;
  50715. PREMULTIPLYALPHA: boolean;
  50716. EMISSIVE: boolean;
  50717. EMISSIVEDIRECTUV: number;
  50718. REFLECTIVITY: boolean;
  50719. REFLECTIVITYDIRECTUV: number;
  50720. SPECULARTERM: boolean;
  50721. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  50722. MICROSURFACEAUTOMATIC: boolean;
  50723. LODBASEDMICROSFURACE: boolean;
  50724. MICROSURFACEMAP: boolean;
  50725. MICROSURFACEMAPDIRECTUV: number;
  50726. METALLICWORKFLOW: boolean;
  50727. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  50728. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  50729. METALLNESSSTOREINMETALMAPBLUE: boolean;
  50730. AOSTOREINMETALMAPRED: boolean;
  50731. METALLICF0FACTORFROMMETALLICMAP: boolean;
  50732. ENVIRONMENTBRDF: boolean;
  50733. ENVIRONMENTBRDF_RGBD: boolean;
  50734. NORMAL: boolean;
  50735. TANGENT: boolean;
  50736. BUMP: boolean;
  50737. BUMPDIRECTUV: number;
  50738. OBJECTSPACE_NORMALMAP: boolean;
  50739. PARALLAX: boolean;
  50740. PARALLAXOCCLUSION: boolean;
  50741. NORMALXYSCALE: boolean;
  50742. LIGHTMAP: boolean;
  50743. LIGHTMAPDIRECTUV: number;
  50744. USELIGHTMAPASSHADOWMAP: boolean;
  50745. GAMMALIGHTMAP: boolean;
  50746. RGBDLIGHTMAP: boolean;
  50747. REFLECTION: boolean;
  50748. REFLECTIONMAP_3D: boolean;
  50749. REFLECTIONMAP_SPHERICAL: boolean;
  50750. REFLECTIONMAP_PLANAR: boolean;
  50751. REFLECTIONMAP_CUBIC: boolean;
  50752. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  50753. REFLECTIONMAP_PROJECTION: boolean;
  50754. REFLECTIONMAP_SKYBOX: boolean;
  50755. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  50756. REFLECTIONMAP_EXPLICIT: boolean;
  50757. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  50758. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  50759. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  50760. INVERTCUBICMAP: boolean;
  50761. USESPHERICALFROMREFLECTIONMAP: boolean;
  50762. USEIRRADIANCEMAP: boolean;
  50763. SPHERICAL_HARMONICS: boolean;
  50764. USESPHERICALINVERTEX: boolean;
  50765. REFLECTIONMAP_OPPOSITEZ: boolean;
  50766. LODINREFLECTIONALPHA: boolean;
  50767. GAMMAREFLECTION: boolean;
  50768. RGBDREFLECTION: boolean;
  50769. LINEARSPECULARREFLECTION: boolean;
  50770. RADIANCEOCCLUSION: boolean;
  50771. HORIZONOCCLUSION: boolean;
  50772. INSTANCES: boolean;
  50773. NUM_BONE_INFLUENCERS: number;
  50774. BonesPerMesh: number;
  50775. BONETEXTURE: boolean;
  50776. NONUNIFORMSCALING: boolean;
  50777. MORPHTARGETS: boolean;
  50778. MORPHTARGETS_NORMAL: boolean;
  50779. MORPHTARGETS_TANGENT: boolean;
  50780. MORPHTARGETS_UV: boolean;
  50781. NUM_MORPH_INFLUENCERS: number;
  50782. IMAGEPROCESSING: boolean;
  50783. VIGNETTE: boolean;
  50784. VIGNETTEBLENDMODEMULTIPLY: boolean;
  50785. VIGNETTEBLENDMODEOPAQUE: boolean;
  50786. TONEMAPPING: boolean;
  50787. TONEMAPPING_ACES: boolean;
  50788. CONTRAST: boolean;
  50789. COLORCURVES: boolean;
  50790. COLORGRADING: boolean;
  50791. COLORGRADING3D: boolean;
  50792. SAMPLER3DGREENDEPTH: boolean;
  50793. SAMPLER3DBGRMAP: boolean;
  50794. IMAGEPROCESSINGPOSTPROCESS: boolean;
  50795. EXPOSURE: boolean;
  50796. MULTIVIEW: boolean;
  50797. USEPHYSICALLIGHTFALLOFF: boolean;
  50798. USEGLTFLIGHTFALLOFF: boolean;
  50799. TWOSIDEDLIGHTING: boolean;
  50800. SHADOWFLOAT: boolean;
  50801. CLIPPLANE: boolean;
  50802. CLIPPLANE2: boolean;
  50803. CLIPPLANE3: boolean;
  50804. CLIPPLANE4: boolean;
  50805. POINTSIZE: boolean;
  50806. FOG: boolean;
  50807. LOGARITHMICDEPTH: boolean;
  50808. FORCENORMALFORWARD: boolean;
  50809. SPECULARAA: boolean;
  50810. CLEARCOAT: boolean;
  50811. CLEARCOAT_DEFAULTIOR: boolean;
  50812. CLEARCOAT_TEXTURE: boolean;
  50813. CLEARCOAT_TEXTUREDIRECTUV: number;
  50814. CLEARCOAT_BUMP: boolean;
  50815. CLEARCOAT_BUMPDIRECTUV: number;
  50816. CLEARCOAT_TINT: boolean;
  50817. CLEARCOAT_TINT_TEXTURE: boolean;
  50818. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50819. ANISOTROPIC: boolean;
  50820. ANISOTROPIC_TEXTURE: boolean;
  50821. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50822. BRDF_V_HEIGHT_CORRELATED: boolean;
  50823. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50824. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50825. SHEEN: boolean;
  50826. SHEEN_TEXTURE: boolean;
  50827. SHEEN_TEXTUREDIRECTUV: number;
  50828. SHEEN_LINKWITHALBEDO: boolean;
  50829. SUBSURFACE: boolean;
  50830. SS_REFRACTION: boolean;
  50831. SS_TRANSLUCENCY: boolean;
  50832. SS_SCATERRING: boolean;
  50833. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50834. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50835. SS_REFRACTIONMAP_3D: boolean;
  50836. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50837. SS_LODINREFRACTIONALPHA: boolean;
  50838. SS_GAMMAREFRACTION: boolean;
  50839. SS_RGBDREFRACTION: boolean;
  50840. SS_LINEARSPECULARREFRACTION: boolean;
  50841. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50842. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50843. UNLIT: boolean;
  50844. DEBUGMODE: number;
  50845. /**
  50846. * Initializes the PBR Material defines.
  50847. */
  50848. constructor();
  50849. /**
  50850. * Resets the PBR Material defines.
  50851. */
  50852. reset(): void;
  50853. }
  50854. /**
  50855. * The Physically based material base class of BJS.
  50856. *
  50857. * This offers the main features of a standard PBR material.
  50858. * For more information, please refer to the documentation :
  50859. * https://doc.babylonjs.com/how_to/physically_based_rendering
  50860. */
  50861. export abstract class PBRBaseMaterial extends PushMaterial {
  50862. /**
  50863. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  50864. */
  50865. static readonly PBRMATERIAL_OPAQUE: number;
  50866. /**
  50867. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  50868. */
  50869. static readonly PBRMATERIAL_ALPHATEST: number;
  50870. /**
  50871. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50872. */
  50873. static readonly PBRMATERIAL_ALPHABLEND: number;
  50874. /**
  50875. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50876. * They are also discarded below the alpha cutoff threshold to improve performances.
  50877. */
  50878. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  50879. /**
  50880. * Defines the default value of how much AO map is occluding the analytical lights
  50881. * (point spot...).
  50882. */
  50883. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  50884. /**
  50885. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  50886. */
  50887. static readonly LIGHTFALLOFF_PHYSICAL: number;
  50888. /**
  50889. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  50890. * to enhance interoperability with other engines.
  50891. */
  50892. static readonly LIGHTFALLOFF_GLTF: number;
  50893. /**
  50894. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  50895. * to enhance interoperability with other materials.
  50896. */
  50897. static readonly LIGHTFALLOFF_STANDARD: number;
  50898. /**
  50899. * Intensity of the direct lights e.g. the four lights available in your scene.
  50900. * This impacts both the direct diffuse and specular highlights.
  50901. */
  50902. protected _directIntensity: number;
  50903. /**
  50904. * Intensity of the emissive part of the material.
  50905. * This helps controlling the emissive effect without modifying the emissive color.
  50906. */
  50907. protected _emissiveIntensity: number;
  50908. /**
  50909. * Intensity of the environment e.g. how much the environment will light the object
  50910. * either through harmonics for rough material or through the refelction for shiny ones.
  50911. */
  50912. protected _environmentIntensity: number;
  50913. /**
  50914. * This is a special control allowing the reduction of the specular highlights coming from the
  50915. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  50916. */
  50917. protected _specularIntensity: number;
  50918. /**
  50919. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  50920. */
  50921. private _lightingInfos;
  50922. /**
  50923. * Debug Control allowing disabling the bump map on this material.
  50924. */
  50925. protected _disableBumpMap: boolean;
  50926. /**
  50927. * AKA Diffuse Texture in standard nomenclature.
  50928. */
  50929. protected _albedoTexture: Nullable<BaseTexture>;
  50930. /**
  50931. * AKA Occlusion Texture in other nomenclature.
  50932. */
  50933. protected _ambientTexture: Nullable<BaseTexture>;
  50934. /**
  50935. * AKA Occlusion Texture Intensity in other nomenclature.
  50936. */
  50937. protected _ambientTextureStrength: number;
  50938. /**
  50939. * Defines how much the AO map is occluding the analytical lights (point spot...).
  50940. * 1 means it completely occludes it
  50941. * 0 mean it has no impact
  50942. */
  50943. protected _ambientTextureImpactOnAnalyticalLights: number;
  50944. /**
  50945. * Stores the alpha values in a texture.
  50946. */
  50947. protected _opacityTexture: Nullable<BaseTexture>;
  50948. /**
  50949. * Stores the reflection values in a texture.
  50950. */
  50951. protected _reflectionTexture: Nullable<BaseTexture>;
  50952. /**
  50953. * Stores the emissive values in a texture.
  50954. */
  50955. protected _emissiveTexture: Nullable<BaseTexture>;
  50956. /**
  50957. * AKA Specular texture in other nomenclature.
  50958. */
  50959. protected _reflectivityTexture: Nullable<BaseTexture>;
  50960. /**
  50961. * Used to switch from specular/glossiness to metallic/roughness workflow.
  50962. */
  50963. protected _metallicTexture: Nullable<BaseTexture>;
  50964. /**
  50965. * Specifies the metallic scalar of the metallic/roughness workflow.
  50966. * Can also be used to scale the metalness values of the metallic texture.
  50967. */
  50968. protected _metallic: Nullable<number>;
  50969. /**
  50970. * Specifies the roughness scalar of the metallic/roughness workflow.
  50971. * Can also be used to scale the roughness values of the metallic texture.
  50972. */
  50973. protected _roughness: Nullable<number>;
  50974. /**
  50975. * Specifies the an F0 factor to help configuring the material F0.
  50976. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  50977. * to 0.5 the previously hard coded value stays the same.
  50978. * Can also be used to scale the F0 values of the metallic texture.
  50979. */
  50980. protected _metallicF0Factor: number;
  50981. /**
  50982. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  50983. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  50984. * your expectation as it multiplies with the texture data.
  50985. */
  50986. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  50987. /**
  50988. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  50989. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  50990. */
  50991. protected _microSurfaceTexture: Nullable<BaseTexture>;
  50992. /**
  50993. * Stores surface normal data used to displace a mesh in a texture.
  50994. */
  50995. protected _bumpTexture: Nullable<BaseTexture>;
  50996. /**
  50997. * Stores the pre-calculated light information of a mesh in a texture.
  50998. */
  50999. protected _lightmapTexture: Nullable<BaseTexture>;
  51000. /**
  51001. * The color of a material in ambient lighting.
  51002. */
  51003. protected _ambientColor: Color3;
  51004. /**
  51005. * AKA Diffuse Color in other nomenclature.
  51006. */
  51007. protected _albedoColor: Color3;
  51008. /**
  51009. * AKA Specular Color in other nomenclature.
  51010. */
  51011. protected _reflectivityColor: Color3;
  51012. /**
  51013. * The color applied when light is reflected from a material.
  51014. */
  51015. protected _reflectionColor: Color3;
  51016. /**
  51017. * The color applied when light is emitted from a material.
  51018. */
  51019. protected _emissiveColor: Color3;
  51020. /**
  51021. * AKA Glossiness in other nomenclature.
  51022. */
  51023. protected _microSurface: number;
  51024. /**
  51025. * Specifies that the material will use the light map as a show map.
  51026. */
  51027. protected _useLightmapAsShadowmap: boolean;
  51028. /**
  51029. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51030. * makes the reflect vector face the model (under horizon).
  51031. */
  51032. protected _useHorizonOcclusion: boolean;
  51033. /**
  51034. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51035. * too much the area relying on ambient texture to define their ambient occlusion.
  51036. */
  51037. protected _useRadianceOcclusion: boolean;
  51038. /**
  51039. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51040. */
  51041. protected _useAlphaFromAlbedoTexture: boolean;
  51042. /**
  51043. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  51044. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51045. */
  51046. protected _useSpecularOverAlpha: boolean;
  51047. /**
  51048. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51049. */
  51050. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51051. /**
  51052. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51053. */
  51054. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  51055. /**
  51056. * Specifies if the metallic texture contains the roughness information in its green channel.
  51057. */
  51058. protected _useRoughnessFromMetallicTextureGreen: boolean;
  51059. /**
  51060. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51061. */
  51062. protected _useMetallnessFromMetallicTextureBlue: boolean;
  51063. /**
  51064. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51065. */
  51066. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  51067. /**
  51068. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51069. */
  51070. protected _useAmbientInGrayScale: boolean;
  51071. /**
  51072. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51073. * The material will try to infer what glossiness each pixel should be.
  51074. */
  51075. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  51076. /**
  51077. * Defines the falloff type used in this material.
  51078. * It by default is Physical.
  51079. */
  51080. protected _lightFalloff: number;
  51081. /**
  51082. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51083. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51084. */
  51085. protected _useRadianceOverAlpha: boolean;
  51086. /**
  51087. * Allows using an object space normal map (instead of tangent space).
  51088. */
  51089. protected _useObjectSpaceNormalMap: boolean;
  51090. /**
  51091. * Allows using the bump map in parallax mode.
  51092. */
  51093. protected _useParallax: boolean;
  51094. /**
  51095. * Allows using the bump map in parallax occlusion mode.
  51096. */
  51097. protected _useParallaxOcclusion: boolean;
  51098. /**
  51099. * Controls the scale bias of the parallax mode.
  51100. */
  51101. protected _parallaxScaleBias: number;
  51102. /**
  51103. * If sets to true, disables all the lights affecting the material.
  51104. */
  51105. protected _disableLighting: boolean;
  51106. /**
  51107. * Number of Simultaneous lights allowed on the material.
  51108. */
  51109. protected _maxSimultaneousLights: number;
  51110. /**
  51111. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  51112. */
  51113. protected _invertNormalMapX: boolean;
  51114. /**
  51115. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  51116. */
  51117. protected _invertNormalMapY: boolean;
  51118. /**
  51119. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51120. */
  51121. protected _twoSidedLighting: boolean;
  51122. /**
  51123. * Defines the alpha limits in alpha test mode.
  51124. */
  51125. protected _alphaCutOff: number;
  51126. /**
  51127. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51128. */
  51129. protected _forceAlphaTest: boolean;
  51130. /**
  51131. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51132. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51133. */
  51134. protected _useAlphaFresnel: boolean;
  51135. /**
  51136. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51137. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51138. */
  51139. protected _useLinearAlphaFresnel: boolean;
  51140. /**
  51141. * The transparency mode of the material.
  51142. */
  51143. protected _transparencyMode: Nullable<number>;
  51144. /**
  51145. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  51146. * from cos thetav and roughness:
  51147. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  51148. */
  51149. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  51150. /**
  51151. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51152. */
  51153. protected _forceIrradianceInFragment: boolean;
  51154. /**
  51155. * Force normal to face away from face.
  51156. */
  51157. protected _forceNormalForward: boolean;
  51158. /**
  51159. * Enables specular anti aliasing in the PBR shader.
  51160. * It will both interacts on the Geometry for analytical and IBL lighting.
  51161. * It also prefilter the roughness map based on the bump values.
  51162. */
  51163. protected _enableSpecularAntiAliasing: boolean;
  51164. /**
  51165. * Default configuration related to image processing available in the PBR Material.
  51166. */
  51167. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51168. /**
  51169. * Keep track of the image processing observer to allow dispose and replace.
  51170. */
  51171. private _imageProcessingObserver;
  51172. /**
  51173. * Attaches a new image processing configuration to the PBR Material.
  51174. * @param configuration
  51175. */
  51176. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51177. /**
  51178. * Stores the available render targets.
  51179. */
  51180. private _renderTargets;
  51181. /**
  51182. * Sets the global ambient color for the material used in lighting calculations.
  51183. */
  51184. private _globalAmbientColor;
  51185. /**
  51186. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  51187. */
  51188. private _useLogarithmicDepth;
  51189. /**
  51190. * If set to true, no lighting calculations will be applied.
  51191. */
  51192. private _unlit;
  51193. private _debugMode;
  51194. /**
  51195. * @hidden
  51196. * This is reserved for the inspector.
  51197. * Defines the material debug mode.
  51198. * It helps seeing only some components of the material while troubleshooting.
  51199. */
  51200. debugMode: number;
  51201. /**
  51202. * @hidden
  51203. * This is reserved for the inspector.
  51204. * Specify from where on screen the debug mode should start.
  51205. * The value goes from -1 (full screen) to 1 (not visible)
  51206. * It helps with side by side comparison against the final render
  51207. * This defaults to -1
  51208. */
  51209. private debugLimit;
  51210. /**
  51211. * @hidden
  51212. * This is reserved for the inspector.
  51213. * As the default viewing range might not be enough (if the ambient is really small for instance)
  51214. * You can use the factor to better multiply the final value.
  51215. */
  51216. private debugFactor;
  51217. /**
  51218. * Defines the clear coat layer parameters for the material.
  51219. */
  51220. readonly clearCoat: PBRClearCoatConfiguration;
  51221. /**
  51222. * Defines the anisotropic parameters for the material.
  51223. */
  51224. readonly anisotropy: PBRAnisotropicConfiguration;
  51225. /**
  51226. * Defines the BRDF parameters for the material.
  51227. */
  51228. readonly brdf: PBRBRDFConfiguration;
  51229. /**
  51230. * Defines the Sheen parameters for the material.
  51231. */
  51232. readonly sheen: PBRSheenConfiguration;
  51233. /**
  51234. * Defines the SubSurface parameters for the material.
  51235. */
  51236. readonly subSurface: PBRSubSurfaceConfiguration;
  51237. /**
  51238. * Custom callback helping to override the default shader used in the material.
  51239. */
  51240. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  51241. protected _rebuildInParallel: boolean;
  51242. /**
  51243. * Instantiates a new PBRMaterial instance.
  51244. *
  51245. * @param name The material name
  51246. * @param scene The scene the material will be use in.
  51247. */
  51248. constructor(name: string, scene: Scene);
  51249. /**
  51250. * Gets a boolean indicating that current material needs to register RTT
  51251. */
  51252. readonly hasRenderTargetTextures: boolean;
  51253. /**
  51254. * Gets the name of the material class.
  51255. */
  51256. getClassName(): string;
  51257. /**
  51258. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51259. */
  51260. /**
  51261. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51262. */
  51263. useLogarithmicDepth: boolean;
  51264. /**
  51265. * Gets the current transparency mode.
  51266. */
  51267. /**
  51268. * Sets the transparency mode of the material.
  51269. *
  51270. * | Value | Type | Description |
  51271. * | ----- | ----------------------------------- | ----------- |
  51272. * | 0 | OPAQUE | |
  51273. * | 1 | ALPHATEST | |
  51274. * | 2 | ALPHABLEND | |
  51275. * | 3 | ALPHATESTANDBLEND | |
  51276. *
  51277. */
  51278. transparencyMode: Nullable<number>;
  51279. /**
  51280. * Returns true if alpha blending should be disabled.
  51281. */
  51282. private readonly _disableAlphaBlending;
  51283. /**
  51284. * Specifies whether or not this material should be rendered in alpha blend mode.
  51285. */
  51286. needAlphaBlending(): boolean;
  51287. /**
  51288. * Specifies if the mesh will require alpha blending.
  51289. * @param mesh - BJS mesh.
  51290. */
  51291. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  51292. /**
  51293. * Specifies whether or not this material should be rendered in alpha test mode.
  51294. */
  51295. needAlphaTesting(): boolean;
  51296. /**
  51297. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  51298. */
  51299. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  51300. /**
  51301. * Gets the texture used for the alpha test.
  51302. */
  51303. getAlphaTestTexture(): Nullable<BaseTexture>;
  51304. /**
  51305. * Specifies that the submesh is ready to be used.
  51306. * @param mesh - BJS mesh.
  51307. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  51308. * @param useInstances - Specifies that instances should be used.
  51309. * @returns - boolean indicating that the submesh is ready or not.
  51310. */
  51311. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51312. /**
  51313. * Specifies if the material uses metallic roughness workflow.
  51314. * @returns boolean specifiying if the material uses metallic roughness workflow.
  51315. */
  51316. isMetallicWorkflow(): boolean;
  51317. private _prepareEffect;
  51318. private _prepareDefines;
  51319. /**
  51320. * Force shader compilation
  51321. */
  51322. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  51323. /**
  51324. * Initializes the uniform buffer layout for the shader.
  51325. */
  51326. buildUniformLayout(): void;
  51327. /**
  51328. * Unbinds the material from the mesh
  51329. */
  51330. unbind(): void;
  51331. /**
  51332. * Binds the submesh data.
  51333. * @param world - The world matrix.
  51334. * @param mesh - The BJS mesh.
  51335. * @param subMesh - A submesh of the BJS mesh.
  51336. */
  51337. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51338. /**
  51339. * Returns the animatable textures.
  51340. * @returns - Array of animatable textures.
  51341. */
  51342. getAnimatables(): IAnimatable[];
  51343. /**
  51344. * Returns the texture used for reflections.
  51345. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  51346. */
  51347. private _getReflectionTexture;
  51348. /**
  51349. * Returns an array of the actively used textures.
  51350. * @returns - Array of BaseTextures
  51351. */
  51352. getActiveTextures(): BaseTexture[];
  51353. /**
  51354. * Checks to see if a texture is used in the material.
  51355. * @param texture - Base texture to use.
  51356. * @returns - Boolean specifying if a texture is used in the material.
  51357. */
  51358. hasTexture(texture: BaseTexture): boolean;
  51359. /**
  51360. * Disposes the resources of the material.
  51361. * @param forceDisposeEffect - Forces the disposal of effects.
  51362. * @param forceDisposeTextures - Forces the disposal of all textures.
  51363. */
  51364. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  51365. }
  51366. }
  51367. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  51368. import { Nullable } from "babylonjs/types";
  51369. import { Scene } from "babylonjs/scene";
  51370. import { Color3 } from "babylonjs/Maths/math.color";
  51371. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  51372. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  51373. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51374. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  51375. /**
  51376. * The Physically based material of BJS.
  51377. *
  51378. * This offers the main features of a standard PBR material.
  51379. * For more information, please refer to the documentation :
  51380. * https://doc.babylonjs.com/how_to/physically_based_rendering
  51381. */
  51382. export class PBRMaterial extends PBRBaseMaterial {
  51383. /**
  51384. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51385. */
  51386. static readonly PBRMATERIAL_OPAQUE: number;
  51387. /**
  51388. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51389. */
  51390. static readonly PBRMATERIAL_ALPHATEST: number;
  51391. /**
  51392. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51393. */
  51394. static readonly PBRMATERIAL_ALPHABLEND: number;
  51395. /**
  51396. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51397. * They are also discarded below the alpha cutoff threshold to improve performances.
  51398. */
  51399. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  51400. /**
  51401. * Defines the default value of how much AO map is occluding the analytical lights
  51402. * (point spot...).
  51403. */
  51404. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  51405. /**
  51406. * Intensity of the direct lights e.g. the four lights available in your scene.
  51407. * This impacts both the direct diffuse and specular highlights.
  51408. */
  51409. directIntensity: number;
  51410. /**
  51411. * Intensity of the emissive part of the material.
  51412. * This helps controlling the emissive effect without modifying the emissive color.
  51413. */
  51414. emissiveIntensity: number;
  51415. /**
  51416. * Intensity of the environment e.g. how much the environment will light the object
  51417. * either through harmonics for rough material or through the refelction for shiny ones.
  51418. */
  51419. environmentIntensity: number;
  51420. /**
  51421. * This is a special control allowing the reduction of the specular highlights coming from the
  51422. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51423. */
  51424. specularIntensity: number;
  51425. /**
  51426. * Debug Control allowing disabling the bump map on this material.
  51427. */
  51428. disableBumpMap: boolean;
  51429. /**
  51430. * AKA Diffuse Texture in standard nomenclature.
  51431. */
  51432. albedoTexture: BaseTexture;
  51433. /**
  51434. * AKA Occlusion Texture in other nomenclature.
  51435. */
  51436. ambientTexture: BaseTexture;
  51437. /**
  51438. * AKA Occlusion Texture Intensity in other nomenclature.
  51439. */
  51440. ambientTextureStrength: number;
  51441. /**
  51442. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51443. * 1 means it completely occludes it
  51444. * 0 mean it has no impact
  51445. */
  51446. ambientTextureImpactOnAnalyticalLights: number;
  51447. /**
  51448. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  51449. */
  51450. opacityTexture: BaseTexture;
  51451. /**
  51452. * Stores the reflection values in a texture.
  51453. */
  51454. reflectionTexture: Nullable<BaseTexture>;
  51455. /**
  51456. * Stores the emissive values in a texture.
  51457. */
  51458. emissiveTexture: BaseTexture;
  51459. /**
  51460. * AKA Specular texture in other nomenclature.
  51461. */
  51462. reflectivityTexture: BaseTexture;
  51463. /**
  51464. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51465. */
  51466. metallicTexture: BaseTexture;
  51467. /**
  51468. * Specifies the metallic scalar of the metallic/roughness workflow.
  51469. * Can also be used to scale the metalness values of the metallic texture.
  51470. */
  51471. metallic: Nullable<number>;
  51472. /**
  51473. * Specifies the roughness scalar of the metallic/roughness workflow.
  51474. * Can also be used to scale the roughness values of the metallic texture.
  51475. */
  51476. roughness: Nullable<number>;
  51477. /**
  51478. * Specifies the an F0 factor to help configuring the material F0.
  51479. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51480. * to 0.5 the previously hard coded value stays the same.
  51481. * Can also be used to scale the F0 values of the metallic texture.
  51482. */
  51483. metallicF0Factor: number;
  51484. /**
  51485. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51486. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51487. * your expectation as it multiplies with the texture data.
  51488. */
  51489. useMetallicF0FactorFromMetallicTexture: boolean;
  51490. /**
  51491. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51492. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51493. */
  51494. microSurfaceTexture: BaseTexture;
  51495. /**
  51496. * Stores surface normal data used to displace a mesh in a texture.
  51497. */
  51498. bumpTexture: BaseTexture;
  51499. /**
  51500. * Stores the pre-calculated light information of a mesh in a texture.
  51501. */
  51502. lightmapTexture: BaseTexture;
  51503. /**
  51504. * Stores the refracted light information in a texture.
  51505. */
  51506. refractionTexture: Nullable<BaseTexture>;
  51507. /**
  51508. * The color of a material in ambient lighting.
  51509. */
  51510. ambientColor: Color3;
  51511. /**
  51512. * AKA Diffuse Color in other nomenclature.
  51513. */
  51514. albedoColor: Color3;
  51515. /**
  51516. * AKA Specular Color in other nomenclature.
  51517. */
  51518. reflectivityColor: Color3;
  51519. /**
  51520. * The color reflected from the material.
  51521. */
  51522. reflectionColor: Color3;
  51523. /**
  51524. * The color emitted from the material.
  51525. */
  51526. emissiveColor: Color3;
  51527. /**
  51528. * AKA Glossiness in other nomenclature.
  51529. */
  51530. microSurface: number;
  51531. /**
  51532. * source material index of refraction (IOR)' / 'destination material IOR.
  51533. */
  51534. indexOfRefraction: number;
  51535. /**
  51536. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  51537. */
  51538. invertRefractionY: boolean;
  51539. /**
  51540. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  51541. * Materials half opaque for instance using refraction could benefit from this control.
  51542. */
  51543. linkRefractionWithTransparency: boolean;
  51544. /**
  51545. * If true, the light map contains occlusion information instead of lighting info.
  51546. */
  51547. useLightmapAsShadowmap: boolean;
  51548. /**
  51549. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51550. */
  51551. useAlphaFromAlbedoTexture: boolean;
  51552. /**
  51553. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51554. */
  51555. forceAlphaTest: boolean;
  51556. /**
  51557. * Defines the alpha limits in alpha test mode.
  51558. */
  51559. alphaCutOff: number;
  51560. /**
  51561. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  51562. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51563. */
  51564. useSpecularOverAlpha: boolean;
  51565. /**
  51566. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51567. */
  51568. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51569. /**
  51570. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51571. */
  51572. useRoughnessFromMetallicTextureAlpha: boolean;
  51573. /**
  51574. * Specifies if the metallic texture contains the roughness information in its green channel.
  51575. */
  51576. useRoughnessFromMetallicTextureGreen: boolean;
  51577. /**
  51578. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51579. */
  51580. useMetallnessFromMetallicTextureBlue: boolean;
  51581. /**
  51582. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51583. */
  51584. useAmbientOcclusionFromMetallicTextureRed: boolean;
  51585. /**
  51586. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51587. */
  51588. useAmbientInGrayScale: boolean;
  51589. /**
  51590. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51591. * The material will try to infer what glossiness each pixel should be.
  51592. */
  51593. useAutoMicroSurfaceFromReflectivityMap: boolean;
  51594. /**
  51595. * BJS is using an harcoded light falloff based on a manually sets up range.
  51596. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  51597. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  51598. */
  51599. /**
  51600. * BJS is using an harcoded light falloff based on a manually sets up range.
  51601. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  51602. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  51603. */
  51604. usePhysicalLightFalloff: boolean;
  51605. /**
  51606. * In order to support the falloff compatibility with gltf, a special mode has been added
  51607. * to reproduce the gltf light falloff.
  51608. */
  51609. /**
  51610. * In order to support the falloff compatibility with gltf, a special mode has been added
  51611. * to reproduce the gltf light falloff.
  51612. */
  51613. useGLTFLightFalloff: boolean;
  51614. /**
  51615. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51616. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51617. */
  51618. useRadianceOverAlpha: boolean;
  51619. /**
  51620. * Allows using an object space normal map (instead of tangent space).
  51621. */
  51622. useObjectSpaceNormalMap: boolean;
  51623. /**
  51624. * Allows using the bump map in parallax mode.
  51625. */
  51626. useParallax: boolean;
  51627. /**
  51628. * Allows using the bump map in parallax occlusion mode.
  51629. */
  51630. useParallaxOcclusion: boolean;
  51631. /**
  51632. * Controls the scale bias of the parallax mode.
  51633. */
  51634. parallaxScaleBias: number;
  51635. /**
  51636. * If sets to true, disables all the lights affecting the material.
  51637. */
  51638. disableLighting: boolean;
  51639. /**
  51640. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51641. */
  51642. forceIrradianceInFragment: boolean;
  51643. /**
  51644. * Number of Simultaneous lights allowed on the material.
  51645. */
  51646. maxSimultaneousLights: number;
  51647. /**
  51648. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51649. */
  51650. invertNormalMapX: boolean;
  51651. /**
  51652. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51653. */
  51654. invertNormalMapY: boolean;
  51655. /**
  51656. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51657. */
  51658. twoSidedLighting: boolean;
  51659. /**
  51660. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51661. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51662. */
  51663. useAlphaFresnel: boolean;
  51664. /**
  51665. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51666. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51667. */
  51668. useLinearAlphaFresnel: boolean;
  51669. /**
  51670. * Let user defines the brdf lookup texture used for IBL.
  51671. * A default 8bit version is embedded but you could point at :
  51672. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  51673. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  51674. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  51675. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  51676. */
  51677. environmentBRDFTexture: Nullable<BaseTexture>;
  51678. /**
  51679. * Force normal to face away from face.
  51680. */
  51681. forceNormalForward: boolean;
  51682. /**
  51683. * Enables specular anti aliasing in the PBR shader.
  51684. * It will both interacts on the Geometry for analytical and IBL lighting.
  51685. * It also prefilter the roughness map based on the bump values.
  51686. */
  51687. enableSpecularAntiAliasing: boolean;
  51688. /**
  51689. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51690. * makes the reflect vector face the model (under horizon).
  51691. */
  51692. useHorizonOcclusion: boolean;
  51693. /**
  51694. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51695. * too much the area relying on ambient texture to define their ambient occlusion.
  51696. */
  51697. useRadianceOcclusion: boolean;
  51698. /**
  51699. * If set to true, no lighting calculations will be applied.
  51700. */
  51701. unlit: boolean;
  51702. /**
  51703. * Gets the image processing configuration used either in this material.
  51704. */
  51705. /**
  51706. * Sets the Default image processing configuration used either in the this material.
  51707. *
  51708. * If sets to null, the scene one is in use.
  51709. */
  51710. imageProcessingConfiguration: ImageProcessingConfiguration;
  51711. /**
  51712. * Gets wether the color curves effect is enabled.
  51713. */
  51714. /**
  51715. * Sets wether the color curves effect is enabled.
  51716. */
  51717. cameraColorCurvesEnabled: boolean;
  51718. /**
  51719. * Gets wether the color grading effect is enabled.
  51720. */
  51721. /**
  51722. * Gets wether the color grading effect is enabled.
  51723. */
  51724. cameraColorGradingEnabled: boolean;
  51725. /**
  51726. * Gets wether tonemapping is enabled or not.
  51727. */
  51728. /**
  51729. * Sets wether tonemapping is enabled or not
  51730. */
  51731. cameraToneMappingEnabled: boolean;
  51732. /**
  51733. * The camera exposure used on this material.
  51734. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51735. * This corresponds to a photographic exposure.
  51736. */
  51737. /**
  51738. * The camera exposure used on this material.
  51739. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51740. * This corresponds to a photographic exposure.
  51741. */
  51742. cameraExposure: number;
  51743. /**
  51744. * Gets The camera contrast used on this material.
  51745. */
  51746. /**
  51747. * Sets The camera contrast used on this material.
  51748. */
  51749. cameraContrast: number;
  51750. /**
  51751. * Gets the Color Grading 2D Lookup Texture.
  51752. */
  51753. /**
  51754. * Sets the Color Grading 2D Lookup Texture.
  51755. */
  51756. cameraColorGradingTexture: Nullable<BaseTexture>;
  51757. /**
  51758. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51759. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51760. * 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;
  51761. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51762. */
  51763. /**
  51764. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51765. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51766. * 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;
  51767. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51768. */
  51769. cameraColorCurves: Nullable<ColorCurves>;
  51770. /**
  51771. * Instantiates a new PBRMaterial instance.
  51772. *
  51773. * @param name The material name
  51774. * @param scene The scene the material will be use in.
  51775. */
  51776. constructor(name: string, scene: Scene);
  51777. /**
  51778. * Returns the name of this material class.
  51779. */
  51780. getClassName(): string;
  51781. /**
  51782. * Makes a duplicate of the current material.
  51783. * @param name - name to use for the new material.
  51784. */
  51785. clone(name: string): PBRMaterial;
  51786. /**
  51787. * Serializes this PBR Material.
  51788. * @returns - An object with the serialized material.
  51789. */
  51790. serialize(): any;
  51791. /**
  51792. * Parses a PBR Material from a serialized object.
  51793. * @param source - Serialized object.
  51794. * @param scene - BJS scene instance.
  51795. * @param rootUrl - url for the scene object
  51796. * @returns - PBRMaterial
  51797. */
  51798. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  51799. }
  51800. }
  51801. declare module "babylonjs/Misc/dds" {
  51802. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  51803. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51804. import { Nullable } from "babylonjs/types";
  51805. import { Scene } from "babylonjs/scene";
  51806. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  51807. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  51808. /**
  51809. * Direct draw surface info
  51810. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  51811. */
  51812. export interface DDSInfo {
  51813. /**
  51814. * Width of the texture
  51815. */
  51816. width: number;
  51817. /**
  51818. * Width of the texture
  51819. */
  51820. height: number;
  51821. /**
  51822. * Number of Mipmaps for the texture
  51823. * @see https://en.wikipedia.org/wiki/Mipmap
  51824. */
  51825. mipmapCount: number;
  51826. /**
  51827. * If the textures format is a known fourCC format
  51828. * @see https://www.fourcc.org/
  51829. */
  51830. isFourCC: boolean;
  51831. /**
  51832. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  51833. */
  51834. isRGB: boolean;
  51835. /**
  51836. * If the texture is a lumincance format
  51837. */
  51838. isLuminance: boolean;
  51839. /**
  51840. * If this is a cube texture
  51841. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  51842. */
  51843. isCube: boolean;
  51844. /**
  51845. * If the texture is a compressed format eg. FOURCC_DXT1
  51846. */
  51847. isCompressed: boolean;
  51848. /**
  51849. * The dxgiFormat of the texture
  51850. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  51851. */
  51852. dxgiFormat: number;
  51853. /**
  51854. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  51855. */
  51856. textureType: number;
  51857. /**
  51858. * Sphericle polynomial created for the dds texture
  51859. */
  51860. sphericalPolynomial?: SphericalPolynomial;
  51861. }
  51862. /**
  51863. * Class used to provide DDS decompression tools
  51864. */
  51865. export class DDSTools {
  51866. /**
  51867. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  51868. */
  51869. static StoreLODInAlphaChannel: boolean;
  51870. /**
  51871. * Gets DDS information from an array buffer
  51872. * @param arrayBuffer defines the array buffer to read data from
  51873. * @returns the DDS information
  51874. */
  51875. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  51876. private static _FloatView;
  51877. private static _Int32View;
  51878. private static _ToHalfFloat;
  51879. private static _FromHalfFloat;
  51880. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  51881. private static _GetHalfFloatRGBAArrayBuffer;
  51882. private static _GetFloatRGBAArrayBuffer;
  51883. private static _GetFloatAsUIntRGBAArrayBuffer;
  51884. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  51885. private static _GetRGBAArrayBuffer;
  51886. private static _ExtractLongWordOrder;
  51887. private static _GetRGBArrayBuffer;
  51888. private static _GetLuminanceArrayBuffer;
  51889. /**
  51890. * Uploads DDS Levels to a Babylon Texture
  51891. * @hidden
  51892. */
  51893. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  51894. }
  51895. module "babylonjs/Engines/thinEngine" {
  51896. interface ThinEngine {
  51897. /**
  51898. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  51899. * @param rootUrl defines the url where the file to load is located
  51900. * @param scene defines the current scene
  51901. * @param lodScale defines scale to apply to the mip map selection
  51902. * @param lodOffset defines offset to apply to the mip map selection
  51903. * @param onLoad defines an optional callback raised when the texture is loaded
  51904. * @param onError defines an optional callback raised if there is an issue to load the texture
  51905. * @param format defines the format of the data
  51906. * @param forcedExtension defines the extension to use to pick the right loader
  51907. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  51908. * @returns the cube texture as an InternalTexture
  51909. */
  51910. 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;
  51911. }
  51912. }
  51913. }
  51914. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  51915. import { Nullable } from "babylonjs/types";
  51916. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51917. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51918. /**
  51919. * Implementation of the DDS Texture Loader.
  51920. * @hidden
  51921. */
  51922. export class _DDSTextureLoader implements IInternalTextureLoader {
  51923. /**
  51924. * Defines wether the loader supports cascade loading the different faces.
  51925. */
  51926. readonly supportCascades: boolean;
  51927. /**
  51928. * This returns if the loader support the current file information.
  51929. * @param extension defines the file extension of the file being loaded
  51930. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51931. * @param fallback defines the fallback internal texture if any
  51932. * @param isBase64 defines whether the texture is encoded as a base64
  51933. * @param isBuffer defines whether the texture data are stored as a buffer
  51934. * @returns true if the loader can load the specified file
  51935. */
  51936. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51937. /**
  51938. * Transform the url before loading if required.
  51939. * @param rootUrl the url of the texture
  51940. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51941. * @returns the transformed texture
  51942. */
  51943. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51944. /**
  51945. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51946. * @param rootUrl the url of the texture
  51947. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51948. * @returns the fallback texture
  51949. */
  51950. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51951. /**
  51952. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51953. * @param data contains the texture data
  51954. * @param texture defines the BabylonJS internal texture
  51955. * @param createPolynomials will be true if polynomials have been requested
  51956. * @param onLoad defines the callback to trigger once the texture is ready
  51957. * @param onError defines the callback to trigger in case of error
  51958. */
  51959. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51960. /**
  51961. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51962. * @param data contains the texture data
  51963. * @param texture defines the BabylonJS internal texture
  51964. * @param callback defines the method to call once ready to upload
  51965. */
  51966. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51967. }
  51968. }
  51969. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  51970. import { Nullable } from "babylonjs/types";
  51971. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51972. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51973. /**
  51974. * Implementation of the ENV Texture Loader.
  51975. * @hidden
  51976. */
  51977. export class _ENVTextureLoader implements IInternalTextureLoader {
  51978. /**
  51979. * Defines wether the loader supports cascade loading the different faces.
  51980. */
  51981. readonly supportCascades: boolean;
  51982. /**
  51983. * This returns if the loader support the current file information.
  51984. * @param extension defines the file extension of the file being loaded
  51985. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51986. * @param fallback defines the fallback internal texture if any
  51987. * @param isBase64 defines whether the texture is encoded as a base64
  51988. * @param isBuffer defines whether the texture data are stored as a buffer
  51989. * @returns true if the loader can load the specified file
  51990. */
  51991. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51992. /**
  51993. * Transform the url before loading if required.
  51994. * @param rootUrl the url of the texture
  51995. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51996. * @returns the transformed texture
  51997. */
  51998. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51999. /**
  52000. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52001. * @param rootUrl the url of the texture
  52002. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52003. * @returns the fallback texture
  52004. */
  52005. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52006. /**
  52007. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52008. * @param data contains the texture data
  52009. * @param texture defines the BabylonJS internal texture
  52010. * @param createPolynomials will be true if polynomials have been requested
  52011. * @param onLoad defines the callback to trigger once the texture is ready
  52012. * @param onError defines the callback to trigger in case of error
  52013. */
  52014. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52015. /**
  52016. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52017. * @param data contains the texture data
  52018. * @param texture defines the BabylonJS internal texture
  52019. * @param callback defines the method to call once ready to upload
  52020. */
  52021. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52022. }
  52023. }
  52024. declare module "babylonjs/Misc/khronosTextureContainer" {
  52025. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52026. /**
  52027. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52028. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52029. */
  52030. export class KhronosTextureContainer {
  52031. /** contents of the KTX container file */
  52032. arrayBuffer: any;
  52033. private static HEADER_LEN;
  52034. private static COMPRESSED_2D;
  52035. private static COMPRESSED_3D;
  52036. private static TEX_2D;
  52037. private static TEX_3D;
  52038. /**
  52039. * Gets the openGL type
  52040. */
  52041. glType: number;
  52042. /**
  52043. * Gets the openGL type size
  52044. */
  52045. glTypeSize: number;
  52046. /**
  52047. * Gets the openGL format
  52048. */
  52049. glFormat: number;
  52050. /**
  52051. * Gets the openGL internal format
  52052. */
  52053. glInternalFormat: number;
  52054. /**
  52055. * Gets the base internal format
  52056. */
  52057. glBaseInternalFormat: number;
  52058. /**
  52059. * Gets image width in pixel
  52060. */
  52061. pixelWidth: number;
  52062. /**
  52063. * Gets image height in pixel
  52064. */
  52065. pixelHeight: number;
  52066. /**
  52067. * Gets image depth in pixels
  52068. */
  52069. pixelDepth: number;
  52070. /**
  52071. * Gets the number of array elements
  52072. */
  52073. numberOfArrayElements: number;
  52074. /**
  52075. * Gets the number of faces
  52076. */
  52077. numberOfFaces: number;
  52078. /**
  52079. * Gets the number of mipmap levels
  52080. */
  52081. numberOfMipmapLevels: number;
  52082. /**
  52083. * Gets the bytes of key value data
  52084. */
  52085. bytesOfKeyValueData: number;
  52086. /**
  52087. * Gets the load type
  52088. */
  52089. loadType: number;
  52090. /**
  52091. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  52092. */
  52093. isInvalid: boolean;
  52094. /**
  52095. * Creates a new KhronosTextureContainer
  52096. * @param arrayBuffer contents of the KTX container file
  52097. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  52098. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  52099. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  52100. */
  52101. constructor(
  52102. /** contents of the KTX container file */
  52103. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  52104. /**
  52105. * Uploads KTX content to a Babylon Texture.
  52106. * It is assumed that the texture has already been created & is currently bound
  52107. * @hidden
  52108. */
  52109. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  52110. private _upload2DCompressedLevels;
  52111. }
  52112. }
  52113. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  52114. import { Nullable } from "babylonjs/types";
  52115. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52116. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  52117. /**
  52118. * Implementation of the KTX Texture Loader.
  52119. * @hidden
  52120. */
  52121. export class _KTXTextureLoader implements IInternalTextureLoader {
  52122. /**
  52123. * Defines wether the loader supports cascade loading the different faces.
  52124. */
  52125. readonly supportCascades: boolean;
  52126. /**
  52127. * This returns if the loader support the current file information.
  52128. * @param extension defines the file extension of the file being loaded
  52129. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52130. * @param fallback defines the fallback internal texture if any
  52131. * @param isBase64 defines whether the texture is encoded as a base64
  52132. * @param isBuffer defines whether the texture data are stored as a buffer
  52133. * @returns true if the loader can load the specified file
  52134. */
  52135. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52136. /**
  52137. * Transform the url before loading if required.
  52138. * @param rootUrl the url of the texture
  52139. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52140. * @returns the transformed texture
  52141. */
  52142. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52143. /**
  52144. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52145. * @param rootUrl the url of the texture
  52146. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52147. * @returns the fallback texture
  52148. */
  52149. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52150. /**
  52151. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52152. * @param data contains the texture data
  52153. * @param texture defines the BabylonJS internal texture
  52154. * @param createPolynomials will be true if polynomials have been requested
  52155. * @param onLoad defines the callback to trigger once the texture is ready
  52156. * @param onError defines the callback to trigger in case of error
  52157. */
  52158. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52159. /**
  52160. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52161. * @param data contains the texture data
  52162. * @param texture defines the BabylonJS internal texture
  52163. * @param callback defines the method to call once ready to upload
  52164. */
  52165. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  52166. }
  52167. }
  52168. declare module "babylonjs/Helpers/sceneHelpers" {
  52169. import { Nullable } from "babylonjs/types";
  52170. import { Mesh } from "babylonjs/Meshes/mesh";
  52171. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52172. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  52173. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  52174. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  52175. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  52176. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  52177. import "babylonjs/Meshes/Builders/boxBuilder";
  52178. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  52179. /** @hidden */
  52180. export var _forceSceneHelpersToBundle: boolean;
  52181. module "babylonjs/scene" {
  52182. interface Scene {
  52183. /**
  52184. * Creates a default light for the scene.
  52185. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  52186. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  52187. */
  52188. createDefaultLight(replace?: boolean): void;
  52189. /**
  52190. * Creates a default camera for the scene.
  52191. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  52192. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52193. * @param replace has default false, when true replaces the active camera in the scene
  52194. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  52195. */
  52196. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52197. /**
  52198. * Creates a default camera and a default light.
  52199. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  52200. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52201. * @param replace has the default false, when true replaces the active camera/light in the scene
  52202. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  52203. */
  52204. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52205. /**
  52206. * Creates a new sky box
  52207. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  52208. * @param environmentTexture defines the texture to use as environment texture
  52209. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  52210. * @param scale defines the overall scale of the skybox
  52211. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  52212. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  52213. * @returns a new mesh holding the sky box
  52214. */
  52215. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  52216. /**
  52217. * Creates a new environment
  52218. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  52219. * @param options defines the options you can use to configure the environment
  52220. * @returns the new EnvironmentHelper
  52221. */
  52222. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  52223. /**
  52224. * Creates a new VREXperienceHelper
  52225. * @see http://doc.babylonjs.com/how_to/webvr_helper
  52226. * @param webVROptions defines the options used to create the new VREXperienceHelper
  52227. * @returns a new VREXperienceHelper
  52228. */
  52229. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  52230. /**
  52231. * Creates a new WebXRDefaultExperience
  52232. * @see http://doc.babylonjs.com/how_to/webxr
  52233. * @param options experience options
  52234. * @returns a promise for a new WebXRDefaultExperience
  52235. */
  52236. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  52237. }
  52238. }
  52239. }
  52240. declare module "babylonjs/Helpers/videoDome" {
  52241. import { Scene } from "babylonjs/scene";
  52242. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52243. import { Mesh } from "babylonjs/Meshes/mesh";
  52244. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  52245. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  52246. import "babylonjs/Meshes/Builders/sphereBuilder";
  52247. /**
  52248. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  52249. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  52250. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  52251. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  52252. */
  52253. export class VideoDome extends TransformNode {
  52254. /**
  52255. * Define the video source as a Monoscopic panoramic 360 video.
  52256. */
  52257. static readonly MODE_MONOSCOPIC: number;
  52258. /**
  52259. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52260. */
  52261. static readonly MODE_TOPBOTTOM: number;
  52262. /**
  52263. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52264. */
  52265. static readonly MODE_SIDEBYSIDE: number;
  52266. private _halfDome;
  52267. private _useDirectMapping;
  52268. /**
  52269. * The video texture being displayed on the sphere
  52270. */
  52271. protected _videoTexture: VideoTexture;
  52272. /**
  52273. * Gets the video texture being displayed on the sphere
  52274. */
  52275. readonly videoTexture: VideoTexture;
  52276. /**
  52277. * The skybox material
  52278. */
  52279. protected _material: BackgroundMaterial;
  52280. /**
  52281. * The surface used for the skybox
  52282. */
  52283. protected _mesh: Mesh;
  52284. /**
  52285. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  52286. */
  52287. private _halfDomeMask;
  52288. /**
  52289. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52290. * Also see the options.resolution property.
  52291. */
  52292. fovMultiplier: number;
  52293. private _videoMode;
  52294. /**
  52295. * Gets or set the current video mode for the video. It can be:
  52296. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  52297. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52298. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52299. */
  52300. videoMode: number;
  52301. /**
  52302. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  52303. *
  52304. */
  52305. /**
  52306. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  52307. */
  52308. halfDome: boolean;
  52309. /**
  52310. * Oberserver used in Stereoscopic VR Mode.
  52311. */
  52312. private _onBeforeCameraRenderObserver;
  52313. /**
  52314. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  52315. * @param name Element's name, child elements will append suffixes for their own names.
  52316. * @param urlsOrVideo defines the url(s) or the video element to use
  52317. * @param options An object containing optional or exposed sub element properties
  52318. */
  52319. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  52320. resolution?: number;
  52321. clickToPlay?: boolean;
  52322. autoPlay?: boolean;
  52323. loop?: boolean;
  52324. size?: number;
  52325. poster?: string;
  52326. faceForward?: boolean;
  52327. useDirectMapping?: boolean;
  52328. halfDomeMode?: boolean;
  52329. }, scene: Scene);
  52330. private _changeVideoMode;
  52331. /**
  52332. * Releases resources associated with this node.
  52333. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  52334. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  52335. */
  52336. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  52337. }
  52338. }
  52339. declare module "babylonjs/Helpers/index" {
  52340. export * from "babylonjs/Helpers/environmentHelper";
  52341. export * from "babylonjs/Helpers/photoDome";
  52342. export * from "babylonjs/Helpers/sceneHelpers";
  52343. export * from "babylonjs/Helpers/videoDome";
  52344. }
  52345. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  52346. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  52347. import { IDisposable } from "babylonjs/scene";
  52348. import { Engine } from "babylonjs/Engines/engine";
  52349. /**
  52350. * This class can be used to get instrumentation data from a Babylon engine
  52351. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52352. */
  52353. export class EngineInstrumentation implements IDisposable {
  52354. /**
  52355. * Define the instrumented engine.
  52356. */
  52357. engine: Engine;
  52358. private _captureGPUFrameTime;
  52359. private _gpuFrameTimeToken;
  52360. private _gpuFrameTime;
  52361. private _captureShaderCompilationTime;
  52362. private _shaderCompilationTime;
  52363. private _onBeginFrameObserver;
  52364. private _onEndFrameObserver;
  52365. private _onBeforeShaderCompilationObserver;
  52366. private _onAfterShaderCompilationObserver;
  52367. /**
  52368. * Gets the perf counter used for GPU frame time
  52369. */
  52370. readonly gpuFrameTimeCounter: PerfCounter;
  52371. /**
  52372. * Gets the GPU frame time capture status
  52373. */
  52374. /**
  52375. * Enable or disable the GPU frame time capture
  52376. */
  52377. captureGPUFrameTime: boolean;
  52378. /**
  52379. * Gets the perf counter used for shader compilation time
  52380. */
  52381. readonly shaderCompilationTimeCounter: PerfCounter;
  52382. /**
  52383. * Gets the shader compilation time capture status
  52384. */
  52385. /**
  52386. * Enable or disable the shader compilation time capture
  52387. */
  52388. captureShaderCompilationTime: boolean;
  52389. /**
  52390. * Instantiates a new engine instrumentation.
  52391. * This class can be used to get instrumentation data from a Babylon engine
  52392. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52393. * @param engine Defines the engine to instrument
  52394. */
  52395. constructor(
  52396. /**
  52397. * Define the instrumented engine.
  52398. */
  52399. engine: Engine);
  52400. /**
  52401. * Dispose and release associated resources.
  52402. */
  52403. dispose(): void;
  52404. }
  52405. }
  52406. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  52407. import { Scene, IDisposable } from "babylonjs/scene";
  52408. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  52409. /**
  52410. * This class can be used to get instrumentation data from a Babylon engine
  52411. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52412. */
  52413. export class SceneInstrumentation implements IDisposable {
  52414. /**
  52415. * Defines the scene to instrument
  52416. */
  52417. scene: Scene;
  52418. private _captureActiveMeshesEvaluationTime;
  52419. private _activeMeshesEvaluationTime;
  52420. private _captureRenderTargetsRenderTime;
  52421. private _renderTargetsRenderTime;
  52422. private _captureFrameTime;
  52423. private _frameTime;
  52424. private _captureRenderTime;
  52425. private _renderTime;
  52426. private _captureInterFrameTime;
  52427. private _interFrameTime;
  52428. private _captureParticlesRenderTime;
  52429. private _particlesRenderTime;
  52430. private _captureSpritesRenderTime;
  52431. private _spritesRenderTime;
  52432. private _capturePhysicsTime;
  52433. private _physicsTime;
  52434. private _captureAnimationsTime;
  52435. private _animationsTime;
  52436. private _captureCameraRenderTime;
  52437. private _cameraRenderTime;
  52438. private _onBeforeActiveMeshesEvaluationObserver;
  52439. private _onAfterActiveMeshesEvaluationObserver;
  52440. private _onBeforeRenderTargetsRenderObserver;
  52441. private _onAfterRenderTargetsRenderObserver;
  52442. private _onAfterRenderObserver;
  52443. private _onBeforeDrawPhaseObserver;
  52444. private _onAfterDrawPhaseObserver;
  52445. private _onBeforeAnimationsObserver;
  52446. private _onBeforeParticlesRenderingObserver;
  52447. private _onAfterParticlesRenderingObserver;
  52448. private _onBeforeSpritesRenderingObserver;
  52449. private _onAfterSpritesRenderingObserver;
  52450. private _onBeforePhysicsObserver;
  52451. private _onAfterPhysicsObserver;
  52452. private _onAfterAnimationsObserver;
  52453. private _onBeforeCameraRenderObserver;
  52454. private _onAfterCameraRenderObserver;
  52455. /**
  52456. * Gets the perf counter used for active meshes evaluation time
  52457. */
  52458. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  52459. /**
  52460. * Gets the active meshes evaluation time capture status
  52461. */
  52462. /**
  52463. * Enable or disable the active meshes evaluation time capture
  52464. */
  52465. captureActiveMeshesEvaluationTime: boolean;
  52466. /**
  52467. * Gets the perf counter used for render targets render time
  52468. */
  52469. readonly renderTargetsRenderTimeCounter: PerfCounter;
  52470. /**
  52471. * Gets the render targets render time capture status
  52472. */
  52473. /**
  52474. * Enable or disable the render targets render time capture
  52475. */
  52476. captureRenderTargetsRenderTime: boolean;
  52477. /**
  52478. * Gets the perf counter used for particles render time
  52479. */
  52480. readonly particlesRenderTimeCounter: PerfCounter;
  52481. /**
  52482. * Gets the particles render time capture status
  52483. */
  52484. /**
  52485. * Enable or disable the particles render time capture
  52486. */
  52487. captureParticlesRenderTime: boolean;
  52488. /**
  52489. * Gets the perf counter used for sprites render time
  52490. */
  52491. readonly spritesRenderTimeCounter: PerfCounter;
  52492. /**
  52493. * Gets the sprites render time capture status
  52494. */
  52495. /**
  52496. * Enable or disable the sprites render time capture
  52497. */
  52498. captureSpritesRenderTime: boolean;
  52499. /**
  52500. * Gets the perf counter used for physics time
  52501. */
  52502. readonly physicsTimeCounter: PerfCounter;
  52503. /**
  52504. * Gets the physics time capture status
  52505. */
  52506. /**
  52507. * Enable or disable the physics time capture
  52508. */
  52509. capturePhysicsTime: boolean;
  52510. /**
  52511. * Gets the perf counter used for animations time
  52512. */
  52513. readonly animationsTimeCounter: PerfCounter;
  52514. /**
  52515. * Gets the animations time capture status
  52516. */
  52517. /**
  52518. * Enable or disable the animations time capture
  52519. */
  52520. captureAnimationsTime: boolean;
  52521. /**
  52522. * Gets the perf counter used for frame time capture
  52523. */
  52524. readonly frameTimeCounter: PerfCounter;
  52525. /**
  52526. * Gets the frame time capture status
  52527. */
  52528. /**
  52529. * Enable or disable the frame time capture
  52530. */
  52531. captureFrameTime: boolean;
  52532. /**
  52533. * Gets the perf counter used for inter-frames time capture
  52534. */
  52535. readonly interFrameTimeCounter: PerfCounter;
  52536. /**
  52537. * Gets the inter-frames time capture status
  52538. */
  52539. /**
  52540. * Enable or disable the inter-frames time capture
  52541. */
  52542. captureInterFrameTime: boolean;
  52543. /**
  52544. * Gets the perf counter used for render time capture
  52545. */
  52546. readonly renderTimeCounter: PerfCounter;
  52547. /**
  52548. * Gets the render time capture status
  52549. */
  52550. /**
  52551. * Enable or disable the render time capture
  52552. */
  52553. captureRenderTime: boolean;
  52554. /**
  52555. * Gets the perf counter used for camera render time capture
  52556. */
  52557. readonly cameraRenderTimeCounter: PerfCounter;
  52558. /**
  52559. * Gets the camera render time capture status
  52560. */
  52561. /**
  52562. * Enable or disable the camera render time capture
  52563. */
  52564. captureCameraRenderTime: boolean;
  52565. /**
  52566. * Gets the perf counter used for draw calls
  52567. */
  52568. readonly drawCallsCounter: PerfCounter;
  52569. /**
  52570. * Instantiates a new scene instrumentation.
  52571. * This class can be used to get instrumentation data from a Babylon engine
  52572. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52573. * @param scene Defines the scene to instrument
  52574. */
  52575. constructor(
  52576. /**
  52577. * Defines the scene to instrument
  52578. */
  52579. scene: Scene);
  52580. /**
  52581. * Dispose and release associated resources.
  52582. */
  52583. dispose(): void;
  52584. }
  52585. }
  52586. declare module "babylonjs/Instrumentation/index" {
  52587. export * from "babylonjs/Instrumentation/engineInstrumentation";
  52588. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  52589. export * from "babylonjs/Instrumentation/timeToken";
  52590. }
  52591. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  52592. /** @hidden */
  52593. export var glowMapGenerationPixelShader: {
  52594. name: string;
  52595. shader: string;
  52596. };
  52597. }
  52598. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  52599. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  52600. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  52601. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  52602. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  52603. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  52604. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  52605. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  52606. /** @hidden */
  52607. export var glowMapGenerationVertexShader: {
  52608. name: string;
  52609. shader: string;
  52610. };
  52611. }
  52612. declare module "babylonjs/Layers/effectLayer" {
  52613. import { Observable } from "babylonjs/Misc/observable";
  52614. import { Nullable } from "babylonjs/types";
  52615. import { Camera } from "babylonjs/Cameras/camera";
  52616. import { Scene } from "babylonjs/scene";
  52617. import { ISize } from "babylonjs/Maths/math.size";
  52618. import { Color4 } from "babylonjs/Maths/math.color";
  52619. import { Engine } from "babylonjs/Engines/engine";
  52620. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52621. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52622. import { Mesh } from "babylonjs/Meshes/mesh";
  52623. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52624. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52625. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52626. import { Effect } from "babylonjs/Materials/effect";
  52627. import { Material } from "babylonjs/Materials/material";
  52628. import "babylonjs/Shaders/glowMapGeneration.fragment";
  52629. import "babylonjs/Shaders/glowMapGeneration.vertex";
  52630. /**
  52631. * Effect layer options. This helps customizing the behaviour
  52632. * of the effect layer.
  52633. */
  52634. export interface IEffectLayerOptions {
  52635. /**
  52636. * Multiplication factor apply to the canvas size to compute the render target size
  52637. * used to generated the objects (the smaller the faster).
  52638. */
  52639. mainTextureRatio: number;
  52640. /**
  52641. * Enforces a fixed size texture to ensure effect stability across devices.
  52642. */
  52643. mainTextureFixedSize?: number;
  52644. /**
  52645. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  52646. */
  52647. alphaBlendingMode: number;
  52648. /**
  52649. * The camera attached to the layer.
  52650. */
  52651. camera: Nullable<Camera>;
  52652. /**
  52653. * The rendering group to draw the layer in.
  52654. */
  52655. renderingGroupId: number;
  52656. }
  52657. /**
  52658. * The effect layer Helps adding post process effect blended with the main pass.
  52659. *
  52660. * This can be for instance use to generate glow or higlight effects on the scene.
  52661. *
  52662. * The effect layer class can not be used directly and is intented to inherited from to be
  52663. * customized per effects.
  52664. */
  52665. export abstract class EffectLayer {
  52666. private _vertexBuffers;
  52667. private _indexBuffer;
  52668. private _cachedDefines;
  52669. private _effectLayerMapGenerationEffect;
  52670. private _effectLayerOptions;
  52671. private _mergeEffect;
  52672. protected _scene: Scene;
  52673. protected _engine: Engine;
  52674. protected _maxSize: number;
  52675. protected _mainTextureDesiredSize: ISize;
  52676. protected _mainTexture: RenderTargetTexture;
  52677. protected _shouldRender: boolean;
  52678. protected _postProcesses: PostProcess[];
  52679. protected _textures: BaseTexture[];
  52680. protected _emissiveTextureAndColor: {
  52681. texture: Nullable<BaseTexture>;
  52682. color: Color4;
  52683. };
  52684. /**
  52685. * The name of the layer
  52686. */
  52687. name: string;
  52688. /**
  52689. * The clear color of the texture used to generate the glow map.
  52690. */
  52691. neutralColor: Color4;
  52692. /**
  52693. * Specifies wether the highlight layer is enabled or not.
  52694. */
  52695. isEnabled: boolean;
  52696. /**
  52697. * Gets the camera attached to the layer.
  52698. */
  52699. readonly camera: Nullable<Camera>;
  52700. /**
  52701. * Gets the rendering group id the layer should render in.
  52702. */
  52703. renderingGroupId: number;
  52704. /**
  52705. * An event triggered when the effect layer has been disposed.
  52706. */
  52707. onDisposeObservable: Observable<EffectLayer>;
  52708. /**
  52709. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  52710. */
  52711. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  52712. /**
  52713. * An event triggered when the generated texture is being merged in the scene.
  52714. */
  52715. onBeforeComposeObservable: Observable<EffectLayer>;
  52716. /**
  52717. * An event triggered when the mesh is rendered into the effect render target.
  52718. */
  52719. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  52720. /**
  52721. * An event triggered after the mesh has been rendered into the effect render target.
  52722. */
  52723. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  52724. /**
  52725. * An event triggered when the generated texture has been merged in the scene.
  52726. */
  52727. onAfterComposeObservable: Observable<EffectLayer>;
  52728. /**
  52729. * An event triggered when the efffect layer changes its size.
  52730. */
  52731. onSizeChangedObservable: Observable<EffectLayer>;
  52732. /** @hidden */
  52733. static _SceneComponentInitialization: (scene: Scene) => void;
  52734. /**
  52735. * Instantiates a new effect Layer and references it in the scene.
  52736. * @param name The name of the layer
  52737. * @param scene The scene to use the layer in
  52738. */
  52739. constructor(
  52740. /** The Friendly of the effect in the scene */
  52741. name: string, scene: Scene);
  52742. /**
  52743. * Get the effect name of the layer.
  52744. * @return The effect name
  52745. */
  52746. abstract getEffectName(): string;
  52747. /**
  52748. * Checks for the readiness of the element composing the layer.
  52749. * @param subMesh the mesh to check for
  52750. * @param useInstances specify wether or not to use instances to render the mesh
  52751. * @return true if ready otherwise, false
  52752. */
  52753. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52754. /**
  52755. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52756. * @returns true if the effect requires stencil during the main canvas render pass.
  52757. */
  52758. abstract needStencil(): boolean;
  52759. /**
  52760. * Create the merge effect. This is the shader use to blit the information back
  52761. * to the main canvas at the end of the scene rendering.
  52762. * @returns The effect containing the shader used to merge the effect on the main canvas
  52763. */
  52764. protected abstract _createMergeEffect(): Effect;
  52765. /**
  52766. * Creates the render target textures and post processes used in the effect layer.
  52767. */
  52768. protected abstract _createTextureAndPostProcesses(): void;
  52769. /**
  52770. * Implementation specific of rendering the generating effect on the main canvas.
  52771. * @param effect The effect used to render through
  52772. */
  52773. protected abstract _internalRender(effect: Effect): void;
  52774. /**
  52775. * Sets the required values for both the emissive texture and and the main color.
  52776. */
  52777. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52778. /**
  52779. * Free any resources and references associated to a mesh.
  52780. * Internal use
  52781. * @param mesh The mesh to free.
  52782. */
  52783. abstract _disposeMesh(mesh: Mesh): void;
  52784. /**
  52785. * Serializes this layer (Glow or Highlight for example)
  52786. * @returns a serialized layer object
  52787. */
  52788. abstract serialize?(): any;
  52789. /**
  52790. * Initializes the effect layer with the required options.
  52791. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  52792. */
  52793. protected _init(options: Partial<IEffectLayerOptions>): void;
  52794. /**
  52795. * Generates the index buffer of the full screen quad blending to the main canvas.
  52796. */
  52797. private _generateIndexBuffer;
  52798. /**
  52799. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  52800. */
  52801. private _generateVertexBuffer;
  52802. /**
  52803. * Sets the main texture desired size which is the closest power of two
  52804. * of the engine canvas size.
  52805. */
  52806. private _setMainTextureSize;
  52807. /**
  52808. * Creates the main texture for the effect layer.
  52809. */
  52810. protected _createMainTexture(): void;
  52811. /**
  52812. * Adds specific effects defines.
  52813. * @param defines The defines to add specifics to.
  52814. */
  52815. protected _addCustomEffectDefines(defines: string[]): void;
  52816. /**
  52817. * Checks for the readiness of the element composing the layer.
  52818. * @param subMesh the mesh to check for
  52819. * @param useInstances specify wether or not to use instances to render the mesh
  52820. * @param emissiveTexture the associated emissive texture used to generate the glow
  52821. * @return true if ready otherwise, false
  52822. */
  52823. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  52824. /**
  52825. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  52826. */
  52827. render(): void;
  52828. /**
  52829. * Determine if a given mesh will be used in the current effect.
  52830. * @param mesh mesh to test
  52831. * @returns true if the mesh will be used
  52832. */
  52833. hasMesh(mesh: AbstractMesh): boolean;
  52834. /**
  52835. * Returns true if the layer contains information to display, otherwise false.
  52836. * @returns true if the glow layer should be rendered
  52837. */
  52838. shouldRender(): boolean;
  52839. /**
  52840. * Returns true if the mesh should render, otherwise false.
  52841. * @param mesh The mesh to render
  52842. * @returns true if it should render otherwise false
  52843. */
  52844. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  52845. /**
  52846. * Returns true if the mesh can be rendered, otherwise false.
  52847. * @param mesh The mesh to render
  52848. * @param material The material used on the mesh
  52849. * @returns true if it can be rendered otherwise false
  52850. */
  52851. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  52852. /**
  52853. * Returns true if the mesh should render, otherwise false.
  52854. * @param mesh The mesh to render
  52855. * @returns true if it should render otherwise false
  52856. */
  52857. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  52858. /**
  52859. * Renders the submesh passed in parameter to the generation map.
  52860. */
  52861. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  52862. /**
  52863. * Defines wether the current material of the mesh should be use to render the effect.
  52864. * @param mesh defines the current mesh to render
  52865. */
  52866. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  52867. /**
  52868. * Rebuild the required buffers.
  52869. * @hidden Internal use only.
  52870. */
  52871. _rebuild(): void;
  52872. /**
  52873. * Dispose only the render target textures and post process.
  52874. */
  52875. private _disposeTextureAndPostProcesses;
  52876. /**
  52877. * Dispose the highlight layer and free resources.
  52878. */
  52879. dispose(): void;
  52880. /**
  52881. * Gets the class name of the effect layer
  52882. * @returns the string with the class name of the effect layer
  52883. */
  52884. getClassName(): string;
  52885. /**
  52886. * Creates an effect layer from parsed effect layer data
  52887. * @param parsedEffectLayer defines effect layer data
  52888. * @param scene defines the current scene
  52889. * @param rootUrl defines the root URL containing the effect layer information
  52890. * @returns a parsed effect Layer
  52891. */
  52892. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  52893. }
  52894. }
  52895. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  52896. import { Scene } from "babylonjs/scene";
  52897. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52898. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52899. import { AbstractScene } from "babylonjs/abstractScene";
  52900. module "babylonjs/abstractScene" {
  52901. interface AbstractScene {
  52902. /**
  52903. * The list of effect layers (highlights/glow) added to the scene
  52904. * @see http://doc.babylonjs.com/how_to/highlight_layer
  52905. * @see http://doc.babylonjs.com/how_to/glow_layer
  52906. */
  52907. effectLayers: Array<EffectLayer>;
  52908. /**
  52909. * Removes the given effect layer from this scene.
  52910. * @param toRemove defines the effect layer to remove
  52911. * @returns the index of the removed effect layer
  52912. */
  52913. removeEffectLayer(toRemove: EffectLayer): number;
  52914. /**
  52915. * Adds the given effect layer to this scene
  52916. * @param newEffectLayer defines the effect layer to add
  52917. */
  52918. addEffectLayer(newEffectLayer: EffectLayer): void;
  52919. }
  52920. }
  52921. /**
  52922. * Defines the layer scene component responsible to manage any effect layers
  52923. * in a given scene.
  52924. */
  52925. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  52926. /**
  52927. * The component name helpfull to identify the component in the list of scene components.
  52928. */
  52929. readonly name: string;
  52930. /**
  52931. * The scene the component belongs to.
  52932. */
  52933. scene: Scene;
  52934. private _engine;
  52935. private _renderEffects;
  52936. private _needStencil;
  52937. private _previousStencilState;
  52938. /**
  52939. * Creates a new instance of the component for the given scene
  52940. * @param scene Defines the scene to register the component in
  52941. */
  52942. constructor(scene: Scene);
  52943. /**
  52944. * Registers the component in a given scene
  52945. */
  52946. register(): void;
  52947. /**
  52948. * Rebuilds the elements related to this component in case of
  52949. * context lost for instance.
  52950. */
  52951. rebuild(): void;
  52952. /**
  52953. * Serializes the component data to the specified json object
  52954. * @param serializationObject The object to serialize to
  52955. */
  52956. serialize(serializationObject: any): void;
  52957. /**
  52958. * Adds all the elements from the container to the scene
  52959. * @param container the container holding the elements
  52960. */
  52961. addFromContainer(container: AbstractScene): void;
  52962. /**
  52963. * Removes all the elements in the container from the scene
  52964. * @param container contains the elements to remove
  52965. * @param dispose if the removed element should be disposed (default: false)
  52966. */
  52967. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52968. /**
  52969. * Disposes the component and the associated ressources.
  52970. */
  52971. dispose(): void;
  52972. private _isReadyForMesh;
  52973. private _renderMainTexture;
  52974. private _setStencil;
  52975. private _setStencilBack;
  52976. private _draw;
  52977. private _drawCamera;
  52978. private _drawRenderingGroup;
  52979. }
  52980. }
  52981. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  52982. /** @hidden */
  52983. export var glowMapMergePixelShader: {
  52984. name: string;
  52985. shader: string;
  52986. };
  52987. }
  52988. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  52989. /** @hidden */
  52990. export var glowMapMergeVertexShader: {
  52991. name: string;
  52992. shader: string;
  52993. };
  52994. }
  52995. declare module "babylonjs/Layers/glowLayer" {
  52996. import { Nullable } from "babylonjs/types";
  52997. import { Camera } from "babylonjs/Cameras/camera";
  52998. import { Scene } from "babylonjs/scene";
  52999. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53000. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53001. import { Mesh } from "babylonjs/Meshes/mesh";
  53002. import { Texture } from "babylonjs/Materials/Textures/texture";
  53003. import { Effect } from "babylonjs/Materials/effect";
  53004. import { Material } from "babylonjs/Materials/material";
  53005. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  53006. import { Color4 } from "babylonjs/Maths/math.color";
  53007. import "babylonjs/Shaders/glowMapMerge.fragment";
  53008. import "babylonjs/Shaders/glowMapMerge.vertex";
  53009. import "babylonjs/Layers/effectLayerSceneComponent";
  53010. module "babylonjs/abstractScene" {
  53011. interface AbstractScene {
  53012. /**
  53013. * Return a the first highlight layer of the scene with a given name.
  53014. * @param name The name of the highlight layer to look for.
  53015. * @return The highlight layer if found otherwise null.
  53016. */
  53017. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  53018. }
  53019. }
  53020. /**
  53021. * Glow layer options. This helps customizing the behaviour
  53022. * of the glow layer.
  53023. */
  53024. export interface IGlowLayerOptions {
  53025. /**
  53026. * Multiplication factor apply to the canvas size to compute the render target size
  53027. * used to generated the glowing objects (the smaller the faster).
  53028. */
  53029. mainTextureRatio: number;
  53030. /**
  53031. * Enforces a fixed size texture to ensure resize independant blur.
  53032. */
  53033. mainTextureFixedSize?: number;
  53034. /**
  53035. * How big is the kernel of the blur texture.
  53036. */
  53037. blurKernelSize: number;
  53038. /**
  53039. * The camera attached to the layer.
  53040. */
  53041. camera: Nullable<Camera>;
  53042. /**
  53043. * Enable MSAA by chosing the number of samples.
  53044. */
  53045. mainTextureSamples?: number;
  53046. /**
  53047. * The rendering group to draw the layer in.
  53048. */
  53049. renderingGroupId: number;
  53050. }
  53051. /**
  53052. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  53053. *
  53054. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  53055. *
  53056. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  53057. */
  53058. export class GlowLayer extends EffectLayer {
  53059. /**
  53060. * Effect Name of the layer.
  53061. */
  53062. static readonly EffectName: string;
  53063. /**
  53064. * The default blur kernel size used for the glow.
  53065. */
  53066. static DefaultBlurKernelSize: number;
  53067. /**
  53068. * The default texture size ratio used for the glow.
  53069. */
  53070. static DefaultTextureRatio: number;
  53071. /**
  53072. * Sets the kernel size of the blur.
  53073. */
  53074. /**
  53075. * Gets the kernel size of the blur.
  53076. */
  53077. blurKernelSize: number;
  53078. /**
  53079. * Sets the glow intensity.
  53080. */
  53081. /**
  53082. * Gets the glow intensity.
  53083. */
  53084. intensity: number;
  53085. private _options;
  53086. private _intensity;
  53087. private _horizontalBlurPostprocess1;
  53088. private _verticalBlurPostprocess1;
  53089. private _horizontalBlurPostprocess2;
  53090. private _verticalBlurPostprocess2;
  53091. private _blurTexture1;
  53092. private _blurTexture2;
  53093. private _postProcesses1;
  53094. private _postProcesses2;
  53095. private _includedOnlyMeshes;
  53096. private _excludedMeshes;
  53097. private _meshesUsingTheirOwnMaterials;
  53098. /**
  53099. * Callback used to let the user override the color selection on a per mesh basis
  53100. */
  53101. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  53102. /**
  53103. * Callback used to let the user override the texture selection on a per mesh basis
  53104. */
  53105. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  53106. /**
  53107. * Instantiates a new glow Layer and references it to the scene.
  53108. * @param name The name of the layer
  53109. * @param scene The scene to use the layer in
  53110. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  53111. */
  53112. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  53113. /**
  53114. * Get the effect name of the layer.
  53115. * @return The effect name
  53116. */
  53117. getEffectName(): string;
  53118. /**
  53119. * Create the merge effect. This is the shader use to blit the information back
  53120. * to the main canvas at the end of the scene rendering.
  53121. */
  53122. protected _createMergeEffect(): Effect;
  53123. /**
  53124. * Creates the render target textures and post processes used in the glow layer.
  53125. */
  53126. protected _createTextureAndPostProcesses(): void;
  53127. /**
  53128. * Checks for the readiness of the element composing the layer.
  53129. * @param subMesh the mesh to check for
  53130. * @param useInstances specify wether or not to use instances to render the mesh
  53131. * @param emissiveTexture the associated emissive texture used to generate the glow
  53132. * @return true if ready otherwise, false
  53133. */
  53134. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53135. /**
  53136. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  53137. */
  53138. needStencil(): boolean;
  53139. /**
  53140. * Returns true if the mesh can be rendered, otherwise false.
  53141. * @param mesh The mesh to render
  53142. * @param material The material used on the mesh
  53143. * @returns true if it can be rendered otherwise false
  53144. */
  53145. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53146. /**
  53147. * Implementation specific of rendering the generating effect on the main canvas.
  53148. * @param effect The effect used to render through
  53149. */
  53150. protected _internalRender(effect: Effect): void;
  53151. /**
  53152. * Sets the required values for both the emissive texture and and the main color.
  53153. */
  53154. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53155. /**
  53156. * Returns true if the mesh should render, otherwise false.
  53157. * @param mesh The mesh to render
  53158. * @returns true if it should render otherwise false
  53159. */
  53160. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53161. /**
  53162. * Adds specific effects defines.
  53163. * @param defines The defines to add specifics to.
  53164. */
  53165. protected _addCustomEffectDefines(defines: string[]): void;
  53166. /**
  53167. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  53168. * @param mesh The mesh to exclude from the glow layer
  53169. */
  53170. addExcludedMesh(mesh: Mesh): void;
  53171. /**
  53172. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  53173. * @param mesh The mesh to remove
  53174. */
  53175. removeExcludedMesh(mesh: Mesh): void;
  53176. /**
  53177. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  53178. * @param mesh The mesh to include in the glow layer
  53179. */
  53180. addIncludedOnlyMesh(mesh: Mesh): void;
  53181. /**
  53182. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  53183. * @param mesh The mesh to remove
  53184. */
  53185. removeIncludedOnlyMesh(mesh: Mesh): void;
  53186. /**
  53187. * Determine if a given mesh will be used in the glow layer
  53188. * @param mesh The mesh to test
  53189. * @returns true if the mesh will be highlighted by the current glow layer
  53190. */
  53191. hasMesh(mesh: AbstractMesh): boolean;
  53192. /**
  53193. * Defines wether the current material of the mesh should be use to render the effect.
  53194. * @param mesh defines the current mesh to render
  53195. */
  53196. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53197. /**
  53198. * Add a mesh to be rendered through its own material and not with emissive only.
  53199. * @param mesh The mesh for which we need to use its material
  53200. */
  53201. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  53202. /**
  53203. * Remove a mesh from being rendered through its own material and not with emissive only.
  53204. * @param mesh The mesh for which we need to not use its material
  53205. */
  53206. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  53207. /**
  53208. * Free any resources and references associated to a mesh.
  53209. * Internal use
  53210. * @param mesh The mesh to free.
  53211. * @hidden
  53212. */
  53213. _disposeMesh(mesh: Mesh): void;
  53214. /**
  53215. * Gets the class name of the effect layer
  53216. * @returns the string with the class name of the effect layer
  53217. */
  53218. getClassName(): string;
  53219. /**
  53220. * Serializes this glow layer
  53221. * @returns a serialized glow layer object
  53222. */
  53223. serialize(): any;
  53224. /**
  53225. * Creates a Glow Layer from parsed glow layer data
  53226. * @param parsedGlowLayer defines glow layer data
  53227. * @param scene defines the current scene
  53228. * @param rootUrl defines the root URL containing the glow layer information
  53229. * @returns a parsed Glow Layer
  53230. */
  53231. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  53232. }
  53233. }
  53234. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  53235. /** @hidden */
  53236. export var glowBlurPostProcessPixelShader: {
  53237. name: string;
  53238. shader: string;
  53239. };
  53240. }
  53241. declare module "babylonjs/Layers/highlightLayer" {
  53242. import { Observable } from "babylonjs/Misc/observable";
  53243. import { Nullable } from "babylonjs/types";
  53244. import { Camera } from "babylonjs/Cameras/camera";
  53245. import { Scene } from "babylonjs/scene";
  53246. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53247. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53248. import { Mesh } from "babylonjs/Meshes/mesh";
  53249. import { Effect } from "babylonjs/Materials/effect";
  53250. import { Material } from "babylonjs/Materials/material";
  53251. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  53252. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  53253. import "babylonjs/Shaders/glowMapMerge.fragment";
  53254. import "babylonjs/Shaders/glowMapMerge.vertex";
  53255. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  53256. module "babylonjs/abstractScene" {
  53257. interface AbstractScene {
  53258. /**
  53259. * Return a the first highlight layer of the scene with a given name.
  53260. * @param name The name of the highlight layer to look for.
  53261. * @return The highlight layer if found otherwise null.
  53262. */
  53263. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  53264. }
  53265. }
  53266. /**
  53267. * Highlight layer options. This helps customizing the behaviour
  53268. * of the highlight layer.
  53269. */
  53270. export interface IHighlightLayerOptions {
  53271. /**
  53272. * Multiplication factor apply to the canvas size to compute the render target size
  53273. * used to generated the glowing objects (the smaller the faster).
  53274. */
  53275. mainTextureRatio: number;
  53276. /**
  53277. * Enforces a fixed size texture to ensure resize independant blur.
  53278. */
  53279. mainTextureFixedSize?: number;
  53280. /**
  53281. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  53282. * of the picture to blur (the smaller the faster).
  53283. */
  53284. blurTextureSizeRatio: number;
  53285. /**
  53286. * How big in texel of the blur texture is the vertical blur.
  53287. */
  53288. blurVerticalSize: number;
  53289. /**
  53290. * How big in texel of the blur texture is the horizontal blur.
  53291. */
  53292. blurHorizontalSize: number;
  53293. /**
  53294. * Alpha blending mode used to apply the blur. Default is combine.
  53295. */
  53296. alphaBlendingMode: number;
  53297. /**
  53298. * The camera attached to the layer.
  53299. */
  53300. camera: Nullable<Camera>;
  53301. /**
  53302. * Should we display highlight as a solid stroke?
  53303. */
  53304. isStroke?: boolean;
  53305. /**
  53306. * The rendering group to draw the layer in.
  53307. */
  53308. renderingGroupId: number;
  53309. }
  53310. /**
  53311. * The highlight layer Helps adding a glow effect around a mesh.
  53312. *
  53313. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  53314. * glowy meshes to your scene.
  53315. *
  53316. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  53317. */
  53318. export class HighlightLayer extends EffectLayer {
  53319. name: string;
  53320. /**
  53321. * Effect Name of the highlight layer.
  53322. */
  53323. static readonly EffectName: string;
  53324. /**
  53325. * The neutral color used during the preparation of the glow effect.
  53326. * This is black by default as the blend operation is a blend operation.
  53327. */
  53328. static NeutralColor: Color4;
  53329. /**
  53330. * Stencil value used for glowing meshes.
  53331. */
  53332. static GlowingMeshStencilReference: number;
  53333. /**
  53334. * Stencil value used for the other meshes in the scene.
  53335. */
  53336. static NormalMeshStencilReference: number;
  53337. /**
  53338. * Specifies whether or not the inner glow is ACTIVE in the layer.
  53339. */
  53340. innerGlow: boolean;
  53341. /**
  53342. * Specifies whether or not the outer glow is ACTIVE in the layer.
  53343. */
  53344. outerGlow: boolean;
  53345. /**
  53346. * Specifies the horizontal size of the blur.
  53347. */
  53348. /**
  53349. * Gets the horizontal size of the blur.
  53350. */
  53351. blurHorizontalSize: number;
  53352. /**
  53353. * Specifies the vertical size of the blur.
  53354. */
  53355. /**
  53356. * Gets the vertical size of the blur.
  53357. */
  53358. blurVerticalSize: number;
  53359. /**
  53360. * An event triggered when the highlight layer is being blurred.
  53361. */
  53362. onBeforeBlurObservable: Observable<HighlightLayer>;
  53363. /**
  53364. * An event triggered when the highlight layer has been blurred.
  53365. */
  53366. onAfterBlurObservable: Observable<HighlightLayer>;
  53367. private _instanceGlowingMeshStencilReference;
  53368. private _options;
  53369. private _downSamplePostprocess;
  53370. private _horizontalBlurPostprocess;
  53371. private _verticalBlurPostprocess;
  53372. private _blurTexture;
  53373. private _meshes;
  53374. private _excludedMeshes;
  53375. /**
  53376. * Instantiates a new highlight Layer and references it to the scene..
  53377. * @param name The name of the layer
  53378. * @param scene The scene to use the layer in
  53379. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  53380. */
  53381. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  53382. /**
  53383. * Get the effect name of the layer.
  53384. * @return The effect name
  53385. */
  53386. getEffectName(): string;
  53387. /**
  53388. * Create the merge effect. This is the shader use to blit the information back
  53389. * to the main canvas at the end of the scene rendering.
  53390. */
  53391. protected _createMergeEffect(): Effect;
  53392. /**
  53393. * Creates the render target textures and post processes used in the highlight layer.
  53394. */
  53395. protected _createTextureAndPostProcesses(): void;
  53396. /**
  53397. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  53398. */
  53399. needStencil(): boolean;
  53400. /**
  53401. * Checks for the readiness of the element composing the layer.
  53402. * @param subMesh the mesh to check for
  53403. * @param useInstances specify wether or not to use instances to render the mesh
  53404. * @param emissiveTexture the associated emissive texture used to generate the glow
  53405. * @return true if ready otherwise, false
  53406. */
  53407. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53408. /**
  53409. * Implementation specific of rendering the generating effect on the main canvas.
  53410. * @param effect The effect used to render through
  53411. */
  53412. protected _internalRender(effect: Effect): void;
  53413. /**
  53414. * Returns true if the layer contains information to display, otherwise false.
  53415. */
  53416. shouldRender(): boolean;
  53417. /**
  53418. * Returns true if the mesh should render, otherwise false.
  53419. * @param mesh The mesh to render
  53420. * @returns true if it should render otherwise false
  53421. */
  53422. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53423. /**
  53424. * Sets the required values for both the emissive texture and and the main color.
  53425. */
  53426. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53427. /**
  53428. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  53429. * @param mesh The mesh to exclude from the highlight layer
  53430. */
  53431. addExcludedMesh(mesh: Mesh): void;
  53432. /**
  53433. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  53434. * @param mesh The mesh to highlight
  53435. */
  53436. removeExcludedMesh(mesh: Mesh): void;
  53437. /**
  53438. * Determine if a given mesh will be highlighted by the current HighlightLayer
  53439. * @param mesh mesh to test
  53440. * @returns true if the mesh will be highlighted by the current HighlightLayer
  53441. */
  53442. hasMesh(mesh: AbstractMesh): boolean;
  53443. /**
  53444. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  53445. * @param mesh The mesh to highlight
  53446. * @param color The color of the highlight
  53447. * @param glowEmissiveOnly Extract the glow from the emissive texture
  53448. */
  53449. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  53450. /**
  53451. * Remove a mesh from the highlight layer in order to make it stop glowing.
  53452. * @param mesh The mesh to highlight
  53453. */
  53454. removeMesh(mesh: Mesh): void;
  53455. /**
  53456. * Force the stencil to the normal expected value for none glowing parts
  53457. */
  53458. private _defaultStencilReference;
  53459. /**
  53460. * Free any resources and references associated to a mesh.
  53461. * Internal use
  53462. * @param mesh The mesh to free.
  53463. * @hidden
  53464. */
  53465. _disposeMesh(mesh: Mesh): void;
  53466. /**
  53467. * Dispose the highlight layer and free resources.
  53468. */
  53469. dispose(): void;
  53470. /**
  53471. * Gets the class name of the effect layer
  53472. * @returns the string with the class name of the effect layer
  53473. */
  53474. getClassName(): string;
  53475. /**
  53476. * Serializes this Highlight layer
  53477. * @returns a serialized Highlight layer object
  53478. */
  53479. serialize(): any;
  53480. /**
  53481. * Creates a Highlight layer from parsed Highlight layer data
  53482. * @param parsedHightlightLayer defines the Highlight layer data
  53483. * @param scene defines the current scene
  53484. * @param rootUrl defines the root URL containing the Highlight layer information
  53485. * @returns a parsed Highlight layer
  53486. */
  53487. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  53488. }
  53489. }
  53490. declare module "babylonjs/Layers/layerSceneComponent" {
  53491. import { Scene } from "babylonjs/scene";
  53492. import { ISceneComponent } from "babylonjs/sceneComponent";
  53493. import { Layer } from "babylonjs/Layers/layer";
  53494. import { AbstractScene } from "babylonjs/abstractScene";
  53495. module "babylonjs/abstractScene" {
  53496. interface AbstractScene {
  53497. /**
  53498. * The list of layers (background and foreground) of the scene
  53499. */
  53500. layers: Array<Layer>;
  53501. }
  53502. }
  53503. /**
  53504. * Defines the layer scene component responsible to manage any layers
  53505. * in a given scene.
  53506. */
  53507. export class LayerSceneComponent implements ISceneComponent {
  53508. /**
  53509. * The component name helpfull to identify the component in the list of scene components.
  53510. */
  53511. readonly name: string;
  53512. /**
  53513. * The scene the component belongs to.
  53514. */
  53515. scene: Scene;
  53516. private _engine;
  53517. /**
  53518. * Creates a new instance of the component for the given scene
  53519. * @param scene Defines the scene to register the component in
  53520. */
  53521. constructor(scene: Scene);
  53522. /**
  53523. * Registers the component in a given scene
  53524. */
  53525. register(): void;
  53526. /**
  53527. * Rebuilds the elements related to this component in case of
  53528. * context lost for instance.
  53529. */
  53530. rebuild(): void;
  53531. /**
  53532. * Disposes the component and the associated ressources.
  53533. */
  53534. dispose(): void;
  53535. private _draw;
  53536. private _drawCameraPredicate;
  53537. private _drawCameraBackground;
  53538. private _drawCameraForeground;
  53539. private _drawRenderTargetPredicate;
  53540. private _drawRenderTargetBackground;
  53541. private _drawRenderTargetForeground;
  53542. /**
  53543. * Adds all the elements from the container to the scene
  53544. * @param container the container holding the elements
  53545. */
  53546. addFromContainer(container: AbstractScene): void;
  53547. /**
  53548. * Removes all the elements in the container from the scene
  53549. * @param container contains the elements to remove
  53550. * @param dispose if the removed element should be disposed (default: false)
  53551. */
  53552. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53553. }
  53554. }
  53555. declare module "babylonjs/Shaders/layer.fragment" {
  53556. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53557. /** @hidden */
  53558. export var layerPixelShader: {
  53559. name: string;
  53560. shader: string;
  53561. };
  53562. }
  53563. declare module "babylonjs/Shaders/layer.vertex" {
  53564. /** @hidden */
  53565. export var layerVertexShader: {
  53566. name: string;
  53567. shader: string;
  53568. };
  53569. }
  53570. declare module "babylonjs/Layers/layer" {
  53571. import { Observable } from "babylonjs/Misc/observable";
  53572. import { Nullable } from "babylonjs/types";
  53573. import { Scene } from "babylonjs/scene";
  53574. import { Vector2 } from "babylonjs/Maths/math.vector";
  53575. import { Color4 } from "babylonjs/Maths/math.color";
  53576. import { Texture } from "babylonjs/Materials/Textures/texture";
  53577. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53578. import "babylonjs/Shaders/layer.fragment";
  53579. import "babylonjs/Shaders/layer.vertex";
  53580. /**
  53581. * This represents a full screen 2d layer.
  53582. * This can be useful to display a picture in the background of your scene for instance.
  53583. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53584. */
  53585. export class Layer {
  53586. /**
  53587. * Define the name of the layer.
  53588. */
  53589. name: string;
  53590. /**
  53591. * Define the texture the layer should display.
  53592. */
  53593. texture: Nullable<Texture>;
  53594. /**
  53595. * Is the layer in background or foreground.
  53596. */
  53597. isBackground: boolean;
  53598. /**
  53599. * Define the color of the layer (instead of texture).
  53600. */
  53601. color: Color4;
  53602. /**
  53603. * Define the scale of the layer in order to zoom in out of the texture.
  53604. */
  53605. scale: Vector2;
  53606. /**
  53607. * Define an offset for the layer in order to shift the texture.
  53608. */
  53609. offset: Vector2;
  53610. /**
  53611. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  53612. */
  53613. alphaBlendingMode: number;
  53614. /**
  53615. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  53616. * Alpha test will not mix with the background color in case of transparency.
  53617. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  53618. */
  53619. alphaTest: boolean;
  53620. /**
  53621. * Define a mask to restrict the layer to only some of the scene cameras.
  53622. */
  53623. layerMask: number;
  53624. /**
  53625. * Define the list of render target the layer is visible into.
  53626. */
  53627. renderTargetTextures: RenderTargetTexture[];
  53628. /**
  53629. * Define if the layer is only used in renderTarget or if it also
  53630. * renders in the main frame buffer of the canvas.
  53631. */
  53632. renderOnlyInRenderTargetTextures: boolean;
  53633. private _scene;
  53634. private _vertexBuffers;
  53635. private _indexBuffer;
  53636. private _effect;
  53637. private _previousDefines;
  53638. /**
  53639. * An event triggered when the layer is disposed.
  53640. */
  53641. onDisposeObservable: Observable<Layer>;
  53642. private _onDisposeObserver;
  53643. /**
  53644. * Back compatibility with callback before the onDisposeObservable existed.
  53645. * The set callback will be triggered when the layer has been disposed.
  53646. */
  53647. onDispose: () => void;
  53648. /**
  53649. * An event triggered before rendering the scene
  53650. */
  53651. onBeforeRenderObservable: Observable<Layer>;
  53652. private _onBeforeRenderObserver;
  53653. /**
  53654. * Back compatibility with callback before the onBeforeRenderObservable existed.
  53655. * The set callback will be triggered just before rendering the layer.
  53656. */
  53657. onBeforeRender: () => void;
  53658. /**
  53659. * An event triggered after rendering the scene
  53660. */
  53661. onAfterRenderObservable: Observable<Layer>;
  53662. private _onAfterRenderObserver;
  53663. /**
  53664. * Back compatibility with callback before the onAfterRenderObservable existed.
  53665. * The set callback will be triggered just after rendering the layer.
  53666. */
  53667. onAfterRender: () => void;
  53668. /**
  53669. * Instantiates a new layer.
  53670. * This represents a full screen 2d layer.
  53671. * This can be useful to display a picture in the background of your scene for instance.
  53672. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53673. * @param name Define the name of the layer in the scene
  53674. * @param imgUrl Define the url of the texture to display in the layer
  53675. * @param scene Define the scene the layer belongs to
  53676. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  53677. * @param color Defines a color for the layer
  53678. */
  53679. constructor(
  53680. /**
  53681. * Define the name of the layer.
  53682. */
  53683. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  53684. private _createIndexBuffer;
  53685. /** @hidden */
  53686. _rebuild(): void;
  53687. /**
  53688. * Renders the layer in the scene.
  53689. */
  53690. render(): void;
  53691. /**
  53692. * Disposes and releases the associated ressources.
  53693. */
  53694. dispose(): void;
  53695. }
  53696. }
  53697. declare module "babylonjs/Layers/index" {
  53698. export * from "babylonjs/Layers/effectLayer";
  53699. export * from "babylonjs/Layers/effectLayerSceneComponent";
  53700. export * from "babylonjs/Layers/glowLayer";
  53701. export * from "babylonjs/Layers/highlightLayer";
  53702. export * from "babylonjs/Layers/layer";
  53703. export * from "babylonjs/Layers/layerSceneComponent";
  53704. }
  53705. declare module "babylonjs/Shaders/lensFlare.fragment" {
  53706. /** @hidden */
  53707. export var lensFlarePixelShader: {
  53708. name: string;
  53709. shader: string;
  53710. };
  53711. }
  53712. declare module "babylonjs/Shaders/lensFlare.vertex" {
  53713. /** @hidden */
  53714. export var lensFlareVertexShader: {
  53715. name: string;
  53716. shader: string;
  53717. };
  53718. }
  53719. declare module "babylonjs/LensFlares/lensFlareSystem" {
  53720. import { Scene } from "babylonjs/scene";
  53721. import { Vector3 } from "babylonjs/Maths/math.vector";
  53722. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53723. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  53724. import "babylonjs/Shaders/lensFlare.fragment";
  53725. import "babylonjs/Shaders/lensFlare.vertex";
  53726. import { Viewport } from "babylonjs/Maths/math.viewport";
  53727. /**
  53728. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53729. * It is usually composed of several `lensFlare`.
  53730. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53731. */
  53732. export class LensFlareSystem {
  53733. /**
  53734. * Define the name of the lens flare system
  53735. */
  53736. name: string;
  53737. /**
  53738. * List of lens flares used in this system.
  53739. */
  53740. lensFlares: LensFlare[];
  53741. /**
  53742. * Define a limit from the border the lens flare can be visible.
  53743. */
  53744. borderLimit: number;
  53745. /**
  53746. * Define a viewport border we do not want to see the lens flare in.
  53747. */
  53748. viewportBorder: number;
  53749. /**
  53750. * Define a predicate which could limit the list of meshes able to occlude the effect.
  53751. */
  53752. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  53753. /**
  53754. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  53755. */
  53756. layerMask: number;
  53757. /**
  53758. * Define the id of the lens flare system in the scene.
  53759. * (equal to name by default)
  53760. */
  53761. id: string;
  53762. private _scene;
  53763. private _emitter;
  53764. private _vertexBuffers;
  53765. private _indexBuffer;
  53766. private _effect;
  53767. private _positionX;
  53768. private _positionY;
  53769. private _isEnabled;
  53770. /** @hidden */
  53771. static _SceneComponentInitialization: (scene: Scene) => void;
  53772. /**
  53773. * Instantiates a lens flare system.
  53774. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53775. * It is usually composed of several `lensFlare`.
  53776. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53777. * @param name Define the name of the lens flare system in the scene
  53778. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  53779. * @param scene Define the scene the lens flare system belongs to
  53780. */
  53781. constructor(
  53782. /**
  53783. * Define the name of the lens flare system
  53784. */
  53785. name: string, emitter: any, scene: Scene);
  53786. /**
  53787. * Define if the lens flare system is enabled.
  53788. */
  53789. isEnabled: boolean;
  53790. /**
  53791. * Get the scene the effects belongs to.
  53792. * @returns the scene holding the lens flare system
  53793. */
  53794. getScene(): Scene;
  53795. /**
  53796. * Get the emitter of the lens flare system.
  53797. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53798. * @returns the emitter of the lens flare system
  53799. */
  53800. getEmitter(): any;
  53801. /**
  53802. * Set the emitter of the lens flare system.
  53803. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53804. * @param newEmitter Define the new emitter of the system
  53805. */
  53806. setEmitter(newEmitter: any): void;
  53807. /**
  53808. * Get the lens flare system emitter position.
  53809. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  53810. * @returns the position
  53811. */
  53812. getEmitterPosition(): Vector3;
  53813. /**
  53814. * @hidden
  53815. */
  53816. computeEffectivePosition(globalViewport: Viewport): boolean;
  53817. /** @hidden */
  53818. _isVisible(): boolean;
  53819. /**
  53820. * @hidden
  53821. */
  53822. render(): boolean;
  53823. /**
  53824. * Dispose and release the lens flare with its associated resources.
  53825. */
  53826. dispose(): void;
  53827. /**
  53828. * Parse a lens flare system from a JSON repressentation
  53829. * @param parsedLensFlareSystem Define the JSON to parse
  53830. * @param scene Define the scene the parsed system should be instantiated in
  53831. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  53832. * @returns the parsed system
  53833. */
  53834. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  53835. /**
  53836. * Serialize the current Lens Flare System into a JSON representation.
  53837. * @returns the serialized JSON
  53838. */
  53839. serialize(): any;
  53840. }
  53841. }
  53842. declare module "babylonjs/LensFlares/lensFlare" {
  53843. import { Nullable } from "babylonjs/types";
  53844. import { Color3 } from "babylonjs/Maths/math.color";
  53845. import { Texture } from "babylonjs/Materials/Textures/texture";
  53846. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  53847. /**
  53848. * This represents one of the lens effect in a `lensFlareSystem`.
  53849. * It controls one of the indiviual texture used in the effect.
  53850. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53851. */
  53852. export class LensFlare {
  53853. /**
  53854. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  53855. */
  53856. size: number;
  53857. /**
  53858. * 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.
  53859. */
  53860. position: number;
  53861. /**
  53862. * Define the lens color.
  53863. */
  53864. color: Color3;
  53865. /**
  53866. * Define the lens texture.
  53867. */
  53868. texture: Nullable<Texture>;
  53869. /**
  53870. * Define the alpha mode to render this particular lens.
  53871. */
  53872. alphaMode: number;
  53873. private _system;
  53874. /**
  53875. * Creates a new Lens Flare.
  53876. * This represents one of the lens effect in a `lensFlareSystem`.
  53877. * It controls one of the indiviual texture used in the effect.
  53878. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53879. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  53880. * @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.
  53881. * @param color Define the lens color
  53882. * @param imgUrl Define the lens texture url
  53883. * @param system Define the `lensFlareSystem` this flare is part of
  53884. * @returns The newly created Lens Flare
  53885. */
  53886. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  53887. /**
  53888. * Instantiates a new Lens Flare.
  53889. * This represents one of the lens effect in a `lensFlareSystem`.
  53890. * It controls one of the indiviual texture used in the effect.
  53891. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53892. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  53893. * @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.
  53894. * @param color Define the lens color
  53895. * @param imgUrl Define the lens texture url
  53896. * @param system Define the `lensFlareSystem` this flare is part of
  53897. */
  53898. constructor(
  53899. /**
  53900. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  53901. */
  53902. size: number,
  53903. /**
  53904. * 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.
  53905. */
  53906. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  53907. /**
  53908. * Dispose and release the lens flare with its associated resources.
  53909. */
  53910. dispose(): void;
  53911. }
  53912. }
  53913. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  53914. import { Nullable } from "babylonjs/types";
  53915. import { Scene } from "babylonjs/scene";
  53916. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  53917. import { AbstractScene } from "babylonjs/abstractScene";
  53918. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  53919. module "babylonjs/abstractScene" {
  53920. interface AbstractScene {
  53921. /**
  53922. * The list of lens flare system added to the scene
  53923. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53924. */
  53925. lensFlareSystems: Array<LensFlareSystem>;
  53926. /**
  53927. * Removes the given lens flare system from this scene.
  53928. * @param toRemove The lens flare system to remove
  53929. * @returns The index of the removed lens flare system
  53930. */
  53931. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  53932. /**
  53933. * Adds the given lens flare system to this scene
  53934. * @param newLensFlareSystem The lens flare system to add
  53935. */
  53936. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  53937. /**
  53938. * Gets a lens flare system using its name
  53939. * @param name defines the name to look for
  53940. * @returns the lens flare system or null if not found
  53941. */
  53942. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  53943. /**
  53944. * Gets a lens flare system using its id
  53945. * @param id defines the id to look for
  53946. * @returns the lens flare system or null if not found
  53947. */
  53948. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  53949. }
  53950. }
  53951. /**
  53952. * Defines the lens flare scene component responsible to manage any lens flares
  53953. * in a given scene.
  53954. */
  53955. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  53956. /**
  53957. * The component name helpfull to identify the component in the list of scene components.
  53958. */
  53959. readonly name: string;
  53960. /**
  53961. * The scene the component belongs to.
  53962. */
  53963. scene: Scene;
  53964. /**
  53965. * Creates a new instance of the component for the given scene
  53966. * @param scene Defines the scene to register the component in
  53967. */
  53968. constructor(scene: Scene);
  53969. /**
  53970. * Registers the component in a given scene
  53971. */
  53972. register(): void;
  53973. /**
  53974. * Rebuilds the elements related to this component in case of
  53975. * context lost for instance.
  53976. */
  53977. rebuild(): void;
  53978. /**
  53979. * Adds all the elements from the container to the scene
  53980. * @param container the container holding the elements
  53981. */
  53982. addFromContainer(container: AbstractScene): void;
  53983. /**
  53984. * Removes all the elements in the container from the scene
  53985. * @param container contains the elements to remove
  53986. * @param dispose if the removed element should be disposed (default: false)
  53987. */
  53988. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53989. /**
  53990. * Serializes the component data to the specified json object
  53991. * @param serializationObject The object to serialize to
  53992. */
  53993. serialize(serializationObject: any): void;
  53994. /**
  53995. * Disposes the component and the associated ressources.
  53996. */
  53997. dispose(): void;
  53998. private _draw;
  53999. }
  54000. }
  54001. declare module "babylonjs/LensFlares/index" {
  54002. export * from "babylonjs/LensFlares/lensFlare";
  54003. export * from "babylonjs/LensFlares/lensFlareSystem";
  54004. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  54005. }
  54006. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  54007. import { Scene } from "babylonjs/scene";
  54008. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  54009. import { AbstractScene } from "babylonjs/abstractScene";
  54010. /**
  54011. * Defines the shadow generator component responsible to manage any shadow generators
  54012. * in a given scene.
  54013. */
  54014. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  54015. /**
  54016. * The component name helpfull to identify the component in the list of scene components.
  54017. */
  54018. readonly name: string;
  54019. /**
  54020. * The scene the component belongs to.
  54021. */
  54022. scene: Scene;
  54023. /**
  54024. * Creates a new instance of the component for the given scene
  54025. * @param scene Defines the scene to register the component in
  54026. */
  54027. constructor(scene: Scene);
  54028. /**
  54029. * Registers the component in a given scene
  54030. */
  54031. register(): void;
  54032. /**
  54033. * Rebuilds the elements related to this component in case of
  54034. * context lost for instance.
  54035. */
  54036. rebuild(): void;
  54037. /**
  54038. * Serializes the component data to the specified json object
  54039. * @param serializationObject The object to serialize to
  54040. */
  54041. serialize(serializationObject: any): void;
  54042. /**
  54043. * Adds all the elements from the container to the scene
  54044. * @param container the container holding the elements
  54045. */
  54046. addFromContainer(container: AbstractScene): void;
  54047. /**
  54048. * Removes all the elements in the container from the scene
  54049. * @param container contains the elements to remove
  54050. * @param dispose if the removed element should be disposed (default: false)
  54051. */
  54052. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54053. /**
  54054. * Rebuilds the elements related to this component in case of
  54055. * context lost for instance.
  54056. */
  54057. dispose(): void;
  54058. private _gatherRenderTargets;
  54059. }
  54060. }
  54061. declare module "babylonjs/Lights/Shadows/index" {
  54062. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  54063. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  54064. }
  54065. declare module "babylonjs/Lights/pointLight" {
  54066. import { Scene } from "babylonjs/scene";
  54067. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  54068. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54069. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  54070. import { Effect } from "babylonjs/Materials/effect";
  54071. /**
  54072. * A point light is a light defined by an unique point in world space.
  54073. * The light is emitted in every direction from this point.
  54074. * A good example of a point light is a standard light bulb.
  54075. * Documentation: https://doc.babylonjs.com/babylon101/lights
  54076. */
  54077. export class PointLight extends ShadowLight {
  54078. private _shadowAngle;
  54079. /**
  54080. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54081. * This specifies what angle the shadow will use to be created.
  54082. *
  54083. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  54084. */
  54085. /**
  54086. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54087. * This specifies what angle the shadow will use to be created.
  54088. *
  54089. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  54090. */
  54091. shadowAngle: number;
  54092. /**
  54093. * Gets the direction if it has been set.
  54094. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54095. */
  54096. /**
  54097. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54098. */
  54099. direction: Vector3;
  54100. /**
  54101. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  54102. * A PointLight emits the light in every direction.
  54103. * It can cast shadows.
  54104. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  54105. * ```javascript
  54106. * var pointLight = new PointLight("pl", camera.position, scene);
  54107. * ```
  54108. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54109. * @param name The light friendly name
  54110. * @param position The position of the point light in the scene
  54111. * @param scene The scene the lights belongs to
  54112. */
  54113. constructor(name: string, position: Vector3, scene: Scene);
  54114. /**
  54115. * Returns the string "PointLight"
  54116. * @returns the class name
  54117. */
  54118. getClassName(): string;
  54119. /**
  54120. * Returns the integer 0.
  54121. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54122. */
  54123. getTypeID(): number;
  54124. /**
  54125. * Specifies wether or not the shadowmap should be a cube texture.
  54126. * @returns true if the shadowmap needs to be a cube texture.
  54127. */
  54128. needCube(): boolean;
  54129. /**
  54130. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  54131. * @param faceIndex The index of the face we are computed the direction to generate shadow
  54132. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  54133. */
  54134. getShadowDirection(faceIndex?: number): Vector3;
  54135. /**
  54136. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  54137. * - fov = PI / 2
  54138. * - aspect ratio : 1.0
  54139. * - z-near and far equal to the active camera minZ and maxZ.
  54140. * Returns the PointLight.
  54141. */
  54142. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54143. protected _buildUniformLayout(): void;
  54144. /**
  54145. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  54146. * @param effect The effect to update
  54147. * @param lightIndex The index of the light in the effect to update
  54148. * @returns The point light
  54149. */
  54150. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  54151. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  54152. /**
  54153. * Prepares the list of defines specific to the light type.
  54154. * @param defines the list of defines
  54155. * @param lightIndex defines the index of the light for the effect
  54156. */
  54157. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54158. }
  54159. }
  54160. declare module "babylonjs/Lights/index" {
  54161. export * from "babylonjs/Lights/light";
  54162. export * from "babylonjs/Lights/shadowLight";
  54163. export * from "babylonjs/Lights/Shadows/index";
  54164. export * from "babylonjs/Lights/directionalLight";
  54165. export * from "babylonjs/Lights/hemisphericLight";
  54166. export * from "babylonjs/Lights/pointLight";
  54167. export * from "babylonjs/Lights/spotLight";
  54168. }
  54169. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  54170. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  54171. /**
  54172. * Header information of HDR texture files.
  54173. */
  54174. export interface HDRInfo {
  54175. /**
  54176. * The height of the texture in pixels.
  54177. */
  54178. height: number;
  54179. /**
  54180. * The width of the texture in pixels.
  54181. */
  54182. width: number;
  54183. /**
  54184. * The index of the beginning of the data in the binary file.
  54185. */
  54186. dataPosition: number;
  54187. }
  54188. /**
  54189. * This groups tools to convert HDR texture to native colors array.
  54190. */
  54191. export class HDRTools {
  54192. private static Ldexp;
  54193. private static Rgbe2float;
  54194. private static readStringLine;
  54195. /**
  54196. * Reads header information from an RGBE texture stored in a native array.
  54197. * More information on this format are available here:
  54198. * https://en.wikipedia.org/wiki/RGBE_image_format
  54199. *
  54200. * @param uint8array The binary file stored in native array.
  54201. * @return The header information.
  54202. */
  54203. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  54204. /**
  54205. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  54206. * This RGBE texture needs to store the information as a panorama.
  54207. *
  54208. * More information on this format are available here:
  54209. * https://en.wikipedia.org/wiki/RGBE_image_format
  54210. *
  54211. * @param buffer The binary file stored in an array buffer.
  54212. * @param size The expected size of the extracted cubemap.
  54213. * @return The Cube Map information.
  54214. */
  54215. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  54216. /**
  54217. * Returns the pixels data extracted from an RGBE texture.
  54218. * This pixels will be stored left to right up to down in the R G B order in one array.
  54219. *
  54220. * More information on this format are available here:
  54221. * https://en.wikipedia.org/wiki/RGBE_image_format
  54222. *
  54223. * @param uint8array The binary file stored in an array buffer.
  54224. * @param hdrInfo The header information of the file.
  54225. * @return The pixels data in RGB right to left up to down order.
  54226. */
  54227. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  54228. private static RGBE_ReadPixels_RLE;
  54229. }
  54230. }
  54231. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  54232. import { Nullable } from "babylonjs/types";
  54233. import { Scene } from "babylonjs/scene";
  54234. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  54235. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54236. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54237. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  54238. /**
  54239. * This represents a texture coming from an HDR input.
  54240. *
  54241. * The only supported format is currently panorama picture stored in RGBE format.
  54242. * Example of such files can be found on HDRLib: http://hdrlib.com/
  54243. */
  54244. export class HDRCubeTexture extends BaseTexture {
  54245. private static _facesMapping;
  54246. private _generateHarmonics;
  54247. private _noMipmap;
  54248. private _textureMatrix;
  54249. private _size;
  54250. private _onLoad;
  54251. private _onError;
  54252. /**
  54253. * The texture URL.
  54254. */
  54255. url: string;
  54256. /**
  54257. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  54258. */
  54259. coordinatesMode: number;
  54260. protected _isBlocking: boolean;
  54261. /**
  54262. * Sets wether or not the texture is blocking during loading.
  54263. */
  54264. /**
  54265. * Gets wether or not the texture is blocking during loading.
  54266. */
  54267. isBlocking: boolean;
  54268. protected _rotationY: number;
  54269. /**
  54270. * Sets texture matrix rotation angle around Y axis in radians.
  54271. */
  54272. /**
  54273. * Gets texture matrix rotation angle around Y axis radians.
  54274. */
  54275. rotationY: number;
  54276. /**
  54277. * Gets or sets the center of the bounding box associated with the cube texture
  54278. * It must define where the camera used to render the texture was set
  54279. */
  54280. boundingBoxPosition: Vector3;
  54281. private _boundingBoxSize;
  54282. /**
  54283. * Gets or sets the size of the bounding box associated with the cube texture
  54284. * When defined, the cubemap will switch to local mode
  54285. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  54286. * @example https://www.babylonjs-playground.com/#RNASML
  54287. */
  54288. boundingBoxSize: Vector3;
  54289. /**
  54290. * Instantiates an HDRTexture from the following parameters.
  54291. *
  54292. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  54293. * @param scene The scene the texture will be used in
  54294. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  54295. * @param noMipmap Forces to not generate the mipmap if true
  54296. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  54297. * @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)
  54298. * @param reserved Reserved flag for internal use.
  54299. */
  54300. 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>);
  54301. /**
  54302. * Get the current class name of the texture useful for serialization or dynamic coding.
  54303. * @returns "HDRCubeTexture"
  54304. */
  54305. getClassName(): string;
  54306. /**
  54307. * Occurs when the file is raw .hdr file.
  54308. */
  54309. private loadTexture;
  54310. clone(): HDRCubeTexture;
  54311. delayLoad(): void;
  54312. /**
  54313. * Get the texture reflection matrix used to rotate/transform the reflection.
  54314. * @returns the reflection matrix
  54315. */
  54316. getReflectionTextureMatrix(): Matrix;
  54317. /**
  54318. * Set the texture reflection matrix used to rotate/transform the reflection.
  54319. * @param value Define the reflection matrix to set
  54320. */
  54321. setReflectionTextureMatrix(value: Matrix): void;
  54322. /**
  54323. * Parses a JSON representation of an HDR Texture in order to create the texture
  54324. * @param parsedTexture Define the JSON representation
  54325. * @param scene Define the scene the texture should be created in
  54326. * @param rootUrl Define the root url in case we need to load relative dependencies
  54327. * @returns the newly created texture after parsing
  54328. */
  54329. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  54330. serialize(): any;
  54331. }
  54332. }
  54333. declare module "babylonjs/Physics/physicsEngine" {
  54334. import { Nullable } from "babylonjs/types";
  54335. import { Vector3 } from "babylonjs/Maths/math.vector";
  54336. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  54337. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  54338. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  54339. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  54340. /**
  54341. * Class used to control physics engine
  54342. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  54343. */
  54344. export class PhysicsEngine implements IPhysicsEngine {
  54345. private _physicsPlugin;
  54346. /**
  54347. * Global value used to control the smallest number supported by the simulation
  54348. */
  54349. static Epsilon: number;
  54350. private _impostors;
  54351. private _joints;
  54352. private _subTimeStep;
  54353. /**
  54354. * Gets the gravity vector used by the simulation
  54355. */
  54356. gravity: Vector3;
  54357. /**
  54358. * Factory used to create the default physics plugin.
  54359. * @returns The default physics plugin
  54360. */
  54361. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  54362. /**
  54363. * Creates a new Physics Engine
  54364. * @param gravity defines the gravity vector used by the simulation
  54365. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  54366. */
  54367. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  54368. /**
  54369. * Sets the gravity vector used by the simulation
  54370. * @param gravity defines the gravity vector to use
  54371. */
  54372. setGravity(gravity: Vector3): void;
  54373. /**
  54374. * Set the time step of the physics engine.
  54375. * Default is 1/60.
  54376. * To slow it down, enter 1/600 for example.
  54377. * To speed it up, 1/30
  54378. * @param newTimeStep defines the new timestep to apply to this world.
  54379. */
  54380. setTimeStep(newTimeStep?: number): void;
  54381. /**
  54382. * Get the time step of the physics engine.
  54383. * @returns the current time step
  54384. */
  54385. getTimeStep(): number;
  54386. /**
  54387. * Set the sub time step of the physics engine.
  54388. * Default is 0 meaning there is no sub steps
  54389. * To increase physics resolution precision, set a small value (like 1 ms)
  54390. * @param subTimeStep defines the new sub timestep used for physics resolution.
  54391. */
  54392. setSubTimeStep(subTimeStep?: number): void;
  54393. /**
  54394. * Get the sub time step of the physics engine.
  54395. * @returns the current sub time step
  54396. */
  54397. getSubTimeStep(): number;
  54398. /**
  54399. * Release all resources
  54400. */
  54401. dispose(): void;
  54402. /**
  54403. * Gets the name of the current physics plugin
  54404. * @returns the name of the plugin
  54405. */
  54406. getPhysicsPluginName(): string;
  54407. /**
  54408. * Adding a new impostor for the impostor tracking.
  54409. * This will be done by the impostor itself.
  54410. * @param impostor the impostor to add
  54411. */
  54412. addImpostor(impostor: PhysicsImpostor): void;
  54413. /**
  54414. * Remove an impostor from the engine.
  54415. * This impostor and its mesh will not longer be updated by the physics engine.
  54416. * @param impostor the impostor to remove
  54417. */
  54418. removeImpostor(impostor: PhysicsImpostor): void;
  54419. /**
  54420. * Add a joint to the physics engine
  54421. * @param mainImpostor defines the main impostor to which the joint is added.
  54422. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  54423. * @param joint defines the joint that will connect both impostors.
  54424. */
  54425. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  54426. /**
  54427. * Removes a joint from the simulation
  54428. * @param mainImpostor defines the impostor used with the joint
  54429. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  54430. * @param joint defines the joint to remove
  54431. */
  54432. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  54433. /**
  54434. * Called by the scene. No need to call it.
  54435. * @param delta defines the timespam between frames
  54436. */
  54437. _step(delta: number): void;
  54438. /**
  54439. * Gets the current plugin used to run the simulation
  54440. * @returns current plugin
  54441. */
  54442. getPhysicsPlugin(): IPhysicsEnginePlugin;
  54443. /**
  54444. * Gets the list of physic impostors
  54445. * @returns an array of PhysicsImpostor
  54446. */
  54447. getImpostors(): Array<PhysicsImpostor>;
  54448. /**
  54449. * Gets the impostor for a physics enabled object
  54450. * @param object defines the object impersonated by the impostor
  54451. * @returns the PhysicsImpostor or null if not found
  54452. */
  54453. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  54454. /**
  54455. * Gets the impostor for a physics body object
  54456. * @param body defines physics body used by the impostor
  54457. * @returns the PhysicsImpostor or null if not found
  54458. */
  54459. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  54460. /**
  54461. * Does a raycast in the physics world
  54462. * @param from when should the ray start?
  54463. * @param to when should the ray end?
  54464. * @returns PhysicsRaycastResult
  54465. */
  54466. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54467. }
  54468. }
  54469. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  54470. import { Nullable } from "babylonjs/types";
  54471. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  54472. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54473. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  54474. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54475. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  54476. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  54477. /** @hidden */
  54478. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  54479. private _useDeltaForWorldStep;
  54480. world: any;
  54481. name: string;
  54482. private _physicsMaterials;
  54483. private _fixedTimeStep;
  54484. private _cannonRaycastResult;
  54485. private _raycastResult;
  54486. private _physicsBodysToRemoveAfterStep;
  54487. BJSCANNON: any;
  54488. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  54489. setGravity(gravity: Vector3): void;
  54490. setTimeStep(timeStep: number): void;
  54491. getTimeStep(): number;
  54492. executeStep(delta: number): void;
  54493. private _removeMarkedPhysicsBodiesFromWorld;
  54494. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54495. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54496. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54497. private _processChildMeshes;
  54498. removePhysicsBody(impostor: PhysicsImpostor): void;
  54499. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54500. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54501. private _addMaterial;
  54502. private _checkWithEpsilon;
  54503. private _createShape;
  54504. private _createHeightmap;
  54505. private _minus90X;
  54506. private _plus90X;
  54507. private _tmpPosition;
  54508. private _tmpDeltaPosition;
  54509. private _tmpUnityRotation;
  54510. private _updatePhysicsBodyTransformation;
  54511. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54512. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54513. isSupported(): boolean;
  54514. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54515. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54516. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54517. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54518. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54519. getBodyMass(impostor: PhysicsImpostor): number;
  54520. getBodyFriction(impostor: PhysicsImpostor): number;
  54521. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54522. getBodyRestitution(impostor: PhysicsImpostor): number;
  54523. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54524. sleepBody(impostor: PhysicsImpostor): void;
  54525. wakeUpBody(impostor: PhysicsImpostor): void;
  54526. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  54527. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  54528. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  54529. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54530. getRadius(impostor: PhysicsImpostor): number;
  54531. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54532. dispose(): void;
  54533. private _extendNamespace;
  54534. /**
  54535. * Does a raycast in the physics world
  54536. * @param from when should the ray start?
  54537. * @param to when should the ray end?
  54538. * @returns PhysicsRaycastResult
  54539. */
  54540. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54541. }
  54542. }
  54543. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  54544. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  54545. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54546. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  54547. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54548. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  54549. import { Nullable } from "babylonjs/types";
  54550. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  54551. /** @hidden */
  54552. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  54553. world: any;
  54554. name: string;
  54555. BJSOIMO: any;
  54556. private _raycastResult;
  54557. constructor(iterations?: number, oimoInjection?: any);
  54558. setGravity(gravity: Vector3): void;
  54559. setTimeStep(timeStep: number): void;
  54560. getTimeStep(): number;
  54561. private _tmpImpostorsArray;
  54562. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  54563. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54564. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54565. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54566. private _tmpPositionVector;
  54567. removePhysicsBody(impostor: PhysicsImpostor): void;
  54568. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54569. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54570. isSupported(): boolean;
  54571. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54572. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54573. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54574. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54575. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54576. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54577. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54578. getBodyMass(impostor: PhysicsImpostor): number;
  54579. getBodyFriction(impostor: PhysicsImpostor): number;
  54580. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54581. getBodyRestitution(impostor: PhysicsImpostor): number;
  54582. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54583. sleepBody(impostor: PhysicsImpostor): void;
  54584. wakeUpBody(impostor: PhysicsImpostor): void;
  54585. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  54586. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  54587. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  54588. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54589. getRadius(impostor: PhysicsImpostor): number;
  54590. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54591. dispose(): void;
  54592. /**
  54593. * Does a raycast in the physics world
  54594. * @param from when should the ray start?
  54595. * @param to when should the ray end?
  54596. * @returns PhysicsRaycastResult
  54597. */
  54598. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54599. }
  54600. }
  54601. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  54602. import { Nullable } from "babylonjs/types";
  54603. import { Scene } from "babylonjs/scene";
  54604. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  54605. import { Color4 } from "babylonjs/Maths/math.color";
  54606. import { Mesh } from "babylonjs/Meshes/mesh";
  54607. /**
  54608. * Class containing static functions to help procedurally build meshes
  54609. */
  54610. export class RibbonBuilder {
  54611. /**
  54612. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54613. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  54614. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  54615. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  54616. * * 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
  54617. * * 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
  54618. * * 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
  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 optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54622. * * 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
  54623. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  54624. * * 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
  54625. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  54626. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54627. * @param name defines the name of the mesh
  54628. * @param options defines the options used to create the mesh
  54629. * @param scene defines the hosting scene
  54630. * @returns the ribbon mesh
  54631. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  54632. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54633. */
  54634. static CreateRibbon(name: string, options: {
  54635. pathArray: Vector3[][];
  54636. closeArray?: boolean;
  54637. closePath?: boolean;
  54638. offset?: number;
  54639. updatable?: boolean;
  54640. sideOrientation?: number;
  54641. frontUVs?: Vector4;
  54642. backUVs?: Vector4;
  54643. instance?: Mesh;
  54644. invertUV?: boolean;
  54645. uvs?: Vector2[];
  54646. colors?: Color4[];
  54647. }, scene?: Nullable<Scene>): Mesh;
  54648. }
  54649. }
  54650. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  54651. import { Nullable } from "babylonjs/types";
  54652. import { Scene } from "babylonjs/scene";
  54653. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  54654. import { Mesh } from "babylonjs/Meshes/mesh";
  54655. /**
  54656. * Class containing static functions to help procedurally build meshes
  54657. */
  54658. export class ShapeBuilder {
  54659. /**
  54660. * 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.
  54661. * * 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.
  54662. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54663. * * 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.
  54664. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  54665. * * 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
  54666. * * 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
  54667. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  54668. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54669. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54670. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  54671. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54672. * @param name defines the name of the mesh
  54673. * @param options defines the options used to create the mesh
  54674. * @param scene defines the hosting scene
  54675. * @returns the extruded shape mesh
  54676. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54677. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54678. */
  54679. static ExtrudeShape(name: string, options: {
  54680. shape: Vector3[];
  54681. path: Vector3[];
  54682. scale?: number;
  54683. rotation?: number;
  54684. cap?: number;
  54685. updatable?: boolean;
  54686. sideOrientation?: number;
  54687. frontUVs?: Vector4;
  54688. backUVs?: Vector4;
  54689. instance?: Mesh;
  54690. invertUV?: boolean;
  54691. }, scene?: Nullable<Scene>): Mesh;
  54692. /**
  54693. * Creates an custom extruded shape mesh.
  54694. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  54695. * * 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.
  54696. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54697. * * 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
  54698. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  54699. * * 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
  54700. * * It must returns a float value that will be the scale value applied to the shape on each path point
  54701. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  54702. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  54703. * * 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
  54704. * * 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
  54705. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  54706. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54707. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54708. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54709. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54710. * @param name defines the name of the mesh
  54711. * @param options defines the options used to create the mesh
  54712. * @param scene defines the hosting scene
  54713. * @returns the custom extruded shape mesh
  54714. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  54715. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54716. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54717. */
  54718. static ExtrudeShapeCustom(name: string, options: {
  54719. shape: Vector3[];
  54720. path: Vector3[];
  54721. scaleFunction?: any;
  54722. rotationFunction?: any;
  54723. ribbonCloseArray?: boolean;
  54724. ribbonClosePath?: boolean;
  54725. cap?: number;
  54726. updatable?: boolean;
  54727. sideOrientation?: number;
  54728. frontUVs?: Vector4;
  54729. backUVs?: Vector4;
  54730. instance?: Mesh;
  54731. invertUV?: boolean;
  54732. }, scene?: Nullable<Scene>): Mesh;
  54733. private static _ExtrudeShapeGeneric;
  54734. }
  54735. }
  54736. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  54737. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  54738. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  54739. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54740. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  54741. import { Nullable } from "babylonjs/types";
  54742. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54743. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  54744. /**
  54745. * AmmoJS Physics plugin
  54746. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  54747. * @see https://github.com/kripken/ammo.js/
  54748. */
  54749. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  54750. private _useDeltaForWorldStep;
  54751. /**
  54752. * Reference to the Ammo library
  54753. */
  54754. bjsAMMO: any;
  54755. /**
  54756. * Created ammoJS world which physics bodies are added to
  54757. */
  54758. world: any;
  54759. /**
  54760. * Name of the plugin
  54761. */
  54762. name: string;
  54763. private _timeStep;
  54764. private _fixedTimeStep;
  54765. private _maxSteps;
  54766. private _tmpQuaternion;
  54767. private _tmpAmmoTransform;
  54768. private _tmpAmmoQuaternion;
  54769. private _tmpAmmoConcreteContactResultCallback;
  54770. private _collisionConfiguration;
  54771. private _dispatcher;
  54772. private _overlappingPairCache;
  54773. private _solver;
  54774. private _softBodySolver;
  54775. private _tmpAmmoVectorA;
  54776. private _tmpAmmoVectorB;
  54777. private _tmpAmmoVectorC;
  54778. private _tmpAmmoVectorD;
  54779. private _tmpContactCallbackResult;
  54780. private _tmpAmmoVectorRCA;
  54781. private _tmpAmmoVectorRCB;
  54782. private _raycastResult;
  54783. private static readonly DISABLE_COLLISION_FLAG;
  54784. private static readonly KINEMATIC_FLAG;
  54785. private static readonly DISABLE_DEACTIVATION_FLAG;
  54786. /**
  54787. * Initializes the ammoJS plugin
  54788. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  54789. * @param ammoInjection can be used to inject your own ammo reference
  54790. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  54791. */
  54792. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  54793. /**
  54794. * Sets the gravity of the physics world (m/(s^2))
  54795. * @param gravity Gravity to set
  54796. */
  54797. setGravity(gravity: Vector3): void;
  54798. /**
  54799. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  54800. * @param timeStep timestep to use in seconds
  54801. */
  54802. setTimeStep(timeStep: number): void;
  54803. /**
  54804. * 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)
  54805. * @param fixedTimeStep fixedTimeStep to use in seconds
  54806. */
  54807. setFixedTimeStep(fixedTimeStep: number): void;
  54808. /**
  54809. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  54810. * @param maxSteps the maximum number of steps by the physics engine per frame
  54811. */
  54812. setMaxSteps(maxSteps: number): void;
  54813. /**
  54814. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  54815. * @returns the current timestep in seconds
  54816. */
  54817. getTimeStep(): number;
  54818. /**
  54819. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  54820. */
  54821. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  54822. private _isImpostorInContact;
  54823. private _isImpostorPairInContact;
  54824. private _stepSimulation;
  54825. /**
  54826. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  54827. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  54828. * After the step the babylon meshes are set to the position of the physics imposters
  54829. * @param delta amount of time to step forward
  54830. * @param impostors array of imposters to update before/after the step
  54831. */
  54832. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  54833. /**
  54834. * Update babylon mesh to match physics world object
  54835. * @param impostor imposter to match
  54836. */
  54837. private _afterSoftStep;
  54838. /**
  54839. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  54840. * @param impostor imposter to match
  54841. */
  54842. private _ropeStep;
  54843. /**
  54844. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  54845. * @param impostor imposter to match
  54846. */
  54847. private _softbodyOrClothStep;
  54848. private _tmpVector;
  54849. private _tmpMatrix;
  54850. /**
  54851. * Applies an impulse on the imposter
  54852. * @param impostor imposter to apply impulse to
  54853. * @param force amount of force to be applied to the imposter
  54854. * @param contactPoint the location to apply the impulse on the imposter
  54855. */
  54856. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54857. /**
  54858. * Applies a force on the imposter
  54859. * @param impostor imposter to apply force
  54860. * @param force amount of force to be applied to the imposter
  54861. * @param contactPoint the location to apply the force on the imposter
  54862. */
  54863. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54864. /**
  54865. * Creates a physics body using the plugin
  54866. * @param impostor the imposter to create the physics body on
  54867. */
  54868. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54869. /**
  54870. * Removes the physics body from the imposter and disposes of the body's memory
  54871. * @param impostor imposter to remove the physics body from
  54872. */
  54873. removePhysicsBody(impostor: PhysicsImpostor): void;
  54874. /**
  54875. * Generates a joint
  54876. * @param impostorJoint the imposter joint to create the joint with
  54877. */
  54878. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54879. /**
  54880. * Removes a joint
  54881. * @param impostorJoint the imposter joint to remove the joint from
  54882. */
  54883. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54884. private _addMeshVerts;
  54885. /**
  54886. * Initialise the soft body vertices to match its object's (mesh) vertices
  54887. * Softbody vertices (nodes) are in world space and to match this
  54888. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  54889. * @param impostor to create the softbody for
  54890. */
  54891. private _softVertexData;
  54892. /**
  54893. * Create an impostor's soft body
  54894. * @param impostor to create the softbody for
  54895. */
  54896. private _createSoftbody;
  54897. /**
  54898. * Create cloth for an impostor
  54899. * @param impostor to create the softbody for
  54900. */
  54901. private _createCloth;
  54902. /**
  54903. * Create rope for an impostor
  54904. * @param impostor to create the softbody for
  54905. */
  54906. private _createRope;
  54907. /**
  54908. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  54909. * @param impostor to create the custom physics shape for
  54910. */
  54911. private _createCustom;
  54912. private _addHullVerts;
  54913. private _createShape;
  54914. /**
  54915. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  54916. * @param impostor imposter containing the physics body and babylon object
  54917. */
  54918. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54919. /**
  54920. * Sets the babylon object's position/rotation from the physics body's position/rotation
  54921. * @param impostor imposter containing the physics body and babylon object
  54922. * @param newPosition new position
  54923. * @param newRotation new rotation
  54924. */
  54925. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54926. /**
  54927. * If this plugin is supported
  54928. * @returns true if its supported
  54929. */
  54930. isSupported(): boolean;
  54931. /**
  54932. * Sets the linear velocity of the physics body
  54933. * @param impostor imposter to set the velocity on
  54934. * @param velocity velocity to set
  54935. */
  54936. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54937. /**
  54938. * Sets the angular velocity of the physics body
  54939. * @param impostor imposter to set the velocity on
  54940. * @param velocity velocity to set
  54941. */
  54942. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54943. /**
  54944. * gets the linear velocity
  54945. * @param impostor imposter to get linear velocity from
  54946. * @returns linear velocity
  54947. */
  54948. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54949. /**
  54950. * gets the angular velocity
  54951. * @param impostor imposter to get angular velocity from
  54952. * @returns angular velocity
  54953. */
  54954. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54955. /**
  54956. * Sets the mass of physics body
  54957. * @param impostor imposter to set the mass on
  54958. * @param mass mass to set
  54959. */
  54960. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54961. /**
  54962. * Gets the mass of the physics body
  54963. * @param impostor imposter to get the mass from
  54964. * @returns mass
  54965. */
  54966. getBodyMass(impostor: PhysicsImpostor): number;
  54967. /**
  54968. * Gets friction of the impostor
  54969. * @param impostor impostor to get friction from
  54970. * @returns friction value
  54971. */
  54972. getBodyFriction(impostor: PhysicsImpostor): number;
  54973. /**
  54974. * Sets friction of the impostor
  54975. * @param impostor impostor to set friction on
  54976. * @param friction friction value
  54977. */
  54978. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54979. /**
  54980. * Gets restitution of the impostor
  54981. * @param impostor impostor to get restitution from
  54982. * @returns restitution value
  54983. */
  54984. getBodyRestitution(impostor: PhysicsImpostor): number;
  54985. /**
  54986. * Sets resitution of the impostor
  54987. * @param impostor impostor to set resitution on
  54988. * @param restitution resitution value
  54989. */
  54990. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54991. /**
  54992. * Gets pressure inside the impostor
  54993. * @param impostor impostor to get pressure from
  54994. * @returns pressure value
  54995. */
  54996. getBodyPressure(impostor: PhysicsImpostor): number;
  54997. /**
  54998. * Sets pressure inside a soft body impostor
  54999. * Cloth and rope must remain 0 pressure
  55000. * @param impostor impostor to set pressure on
  55001. * @param pressure pressure value
  55002. */
  55003. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  55004. /**
  55005. * Gets stiffness of the impostor
  55006. * @param impostor impostor to get stiffness from
  55007. * @returns pressure value
  55008. */
  55009. getBodyStiffness(impostor: PhysicsImpostor): number;
  55010. /**
  55011. * Sets stiffness of the impostor
  55012. * @param impostor impostor to set stiffness on
  55013. * @param stiffness stiffness value from 0 to 1
  55014. */
  55015. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  55016. /**
  55017. * Gets velocityIterations of the impostor
  55018. * @param impostor impostor to get velocity iterations from
  55019. * @returns velocityIterations value
  55020. */
  55021. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  55022. /**
  55023. * Sets velocityIterations of the impostor
  55024. * @param impostor impostor to set velocity iterations on
  55025. * @param velocityIterations velocityIterations value
  55026. */
  55027. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  55028. /**
  55029. * Gets positionIterations of the impostor
  55030. * @param impostor impostor to get position iterations from
  55031. * @returns positionIterations value
  55032. */
  55033. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  55034. /**
  55035. * Sets positionIterations of the impostor
  55036. * @param impostor impostor to set position on
  55037. * @param positionIterations positionIterations value
  55038. */
  55039. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  55040. /**
  55041. * Append an anchor to a cloth object
  55042. * @param impostor is the cloth impostor to add anchor to
  55043. * @param otherImpostor is the rigid impostor to anchor to
  55044. * @param width ratio across width from 0 to 1
  55045. * @param height ratio up height from 0 to 1
  55046. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  55047. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  55048. */
  55049. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  55050. /**
  55051. * Append an hook to a rope object
  55052. * @param impostor is the rope impostor to add hook to
  55053. * @param otherImpostor is the rigid impostor to hook to
  55054. * @param length ratio along the rope from 0 to 1
  55055. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  55056. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  55057. */
  55058. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  55059. /**
  55060. * Sleeps the physics body and stops it from being active
  55061. * @param impostor impostor to sleep
  55062. */
  55063. sleepBody(impostor: PhysicsImpostor): void;
  55064. /**
  55065. * Activates the physics body
  55066. * @param impostor impostor to activate
  55067. */
  55068. wakeUpBody(impostor: PhysicsImpostor): void;
  55069. /**
  55070. * Updates the distance parameters of the joint
  55071. * @param joint joint to update
  55072. * @param maxDistance maximum distance of the joint
  55073. * @param minDistance minimum distance of the joint
  55074. */
  55075. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55076. /**
  55077. * Sets a motor on the joint
  55078. * @param joint joint to set motor on
  55079. * @param speed speed of the motor
  55080. * @param maxForce maximum force of the motor
  55081. * @param motorIndex index of the motor
  55082. */
  55083. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55084. /**
  55085. * Sets the motors limit
  55086. * @param joint joint to set limit on
  55087. * @param upperLimit upper limit
  55088. * @param lowerLimit lower limit
  55089. */
  55090. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55091. /**
  55092. * Syncs the position and rotation of a mesh with the impostor
  55093. * @param mesh mesh to sync
  55094. * @param impostor impostor to update the mesh with
  55095. */
  55096. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55097. /**
  55098. * Gets the radius of the impostor
  55099. * @param impostor impostor to get radius from
  55100. * @returns the radius
  55101. */
  55102. getRadius(impostor: PhysicsImpostor): number;
  55103. /**
  55104. * Gets the box size of the impostor
  55105. * @param impostor impostor to get box size from
  55106. * @param result the resulting box size
  55107. */
  55108. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55109. /**
  55110. * Disposes of the impostor
  55111. */
  55112. dispose(): void;
  55113. /**
  55114. * Does a raycast in the physics world
  55115. * @param from when should the ray start?
  55116. * @param to when should the ray end?
  55117. * @returns PhysicsRaycastResult
  55118. */
  55119. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55120. }
  55121. }
  55122. declare module "babylonjs/Probes/reflectionProbe" {
  55123. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55124. import { Vector3 } from "babylonjs/Maths/math.vector";
  55125. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55126. import { Nullable } from "babylonjs/types";
  55127. import { Scene } from "babylonjs/scene";
  55128. module "babylonjs/abstractScene" {
  55129. interface AbstractScene {
  55130. /**
  55131. * The list of reflection probes added to the scene
  55132. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  55133. */
  55134. reflectionProbes: Array<ReflectionProbe>;
  55135. /**
  55136. * Removes the given reflection probe from this scene.
  55137. * @param toRemove The reflection probe to remove
  55138. * @returns The index of the removed reflection probe
  55139. */
  55140. removeReflectionProbe(toRemove: ReflectionProbe): number;
  55141. /**
  55142. * Adds the given reflection probe to this scene.
  55143. * @param newReflectionProbe The reflection probe to add
  55144. */
  55145. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  55146. }
  55147. }
  55148. /**
  55149. * Class used to generate realtime reflection / refraction cube textures
  55150. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  55151. */
  55152. export class ReflectionProbe {
  55153. /** defines the name of the probe */
  55154. name: string;
  55155. private _scene;
  55156. private _renderTargetTexture;
  55157. private _projectionMatrix;
  55158. private _viewMatrix;
  55159. private _target;
  55160. private _add;
  55161. private _attachedMesh;
  55162. private _invertYAxis;
  55163. /** Gets or sets probe position (center of the cube map) */
  55164. position: Vector3;
  55165. /**
  55166. * Creates a new reflection probe
  55167. * @param name defines the name of the probe
  55168. * @param size defines the texture resolution (for each face)
  55169. * @param scene defines the hosting scene
  55170. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  55171. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  55172. */
  55173. constructor(
  55174. /** defines the name of the probe */
  55175. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  55176. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  55177. samples: number;
  55178. /** Gets or sets the refresh rate to use (on every frame by default) */
  55179. refreshRate: number;
  55180. /**
  55181. * Gets the hosting scene
  55182. * @returns a Scene
  55183. */
  55184. getScene(): Scene;
  55185. /** Gets the internal CubeTexture used to render to */
  55186. readonly cubeTexture: RenderTargetTexture;
  55187. /** Gets the list of meshes to render */
  55188. readonly renderList: Nullable<AbstractMesh[]>;
  55189. /**
  55190. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  55191. * @param mesh defines the mesh to attach to
  55192. */
  55193. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  55194. /**
  55195. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  55196. * @param renderingGroupId The rendering group id corresponding to its index
  55197. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  55198. */
  55199. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  55200. /**
  55201. * Clean all associated resources
  55202. */
  55203. dispose(): void;
  55204. /**
  55205. * Converts the reflection probe information to a readable string for debug purpose.
  55206. * @param fullDetails Supports for multiple levels of logging within scene loading
  55207. * @returns the human readable reflection probe info
  55208. */
  55209. toString(fullDetails?: boolean): string;
  55210. /**
  55211. * Get the class name of the relfection probe.
  55212. * @returns "ReflectionProbe"
  55213. */
  55214. getClassName(): string;
  55215. /**
  55216. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  55217. * @returns The JSON representation of the texture
  55218. */
  55219. serialize(): any;
  55220. /**
  55221. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  55222. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  55223. * @param scene Define the scene the parsed reflection probe should be instantiated in
  55224. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  55225. * @returns The parsed reflection probe if successful
  55226. */
  55227. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  55228. }
  55229. }
  55230. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  55231. /** @hidden */
  55232. export var _BabylonLoaderRegistered: boolean;
  55233. /**
  55234. * Helps setting up some configuration for the babylon file loader.
  55235. */
  55236. export class BabylonFileLoaderConfiguration {
  55237. /**
  55238. * The loader does not allow injecting custom physix engine into the plugins.
  55239. * Unfortunately in ES6, we need to manually inject them into the plugin.
  55240. * So you could set this variable to your engine import to make it work.
  55241. */
  55242. static LoaderInjectedPhysicsEngine: any;
  55243. }
  55244. }
  55245. declare module "babylonjs/Loading/Plugins/index" {
  55246. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  55247. }
  55248. declare module "babylonjs/Loading/index" {
  55249. export * from "babylonjs/Loading/loadingScreen";
  55250. export * from "babylonjs/Loading/Plugins/index";
  55251. export * from "babylonjs/Loading/sceneLoader";
  55252. export * from "babylonjs/Loading/sceneLoaderFlags";
  55253. }
  55254. declare module "babylonjs/Materials/Background/index" {
  55255. export * from "babylonjs/Materials/Background/backgroundMaterial";
  55256. }
  55257. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  55258. import { Scene } from "babylonjs/scene";
  55259. import { Color3 } from "babylonjs/Maths/math.color";
  55260. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  55261. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55262. /**
  55263. * The Physically based simple base material of BJS.
  55264. *
  55265. * This enables better naming and convention enforcements on top of the pbrMaterial.
  55266. * It is used as the base class for both the specGloss and metalRough conventions.
  55267. */
  55268. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  55269. /**
  55270. * Number of Simultaneous lights allowed on the material.
  55271. */
  55272. maxSimultaneousLights: number;
  55273. /**
  55274. * If sets to true, disables all the lights affecting the material.
  55275. */
  55276. disableLighting: boolean;
  55277. /**
  55278. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  55279. */
  55280. environmentTexture: BaseTexture;
  55281. /**
  55282. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  55283. */
  55284. invertNormalMapX: boolean;
  55285. /**
  55286. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  55287. */
  55288. invertNormalMapY: boolean;
  55289. /**
  55290. * Normal map used in the model.
  55291. */
  55292. normalTexture: BaseTexture;
  55293. /**
  55294. * Emissivie color used to self-illuminate the model.
  55295. */
  55296. emissiveColor: Color3;
  55297. /**
  55298. * Emissivie texture used to self-illuminate the model.
  55299. */
  55300. emissiveTexture: BaseTexture;
  55301. /**
  55302. * Occlusion Channel Strenght.
  55303. */
  55304. occlusionStrength: number;
  55305. /**
  55306. * Occlusion Texture of the material (adding extra occlusion effects).
  55307. */
  55308. occlusionTexture: BaseTexture;
  55309. /**
  55310. * Defines the alpha limits in alpha test mode.
  55311. */
  55312. alphaCutOff: number;
  55313. /**
  55314. * Gets the current double sided mode.
  55315. */
  55316. /**
  55317. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  55318. */
  55319. doubleSided: boolean;
  55320. /**
  55321. * Stores the pre-calculated light information of a mesh in a texture.
  55322. */
  55323. lightmapTexture: BaseTexture;
  55324. /**
  55325. * If true, the light map contains occlusion information instead of lighting info.
  55326. */
  55327. useLightmapAsShadowmap: boolean;
  55328. /**
  55329. * Instantiates a new PBRMaterial instance.
  55330. *
  55331. * @param name The material name
  55332. * @param scene The scene the material will be use in.
  55333. */
  55334. constructor(name: string, scene: Scene);
  55335. getClassName(): string;
  55336. }
  55337. }
  55338. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  55339. import { Scene } from "babylonjs/scene";
  55340. import { Color3 } from "babylonjs/Maths/math.color";
  55341. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55342. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  55343. /**
  55344. * The PBR material of BJS following the metal roughness convention.
  55345. *
  55346. * This fits to the PBR convention in the GLTF definition:
  55347. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  55348. */
  55349. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  55350. /**
  55351. * The base color has two different interpretations depending on the value of metalness.
  55352. * When the material is a metal, the base color is the specific measured reflectance value
  55353. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  55354. * of the material.
  55355. */
  55356. baseColor: Color3;
  55357. /**
  55358. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  55359. * well as opacity information in the alpha channel.
  55360. */
  55361. baseTexture: BaseTexture;
  55362. /**
  55363. * Specifies the metallic scalar value of the material.
  55364. * Can also be used to scale the metalness values of the metallic texture.
  55365. */
  55366. metallic: number;
  55367. /**
  55368. * Specifies the roughness scalar value of the material.
  55369. * Can also be used to scale the roughness values of the metallic texture.
  55370. */
  55371. roughness: number;
  55372. /**
  55373. * Texture containing both the metallic value in the B channel and the
  55374. * roughness value in the G channel to keep better precision.
  55375. */
  55376. metallicRoughnessTexture: BaseTexture;
  55377. /**
  55378. * Instantiates a new PBRMetalRoughnessMaterial instance.
  55379. *
  55380. * @param name The material name
  55381. * @param scene The scene the material will be use in.
  55382. */
  55383. constructor(name: string, scene: Scene);
  55384. /**
  55385. * Return the currrent class name of the material.
  55386. */
  55387. getClassName(): string;
  55388. /**
  55389. * Makes a duplicate of the current material.
  55390. * @param name - name to use for the new material.
  55391. */
  55392. clone(name: string): PBRMetallicRoughnessMaterial;
  55393. /**
  55394. * Serialize the material to a parsable JSON object.
  55395. */
  55396. serialize(): any;
  55397. /**
  55398. * Parses a JSON object correponding to the serialize function.
  55399. */
  55400. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  55401. }
  55402. }
  55403. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  55404. import { Scene } from "babylonjs/scene";
  55405. import { Color3 } from "babylonjs/Maths/math.color";
  55406. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55407. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  55408. /**
  55409. * The PBR material of BJS following the specular glossiness convention.
  55410. *
  55411. * This fits to the PBR convention in the GLTF definition:
  55412. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  55413. */
  55414. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  55415. /**
  55416. * Specifies the diffuse color of the material.
  55417. */
  55418. diffuseColor: Color3;
  55419. /**
  55420. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  55421. * channel.
  55422. */
  55423. diffuseTexture: BaseTexture;
  55424. /**
  55425. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  55426. */
  55427. specularColor: Color3;
  55428. /**
  55429. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  55430. */
  55431. glossiness: number;
  55432. /**
  55433. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  55434. */
  55435. specularGlossinessTexture: BaseTexture;
  55436. /**
  55437. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  55438. *
  55439. * @param name The material name
  55440. * @param scene The scene the material will be use in.
  55441. */
  55442. constructor(name: string, scene: Scene);
  55443. /**
  55444. * Return the currrent class name of the material.
  55445. */
  55446. getClassName(): string;
  55447. /**
  55448. * Makes a duplicate of the current material.
  55449. * @param name - name to use for the new material.
  55450. */
  55451. clone(name: string): PBRSpecularGlossinessMaterial;
  55452. /**
  55453. * Serialize the material to a parsable JSON object.
  55454. */
  55455. serialize(): any;
  55456. /**
  55457. * Parses a JSON object correponding to the serialize function.
  55458. */
  55459. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  55460. }
  55461. }
  55462. declare module "babylonjs/Materials/PBR/index" {
  55463. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  55464. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  55465. export * from "babylonjs/Materials/PBR/pbrMaterial";
  55466. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  55467. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  55468. }
  55469. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  55470. import { Nullable } from "babylonjs/types";
  55471. import { Scene } from "babylonjs/scene";
  55472. import { Matrix } from "babylonjs/Maths/math.vector";
  55473. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55474. /**
  55475. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  55476. * It can help converting any input color in a desired output one. This can then be used to create effects
  55477. * from sepia, black and white to sixties or futuristic rendering...
  55478. *
  55479. * The only supported format is currently 3dl.
  55480. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  55481. */
  55482. export class ColorGradingTexture extends BaseTexture {
  55483. /**
  55484. * The current texture matrix. (will always be identity in color grading texture)
  55485. */
  55486. private _textureMatrix;
  55487. /**
  55488. * The texture URL.
  55489. */
  55490. url: string;
  55491. /**
  55492. * Empty line regex stored for GC.
  55493. */
  55494. private static _noneEmptyLineRegex;
  55495. private _engine;
  55496. /**
  55497. * Instantiates a ColorGradingTexture from the following parameters.
  55498. *
  55499. * @param url The location of the color gradind data (currently only supporting 3dl)
  55500. * @param scene The scene the texture will be used in
  55501. */
  55502. constructor(url: string, scene: Scene);
  55503. /**
  55504. * Returns the texture matrix used in most of the material.
  55505. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  55506. */
  55507. getTextureMatrix(): Matrix;
  55508. /**
  55509. * Occurs when the file being loaded is a .3dl LUT file.
  55510. */
  55511. private load3dlTexture;
  55512. /**
  55513. * Starts the loading process of the texture.
  55514. */
  55515. private loadTexture;
  55516. /**
  55517. * Clones the color gradind texture.
  55518. */
  55519. clone(): ColorGradingTexture;
  55520. /**
  55521. * Called during delayed load for textures.
  55522. */
  55523. delayLoad(): void;
  55524. /**
  55525. * Parses a color grading texture serialized by Babylon.
  55526. * @param parsedTexture The texture information being parsedTexture
  55527. * @param scene The scene to load the texture in
  55528. * @param rootUrl The root url of the data assets to load
  55529. * @return A color gradind texture
  55530. */
  55531. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  55532. /**
  55533. * Serializes the LUT texture to json format.
  55534. */
  55535. serialize(): any;
  55536. }
  55537. }
  55538. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  55539. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55540. import { Scene } from "babylonjs/scene";
  55541. import { Nullable } from "babylonjs/types";
  55542. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55543. /**
  55544. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  55545. */
  55546. export class EquiRectangularCubeTexture extends BaseTexture {
  55547. /** The six faces of the cube. */
  55548. private static _FacesMapping;
  55549. private _noMipmap;
  55550. private _onLoad;
  55551. private _onError;
  55552. /** The size of the cubemap. */
  55553. private _size;
  55554. /** The buffer of the image. */
  55555. private _buffer;
  55556. /** The width of the input image. */
  55557. private _width;
  55558. /** The height of the input image. */
  55559. private _height;
  55560. /** The URL to the image. */
  55561. url: string;
  55562. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  55563. coordinatesMode: number;
  55564. /**
  55565. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  55566. * @param url The location of the image
  55567. * @param scene The scene the texture will be used in
  55568. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  55569. * @param noMipmap Forces to not generate the mipmap if true
  55570. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  55571. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  55572. * @param onLoad — defines a callback called when texture is loaded
  55573. * @param onError — defines a callback called if there is an error
  55574. */
  55575. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  55576. /**
  55577. * Load the image data, by putting the image on a canvas and extracting its buffer.
  55578. */
  55579. private loadImage;
  55580. /**
  55581. * Convert the image buffer into a cubemap and create a CubeTexture.
  55582. */
  55583. private loadTexture;
  55584. /**
  55585. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  55586. * @param buffer The ArrayBuffer that should be converted.
  55587. * @returns The buffer as Float32Array.
  55588. */
  55589. private getFloat32ArrayFromArrayBuffer;
  55590. /**
  55591. * Get the current class name of the texture useful for serialization or dynamic coding.
  55592. * @returns "EquiRectangularCubeTexture"
  55593. */
  55594. getClassName(): string;
  55595. /**
  55596. * Create a clone of the current EquiRectangularCubeTexture and return it.
  55597. * @returns A clone of the current EquiRectangularCubeTexture.
  55598. */
  55599. clone(): EquiRectangularCubeTexture;
  55600. }
  55601. }
  55602. declare module "babylonjs/Misc/tga" {
  55603. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55604. /**
  55605. * Based on jsTGALoader - Javascript loader for TGA file
  55606. * By Vincent Thibault
  55607. * @see http://blog.robrowser.com/javascript-tga-loader.html
  55608. */
  55609. export class TGATools {
  55610. private static _TYPE_INDEXED;
  55611. private static _TYPE_RGB;
  55612. private static _TYPE_GREY;
  55613. private static _TYPE_RLE_INDEXED;
  55614. private static _TYPE_RLE_RGB;
  55615. private static _TYPE_RLE_GREY;
  55616. private static _ORIGIN_MASK;
  55617. private static _ORIGIN_SHIFT;
  55618. private static _ORIGIN_BL;
  55619. private static _ORIGIN_BR;
  55620. private static _ORIGIN_UL;
  55621. private static _ORIGIN_UR;
  55622. /**
  55623. * Gets the header of a TGA file
  55624. * @param data defines the TGA data
  55625. * @returns the header
  55626. */
  55627. static GetTGAHeader(data: Uint8Array): any;
  55628. /**
  55629. * Uploads TGA content to a Babylon Texture
  55630. * @hidden
  55631. */
  55632. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  55633. /** @hidden */
  55634. 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;
  55635. /** @hidden */
  55636. 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;
  55637. /** @hidden */
  55638. 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;
  55639. /** @hidden */
  55640. 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;
  55641. /** @hidden */
  55642. 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;
  55643. /** @hidden */
  55644. 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;
  55645. }
  55646. }
  55647. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  55648. import { Nullable } from "babylonjs/types";
  55649. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55650. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  55651. /**
  55652. * Implementation of the TGA Texture Loader.
  55653. * @hidden
  55654. */
  55655. export class _TGATextureLoader implements IInternalTextureLoader {
  55656. /**
  55657. * Defines wether the loader supports cascade loading the different faces.
  55658. */
  55659. readonly supportCascades: boolean;
  55660. /**
  55661. * This returns if the loader support the current file information.
  55662. * @param extension defines the file extension of the file being loaded
  55663. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55664. * @param fallback defines the fallback internal texture if any
  55665. * @param isBase64 defines whether the texture is encoded as a base64
  55666. * @param isBuffer defines whether the texture data are stored as a buffer
  55667. * @returns true if the loader can load the specified file
  55668. */
  55669. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  55670. /**
  55671. * Transform the url before loading if required.
  55672. * @param rootUrl the url of the texture
  55673. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55674. * @returns the transformed texture
  55675. */
  55676. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  55677. /**
  55678. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  55679. * @param rootUrl the url of the texture
  55680. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55681. * @returns the fallback texture
  55682. */
  55683. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  55684. /**
  55685. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  55686. * @param data contains the texture data
  55687. * @param texture defines the BabylonJS internal texture
  55688. * @param createPolynomials will be true if polynomials have been requested
  55689. * @param onLoad defines the callback to trigger once the texture is ready
  55690. * @param onError defines the callback to trigger in case of error
  55691. */
  55692. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55693. /**
  55694. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  55695. * @param data contains the texture data
  55696. * @param texture defines the BabylonJS internal texture
  55697. * @param callback defines the method to call once ready to upload
  55698. */
  55699. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55700. }
  55701. }
  55702. declare module "babylonjs/Misc/basis" {
  55703. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55704. /**
  55705. * Info about the .basis files
  55706. */
  55707. class BasisFileInfo {
  55708. /**
  55709. * If the file has alpha
  55710. */
  55711. hasAlpha: boolean;
  55712. /**
  55713. * Info about each image of the basis file
  55714. */
  55715. images: Array<{
  55716. levels: Array<{
  55717. width: number;
  55718. height: number;
  55719. transcodedPixels: ArrayBufferView;
  55720. }>;
  55721. }>;
  55722. }
  55723. /**
  55724. * Result of transcoding a basis file
  55725. */
  55726. class TranscodeResult {
  55727. /**
  55728. * Info about the .basis file
  55729. */
  55730. fileInfo: BasisFileInfo;
  55731. /**
  55732. * Format to use when loading the file
  55733. */
  55734. format: number;
  55735. }
  55736. /**
  55737. * Configuration options for the Basis transcoder
  55738. */
  55739. export class BasisTranscodeConfiguration {
  55740. /**
  55741. * Supported compression formats used to determine the supported output format of the transcoder
  55742. */
  55743. supportedCompressionFormats?: {
  55744. /**
  55745. * etc1 compression format
  55746. */
  55747. etc1?: boolean;
  55748. /**
  55749. * s3tc compression format
  55750. */
  55751. s3tc?: boolean;
  55752. /**
  55753. * pvrtc compression format
  55754. */
  55755. pvrtc?: boolean;
  55756. /**
  55757. * etc2 compression format
  55758. */
  55759. etc2?: boolean;
  55760. };
  55761. /**
  55762. * If mipmap levels should be loaded for transcoded images (Default: true)
  55763. */
  55764. loadMipmapLevels?: boolean;
  55765. /**
  55766. * Index of a single image to load (Default: all images)
  55767. */
  55768. loadSingleImage?: number;
  55769. }
  55770. /**
  55771. * Used to load .Basis files
  55772. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  55773. */
  55774. export class BasisTools {
  55775. private static _IgnoreSupportedFormats;
  55776. /**
  55777. * URL to use when loading the basis transcoder
  55778. */
  55779. static JSModuleURL: string;
  55780. /**
  55781. * URL to use when loading the wasm module for the transcoder
  55782. */
  55783. static WasmModuleURL: string;
  55784. /**
  55785. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  55786. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  55787. * @returns internal format corresponding to the Basis format
  55788. */
  55789. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  55790. private static _WorkerPromise;
  55791. private static _Worker;
  55792. private static _actionId;
  55793. private static _CreateWorkerAsync;
  55794. /**
  55795. * Transcodes a loaded image file to compressed pixel data
  55796. * @param imageData image data to transcode
  55797. * @param config configuration options for the transcoding
  55798. * @returns a promise resulting in the transcoded image
  55799. */
  55800. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  55801. /**
  55802. * Loads a texture from the transcode result
  55803. * @param texture texture load to
  55804. * @param transcodeResult the result of transcoding the basis file to load from
  55805. */
  55806. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  55807. }
  55808. }
  55809. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  55810. import { Nullable } from "babylonjs/types";
  55811. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55812. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  55813. /**
  55814. * Loader for .basis file format
  55815. */
  55816. export class _BasisTextureLoader implements IInternalTextureLoader {
  55817. /**
  55818. * Defines whether the loader supports cascade loading the different faces.
  55819. */
  55820. readonly supportCascades: boolean;
  55821. /**
  55822. * This returns if the loader support the current file information.
  55823. * @param extension defines the file extension of the file being loaded
  55824. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55825. * @param fallback defines the fallback internal texture if any
  55826. * @param isBase64 defines whether the texture is encoded as a base64
  55827. * @param isBuffer defines whether the texture data are stored as a buffer
  55828. * @returns true if the loader can load the specified file
  55829. */
  55830. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  55831. /**
  55832. * Transform the url before loading if required.
  55833. * @param rootUrl the url of the texture
  55834. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55835. * @returns the transformed texture
  55836. */
  55837. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  55838. /**
  55839. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  55840. * @param rootUrl the url of the texture
  55841. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55842. * @returns the fallback texture
  55843. */
  55844. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  55845. /**
  55846. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  55847. * @param data contains the texture data
  55848. * @param texture defines the BabylonJS internal texture
  55849. * @param createPolynomials will be true if polynomials have been requested
  55850. * @param onLoad defines the callback to trigger once the texture is ready
  55851. * @param onError defines the callback to trigger in case of error
  55852. */
  55853. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55854. /**
  55855. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  55856. * @param data contains the texture data
  55857. * @param texture defines the BabylonJS internal texture
  55858. * @param callback defines the method to call once ready to upload
  55859. */
  55860. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55861. }
  55862. }
  55863. declare module "babylonjs/Materials/Textures/Loaders/index" {
  55864. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  55865. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  55866. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  55867. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  55868. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  55869. }
  55870. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  55871. import { Scene } from "babylonjs/scene";
  55872. import { Texture } from "babylonjs/Materials/Textures/texture";
  55873. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  55874. /**
  55875. * 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.
  55876. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  55877. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  55878. */
  55879. export class CustomProceduralTexture extends ProceduralTexture {
  55880. private _animate;
  55881. private _time;
  55882. private _config;
  55883. private _texturePath;
  55884. /**
  55885. * Instantiates a new Custom Procedural Texture.
  55886. * 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.
  55887. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  55888. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  55889. * @param name Define the name of the texture
  55890. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  55891. * @param size Define the size of the texture to create
  55892. * @param scene Define the scene the texture belongs to
  55893. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  55894. * @param generateMipMaps Define if the texture should creates mip maps or not
  55895. */
  55896. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  55897. private _loadJson;
  55898. /**
  55899. * Is the texture ready to be used ? (rendered at least once)
  55900. * @returns true if ready, otherwise, false.
  55901. */
  55902. isReady(): boolean;
  55903. /**
  55904. * Render the texture to its associated render target.
  55905. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  55906. */
  55907. render(useCameraPostProcess?: boolean): void;
  55908. /**
  55909. * Update the list of dependant textures samplers in the shader.
  55910. */
  55911. updateTextures(): void;
  55912. /**
  55913. * Update the uniform values of the procedural texture in the shader.
  55914. */
  55915. updateShaderUniforms(): void;
  55916. /**
  55917. * Define if the texture animates or not.
  55918. */
  55919. animate: boolean;
  55920. }
  55921. }
  55922. declare module "babylonjs/Shaders/noise.fragment" {
  55923. /** @hidden */
  55924. export var noisePixelShader: {
  55925. name: string;
  55926. shader: string;
  55927. };
  55928. }
  55929. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  55930. import { Nullable } from "babylonjs/types";
  55931. import { Scene } from "babylonjs/scene";
  55932. import { Texture } from "babylonjs/Materials/Textures/texture";
  55933. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  55934. import "babylonjs/Shaders/noise.fragment";
  55935. /**
  55936. * Class used to generate noise procedural textures
  55937. */
  55938. export class NoiseProceduralTexture extends ProceduralTexture {
  55939. private _time;
  55940. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  55941. brightness: number;
  55942. /** Defines the number of octaves to process */
  55943. octaves: number;
  55944. /** Defines the level of persistence (0.8 by default) */
  55945. persistence: number;
  55946. /** Gets or sets animation speed factor (default is 1) */
  55947. animationSpeedFactor: number;
  55948. /**
  55949. * Creates a new NoiseProceduralTexture
  55950. * @param name defines the name fo the texture
  55951. * @param size defines the size of the texture (default is 256)
  55952. * @param scene defines the hosting scene
  55953. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  55954. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  55955. */
  55956. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  55957. private _updateShaderUniforms;
  55958. protected _getDefines(): string;
  55959. /** Generate the current state of the procedural texture */
  55960. render(useCameraPostProcess?: boolean): void;
  55961. /**
  55962. * Serializes this noise procedural texture
  55963. * @returns a serialized noise procedural texture object
  55964. */
  55965. serialize(): any;
  55966. /**
  55967. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  55968. * @param parsedTexture defines parsed texture data
  55969. * @param scene defines the current scene
  55970. * @param rootUrl defines the root URL containing noise procedural texture information
  55971. * @returns a parsed NoiseProceduralTexture
  55972. */
  55973. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  55974. }
  55975. }
  55976. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  55977. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  55978. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  55979. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  55980. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  55981. }
  55982. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  55983. import { Nullable } from "babylonjs/types";
  55984. import { Scene } from "babylonjs/scene";
  55985. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  55986. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55987. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  55988. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55989. /**
  55990. * Raw cube texture where the raw buffers are passed in
  55991. */
  55992. export class RawCubeTexture extends CubeTexture {
  55993. /**
  55994. * Creates a cube texture where the raw buffers are passed in.
  55995. * @param scene defines the scene the texture is attached to
  55996. * @param data defines the array of data to use to create each face
  55997. * @param size defines the size of the textures
  55998. * @param format defines the format of the data
  55999. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  56000. * @param generateMipMaps defines if the engine should generate the mip levels
  56001. * @param invertY defines if data must be stored with Y axis inverted
  56002. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  56003. * @param compression defines the compression used (null by default)
  56004. */
  56005. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  56006. /**
  56007. * Updates the raw cube texture.
  56008. * @param data defines the data to store
  56009. * @param format defines the data format
  56010. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  56011. * @param invertY defines if data must be stored with Y axis inverted
  56012. * @param compression defines the compression used (null by default)
  56013. * @param level defines which level of the texture to update
  56014. */
  56015. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  56016. /**
  56017. * Updates a raw cube texture with RGBD encoded data.
  56018. * @param data defines the array of data [mipmap][face] to use to create each face
  56019. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  56020. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  56021. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  56022. * @returns a promsie that resolves when the operation is complete
  56023. */
  56024. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  56025. /**
  56026. * Clones the raw cube texture.
  56027. * @return a new cube texture
  56028. */
  56029. clone(): CubeTexture;
  56030. /** @hidden */
  56031. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  56032. }
  56033. }
  56034. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  56035. import { Scene } from "babylonjs/scene";
  56036. import { Texture } from "babylonjs/Materials/Textures/texture";
  56037. import "babylonjs/Engines/Extensions/engine.rawTexture";
  56038. /**
  56039. * Class used to store 3D textures containing user data
  56040. */
  56041. export class RawTexture3D extends Texture {
  56042. /** Gets or sets the texture format to use */
  56043. format: number;
  56044. private _engine;
  56045. /**
  56046. * Create a new RawTexture3D
  56047. * @param data defines the data of the texture
  56048. * @param width defines the width of the texture
  56049. * @param height defines the height of the texture
  56050. * @param depth defines the depth of the texture
  56051. * @param format defines the texture format to use
  56052. * @param scene defines the hosting scene
  56053. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56054. * @param invertY defines if texture must be stored with Y axis inverted
  56055. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56056. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56057. */
  56058. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56059. /** Gets or sets the texture format to use */
  56060. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56061. /**
  56062. * Update the texture with new data
  56063. * @param data defines the data to store in the texture
  56064. */
  56065. update(data: ArrayBufferView): void;
  56066. }
  56067. }
  56068. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  56069. import { Scene } from "babylonjs/scene";
  56070. import { Texture } from "babylonjs/Materials/Textures/texture";
  56071. import "babylonjs/Engines/Extensions/engine.rawTexture";
  56072. /**
  56073. * Class used to store 2D array textures containing user data
  56074. */
  56075. export class RawTexture2DArray extends Texture {
  56076. /** Gets or sets the texture format to use */
  56077. format: number;
  56078. private _engine;
  56079. /**
  56080. * Create a new RawTexture2DArray
  56081. * @param data defines the data of the texture
  56082. * @param width defines the width of the texture
  56083. * @param height defines the height of the texture
  56084. * @param depth defines the number of layers of the texture
  56085. * @param format defines the texture format to use
  56086. * @param scene defines the hosting scene
  56087. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56088. * @param invertY defines if texture must be stored with Y axis inverted
  56089. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56090. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56091. */
  56092. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56093. /** Gets or sets the texture format to use */
  56094. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56095. /**
  56096. * Update the texture with new data
  56097. * @param data defines the data to store in the texture
  56098. */
  56099. update(data: ArrayBufferView): void;
  56100. }
  56101. }
  56102. declare module "babylonjs/Materials/Textures/refractionTexture" {
  56103. import { Scene } from "babylonjs/scene";
  56104. import { Plane } from "babylonjs/Maths/math.plane";
  56105. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56106. /**
  56107. * Creates a refraction texture used by refraction channel of the standard material.
  56108. * It is like a mirror but to see through a material.
  56109. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56110. */
  56111. export class RefractionTexture extends RenderTargetTexture {
  56112. /**
  56113. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  56114. * 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.
  56115. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56116. */
  56117. refractionPlane: Plane;
  56118. /**
  56119. * Define how deep under the surface we should see.
  56120. */
  56121. depth: number;
  56122. /**
  56123. * Creates a refraction texture used by refraction channel of the standard material.
  56124. * It is like a mirror but to see through a material.
  56125. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56126. * @param name Define the texture name
  56127. * @param size Define the size of the underlying texture
  56128. * @param scene Define the scene the refraction belongs to
  56129. * @param generateMipMaps Define if we need to generate mips level for the refraction
  56130. */
  56131. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  56132. /**
  56133. * Clone the refraction texture.
  56134. * @returns the cloned texture
  56135. */
  56136. clone(): RefractionTexture;
  56137. /**
  56138. * Serialize the texture to a JSON representation you could use in Parse later on
  56139. * @returns the serialized JSON representation
  56140. */
  56141. serialize(): any;
  56142. }
  56143. }
  56144. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  56145. import { Nullable } from "babylonjs/types";
  56146. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56147. import { Matrix } from "babylonjs/Maths/math.vector";
  56148. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  56149. import "babylonjs/Engines/Extensions/engine.videoTexture";
  56150. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  56151. import { Scene } from "babylonjs/scene";
  56152. /**
  56153. * Defines the options related to the creation of an HtmlElementTexture
  56154. */
  56155. export interface IHtmlElementTextureOptions {
  56156. /**
  56157. * Defines wether mip maps should be created or not.
  56158. */
  56159. generateMipMaps?: boolean;
  56160. /**
  56161. * Defines the sampling mode of the texture.
  56162. */
  56163. samplingMode?: number;
  56164. /**
  56165. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  56166. */
  56167. engine: Nullable<ThinEngine>;
  56168. /**
  56169. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  56170. */
  56171. scene: Nullable<Scene>;
  56172. }
  56173. /**
  56174. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  56175. * To be as efficient as possible depending on your constraints nothing aside the first upload
  56176. * is automatically managed.
  56177. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  56178. * in your application.
  56179. *
  56180. * As the update is not automatic, you need to call them manually.
  56181. */
  56182. export class HtmlElementTexture extends BaseTexture {
  56183. /**
  56184. * The texture URL.
  56185. */
  56186. element: HTMLVideoElement | HTMLCanvasElement;
  56187. private static readonly DefaultOptions;
  56188. private _textureMatrix;
  56189. private _engine;
  56190. private _isVideo;
  56191. private _generateMipMaps;
  56192. private _samplingMode;
  56193. /**
  56194. * Instantiates a HtmlElementTexture from the following parameters.
  56195. *
  56196. * @param name Defines the name of the texture
  56197. * @param element Defines the video or canvas the texture is filled with
  56198. * @param options Defines the other none mandatory texture creation options
  56199. */
  56200. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  56201. private _createInternalTexture;
  56202. /**
  56203. * Returns the texture matrix used in most of the material.
  56204. */
  56205. getTextureMatrix(): Matrix;
  56206. /**
  56207. * Updates the content of the texture.
  56208. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  56209. */
  56210. update(invertY?: Nullable<boolean>): void;
  56211. }
  56212. }
  56213. declare module "babylonjs/Materials/Textures/index" {
  56214. export * from "babylonjs/Materials/Textures/baseTexture";
  56215. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  56216. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  56217. export * from "babylonjs/Materials/Textures/cubeTexture";
  56218. export * from "babylonjs/Materials/Textures/dynamicTexture";
  56219. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  56220. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  56221. export * from "babylonjs/Materials/Textures/internalTexture";
  56222. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  56223. export * from "babylonjs/Materials/Textures/Loaders/index";
  56224. export * from "babylonjs/Materials/Textures/mirrorTexture";
  56225. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  56226. export * from "babylonjs/Materials/Textures/Procedurals/index";
  56227. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  56228. export * from "babylonjs/Materials/Textures/rawTexture";
  56229. export * from "babylonjs/Materials/Textures/rawTexture3D";
  56230. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  56231. export * from "babylonjs/Materials/Textures/refractionTexture";
  56232. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  56233. export * from "babylonjs/Materials/Textures/texture";
  56234. export * from "babylonjs/Materials/Textures/videoTexture";
  56235. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  56236. }
  56237. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  56238. /**
  56239. * Enum used to define the target of a block
  56240. */
  56241. export enum NodeMaterialBlockTargets {
  56242. /** Vertex shader */
  56243. Vertex = 1,
  56244. /** Fragment shader */
  56245. Fragment = 2,
  56246. /** Neutral */
  56247. Neutral = 4,
  56248. /** Vertex and Fragment */
  56249. VertexAndFragment = 3
  56250. }
  56251. }
  56252. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  56253. /**
  56254. * Defines the kind of connection point for node based material
  56255. */
  56256. export enum NodeMaterialBlockConnectionPointTypes {
  56257. /** Float */
  56258. Float = 1,
  56259. /** Int */
  56260. Int = 2,
  56261. /** Vector2 */
  56262. Vector2 = 4,
  56263. /** Vector3 */
  56264. Vector3 = 8,
  56265. /** Vector4 */
  56266. Vector4 = 16,
  56267. /** Color3 */
  56268. Color3 = 32,
  56269. /** Color4 */
  56270. Color4 = 64,
  56271. /** Matrix */
  56272. Matrix = 128,
  56273. /** Detect type based on connection */
  56274. AutoDetect = 1024,
  56275. /** Output type that will be defined by input type */
  56276. BasedOnInput = 2048
  56277. }
  56278. }
  56279. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  56280. /**
  56281. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  56282. */
  56283. export enum NodeMaterialBlockConnectionPointMode {
  56284. /** Value is an uniform */
  56285. Uniform = 0,
  56286. /** Value is a mesh attribute */
  56287. Attribute = 1,
  56288. /** Value is a varying between vertex and fragment shaders */
  56289. Varying = 2,
  56290. /** Mode is undefined */
  56291. Undefined = 3
  56292. }
  56293. }
  56294. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  56295. /**
  56296. * Enum used to define system values e.g. values automatically provided by the system
  56297. */
  56298. export enum NodeMaterialSystemValues {
  56299. /** World */
  56300. World = 1,
  56301. /** View */
  56302. View = 2,
  56303. /** Projection */
  56304. Projection = 3,
  56305. /** ViewProjection */
  56306. ViewProjection = 4,
  56307. /** WorldView */
  56308. WorldView = 5,
  56309. /** WorldViewProjection */
  56310. WorldViewProjection = 6,
  56311. /** CameraPosition */
  56312. CameraPosition = 7,
  56313. /** Fog Color */
  56314. FogColor = 8,
  56315. /** Delta time */
  56316. DeltaTime = 9
  56317. }
  56318. }
  56319. declare module "babylonjs/Materials/Node/Enums/index" {
  56320. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56321. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56322. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  56323. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  56324. }
  56325. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  56326. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56327. /**
  56328. * Root class for all node material optimizers
  56329. */
  56330. export class NodeMaterialOptimizer {
  56331. /**
  56332. * Function used to optimize a NodeMaterial graph
  56333. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  56334. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  56335. */
  56336. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  56337. }
  56338. }
  56339. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  56340. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56341. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56342. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56343. import { Scene } from "babylonjs/scene";
  56344. /**
  56345. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  56346. */
  56347. export class TransformBlock extends NodeMaterialBlock {
  56348. /**
  56349. * Defines the value to use to complement W value to transform it to a Vector4
  56350. */
  56351. complementW: number;
  56352. /**
  56353. * Defines the value to use to complement z value to transform it to a Vector4
  56354. */
  56355. complementZ: number;
  56356. /**
  56357. * Creates a new TransformBlock
  56358. * @param name defines the block name
  56359. */
  56360. constructor(name: string);
  56361. /**
  56362. * Gets the current class name
  56363. * @returns the class name
  56364. */
  56365. getClassName(): string;
  56366. /**
  56367. * Gets the vector input
  56368. */
  56369. readonly vector: NodeMaterialConnectionPoint;
  56370. /**
  56371. * Gets the output component
  56372. */
  56373. readonly output: NodeMaterialConnectionPoint;
  56374. /**
  56375. * Gets the matrix transform input
  56376. */
  56377. readonly transform: NodeMaterialConnectionPoint;
  56378. protected _buildBlock(state: NodeMaterialBuildState): this;
  56379. serialize(): any;
  56380. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56381. protected _dumpPropertiesCode(): string;
  56382. }
  56383. }
  56384. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  56385. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56386. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56387. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56388. /**
  56389. * Block used to output the vertex position
  56390. */
  56391. export class VertexOutputBlock extends NodeMaterialBlock {
  56392. /**
  56393. * Creates a new VertexOutputBlock
  56394. * @param name defines the block name
  56395. */
  56396. constructor(name: string);
  56397. /**
  56398. * Gets the current class name
  56399. * @returns the class name
  56400. */
  56401. getClassName(): string;
  56402. /**
  56403. * Gets the vector input component
  56404. */
  56405. readonly vector: NodeMaterialConnectionPoint;
  56406. protected _buildBlock(state: NodeMaterialBuildState): this;
  56407. }
  56408. }
  56409. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  56410. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56411. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56412. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56413. /**
  56414. * Block used to output the final color
  56415. */
  56416. export class FragmentOutputBlock extends NodeMaterialBlock {
  56417. /**
  56418. * Create a new FragmentOutputBlock
  56419. * @param name defines the block name
  56420. */
  56421. constructor(name: string);
  56422. /**
  56423. * Gets the current class name
  56424. * @returns the class name
  56425. */
  56426. getClassName(): string;
  56427. /**
  56428. * Gets the rgba input component
  56429. */
  56430. readonly rgba: NodeMaterialConnectionPoint;
  56431. /**
  56432. * Gets the rgb input component
  56433. */
  56434. readonly rgb: NodeMaterialConnectionPoint;
  56435. /**
  56436. * Gets the a input component
  56437. */
  56438. readonly a: NodeMaterialConnectionPoint;
  56439. protected _buildBlock(state: NodeMaterialBuildState): this;
  56440. }
  56441. }
  56442. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  56443. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56444. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56445. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56446. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56447. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56448. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56449. import { Effect } from "babylonjs/Materials/effect";
  56450. import { Mesh } from "babylonjs/Meshes/mesh";
  56451. import { Nullable } from "babylonjs/types";
  56452. import { Scene } from "babylonjs/scene";
  56453. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  56454. /**
  56455. * Block used to read a reflection texture from a sampler
  56456. */
  56457. export class ReflectionTextureBlock extends NodeMaterialBlock {
  56458. private _define3DName;
  56459. private _defineCubicName;
  56460. private _defineExplicitName;
  56461. private _defineProjectionName;
  56462. private _defineLocalCubicName;
  56463. private _defineSphericalName;
  56464. private _definePlanarName;
  56465. private _defineEquirectangularName;
  56466. private _defineMirroredEquirectangularFixedName;
  56467. private _defineEquirectangularFixedName;
  56468. private _defineSkyboxName;
  56469. private _cubeSamplerName;
  56470. private _2DSamplerName;
  56471. private _positionUVWName;
  56472. private _directionWName;
  56473. private _reflectionCoordsName;
  56474. private _reflection2DCoordsName;
  56475. private _reflectionColorName;
  56476. private _reflectionMatrixName;
  56477. /**
  56478. * Gets or sets the texture associated with the node
  56479. */
  56480. texture: Nullable<BaseTexture>;
  56481. /**
  56482. * Create a new TextureBlock
  56483. * @param name defines the block name
  56484. */
  56485. constructor(name: string);
  56486. /**
  56487. * Gets the current class name
  56488. * @returns the class name
  56489. */
  56490. getClassName(): string;
  56491. /**
  56492. * Gets the world position input component
  56493. */
  56494. readonly position: NodeMaterialConnectionPoint;
  56495. /**
  56496. * Gets the world position input component
  56497. */
  56498. readonly worldPosition: NodeMaterialConnectionPoint;
  56499. /**
  56500. * Gets the world normal input component
  56501. */
  56502. readonly worldNormal: NodeMaterialConnectionPoint;
  56503. /**
  56504. * Gets the world input component
  56505. */
  56506. readonly world: NodeMaterialConnectionPoint;
  56507. /**
  56508. * Gets the camera (or eye) position component
  56509. */
  56510. readonly cameraPosition: NodeMaterialConnectionPoint;
  56511. /**
  56512. * Gets the view input component
  56513. */
  56514. readonly view: NodeMaterialConnectionPoint;
  56515. /**
  56516. * Gets the rgb output component
  56517. */
  56518. readonly rgb: NodeMaterialConnectionPoint;
  56519. /**
  56520. * Gets the r output component
  56521. */
  56522. readonly r: NodeMaterialConnectionPoint;
  56523. /**
  56524. * Gets the g output component
  56525. */
  56526. readonly g: NodeMaterialConnectionPoint;
  56527. /**
  56528. * Gets the b output component
  56529. */
  56530. readonly b: NodeMaterialConnectionPoint;
  56531. autoConfigure(material: NodeMaterial): void;
  56532. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56533. isReady(): boolean;
  56534. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56535. private _injectVertexCode;
  56536. private _writeOutput;
  56537. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56538. protected _dumpPropertiesCode(): string;
  56539. serialize(): any;
  56540. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56541. }
  56542. }
  56543. declare module "babylonjs/Materials/Node/nodeMaterial" {
  56544. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56545. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  56546. import { Scene } from "babylonjs/scene";
  56547. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56548. import { Matrix } from "babylonjs/Maths/math.vector";
  56549. import { Mesh } from "babylonjs/Meshes/mesh";
  56550. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56551. import { Observable } from "babylonjs/Misc/observable";
  56552. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56553. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  56554. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  56555. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  56556. import { Nullable } from "babylonjs/types";
  56557. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56558. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  56559. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  56560. /**
  56561. * Interface used to configure the node material editor
  56562. */
  56563. export interface INodeMaterialEditorOptions {
  56564. /** Define the URl to load node editor script */
  56565. editorURL?: string;
  56566. }
  56567. /** @hidden */
  56568. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  56569. /** BONES */
  56570. NUM_BONE_INFLUENCERS: number;
  56571. BonesPerMesh: number;
  56572. BONETEXTURE: boolean;
  56573. /** MORPH TARGETS */
  56574. MORPHTARGETS: boolean;
  56575. MORPHTARGETS_NORMAL: boolean;
  56576. MORPHTARGETS_TANGENT: boolean;
  56577. MORPHTARGETS_UV: boolean;
  56578. NUM_MORPH_INFLUENCERS: number;
  56579. /** IMAGE PROCESSING */
  56580. IMAGEPROCESSING: boolean;
  56581. VIGNETTE: boolean;
  56582. VIGNETTEBLENDMODEMULTIPLY: boolean;
  56583. VIGNETTEBLENDMODEOPAQUE: boolean;
  56584. TONEMAPPING: boolean;
  56585. TONEMAPPING_ACES: boolean;
  56586. CONTRAST: boolean;
  56587. EXPOSURE: boolean;
  56588. COLORCURVES: boolean;
  56589. COLORGRADING: boolean;
  56590. COLORGRADING3D: boolean;
  56591. SAMPLER3DGREENDEPTH: boolean;
  56592. SAMPLER3DBGRMAP: boolean;
  56593. IMAGEPROCESSINGPOSTPROCESS: boolean;
  56594. /** MISC. */
  56595. BUMPDIRECTUV: number;
  56596. constructor();
  56597. setValue(name: string, value: boolean): void;
  56598. }
  56599. /**
  56600. * Class used to configure NodeMaterial
  56601. */
  56602. export interface INodeMaterialOptions {
  56603. /**
  56604. * Defines if blocks should emit comments
  56605. */
  56606. emitComments: boolean;
  56607. }
  56608. /**
  56609. * Class used to create a node based material built by assembling shader blocks
  56610. */
  56611. export class NodeMaterial extends PushMaterial {
  56612. private static _BuildIdGenerator;
  56613. private _options;
  56614. private _vertexCompilationState;
  56615. private _fragmentCompilationState;
  56616. private _sharedData;
  56617. private _buildId;
  56618. private _buildWasSuccessful;
  56619. private _cachedWorldViewMatrix;
  56620. private _cachedWorldViewProjectionMatrix;
  56621. private _optimizers;
  56622. private _animationFrame;
  56623. /** Define the URl to load node editor script */
  56624. static EditorURL: string;
  56625. private BJSNODEMATERIALEDITOR;
  56626. /** Get the inspector from bundle or global */
  56627. private _getGlobalNodeMaterialEditor;
  56628. /**
  56629. * Gets or sets data used by visual editor
  56630. * @see https://nme.babylonjs.com
  56631. */
  56632. editorData: any;
  56633. /**
  56634. * Gets or sets a boolean indicating that alpha value must be ignored (This will turn alpha blending off even if an alpha value is produced by the material)
  56635. */
  56636. ignoreAlpha: boolean;
  56637. /**
  56638. * Defines the maximum number of lights that can be used in the material
  56639. */
  56640. maxSimultaneousLights: number;
  56641. /**
  56642. * Observable raised when the material is built
  56643. */
  56644. onBuildObservable: Observable<NodeMaterial>;
  56645. /**
  56646. * Gets or sets the root nodes of the material vertex shader
  56647. */
  56648. _vertexOutputNodes: NodeMaterialBlock[];
  56649. /**
  56650. * Gets or sets the root nodes of the material fragment (pixel) shader
  56651. */
  56652. _fragmentOutputNodes: NodeMaterialBlock[];
  56653. /** Gets or sets options to control the node material overall behavior */
  56654. options: INodeMaterialOptions;
  56655. /**
  56656. * Default configuration related to image processing available in the standard Material.
  56657. */
  56658. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  56659. /**
  56660. * Gets the image processing configuration used either in this material.
  56661. */
  56662. /**
  56663. * Sets the Default image processing configuration used either in the this material.
  56664. *
  56665. * If sets to null, the scene one is in use.
  56666. */
  56667. imageProcessingConfiguration: ImageProcessingConfiguration;
  56668. /**
  56669. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  56670. */
  56671. attachedBlocks: NodeMaterialBlock[];
  56672. /**
  56673. * Create a new node based material
  56674. * @param name defines the material name
  56675. * @param scene defines the hosting scene
  56676. * @param options defines creation option
  56677. */
  56678. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  56679. /**
  56680. * Gets the current class name of the material e.g. "NodeMaterial"
  56681. * @returns the class name
  56682. */
  56683. getClassName(): string;
  56684. /**
  56685. * Keep track of the image processing observer to allow dispose and replace.
  56686. */
  56687. private _imageProcessingObserver;
  56688. /**
  56689. * Attaches a new image processing configuration to the Standard Material.
  56690. * @param configuration
  56691. */
  56692. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  56693. /**
  56694. * Get a block by its name
  56695. * @param name defines the name of the block to retrieve
  56696. * @returns the required block or null if not found
  56697. */
  56698. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  56699. /**
  56700. * Get a block by its name
  56701. * @param predicate defines the predicate used to find the good candidate
  56702. * @returns the required block or null if not found
  56703. */
  56704. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  56705. /**
  56706. * Get an input block by its name
  56707. * @param predicate defines the predicate used to find the good candidate
  56708. * @returns the required input block or null if not found
  56709. */
  56710. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  56711. /**
  56712. * Gets the list of input blocks attached to this material
  56713. * @returns an array of InputBlocks
  56714. */
  56715. getInputBlocks(): InputBlock[];
  56716. /**
  56717. * Adds a new optimizer to the list of optimizers
  56718. * @param optimizer defines the optimizers to add
  56719. * @returns the current material
  56720. */
  56721. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  56722. /**
  56723. * Remove an optimizer from the list of optimizers
  56724. * @param optimizer defines the optimizers to remove
  56725. * @returns the current material
  56726. */
  56727. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  56728. /**
  56729. * Add a new block to the list of output nodes
  56730. * @param node defines the node to add
  56731. * @returns the current material
  56732. */
  56733. addOutputNode(node: NodeMaterialBlock): this;
  56734. /**
  56735. * Remove a block from the list of root nodes
  56736. * @param node defines the node to remove
  56737. * @returns the current material
  56738. */
  56739. removeOutputNode(node: NodeMaterialBlock): this;
  56740. private _addVertexOutputNode;
  56741. private _removeVertexOutputNode;
  56742. private _addFragmentOutputNode;
  56743. private _removeFragmentOutputNode;
  56744. /**
  56745. * Specifies if the material will require alpha blending
  56746. * @returns a boolean specifying if alpha blending is needed
  56747. */
  56748. needAlphaBlending(): boolean;
  56749. /**
  56750. * Specifies if this material should be rendered in alpha test mode
  56751. * @returns a boolean specifying if an alpha test is needed.
  56752. */
  56753. needAlphaTesting(): boolean;
  56754. private _initializeBlock;
  56755. private _resetDualBlocks;
  56756. /**
  56757. * Remove a block from the current node material
  56758. * @param block defines the block to remove
  56759. */
  56760. removeBlock(block: NodeMaterialBlock): void;
  56761. /**
  56762. * Build the material and generates the inner effect
  56763. * @param verbose defines if the build should log activity
  56764. */
  56765. build(verbose?: boolean): void;
  56766. /**
  56767. * Runs an otpimization phase to try to improve the shader code
  56768. */
  56769. optimize(): void;
  56770. private _prepareDefinesForAttributes;
  56771. /**
  56772. * Get if the submesh is ready to be used and all its information available.
  56773. * Child classes can use it to update shaders
  56774. * @param mesh defines the mesh to check
  56775. * @param subMesh defines which submesh to check
  56776. * @param useInstances specifies that instances should be used
  56777. * @returns a boolean indicating that the submesh is ready or not
  56778. */
  56779. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  56780. /**
  56781. * Get a string representing the shaders built by the current node graph
  56782. */
  56783. readonly compiledShaders: string;
  56784. /**
  56785. * Binds the world matrix to the material
  56786. * @param world defines the world transformation matrix
  56787. */
  56788. bindOnlyWorldMatrix(world: Matrix): void;
  56789. /**
  56790. * Binds the submesh to this material by preparing the effect and shader to draw
  56791. * @param world defines the world transformation matrix
  56792. * @param mesh defines the mesh containing the submesh
  56793. * @param subMesh defines the submesh to bind the material to
  56794. */
  56795. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  56796. /**
  56797. * Gets the active textures from the material
  56798. * @returns an array of textures
  56799. */
  56800. getActiveTextures(): BaseTexture[];
  56801. /**
  56802. * Gets the list of texture blocks
  56803. * @returns an array of texture blocks
  56804. */
  56805. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  56806. /**
  56807. * Specifies if the material uses a texture
  56808. * @param texture defines the texture to check against the material
  56809. * @returns a boolean specifying if the material uses the texture
  56810. */
  56811. hasTexture(texture: BaseTexture): boolean;
  56812. /**
  56813. * Disposes the material
  56814. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  56815. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  56816. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  56817. */
  56818. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  56819. /** Creates the node editor window. */
  56820. private _createNodeEditor;
  56821. /**
  56822. * Launch the node material editor
  56823. * @param config Define the configuration of the editor
  56824. * @return a promise fulfilled when the node editor is visible
  56825. */
  56826. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  56827. /**
  56828. * Clear the current material
  56829. */
  56830. clear(): void;
  56831. /**
  56832. * Clear the current material and set it to a default state
  56833. */
  56834. setToDefault(): void;
  56835. /**
  56836. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  56837. * @param url defines the url to load from
  56838. * @returns a promise that will fullfil when the material is fully loaded
  56839. */
  56840. loadAsync(url: string): Promise<void>;
  56841. private _gatherBlocks;
  56842. /**
  56843. * Generate a string containing the code declaration required to create an equivalent of this material
  56844. * @returns a string
  56845. */
  56846. generateCode(): string;
  56847. /**
  56848. * Serializes this material in a JSON representation
  56849. * @returns the serialized material object
  56850. */
  56851. serialize(): any;
  56852. private _restoreConnections;
  56853. /**
  56854. * Clear the current graph and load a new one from a serialization object
  56855. * @param source defines the JSON representation of the material
  56856. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56857. */
  56858. loadFromSerialization(source: any, rootUrl?: string): void;
  56859. /**
  56860. * Creates a node material from parsed material data
  56861. * @param source defines the JSON representation of the material
  56862. * @param scene defines the hosting scene
  56863. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56864. * @returns a new node material
  56865. */
  56866. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  56867. /**
  56868. * Creates a new node material set to default basic configuration
  56869. * @param name defines the name of the material
  56870. * @param scene defines the hosting scene
  56871. * @returns a new NodeMaterial
  56872. */
  56873. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  56874. }
  56875. }
  56876. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  56877. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56878. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56879. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56880. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56881. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56882. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56883. import { Effect } from "babylonjs/Materials/effect";
  56884. import { Mesh } from "babylonjs/Meshes/mesh";
  56885. import { Nullable } from "babylonjs/types";
  56886. import { Texture } from "babylonjs/Materials/Textures/texture";
  56887. import { Scene } from "babylonjs/scene";
  56888. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56889. /**
  56890. * Block used to read a texture from a sampler
  56891. */
  56892. export class TextureBlock extends NodeMaterialBlock {
  56893. private _defineName;
  56894. private _linearDefineName;
  56895. private _tempTextureRead;
  56896. private _samplerName;
  56897. private _transformedUVName;
  56898. private _textureTransformName;
  56899. private _textureInfoName;
  56900. private _mainUVName;
  56901. private _mainUVDefineName;
  56902. /**
  56903. * Gets or sets the texture associated with the node
  56904. */
  56905. texture: Nullable<Texture>;
  56906. /**
  56907. * Create a new TextureBlock
  56908. * @param name defines the block name
  56909. */
  56910. constructor(name: string);
  56911. /**
  56912. * Gets the current class name
  56913. * @returns the class name
  56914. */
  56915. getClassName(): string;
  56916. /**
  56917. * Gets the uv input component
  56918. */
  56919. readonly uv: NodeMaterialConnectionPoint;
  56920. /**
  56921. * Gets the rgba output component
  56922. */
  56923. readonly rgba: NodeMaterialConnectionPoint;
  56924. /**
  56925. * Gets the rgb output component
  56926. */
  56927. readonly rgb: NodeMaterialConnectionPoint;
  56928. /**
  56929. * Gets the r output component
  56930. */
  56931. readonly r: NodeMaterialConnectionPoint;
  56932. /**
  56933. * Gets the g output component
  56934. */
  56935. readonly g: NodeMaterialConnectionPoint;
  56936. /**
  56937. * Gets the b output component
  56938. */
  56939. readonly b: NodeMaterialConnectionPoint;
  56940. /**
  56941. * Gets the a output component
  56942. */
  56943. readonly a: NodeMaterialConnectionPoint;
  56944. readonly target: NodeMaterialBlockTargets;
  56945. autoConfigure(material: NodeMaterial): void;
  56946. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56947. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56948. private _getTextureBase;
  56949. isReady(): boolean;
  56950. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56951. private readonly _isMixed;
  56952. private _injectVertexCode;
  56953. private _writeTextureRead;
  56954. private _writeOutput;
  56955. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56956. protected _dumpPropertiesCode(): string;
  56957. serialize(): any;
  56958. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56959. }
  56960. }
  56961. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  56962. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56963. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56964. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56965. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  56966. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  56967. import { Scene } from "babylonjs/scene";
  56968. /**
  56969. * Class used to store shared data between 2 NodeMaterialBuildState
  56970. */
  56971. export class NodeMaterialBuildStateSharedData {
  56972. /**
  56973. * Gets the list of emitted varyings
  56974. */
  56975. temps: string[];
  56976. /**
  56977. * Gets the list of emitted varyings
  56978. */
  56979. varyings: string[];
  56980. /**
  56981. * Gets the varying declaration string
  56982. */
  56983. varyingDeclaration: string;
  56984. /**
  56985. * Input blocks
  56986. */
  56987. inputBlocks: InputBlock[];
  56988. /**
  56989. * Input blocks
  56990. */
  56991. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  56992. /**
  56993. * Bindable blocks (Blocks that need to set data to the effect)
  56994. */
  56995. bindableBlocks: NodeMaterialBlock[];
  56996. /**
  56997. * List of blocks that can provide a compilation fallback
  56998. */
  56999. blocksWithFallbacks: NodeMaterialBlock[];
  57000. /**
  57001. * List of blocks that can provide a define update
  57002. */
  57003. blocksWithDefines: NodeMaterialBlock[];
  57004. /**
  57005. * List of blocks that can provide a repeatable content
  57006. */
  57007. repeatableContentBlocks: NodeMaterialBlock[];
  57008. /**
  57009. * List of blocks that can provide a dynamic list of uniforms
  57010. */
  57011. dynamicUniformBlocks: NodeMaterialBlock[];
  57012. /**
  57013. * List of blocks that can block the isReady function for the material
  57014. */
  57015. blockingBlocks: NodeMaterialBlock[];
  57016. /**
  57017. * Gets the list of animated inputs
  57018. */
  57019. animatedInputs: InputBlock[];
  57020. /**
  57021. * Build Id used to avoid multiple recompilations
  57022. */
  57023. buildId: number;
  57024. /** List of emitted variables */
  57025. variableNames: {
  57026. [key: string]: number;
  57027. };
  57028. /** List of emitted defines */
  57029. defineNames: {
  57030. [key: string]: number;
  57031. };
  57032. /** Should emit comments? */
  57033. emitComments: boolean;
  57034. /** Emit build activity */
  57035. verbose: boolean;
  57036. /** Gets or sets the hosting scene */
  57037. scene: Scene;
  57038. /**
  57039. * Gets the compilation hints emitted at compilation time
  57040. */
  57041. hints: {
  57042. needWorldViewMatrix: boolean;
  57043. needWorldViewProjectionMatrix: boolean;
  57044. needAlphaBlending: boolean;
  57045. needAlphaTesting: boolean;
  57046. };
  57047. /**
  57048. * List of compilation checks
  57049. */
  57050. checks: {
  57051. emitVertex: boolean;
  57052. emitFragment: boolean;
  57053. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  57054. };
  57055. /** Creates a new shared data */
  57056. constructor();
  57057. /**
  57058. * Emits console errors and exceptions if there is a failing check
  57059. */
  57060. emitErrors(): void;
  57061. }
  57062. }
  57063. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  57064. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  57065. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  57066. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  57067. /**
  57068. * Class used to store node based material build state
  57069. */
  57070. export class NodeMaterialBuildState {
  57071. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  57072. supportUniformBuffers: boolean;
  57073. /**
  57074. * Gets the list of emitted attributes
  57075. */
  57076. attributes: string[];
  57077. /**
  57078. * Gets the list of emitted uniforms
  57079. */
  57080. uniforms: string[];
  57081. /**
  57082. * Gets the list of emitted constants
  57083. */
  57084. constants: string[];
  57085. /**
  57086. * Gets the list of emitted samplers
  57087. */
  57088. samplers: string[];
  57089. /**
  57090. * Gets the list of emitted functions
  57091. */
  57092. functions: {
  57093. [key: string]: string;
  57094. };
  57095. /**
  57096. * Gets the list of emitted extensions
  57097. */
  57098. extensions: {
  57099. [key: string]: string;
  57100. };
  57101. /**
  57102. * Gets the target of the compilation state
  57103. */
  57104. target: NodeMaterialBlockTargets;
  57105. /**
  57106. * Gets the list of emitted counters
  57107. */
  57108. counters: {
  57109. [key: string]: number;
  57110. };
  57111. /**
  57112. * Shared data between multiple NodeMaterialBuildState instances
  57113. */
  57114. sharedData: NodeMaterialBuildStateSharedData;
  57115. /** @hidden */
  57116. _vertexState: NodeMaterialBuildState;
  57117. /** @hidden */
  57118. _attributeDeclaration: string;
  57119. /** @hidden */
  57120. _uniformDeclaration: string;
  57121. /** @hidden */
  57122. _constantDeclaration: string;
  57123. /** @hidden */
  57124. _samplerDeclaration: string;
  57125. /** @hidden */
  57126. _varyingTransfer: string;
  57127. private _repeatableContentAnchorIndex;
  57128. /** @hidden */
  57129. _builtCompilationString: string;
  57130. /**
  57131. * Gets the emitted compilation strings
  57132. */
  57133. compilationString: string;
  57134. /**
  57135. * Finalize the compilation strings
  57136. * @param state defines the current compilation state
  57137. */
  57138. finalize(state: NodeMaterialBuildState): void;
  57139. /** @hidden */
  57140. readonly _repeatableContentAnchor: string;
  57141. /** @hidden */
  57142. _getFreeVariableName(prefix: string): string;
  57143. /** @hidden */
  57144. _getFreeDefineName(prefix: string): string;
  57145. /** @hidden */
  57146. _excludeVariableName(name: string): void;
  57147. /** @hidden */
  57148. _emit2DSampler(name: string): void;
  57149. /** @hidden */
  57150. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  57151. /** @hidden */
  57152. _emitExtension(name: string, extension: string): void;
  57153. /** @hidden */
  57154. _emitFunction(name: string, code: string, comments: string): void;
  57155. /** @hidden */
  57156. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  57157. replaceStrings?: {
  57158. search: RegExp;
  57159. replace: string;
  57160. }[];
  57161. repeatKey?: string;
  57162. }): string;
  57163. /** @hidden */
  57164. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  57165. repeatKey?: string;
  57166. removeAttributes?: boolean;
  57167. removeUniforms?: boolean;
  57168. removeVaryings?: boolean;
  57169. removeIfDef?: boolean;
  57170. replaceStrings?: {
  57171. search: RegExp;
  57172. replace: string;
  57173. }[];
  57174. }, storeKey?: string): void;
  57175. /** @hidden */
  57176. _registerTempVariable(name: string): boolean;
  57177. /** @hidden */
  57178. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  57179. /** @hidden */
  57180. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  57181. /** @hidden */
  57182. _emitFloat(value: number): string;
  57183. }
  57184. }
  57185. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  57186. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  57187. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57188. import { Nullable } from "babylonjs/types";
  57189. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57190. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  57191. import { Effect } from "babylonjs/Materials/effect";
  57192. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57193. import { Mesh } from "babylonjs/Meshes/mesh";
  57194. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57195. import { Scene } from "babylonjs/scene";
  57196. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57197. /**
  57198. * Defines a block that can be used inside a node based material
  57199. */
  57200. export class NodeMaterialBlock {
  57201. private _buildId;
  57202. private _buildTarget;
  57203. private _target;
  57204. private _isFinalMerger;
  57205. private _isInput;
  57206. protected _isUnique: boolean;
  57207. /** @hidden */
  57208. _codeVariableName: string;
  57209. /** @hidden */
  57210. _inputs: NodeMaterialConnectionPoint[];
  57211. /** @hidden */
  57212. _outputs: NodeMaterialConnectionPoint[];
  57213. /** @hidden */
  57214. _preparationId: number;
  57215. /**
  57216. * Gets or sets the name of the block
  57217. */
  57218. name: string;
  57219. /**
  57220. * Gets or sets the unique id of the node
  57221. */
  57222. uniqueId: number;
  57223. /**
  57224. * Gets or sets the comments associated with this block
  57225. */
  57226. comments: string;
  57227. /**
  57228. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  57229. */
  57230. readonly isUnique: boolean;
  57231. /**
  57232. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  57233. */
  57234. readonly isFinalMerger: boolean;
  57235. /**
  57236. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  57237. */
  57238. readonly isInput: boolean;
  57239. /**
  57240. * Gets or sets the build Id
  57241. */
  57242. buildId: number;
  57243. /**
  57244. * Gets or sets the target of the block
  57245. */
  57246. target: NodeMaterialBlockTargets;
  57247. /**
  57248. * Gets the list of input points
  57249. */
  57250. readonly inputs: NodeMaterialConnectionPoint[];
  57251. /** Gets the list of output points */
  57252. readonly outputs: NodeMaterialConnectionPoint[];
  57253. /**
  57254. * Find an input by its name
  57255. * @param name defines the name of the input to look for
  57256. * @returns the input or null if not found
  57257. */
  57258. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  57259. /**
  57260. * Find an output by its name
  57261. * @param name defines the name of the outputto look for
  57262. * @returns the output or null if not found
  57263. */
  57264. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  57265. /**
  57266. * Creates a new NodeMaterialBlock
  57267. * @param name defines the block name
  57268. * @param target defines the target of that block (Vertex by default)
  57269. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  57270. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  57271. */
  57272. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  57273. /**
  57274. * Initialize the block and prepare the context for build
  57275. * @param state defines the state that will be used for the build
  57276. */
  57277. initialize(state: NodeMaterialBuildState): void;
  57278. /**
  57279. * Bind data to effect. Will only be called for blocks with isBindable === true
  57280. * @param effect defines the effect to bind data to
  57281. * @param nodeMaterial defines the hosting NodeMaterial
  57282. * @param mesh defines the mesh that will be rendered
  57283. */
  57284. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57285. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  57286. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  57287. protected _writeFloat(value: number): string;
  57288. /**
  57289. * Gets the current class name e.g. "NodeMaterialBlock"
  57290. * @returns the class name
  57291. */
  57292. getClassName(): string;
  57293. /**
  57294. * Register a new input. Must be called inside a block constructor
  57295. * @param name defines the connection point name
  57296. * @param type defines the connection point type
  57297. * @param isOptional defines a boolean indicating that this input can be omitted
  57298. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  57299. * @returns the current block
  57300. */
  57301. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  57302. /**
  57303. * Register a new output. Must be called inside a block constructor
  57304. * @param name defines the connection point name
  57305. * @param type defines the connection point type
  57306. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  57307. * @returns the current block
  57308. */
  57309. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  57310. /**
  57311. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  57312. * @param forOutput defines an optional connection point to check compatibility with
  57313. * @returns the first available input or null
  57314. */
  57315. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  57316. /**
  57317. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  57318. * @param forBlock defines an optional block to check compatibility with
  57319. * @returns the first available input or null
  57320. */
  57321. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  57322. /**
  57323. * Gets the sibling of the given output
  57324. * @param current defines the current output
  57325. * @returns the next output in the list or null
  57326. */
  57327. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  57328. /**
  57329. * Connect current block with another block
  57330. * @param other defines the block to connect with
  57331. * @param options define the various options to help pick the right connections
  57332. * @returns the current block
  57333. */
  57334. connectTo(other: NodeMaterialBlock, options?: {
  57335. input?: string;
  57336. output?: string;
  57337. outputSwizzle?: string;
  57338. }): this | undefined;
  57339. protected _buildBlock(state: NodeMaterialBuildState): void;
  57340. /**
  57341. * Add uniforms, samplers and uniform buffers at compilation time
  57342. * @param state defines the state to update
  57343. * @param nodeMaterial defines the node material requesting the update
  57344. * @param defines defines the material defines to update
  57345. * @param uniformBuffers defines the list of uniform buffer names
  57346. */
  57347. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  57348. /**
  57349. * Add potential fallbacks if shader compilation fails
  57350. * @param mesh defines the mesh to be rendered
  57351. * @param fallbacks defines the current prioritized list of fallbacks
  57352. */
  57353. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  57354. /**
  57355. * Initialize defines for shader compilation
  57356. * @param mesh defines the mesh to be rendered
  57357. * @param nodeMaterial defines the node material requesting the update
  57358. * @param defines defines the material defines to update
  57359. * @param useInstances specifies that instances should be used
  57360. */
  57361. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57362. /**
  57363. * Update defines for shader compilation
  57364. * @param mesh defines the mesh to be rendered
  57365. * @param nodeMaterial defines the node material requesting the update
  57366. * @param defines defines the material defines to update
  57367. * @param useInstances specifies that instances should be used
  57368. */
  57369. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57370. /**
  57371. * Lets the block try to connect some inputs automatically
  57372. * @param material defines the hosting NodeMaterial
  57373. */
  57374. autoConfigure(material: NodeMaterial): void;
  57375. /**
  57376. * Function called when a block is declared as repeatable content generator
  57377. * @param vertexShaderState defines the current compilation state for the vertex shader
  57378. * @param fragmentShaderState defines the current compilation state for the fragment shader
  57379. * @param mesh defines the mesh to be rendered
  57380. * @param defines defines the material defines to update
  57381. */
  57382. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  57383. /**
  57384. * Checks if the block is ready
  57385. * @param mesh defines the mesh to be rendered
  57386. * @param nodeMaterial defines the node material requesting the update
  57387. * @param defines defines the material defines to update
  57388. * @param useInstances specifies that instances should be used
  57389. * @returns true if the block is ready
  57390. */
  57391. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  57392. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  57393. private _processBuild;
  57394. /**
  57395. * Compile the current node and generate the shader code
  57396. * @param state defines the current compilation state (uniforms, samplers, current string)
  57397. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  57398. * @returns true if already built
  57399. */
  57400. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  57401. protected _inputRename(name: string): string;
  57402. protected _outputRename(name: string): string;
  57403. protected _dumpPropertiesCode(): string;
  57404. /** @hidden */
  57405. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  57406. /** @hidden */
  57407. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  57408. /**
  57409. * Clone the current block to a new identical block
  57410. * @param scene defines the hosting scene
  57411. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57412. * @returns a copy of the current block
  57413. */
  57414. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  57415. /**
  57416. * Serializes this block in a JSON representation
  57417. * @returns the serialized block object
  57418. */
  57419. serialize(): any;
  57420. /** @hidden */
  57421. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57422. /**
  57423. * Release resources
  57424. */
  57425. dispose(): void;
  57426. }
  57427. }
  57428. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  57429. /**
  57430. * Enum defining the type of animations supported by InputBlock
  57431. */
  57432. export enum AnimatedInputBlockTypes {
  57433. /** No animation */
  57434. None = 0,
  57435. /** Time based animation. Will only work for floats */
  57436. Time = 1
  57437. }
  57438. }
  57439. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  57440. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57441. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  57442. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  57443. import { Nullable } from "babylonjs/types";
  57444. import { Effect } from "babylonjs/Materials/effect";
  57445. import { Matrix } from "babylonjs/Maths/math.vector";
  57446. import { Scene } from "babylonjs/scene";
  57447. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57448. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57449. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  57450. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  57451. /**
  57452. * Block used to expose an input value
  57453. */
  57454. export class InputBlock extends NodeMaterialBlock {
  57455. private _mode;
  57456. private _associatedVariableName;
  57457. private _storedValue;
  57458. private _valueCallback;
  57459. private _type;
  57460. private _animationType;
  57461. /** Gets or set a value used to limit the range of float values */
  57462. min: number;
  57463. /** Gets or set a value used to limit the range of float values */
  57464. max: number;
  57465. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  57466. matrixMode: number;
  57467. /** @hidden */
  57468. _systemValue: Nullable<NodeMaterialSystemValues>;
  57469. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  57470. visibleInInspector: boolean;
  57471. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  57472. isConstant: boolean;
  57473. /** Gets or sets the group to use to display this block in the Inspector */
  57474. groupInInspector: string;
  57475. /**
  57476. * Gets or sets the connection point type (default is float)
  57477. */
  57478. readonly type: NodeMaterialBlockConnectionPointTypes;
  57479. /**
  57480. * Creates a new InputBlock
  57481. * @param name defines the block name
  57482. * @param target defines the target of that block (Vertex by default)
  57483. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  57484. */
  57485. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  57486. /**
  57487. * Gets the output component
  57488. */
  57489. readonly output: NodeMaterialConnectionPoint;
  57490. /**
  57491. * Set the source of this connection point to a vertex attribute
  57492. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  57493. * @returns the current connection point
  57494. */
  57495. setAsAttribute(attributeName?: string): InputBlock;
  57496. /**
  57497. * Set the source of this connection point to a system value
  57498. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  57499. * @returns the current connection point
  57500. */
  57501. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  57502. /**
  57503. * Gets or sets the value of that point.
  57504. * Please note that this value will be ignored if valueCallback is defined
  57505. */
  57506. value: any;
  57507. /**
  57508. * Gets or sets a callback used to get the value of that point.
  57509. * Please note that setting this value will force the connection point to ignore the value property
  57510. */
  57511. valueCallback: () => any;
  57512. /**
  57513. * Gets or sets the associated variable name in the shader
  57514. */
  57515. associatedVariableName: string;
  57516. /** Gets or sets the type of animation applied to the input */
  57517. animationType: AnimatedInputBlockTypes;
  57518. /**
  57519. * Gets a boolean indicating that this connection point not defined yet
  57520. */
  57521. readonly isUndefined: boolean;
  57522. /**
  57523. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  57524. * In this case the connection point name must be the name of the uniform to use.
  57525. * Can only be set on inputs
  57526. */
  57527. isUniform: boolean;
  57528. /**
  57529. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  57530. * In this case the connection point name must be the name of the attribute to use
  57531. * Can only be set on inputs
  57532. */
  57533. isAttribute: boolean;
  57534. /**
  57535. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  57536. * Can only be set on exit points
  57537. */
  57538. isVarying: boolean;
  57539. /**
  57540. * Gets a boolean indicating that the current connection point is a system value
  57541. */
  57542. readonly isSystemValue: boolean;
  57543. /**
  57544. * Gets or sets the current well known value or null if not defined as a system value
  57545. */
  57546. systemValue: Nullable<NodeMaterialSystemValues>;
  57547. /**
  57548. * Gets the current class name
  57549. * @returns the class name
  57550. */
  57551. getClassName(): string;
  57552. /**
  57553. * Animate the input if animationType !== None
  57554. * @param scene defines the rendering scene
  57555. */
  57556. animate(scene: Scene): void;
  57557. private _emitDefine;
  57558. initialize(state: NodeMaterialBuildState): void;
  57559. /**
  57560. * Set the input block to its default value (based on its type)
  57561. */
  57562. setDefaultValue(): void;
  57563. private _emitConstant;
  57564. private _emit;
  57565. /** @hidden */
  57566. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  57567. /** @hidden */
  57568. _transmit(effect: Effect, scene: Scene): void;
  57569. protected _buildBlock(state: NodeMaterialBuildState): void;
  57570. protected _dumpPropertiesCode(): string;
  57571. serialize(): any;
  57572. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57573. }
  57574. }
  57575. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  57576. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  57577. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  57578. import { Nullable } from "babylonjs/types";
  57579. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  57580. import { Observable } from "babylonjs/Misc/observable";
  57581. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57582. /**
  57583. * Enum used to define the compatibility state between two connection points
  57584. */
  57585. export enum NodeMaterialConnectionPointCompatibilityStates {
  57586. /** Points are compatibles */
  57587. Compatible = 0,
  57588. /** Points are incompatible because of their types */
  57589. TypeIncompatible = 1,
  57590. /** Points are incompatible because of their targets (vertex vs fragment) */
  57591. TargetIncompatible = 2
  57592. }
  57593. /**
  57594. * Defines the direction of a connection point
  57595. */
  57596. export enum NodeMaterialConnectionPointDirection {
  57597. /** Input */
  57598. Input = 0,
  57599. /** Output */
  57600. Output = 1
  57601. }
  57602. /**
  57603. * Defines a connection point for a block
  57604. */
  57605. export class NodeMaterialConnectionPoint {
  57606. /** @hidden */
  57607. _ownerBlock: NodeMaterialBlock;
  57608. /** @hidden */
  57609. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  57610. private _endpoints;
  57611. private _associatedVariableName;
  57612. private _direction;
  57613. /** @hidden */
  57614. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  57615. /** @hidden */
  57616. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  57617. private _type;
  57618. /** @hidden */
  57619. _enforceAssociatedVariableName: boolean;
  57620. /** Gets the direction of the point */
  57621. readonly direction: NodeMaterialConnectionPointDirection;
  57622. /**
  57623. * Gets or sets the additional types supported by this connection point
  57624. */
  57625. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  57626. /**
  57627. * Gets or sets the additional types excluded by this connection point
  57628. */
  57629. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  57630. /**
  57631. * Observable triggered when this point is connected
  57632. */
  57633. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  57634. /**
  57635. * Gets or sets the associated variable name in the shader
  57636. */
  57637. associatedVariableName: string;
  57638. /**
  57639. * Gets or sets the connection point type (default is float)
  57640. */
  57641. type: NodeMaterialBlockConnectionPointTypes;
  57642. /**
  57643. * Gets or sets the connection point name
  57644. */
  57645. name: string;
  57646. /**
  57647. * Gets or sets a boolean indicating that this connection point can be omitted
  57648. */
  57649. isOptional: boolean;
  57650. /**
  57651. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  57652. */
  57653. define: string;
  57654. /** @hidden */
  57655. _prioritizeVertex: boolean;
  57656. private _target;
  57657. /** Gets or sets the target of that connection point */
  57658. target: NodeMaterialBlockTargets;
  57659. /**
  57660. * Gets a boolean indicating that the current point is connected
  57661. */
  57662. readonly isConnected: boolean;
  57663. /**
  57664. * Gets a boolean indicating that the current point is connected to an input block
  57665. */
  57666. readonly isConnectedToInputBlock: boolean;
  57667. /**
  57668. * Gets a the connected input block (if any)
  57669. */
  57670. readonly connectInputBlock: Nullable<InputBlock>;
  57671. /** Get the other side of the connection (if any) */
  57672. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  57673. /** Get the block that owns this connection point */
  57674. readonly ownerBlock: NodeMaterialBlock;
  57675. /** Get the block connected on the other side of this connection (if any) */
  57676. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  57677. /** Get the block connected on the endpoints of this connection (if any) */
  57678. readonly connectedBlocks: Array<NodeMaterialBlock>;
  57679. /** Gets the list of connected endpoints */
  57680. readonly endpoints: NodeMaterialConnectionPoint[];
  57681. /** Gets a boolean indicating if that output point is connected to at least one input */
  57682. readonly hasEndpoints: boolean;
  57683. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  57684. readonly isConnectedInVertexShader: boolean;
  57685. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  57686. readonly isConnectedInFragmentShader: boolean;
  57687. /**
  57688. * Creates a new connection point
  57689. * @param name defines the connection point name
  57690. * @param ownerBlock defines the block hosting this connection point
  57691. * @param direction defines the direction of the connection point
  57692. */
  57693. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  57694. /**
  57695. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  57696. * @returns the class name
  57697. */
  57698. getClassName(): string;
  57699. /**
  57700. * Gets a boolean indicating if the current point can be connected to another point
  57701. * @param connectionPoint defines the other connection point
  57702. * @returns a boolean
  57703. */
  57704. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  57705. /**
  57706. * Gets a number indicating if the current point can be connected to another point
  57707. * @param connectionPoint defines the other connection point
  57708. * @returns a number defining the compatibility state
  57709. */
  57710. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  57711. /**
  57712. * Connect this point to another connection point
  57713. * @param connectionPoint defines the other connection point
  57714. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  57715. * @returns the current connection point
  57716. */
  57717. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  57718. /**
  57719. * Disconnect this point from one of his endpoint
  57720. * @param endpoint defines the other connection point
  57721. * @returns the current connection point
  57722. */
  57723. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  57724. /**
  57725. * Serializes this point in a JSON representation
  57726. * @returns the serialized point object
  57727. */
  57728. serialize(): any;
  57729. /**
  57730. * Release resources
  57731. */
  57732. dispose(): void;
  57733. }
  57734. }
  57735. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  57736. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57737. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57738. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57739. import { Mesh } from "babylonjs/Meshes/mesh";
  57740. import { Effect } from "babylonjs/Materials/effect";
  57741. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57742. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57743. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57744. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57745. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57746. /**
  57747. * Block used to add support for vertex skinning (bones)
  57748. */
  57749. export class BonesBlock extends NodeMaterialBlock {
  57750. /**
  57751. * Creates a new BonesBlock
  57752. * @param name defines the block name
  57753. */
  57754. constructor(name: string);
  57755. /**
  57756. * Initialize the block and prepare the context for build
  57757. * @param state defines the state that will be used for the build
  57758. */
  57759. initialize(state: NodeMaterialBuildState): void;
  57760. /**
  57761. * Gets the current class name
  57762. * @returns the class name
  57763. */
  57764. getClassName(): string;
  57765. /**
  57766. * Gets the matrix indices input component
  57767. */
  57768. readonly matricesIndices: NodeMaterialConnectionPoint;
  57769. /**
  57770. * Gets the matrix weights input component
  57771. */
  57772. readonly matricesWeights: NodeMaterialConnectionPoint;
  57773. /**
  57774. * Gets the extra matrix indices input component
  57775. */
  57776. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  57777. /**
  57778. * Gets the extra matrix weights input component
  57779. */
  57780. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  57781. /**
  57782. * Gets the world input component
  57783. */
  57784. readonly world: NodeMaterialConnectionPoint;
  57785. /**
  57786. * Gets the output component
  57787. */
  57788. readonly output: NodeMaterialConnectionPoint;
  57789. autoConfigure(material: NodeMaterial): void;
  57790. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  57791. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57792. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57793. protected _buildBlock(state: NodeMaterialBuildState): this;
  57794. }
  57795. }
  57796. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  57797. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57798. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57799. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57800. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57801. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57802. /**
  57803. * Block used to add support for instances
  57804. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  57805. */
  57806. export class InstancesBlock extends NodeMaterialBlock {
  57807. /**
  57808. * Creates a new InstancesBlock
  57809. * @param name defines the block name
  57810. */
  57811. constructor(name: string);
  57812. /**
  57813. * Gets the current class name
  57814. * @returns the class name
  57815. */
  57816. getClassName(): string;
  57817. /**
  57818. * Gets the first world row input component
  57819. */
  57820. readonly world0: NodeMaterialConnectionPoint;
  57821. /**
  57822. * Gets the second world row input component
  57823. */
  57824. readonly world1: NodeMaterialConnectionPoint;
  57825. /**
  57826. * Gets the third world row input component
  57827. */
  57828. readonly world2: NodeMaterialConnectionPoint;
  57829. /**
  57830. * Gets the forth world row input component
  57831. */
  57832. readonly world3: NodeMaterialConnectionPoint;
  57833. /**
  57834. * Gets the world input component
  57835. */
  57836. readonly world: NodeMaterialConnectionPoint;
  57837. /**
  57838. * Gets the output component
  57839. */
  57840. readonly output: NodeMaterialConnectionPoint;
  57841. autoConfigure(material: NodeMaterial): void;
  57842. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57843. protected _buildBlock(state: NodeMaterialBuildState): this;
  57844. }
  57845. }
  57846. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  57847. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57848. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57849. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57850. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57851. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57852. import { Effect } from "babylonjs/Materials/effect";
  57853. import { Mesh } from "babylonjs/Meshes/mesh";
  57854. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  57855. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  57856. /**
  57857. * Block used to add morph targets support to vertex shader
  57858. */
  57859. export class MorphTargetsBlock extends NodeMaterialBlock {
  57860. private _repeatableContentAnchor;
  57861. private _repeatebleContentGenerated;
  57862. /**
  57863. * Create a new MorphTargetsBlock
  57864. * @param name defines the block name
  57865. */
  57866. constructor(name: string);
  57867. /**
  57868. * Gets the current class name
  57869. * @returns the class name
  57870. */
  57871. getClassName(): string;
  57872. /**
  57873. * Gets the position input component
  57874. */
  57875. readonly position: NodeMaterialConnectionPoint;
  57876. /**
  57877. * Gets the normal input component
  57878. */
  57879. readonly normal: NodeMaterialConnectionPoint;
  57880. /**
  57881. * Gets the tangent input component
  57882. */
  57883. readonly tangent: NodeMaterialConnectionPoint;
  57884. /**
  57885. * Gets the tangent input component
  57886. */
  57887. readonly uv: NodeMaterialConnectionPoint;
  57888. /**
  57889. * Gets the position output component
  57890. */
  57891. readonly positionOutput: NodeMaterialConnectionPoint;
  57892. /**
  57893. * Gets the normal output component
  57894. */
  57895. readonly normalOutput: NodeMaterialConnectionPoint;
  57896. /**
  57897. * Gets the tangent output component
  57898. */
  57899. readonly tangentOutput: NodeMaterialConnectionPoint;
  57900. /**
  57901. * Gets the tangent output component
  57902. */
  57903. readonly uvOutput: NodeMaterialConnectionPoint;
  57904. initialize(state: NodeMaterialBuildState): void;
  57905. autoConfigure(material: NodeMaterial): void;
  57906. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57907. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57908. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  57909. protected _buildBlock(state: NodeMaterialBuildState): this;
  57910. }
  57911. }
  57912. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  57913. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57914. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57915. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57916. import { Nullable } from "babylonjs/types";
  57917. import { Scene } from "babylonjs/scene";
  57918. import { Effect } from "babylonjs/Materials/effect";
  57919. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57920. import { Mesh } from "babylonjs/Meshes/mesh";
  57921. import { Light } from "babylonjs/Lights/light";
  57922. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57923. /**
  57924. * Block used to get data information from a light
  57925. */
  57926. export class LightInformationBlock extends NodeMaterialBlock {
  57927. private _lightDataUniformName;
  57928. private _lightColorUniformName;
  57929. private _lightTypeDefineName;
  57930. /**
  57931. * Gets or sets the light associated with this block
  57932. */
  57933. light: Nullable<Light>;
  57934. /**
  57935. * Creates a new LightInformationBlock
  57936. * @param name defines the block name
  57937. */
  57938. constructor(name: string);
  57939. /**
  57940. * Gets the current class name
  57941. * @returns the class name
  57942. */
  57943. getClassName(): string;
  57944. /**
  57945. * Gets the world position input component
  57946. */
  57947. readonly worldPosition: NodeMaterialConnectionPoint;
  57948. /**
  57949. * Gets the direction output component
  57950. */
  57951. readonly direction: NodeMaterialConnectionPoint;
  57952. /**
  57953. * Gets the direction output component
  57954. */
  57955. readonly color: NodeMaterialConnectionPoint;
  57956. /**
  57957. * Gets the direction output component
  57958. */
  57959. readonly intensity: NodeMaterialConnectionPoint;
  57960. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57961. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57962. protected _buildBlock(state: NodeMaterialBuildState): this;
  57963. serialize(): any;
  57964. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57965. }
  57966. }
  57967. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  57968. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  57969. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  57970. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  57971. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  57972. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  57973. }
  57974. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  57975. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57976. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57977. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57978. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57979. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57980. import { Effect } from "babylonjs/Materials/effect";
  57981. import { Mesh } from "babylonjs/Meshes/mesh";
  57982. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57983. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  57984. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  57985. /**
  57986. * Block used to add image processing support to fragment shader
  57987. */
  57988. export class ImageProcessingBlock extends NodeMaterialBlock {
  57989. /**
  57990. * Create a new ImageProcessingBlock
  57991. * @param name defines the block name
  57992. */
  57993. constructor(name: string);
  57994. /**
  57995. * Gets the current class name
  57996. * @returns the class name
  57997. */
  57998. getClassName(): string;
  57999. /**
  58000. * Gets the color input component
  58001. */
  58002. readonly color: NodeMaterialConnectionPoint;
  58003. /**
  58004. * Gets the output component
  58005. */
  58006. readonly output: NodeMaterialConnectionPoint;
  58007. /**
  58008. * Initialize the block and prepare the context for build
  58009. * @param state defines the state that will be used for the build
  58010. */
  58011. initialize(state: NodeMaterialBuildState): void;
  58012. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  58013. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58014. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58015. protected _buildBlock(state: NodeMaterialBuildState): this;
  58016. }
  58017. }
  58018. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  58019. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58020. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58021. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58022. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  58023. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58024. import { Effect } from "babylonjs/Materials/effect";
  58025. import { Mesh } from "babylonjs/Meshes/mesh";
  58026. import { Scene } from "babylonjs/scene";
  58027. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  58028. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  58029. /**
  58030. * Block used to pertub normals based on a normal map
  58031. */
  58032. export class PerturbNormalBlock extends NodeMaterialBlock {
  58033. private _tangentSpaceParameterName;
  58034. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  58035. invertX: boolean;
  58036. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  58037. invertY: boolean;
  58038. /**
  58039. * Create a new PerturbNormalBlock
  58040. * @param name defines the block name
  58041. */
  58042. constructor(name: string);
  58043. /**
  58044. * Gets the current class name
  58045. * @returns the class name
  58046. */
  58047. getClassName(): string;
  58048. /**
  58049. * Gets the world position input component
  58050. */
  58051. readonly worldPosition: NodeMaterialConnectionPoint;
  58052. /**
  58053. * Gets the world normal input component
  58054. */
  58055. readonly worldNormal: NodeMaterialConnectionPoint;
  58056. /**
  58057. * Gets the uv input component
  58058. */
  58059. readonly uv: NodeMaterialConnectionPoint;
  58060. /**
  58061. * Gets the normal map color input component
  58062. */
  58063. readonly normalMapColor: NodeMaterialConnectionPoint;
  58064. /**
  58065. * Gets the strength input component
  58066. */
  58067. readonly strength: NodeMaterialConnectionPoint;
  58068. /**
  58069. * Gets the output component
  58070. */
  58071. readonly output: NodeMaterialConnectionPoint;
  58072. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58073. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58074. autoConfigure(material: NodeMaterial): void;
  58075. protected _buildBlock(state: NodeMaterialBuildState): this;
  58076. protected _dumpPropertiesCode(): string;
  58077. serialize(): any;
  58078. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58079. }
  58080. }
  58081. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  58082. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58083. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58084. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58085. /**
  58086. * Block used to discard a pixel if a value is smaller than a cutoff
  58087. */
  58088. export class DiscardBlock extends NodeMaterialBlock {
  58089. /**
  58090. * Create a new DiscardBlock
  58091. * @param name defines the block name
  58092. */
  58093. constructor(name: string);
  58094. /**
  58095. * Gets the current class name
  58096. * @returns the class name
  58097. */
  58098. getClassName(): string;
  58099. /**
  58100. * Gets the color input component
  58101. */
  58102. readonly value: NodeMaterialConnectionPoint;
  58103. /**
  58104. * Gets the cutoff input component
  58105. */
  58106. readonly cutoff: NodeMaterialConnectionPoint;
  58107. protected _buildBlock(state: NodeMaterialBuildState): this;
  58108. }
  58109. }
  58110. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  58111. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58112. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58113. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58114. /**
  58115. * Block used to test if the fragment shader is front facing
  58116. */
  58117. export class FrontFacingBlock extends NodeMaterialBlock {
  58118. /**
  58119. * Creates a new FrontFacingBlock
  58120. * @param name defines the block name
  58121. */
  58122. constructor(name: string);
  58123. /**
  58124. * Gets the current class name
  58125. * @returns the class name
  58126. */
  58127. getClassName(): string;
  58128. /**
  58129. * Gets the output component
  58130. */
  58131. readonly output: NodeMaterialConnectionPoint;
  58132. protected _buildBlock(state: NodeMaterialBuildState): this;
  58133. }
  58134. }
  58135. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  58136. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58137. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58138. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58139. /**
  58140. * Block used to get the derivative value on x and y of a given input
  58141. */
  58142. export class DerivativeBlock extends NodeMaterialBlock {
  58143. /**
  58144. * Create a new DerivativeBlock
  58145. * @param name defines the block name
  58146. */
  58147. constructor(name: string);
  58148. /**
  58149. * Gets the current class name
  58150. * @returns the class name
  58151. */
  58152. getClassName(): string;
  58153. /**
  58154. * Gets the input component
  58155. */
  58156. readonly input: NodeMaterialConnectionPoint;
  58157. /**
  58158. * Gets the derivative output on x
  58159. */
  58160. readonly dx: NodeMaterialConnectionPoint;
  58161. /**
  58162. * Gets the derivative output on y
  58163. */
  58164. readonly dy: NodeMaterialConnectionPoint;
  58165. protected _buildBlock(state: NodeMaterialBuildState): this;
  58166. }
  58167. }
  58168. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  58169. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  58170. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  58171. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  58172. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  58173. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  58174. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  58175. }
  58176. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  58177. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58178. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58179. import { Mesh } from "babylonjs/Meshes/mesh";
  58180. import { Effect } from "babylonjs/Materials/effect";
  58181. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58182. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58183. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  58184. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  58185. /**
  58186. * Block used to add support for scene fog
  58187. */
  58188. export class FogBlock extends NodeMaterialBlock {
  58189. private _fogDistanceName;
  58190. private _fogParameters;
  58191. /**
  58192. * Create a new FogBlock
  58193. * @param name defines the block name
  58194. */
  58195. constructor(name: string);
  58196. /**
  58197. * Gets the current class name
  58198. * @returns the class name
  58199. */
  58200. getClassName(): string;
  58201. /**
  58202. * Gets the world position input component
  58203. */
  58204. readonly worldPosition: NodeMaterialConnectionPoint;
  58205. /**
  58206. * Gets the view input component
  58207. */
  58208. readonly view: NodeMaterialConnectionPoint;
  58209. /**
  58210. * Gets the color input component
  58211. */
  58212. readonly input: NodeMaterialConnectionPoint;
  58213. /**
  58214. * Gets the fog color input component
  58215. */
  58216. readonly fogColor: NodeMaterialConnectionPoint;
  58217. /**
  58218. * Gets the output component
  58219. */
  58220. readonly output: NodeMaterialConnectionPoint;
  58221. autoConfigure(material: NodeMaterial): void;
  58222. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58223. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58224. protected _buildBlock(state: NodeMaterialBuildState): this;
  58225. }
  58226. }
  58227. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  58228. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58229. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58230. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58231. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58232. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  58233. import { Effect } from "babylonjs/Materials/effect";
  58234. import { Mesh } from "babylonjs/Meshes/mesh";
  58235. import { Light } from "babylonjs/Lights/light";
  58236. import { Nullable } from "babylonjs/types";
  58237. import { Scene } from "babylonjs/scene";
  58238. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  58239. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  58240. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  58241. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58242. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  58243. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  58244. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  58245. /**
  58246. * Block used to add light in the fragment shader
  58247. */
  58248. export class LightBlock extends NodeMaterialBlock {
  58249. private _lightId;
  58250. /**
  58251. * Gets or sets the light associated with this block
  58252. */
  58253. light: Nullable<Light>;
  58254. /**
  58255. * Create a new LightBlock
  58256. * @param name defines the block name
  58257. */
  58258. constructor(name: string);
  58259. /**
  58260. * Gets the current class name
  58261. * @returns the class name
  58262. */
  58263. getClassName(): string;
  58264. /**
  58265. * Gets the world position input component
  58266. */
  58267. readonly worldPosition: NodeMaterialConnectionPoint;
  58268. /**
  58269. * Gets the world normal input component
  58270. */
  58271. readonly worldNormal: NodeMaterialConnectionPoint;
  58272. /**
  58273. * Gets the camera (or eye) position component
  58274. */
  58275. readonly cameraPosition: NodeMaterialConnectionPoint;
  58276. /**
  58277. * Gets the glossiness component
  58278. */
  58279. readonly glossiness: NodeMaterialConnectionPoint;
  58280. /**
  58281. * Gets the glossinness power component
  58282. */
  58283. readonly glossPower: NodeMaterialConnectionPoint;
  58284. /**
  58285. * Gets the diffuse color component
  58286. */
  58287. readonly diffuseColor: NodeMaterialConnectionPoint;
  58288. /**
  58289. * Gets the specular color component
  58290. */
  58291. readonly specularColor: NodeMaterialConnectionPoint;
  58292. /**
  58293. * Gets the diffuse output component
  58294. */
  58295. readonly diffuseOutput: NodeMaterialConnectionPoint;
  58296. /**
  58297. * Gets the specular output component
  58298. */
  58299. readonly specularOutput: NodeMaterialConnectionPoint;
  58300. autoConfigure(material: NodeMaterial): void;
  58301. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58302. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  58303. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58304. private _injectVertexCode;
  58305. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58306. serialize(): any;
  58307. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58308. }
  58309. }
  58310. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  58311. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  58312. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  58313. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  58314. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  58315. }
  58316. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  58317. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  58318. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  58319. }
  58320. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  58321. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58322. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58323. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58324. /**
  58325. * Block used to multiply 2 values
  58326. */
  58327. export class MultiplyBlock extends NodeMaterialBlock {
  58328. /**
  58329. * Creates a new MultiplyBlock
  58330. * @param name defines the block name
  58331. */
  58332. constructor(name: string);
  58333. /**
  58334. * Gets the current class name
  58335. * @returns the class name
  58336. */
  58337. getClassName(): string;
  58338. /**
  58339. * Gets the left operand input component
  58340. */
  58341. readonly left: NodeMaterialConnectionPoint;
  58342. /**
  58343. * Gets the right operand input component
  58344. */
  58345. readonly right: NodeMaterialConnectionPoint;
  58346. /**
  58347. * Gets the output component
  58348. */
  58349. readonly output: NodeMaterialConnectionPoint;
  58350. protected _buildBlock(state: NodeMaterialBuildState): this;
  58351. }
  58352. }
  58353. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  58354. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58355. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58356. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58357. /**
  58358. * Block used to add 2 vectors
  58359. */
  58360. export class AddBlock extends NodeMaterialBlock {
  58361. /**
  58362. * Creates a new AddBlock
  58363. * @param name defines the block name
  58364. */
  58365. constructor(name: string);
  58366. /**
  58367. * Gets the current class name
  58368. * @returns the class name
  58369. */
  58370. getClassName(): string;
  58371. /**
  58372. * Gets the left operand input component
  58373. */
  58374. readonly left: NodeMaterialConnectionPoint;
  58375. /**
  58376. * Gets the right operand input component
  58377. */
  58378. readonly right: NodeMaterialConnectionPoint;
  58379. /**
  58380. * Gets the output component
  58381. */
  58382. readonly output: NodeMaterialConnectionPoint;
  58383. protected _buildBlock(state: NodeMaterialBuildState): this;
  58384. }
  58385. }
  58386. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  58387. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58388. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58389. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58390. /**
  58391. * Block used to scale a vector by a float
  58392. */
  58393. export class ScaleBlock extends NodeMaterialBlock {
  58394. /**
  58395. * Creates a new ScaleBlock
  58396. * @param name defines the block name
  58397. */
  58398. constructor(name: string);
  58399. /**
  58400. * Gets the current class name
  58401. * @returns the class name
  58402. */
  58403. getClassName(): string;
  58404. /**
  58405. * Gets the input component
  58406. */
  58407. readonly input: NodeMaterialConnectionPoint;
  58408. /**
  58409. * Gets the factor input component
  58410. */
  58411. readonly factor: NodeMaterialConnectionPoint;
  58412. /**
  58413. * Gets the output component
  58414. */
  58415. readonly output: NodeMaterialConnectionPoint;
  58416. protected _buildBlock(state: NodeMaterialBuildState): this;
  58417. }
  58418. }
  58419. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  58420. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58421. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58422. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58423. import { Scene } from "babylonjs/scene";
  58424. /**
  58425. * Block used to clamp a float
  58426. */
  58427. export class ClampBlock extends NodeMaterialBlock {
  58428. /** Gets or sets the minimum range */
  58429. minimum: number;
  58430. /** Gets or sets the maximum range */
  58431. maximum: number;
  58432. /**
  58433. * Creates a new ClampBlock
  58434. * @param name defines the block name
  58435. */
  58436. constructor(name: string);
  58437. /**
  58438. * Gets the current class name
  58439. * @returns the class name
  58440. */
  58441. getClassName(): string;
  58442. /**
  58443. * Gets the value input component
  58444. */
  58445. readonly value: NodeMaterialConnectionPoint;
  58446. /**
  58447. * Gets the output component
  58448. */
  58449. readonly output: NodeMaterialConnectionPoint;
  58450. protected _buildBlock(state: NodeMaterialBuildState): this;
  58451. protected _dumpPropertiesCode(): string;
  58452. serialize(): any;
  58453. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58454. }
  58455. }
  58456. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  58457. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58458. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58459. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58460. /**
  58461. * Block used to apply a cross product between 2 vectors
  58462. */
  58463. export class CrossBlock extends NodeMaterialBlock {
  58464. /**
  58465. * Creates a new CrossBlock
  58466. * @param name defines the block name
  58467. */
  58468. constructor(name: string);
  58469. /**
  58470. * Gets the current class name
  58471. * @returns the class name
  58472. */
  58473. getClassName(): string;
  58474. /**
  58475. * Gets the left operand input component
  58476. */
  58477. readonly left: NodeMaterialConnectionPoint;
  58478. /**
  58479. * Gets the right operand input component
  58480. */
  58481. readonly right: NodeMaterialConnectionPoint;
  58482. /**
  58483. * Gets the output component
  58484. */
  58485. readonly output: NodeMaterialConnectionPoint;
  58486. protected _buildBlock(state: NodeMaterialBuildState): this;
  58487. }
  58488. }
  58489. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  58490. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58491. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58492. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58493. /**
  58494. * Block used to apply a dot product between 2 vectors
  58495. */
  58496. export class DotBlock extends NodeMaterialBlock {
  58497. /**
  58498. * Creates a new DotBlock
  58499. * @param name defines the block name
  58500. */
  58501. constructor(name: string);
  58502. /**
  58503. * Gets the current class name
  58504. * @returns the class name
  58505. */
  58506. getClassName(): string;
  58507. /**
  58508. * Gets the left operand input component
  58509. */
  58510. readonly left: NodeMaterialConnectionPoint;
  58511. /**
  58512. * Gets the right operand input component
  58513. */
  58514. readonly right: NodeMaterialConnectionPoint;
  58515. /**
  58516. * Gets the output component
  58517. */
  58518. readonly output: NodeMaterialConnectionPoint;
  58519. protected _buildBlock(state: NodeMaterialBuildState): this;
  58520. }
  58521. }
  58522. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  58523. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58524. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58525. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58526. import { Vector2 } from "babylonjs/Maths/math.vector";
  58527. import { Scene } from "babylonjs/scene";
  58528. /**
  58529. * Block used to remap a float from a range to a new one
  58530. */
  58531. export class RemapBlock extends NodeMaterialBlock {
  58532. /**
  58533. * Gets or sets the source range
  58534. */
  58535. sourceRange: Vector2;
  58536. /**
  58537. * Gets or sets the target range
  58538. */
  58539. targetRange: Vector2;
  58540. /**
  58541. * Creates a new RemapBlock
  58542. * @param name defines the block name
  58543. */
  58544. constructor(name: string);
  58545. /**
  58546. * Gets the current class name
  58547. * @returns the class name
  58548. */
  58549. getClassName(): string;
  58550. /**
  58551. * Gets the input component
  58552. */
  58553. readonly input: NodeMaterialConnectionPoint;
  58554. /**
  58555. * Gets the source min input component
  58556. */
  58557. readonly sourceMin: NodeMaterialConnectionPoint;
  58558. /**
  58559. * Gets the source max input component
  58560. */
  58561. readonly sourceMax: NodeMaterialConnectionPoint;
  58562. /**
  58563. * Gets the target min input component
  58564. */
  58565. readonly targetMin: NodeMaterialConnectionPoint;
  58566. /**
  58567. * Gets the target max input component
  58568. */
  58569. readonly targetMax: NodeMaterialConnectionPoint;
  58570. /**
  58571. * Gets the output component
  58572. */
  58573. readonly output: NodeMaterialConnectionPoint;
  58574. protected _buildBlock(state: NodeMaterialBuildState): this;
  58575. protected _dumpPropertiesCode(): string;
  58576. serialize(): any;
  58577. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58578. }
  58579. }
  58580. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  58581. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58582. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58583. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58584. /**
  58585. * Block used to normalize a vector
  58586. */
  58587. export class NormalizeBlock extends NodeMaterialBlock {
  58588. /**
  58589. * Creates a new NormalizeBlock
  58590. * @param name defines the block name
  58591. */
  58592. constructor(name: string);
  58593. /**
  58594. * Gets the current class name
  58595. * @returns the class name
  58596. */
  58597. getClassName(): string;
  58598. /**
  58599. * Gets the input component
  58600. */
  58601. readonly input: NodeMaterialConnectionPoint;
  58602. /**
  58603. * Gets the output component
  58604. */
  58605. readonly output: NodeMaterialConnectionPoint;
  58606. protected _buildBlock(state: NodeMaterialBuildState): this;
  58607. }
  58608. }
  58609. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  58610. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58611. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58612. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58613. import { Scene } from "babylonjs/scene";
  58614. /**
  58615. * Operations supported by the Trigonometry block
  58616. */
  58617. export enum TrigonometryBlockOperations {
  58618. /** Cos */
  58619. Cos = 0,
  58620. /** Sin */
  58621. Sin = 1,
  58622. /** Abs */
  58623. Abs = 2,
  58624. /** Exp */
  58625. Exp = 3,
  58626. /** Exp2 */
  58627. Exp2 = 4,
  58628. /** Round */
  58629. Round = 5,
  58630. /** Floor */
  58631. Floor = 6,
  58632. /** Ceiling */
  58633. Ceiling = 7,
  58634. /** Square root */
  58635. Sqrt = 8,
  58636. /** Log */
  58637. Log = 9,
  58638. /** Tangent */
  58639. Tan = 10,
  58640. /** Arc tangent */
  58641. ArcTan = 11,
  58642. /** Arc cosinus */
  58643. ArcCos = 12,
  58644. /** Arc sinus */
  58645. ArcSin = 13,
  58646. /** Fraction */
  58647. Fract = 14,
  58648. /** Sign */
  58649. Sign = 15,
  58650. /** To radians (from degrees) */
  58651. Radians = 16,
  58652. /** To degrees (from radians) */
  58653. Degrees = 17
  58654. }
  58655. /**
  58656. * Block used to apply trigonometry operation to floats
  58657. */
  58658. export class TrigonometryBlock extends NodeMaterialBlock {
  58659. /**
  58660. * Gets or sets the operation applied by the block
  58661. */
  58662. operation: TrigonometryBlockOperations;
  58663. /**
  58664. * Creates a new TrigonometryBlock
  58665. * @param name defines the block name
  58666. */
  58667. constructor(name: string);
  58668. /**
  58669. * Gets the current class name
  58670. * @returns the class name
  58671. */
  58672. getClassName(): string;
  58673. /**
  58674. * Gets the input component
  58675. */
  58676. readonly input: NodeMaterialConnectionPoint;
  58677. /**
  58678. * Gets the output component
  58679. */
  58680. readonly output: NodeMaterialConnectionPoint;
  58681. protected _buildBlock(state: NodeMaterialBuildState): this;
  58682. serialize(): any;
  58683. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58684. protected _dumpPropertiesCode(): string;
  58685. }
  58686. }
  58687. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  58688. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58689. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58690. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58691. /**
  58692. * Block used to create a Color3/4 out of individual inputs (one for each component)
  58693. */
  58694. export class ColorMergerBlock extends NodeMaterialBlock {
  58695. /**
  58696. * Create a new ColorMergerBlock
  58697. * @param name defines the block name
  58698. */
  58699. constructor(name: string);
  58700. /**
  58701. * Gets the current class name
  58702. * @returns the class name
  58703. */
  58704. getClassName(): string;
  58705. /**
  58706. * Gets the rgb component (input)
  58707. */
  58708. readonly rgbIn: NodeMaterialConnectionPoint;
  58709. /**
  58710. * Gets the r component (input)
  58711. */
  58712. readonly r: NodeMaterialConnectionPoint;
  58713. /**
  58714. * Gets the g component (input)
  58715. */
  58716. readonly g: NodeMaterialConnectionPoint;
  58717. /**
  58718. * Gets the b component (input)
  58719. */
  58720. readonly b: NodeMaterialConnectionPoint;
  58721. /**
  58722. * Gets the a component (input)
  58723. */
  58724. readonly a: NodeMaterialConnectionPoint;
  58725. /**
  58726. * Gets the rgba component (output)
  58727. */
  58728. readonly rgba: NodeMaterialConnectionPoint;
  58729. /**
  58730. * Gets the rgb component (output)
  58731. */
  58732. readonly rgbOut: NodeMaterialConnectionPoint;
  58733. /**
  58734. * Gets the rgb component (output)
  58735. * @deprecated Please use rgbOut instead.
  58736. */
  58737. readonly rgb: NodeMaterialConnectionPoint;
  58738. protected _buildBlock(state: NodeMaterialBuildState): this;
  58739. }
  58740. }
  58741. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  58742. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58743. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58744. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58745. /**
  58746. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  58747. */
  58748. export class VectorMergerBlock extends NodeMaterialBlock {
  58749. /**
  58750. * Create a new VectorMergerBlock
  58751. * @param name defines the block name
  58752. */
  58753. constructor(name: string);
  58754. /**
  58755. * Gets the current class name
  58756. * @returns the class name
  58757. */
  58758. getClassName(): string;
  58759. /**
  58760. * Gets the xyz component (input)
  58761. */
  58762. readonly xyzIn: NodeMaterialConnectionPoint;
  58763. /**
  58764. * Gets the xy component (input)
  58765. */
  58766. readonly xyIn: NodeMaterialConnectionPoint;
  58767. /**
  58768. * Gets the x component (input)
  58769. */
  58770. readonly x: NodeMaterialConnectionPoint;
  58771. /**
  58772. * Gets the y component (input)
  58773. */
  58774. readonly y: NodeMaterialConnectionPoint;
  58775. /**
  58776. * Gets the z component (input)
  58777. */
  58778. readonly z: NodeMaterialConnectionPoint;
  58779. /**
  58780. * Gets the w component (input)
  58781. */
  58782. readonly w: NodeMaterialConnectionPoint;
  58783. /**
  58784. * Gets the xyzw component (output)
  58785. */
  58786. readonly xyzw: NodeMaterialConnectionPoint;
  58787. /**
  58788. * Gets the xyz component (output)
  58789. */
  58790. readonly xyzOut: NodeMaterialConnectionPoint;
  58791. /**
  58792. * Gets the xy component (output)
  58793. */
  58794. readonly xyOut: NodeMaterialConnectionPoint;
  58795. /**
  58796. * Gets the xy component (output)
  58797. * @deprecated Please use xyOut instead.
  58798. */
  58799. readonly xy: NodeMaterialConnectionPoint;
  58800. /**
  58801. * Gets the xyz component (output)
  58802. * @deprecated Please use xyzOut instead.
  58803. */
  58804. readonly xyz: NodeMaterialConnectionPoint;
  58805. protected _buildBlock(state: NodeMaterialBuildState): this;
  58806. }
  58807. }
  58808. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  58809. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58810. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58811. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58812. /**
  58813. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  58814. */
  58815. export class ColorSplitterBlock extends NodeMaterialBlock {
  58816. /**
  58817. * Create a new ColorSplitterBlock
  58818. * @param name defines the block name
  58819. */
  58820. constructor(name: string);
  58821. /**
  58822. * Gets the current class name
  58823. * @returns the class name
  58824. */
  58825. getClassName(): string;
  58826. /**
  58827. * Gets the rgba component (input)
  58828. */
  58829. readonly rgba: NodeMaterialConnectionPoint;
  58830. /**
  58831. * Gets the rgb component (input)
  58832. */
  58833. readonly rgbIn: NodeMaterialConnectionPoint;
  58834. /**
  58835. * Gets the rgb component (output)
  58836. */
  58837. readonly rgbOut: NodeMaterialConnectionPoint;
  58838. /**
  58839. * Gets the r component (output)
  58840. */
  58841. readonly r: NodeMaterialConnectionPoint;
  58842. /**
  58843. * Gets the g component (output)
  58844. */
  58845. readonly g: NodeMaterialConnectionPoint;
  58846. /**
  58847. * Gets the b component (output)
  58848. */
  58849. readonly b: NodeMaterialConnectionPoint;
  58850. /**
  58851. * Gets the a component (output)
  58852. */
  58853. readonly a: NodeMaterialConnectionPoint;
  58854. protected _inputRename(name: string): string;
  58855. protected _outputRename(name: string): string;
  58856. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58857. }
  58858. }
  58859. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  58860. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58861. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58862. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58863. /**
  58864. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  58865. */
  58866. export class VectorSplitterBlock extends NodeMaterialBlock {
  58867. /**
  58868. * Create a new VectorSplitterBlock
  58869. * @param name defines the block name
  58870. */
  58871. constructor(name: string);
  58872. /**
  58873. * Gets the current class name
  58874. * @returns the class name
  58875. */
  58876. getClassName(): string;
  58877. /**
  58878. * Gets the xyzw component (input)
  58879. */
  58880. readonly xyzw: NodeMaterialConnectionPoint;
  58881. /**
  58882. * Gets the xyz component (input)
  58883. */
  58884. readonly xyzIn: NodeMaterialConnectionPoint;
  58885. /**
  58886. * Gets the xy component (input)
  58887. */
  58888. readonly xyIn: NodeMaterialConnectionPoint;
  58889. /**
  58890. * Gets the xyz component (output)
  58891. */
  58892. readonly xyzOut: NodeMaterialConnectionPoint;
  58893. /**
  58894. * Gets the xy component (output)
  58895. */
  58896. readonly xyOut: NodeMaterialConnectionPoint;
  58897. /**
  58898. * Gets the x component (output)
  58899. */
  58900. readonly x: NodeMaterialConnectionPoint;
  58901. /**
  58902. * Gets the y component (output)
  58903. */
  58904. readonly y: NodeMaterialConnectionPoint;
  58905. /**
  58906. * Gets the z component (output)
  58907. */
  58908. readonly z: NodeMaterialConnectionPoint;
  58909. /**
  58910. * Gets the w component (output)
  58911. */
  58912. readonly w: NodeMaterialConnectionPoint;
  58913. protected _inputRename(name: string): string;
  58914. protected _outputRename(name: string): string;
  58915. protected _buildBlock(state: NodeMaterialBuildState): this;
  58916. }
  58917. }
  58918. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  58919. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58920. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58921. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58922. /**
  58923. * Block used to lerp between 2 values
  58924. */
  58925. export class LerpBlock extends NodeMaterialBlock {
  58926. /**
  58927. * Creates a new LerpBlock
  58928. * @param name defines the block name
  58929. */
  58930. constructor(name: string);
  58931. /**
  58932. * Gets the current class name
  58933. * @returns the class name
  58934. */
  58935. getClassName(): string;
  58936. /**
  58937. * Gets the left operand input component
  58938. */
  58939. readonly left: NodeMaterialConnectionPoint;
  58940. /**
  58941. * Gets the right operand input component
  58942. */
  58943. readonly right: NodeMaterialConnectionPoint;
  58944. /**
  58945. * Gets the gradient operand input component
  58946. */
  58947. readonly gradient: NodeMaterialConnectionPoint;
  58948. /**
  58949. * Gets the output component
  58950. */
  58951. readonly output: NodeMaterialConnectionPoint;
  58952. protected _buildBlock(state: NodeMaterialBuildState): this;
  58953. }
  58954. }
  58955. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  58956. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58957. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58958. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58959. /**
  58960. * Block used to divide 2 vectors
  58961. */
  58962. export class DivideBlock extends NodeMaterialBlock {
  58963. /**
  58964. * Creates a new DivideBlock
  58965. * @param name defines the block name
  58966. */
  58967. constructor(name: string);
  58968. /**
  58969. * Gets the current class name
  58970. * @returns the class name
  58971. */
  58972. getClassName(): string;
  58973. /**
  58974. * Gets the left operand input component
  58975. */
  58976. readonly left: NodeMaterialConnectionPoint;
  58977. /**
  58978. * Gets the right operand input component
  58979. */
  58980. readonly right: NodeMaterialConnectionPoint;
  58981. /**
  58982. * Gets the output component
  58983. */
  58984. readonly output: NodeMaterialConnectionPoint;
  58985. protected _buildBlock(state: NodeMaterialBuildState): this;
  58986. }
  58987. }
  58988. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  58989. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58990. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58991. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58992. /**
  58993. * Block used to subtract 2 vectors
  58994. */
  58995. export class SubtractBlock extends NodeMaterialBlock {
  58996. /**
  58997. * Creates a new SubtractBlock
  58998. * @param name defines the block name
  58999. */
  59000. constructor(name: string);
  59001. /**
  59002. * Gets the current class name
  59003. * @returns the class name
  59004. */
  59005. getClassName(): string;
  59006. /**
  59007. * Gets the left operand input component
  59008. */
  59009. readonly left: NodeMaterialConnectionPoint;
  59010. /**
  59011. * Gets the right operand input component
  59012. */
  59013. readonly right: NodeMaterialConnectionPoint;
  59014. /**
  59015. * Gets the output component
  59016. */
  59017. readonly output: NodeMaterialConnectionPoint;
  59018. protected _buildBlock(state: NodeMaterialBuildState): this;
  59019. }
  59020. }
  59021. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  59022. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59023. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59024. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59025. /**
  59026. * Block used to step a value
  59027. */
  59028. export class StepBlock extends NodeMaterialBlock {
  59029. /**
  59030. * Creates a new StepBlock
  59031. * @param name defines the block name
  59032. */
  59033. constructor(name: string);
  59034. /**
  59035. * Gets the current class name
  59036. * @returns the class name
  59037. */
  59038. getClassName(): string;
  59039. /**
  59040. * Gets the value operand input component
  59041. */
  59042. readonly value: NodeMaterialConnectionPoint;
  59043. /**
  59044. * Gets the edge operand input component
  59045. */
  59046. readonly edge: NodeMaterialConnectionPoint;
  59047. /**
  59048. * Gets the output component
  59049. */
  59050. readonly output: NodeMaterialConnectionPoint;
  59051. protected _buildBlock(state: NodeMaterialBuildState): this;
  59052. }
  59053. }
  59054. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  59055. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59056. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59057. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59058. /**
  59059. * Block used to get the opposite (1 - x) of a value
  59060. */
  59061. export class OneMinusBlock extends NodeMaterialBlock {
  59062. /**
  59063. * Creates a new OneMinusBlock
  59064. * @param name defines the block name
  59065. */
  59066. constructor(name: string);
  59067. /**
  59068. * Gets the current class name
  59069. * @returns the class name
  59070. */
  59071. getClassName(): string;
  59072. /**
  59073. * Gets the input component
  59074. */
  59075. readonly input: NodeMaterialConnectionPoint;
  59076. /**
  59077. * Gets the output component
  59078. */
  59079. readonly output: NodeMaterialConnectionPoint;
  59080. protected _buildBlock(state: NodeMaterialBuildState): this;
  59081. }
  59082. }
  59083. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  59084. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59085. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59086. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59087. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  59088. /**
  59089. * Block used to get the view direction
  59090. */
  59091. export class ViewDirectionBlock extends NodeMaterialBlock {
  59092. /**
  59093. * Creates a new ViewDirectionBlock
  59094. * @param name defines the block name
  59095. */
  59096. constructor(name: string);
  59097. /**
  59098. * Gets the current class name
  59099. * @returns the class name
  59100. */
  59101. getClassName(): string;
  59102. /**
  59103. * Gets the world position component
  59104. */
  59105. readonly worldPosition: NodeMaterialConnectionPoint;
  59106. /**
  59107. * Gets the camera position component
  59108. */
  59109. readonly cameraPosition: NodeMaterialConnectionPoint;
  59110. /**
  59111. * Gets the output component
  59112. */
  59113. readonly output: NodeMaterialConnectionPoint;
  59114. autoConfigure(material: NodeMaterial): void;
  59115. protected _buildBlock(state: NodeMaterialBuildState): this;
  59116. }
  59117. }
  59118. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  59119. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59120. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59121. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59122. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  59123. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  59124. /**
  59125. * Block used to compute fresnel value
  59126. */
  59127. export class FresnelBlock extends NodeMaterialBlock {
  59128. /**
  59129. * Create a new FresnelBlock
  59130. * @param name defines the block name
  59131. */
  59132. constructor(name: string);
  59133. /**
  59134. * Gets the current class name
  59135. * @returns the class name
  59136. */
  59137. getClassName(): string;
  59138. /**
  59139. * Gets the world normal input component
  59140. */
  59141. readonly worldNormal: NodeMaterialConnectionPoint;
  59142. /**
  59143. * Gets the view direction input component
  59144. */
  59145. readonly viewDirection: NodeMaterialConnectionPoint;
  59146. /**
  59147. * Gets the bias input component
  59148. */
  59149. readonly bias: NodeMaterialConnectionPoint;
  59150. /**
  59151. * Gets the camera (or eye) position component
  59152. */
  59153. readonly power: NodeMaterialConnectionPoint;
  59154. /**
  59155. * Gets the fresnel output component
  59156. */
  59157. readonly fresnel: NodeMaterialConnectionPoint;
  59158. autoConfigure(material: NodeMaterial): void;
  59159. protected _buildBlock(state: NodeMaterialBuildState): this;
  59160. }
  59161. }
  59162. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  59163. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59164. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59165. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59166. /**
  59167. * Block used to get the max of 2 values
  59168. */
  59169. export class MaxBlock extends NodeMaterialBlock {
  59170. /**
  59171. * Creates a new MaxBlock
  59172. * @param name defines the block name
  59173. */
  59174. constructor(name: string);
  59175. /**
  59176. * Gets the current class name
  59177. * @returns the class name
  59178. */
  59179. getClassName(): string;
  59180. /**
  59181. * Gets the left operand input component
  59182. */
  59183. readonly left: NodeMaterialConnectionPoint;
  59184. /**
  59185. * Gets the right operand input component
  59186. */
  59187. readonly right: NodeMaterialConnectionPoint;
  59188. /**
  59189. * Gets the output component
  59190. */
  59191. readonly output: NodeMaterialConnectionPoint;
  59192. protected _buildBlock(state: NodeMaterialBuildState): this;
  59193. }
  59194. }
  59195. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  59196. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59197. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59198. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59199. /**
  59200. * Block used to get the min of 2 values
  59201. */
  59202. export class MinBlock extends NodeMaterialBlock {
  59203. /**
  59204. * Creates a new MinBlock
  59205. * @param name defines the block name
  59206. */
  59207. constructor(name: string);
  59208. /**
  59209. * Gets the current class name
  59210. * @returns the class name
  59211. */
  59212. getClassName(): string;
  59213. /**
  59214. * Gets the left operand input component
  59215. */
  59216. readonly left: NodeMaterialConnectionPoint;
  59217. /**
  59218. * Gets the right operand input component
  59219. */
  59220. readonly right: NodeMaterialConnectionPoint;
  59221. /**
  59222. * Gets the output component
  59223. */
  59224. readonly output: NodeMaterialConnectionPoint;
  59225. protected _buildBlock(state: NodeMaterialBuildState): this;
  59226. }
  59227. }
  59228. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  59229. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59230. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59231. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59232. /**
  59233. * Block used to get the distance between 2 values
  59234. */
  59235. export class DistanceBlock extends NodeMaterialBlock {
  59236. /**
  59237. * Creates a new DistanceBlock
  59238. * @param name defines the block name
  59239. */
  59240. constructor(name: string);
  59241. /**
  59242. * Gets the current class name
  59243. * @returns the class name
  59244. */
  59245. getClassName(): string;
  59246. /**
  59247. * Gets the left operand input component
  59248. */
  59249. readonly left: NodeMaterialConnectionPoint;
  59250. /**
  59251. * Gets the right operand input component
  59252. */
  59253. readonly right: NodeMaterialConnectionPoint;
  59254. /**
  59255. * Gets the output component
  59256. */
  59257. readonly output: NodeMaterialConnectionPoint;
  59258. protected _buildBlock(state: NodeMaterialBuildState): this;
  59259. }
  59260. }
  59261. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  59262. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59263. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59264. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59265. /**
  59266. * Block used to get the length of a vector
  59267. */
  59268. export class LengthBlock extends NodeMaterialBlock {
  59269. /**
  59270. * Creates a new LengthBlock
  59271. * @param name defines the block name
  59272. */
  59273. constructor(name: string);
  59274. /**
  59275. * Gets the current class name
  59276. * @returns the class name
  59277. */
  59278. getClassName(): string;
  59279. /**
  59280. * Gets the value input component
  59281. */
  59282. readonly value: NodeMaterialConnectionPoint;
  59283. /**
  59284. * Gets the output component
  59285. */
  59286. readonly output: NodeMaterialConnectionPoint;
  59287. protected _buildBlock(state: NodeMaterialBuildState): this;
  59288. }
  59289. }
  59290. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  59291. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59292. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59293. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59294. /**
  59295. * Block used to get negative version of a value (i.e. x * -1)
  59296. */
  59297. export class NegateBlock extends NodeMaterialBlock {
  59298. /**
  59299. * Creates a new NegateBlock
  59300. * @param name defines the block name
  59301. */
  59302. constructor(name: string);
  59303. /**
  59304. * Gets the current class name
  59305. * @returns the class name
  59306. */
  59307. getClassName(): string;
  59308. /**
  59309. * Gets the value input component
  59310. */
  59311. readonly value: NodeMaterialConnectionPoint;
  59312. /**
  59313. * Gets the output component
  59314. */
  59315. readonly output: NodeMaterialConnectionPoint;
  59316. protected _buildBlock(state: NodeMaterialBuildState): this;
  59317. }
  59318. }
  59319. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  59320. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59321. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59322. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59323. /**
  59324. * Block used to get the value of the first parameter raised to the power of the second
  59325. */
  59326. export class PowBlock extends NodeMaterialBlock {
  59327. /**
  59328. * Creates a new PowBlock
  59329. * @param name defines the block name
  59330. */
  59331. constructor(name: string);
  59332. /**
  59333. * Gets the current class name
  59334. * @returns the class name
  59335. */
  59336. getClassName(): string;
  59337. /**
  59338. * Gets the value operand input component
  59339. */
  59340. readonly value: NodeMaterialConnectionPoint;
  59341. /**
  59342. * Gets the power operand input component
  59343. */
  59344. readonly power: NodeMaterialConnectionPoint;
  59345. /**
  59346. * Gets the output component
  59347. */
  59348. readonly output: NodeMaterialConnectionPoint;
  59349. protected _buildBlock(state: NodeMaterialBuildState): this;
  59350. }
  59351. }
  59352. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  59353. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59354. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59355. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59356. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59357. /**
  59358. * Block used to get a random number
  59359. */
  59360. export class RandomNumberBlock extends NodeMaterialBlock {
  59361. /**
  59362. * Creates a new RandomNumberBlock
  59363. * @param name defines the block name
  59364. */
  59365. constructor(name: string);
  59366. /**
  59367. * Gets the current class name
  59368. * @returns the class name
  59369. */
  59370. getClassName(): string;
  59371. /**
  59372. * Gets the seed input component
  59373. */
  59374. readonly seed: NodeMaterialConnectionPoint;
  59375. /**
  59376. * Gets the output component
  59377. */
  59378. readonly output: NodeMaterialConnectionPoint;
  59379. protected _buildBlock(state: NodeMaterialBuildState): this;
  59380. }
  59381. }
  59382. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  59383. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59384. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59385. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59386. /**
  59387. * Block used to compute arc tangent of 2 values
  59388. */
  59389. export class ArcTan2Block extends NodeMaterialBlock {
  59390. /**
  59391. * Creates a new ArcTan2Block
  59392. * @param name defines the block name
  59393. */
  59394. constructor(name: string);
  59395. /**
  59396. * Gets the current class name
  59397. * @returns the class name
  59398. */
  59399. getClassName(): string;
  59400. /**
  59401. * Gets the x operand input component
  59402. */
  59403. readonly x: NodeMaterialConnectionPoint;
  59404. /**
  59405. * Gets the y operand input component
  59406. */
  59407. readonly y: NodeMaterialConnectionPoint;
  59408. /**
  59409. * Gets the output component
  59410. */
  59411. readonly output: NodeMaterialConnectionPoint;
  59412. protected _buildBlock(state: NodeMaterialBuildState): this;
  59413. }
  59414. }
  59415. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  59416. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59417. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59418. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59419. /**
  59420. * Block used to smooth step a value
  59421. */
  59422. export class SmoothStepBlock extends NodeMaterialBlock {
  59423. /**
  59424. * Creates a new SmoothStepBlock
  59425. * @param name defines the block name
  59426. */
  59427. constructor(name: string);
  59428. /**
  59429. * Gets the current class name
  59430. * @returns the class name
  59431. */
  59432. getClassName(): string;
  59433. /**
  59434. * Gets the value operand input component
  59435. */
  59436. readonly value: NodeMaterialConnectionPoint;
  59437. /**
  59438. * Gets the first edge operand input component
  59439. */
  59440. readonly edge0: NodeMaterialConnectionPoint;
  59441. /**
  59442. * Gets the second edge operand input component
  59443. */
  59444. readonly edge1: NodeMaterialConnectionPoint;
  59445. /**
  59446. * Gets the output component
  59447. */
  59448. readonly output: NodeMaterialConnectionPoint;
  59449. protected _buildBlock(state: NodeMaterialBuildState): this;
  59450. }
  59451. }
  59452. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  59453. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59454. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59455. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59456. /**
  59457. * Block used to get the reciprocal (1 / x) of a value
  59458. */
  59459. export class ReciprocalBlock extends NodeMaterialBlock {
  59460. /**
  59461. * Creates a new ReciprocalBlock
  59462. * @param name defines the block name
  59463. */
  59464. constructor(name: string);
  59465. /**
  59466. * Gets the current class name
  59467. * @returns the class name
  59468. */
  59469. getClassName(): string;
  59470. /**
  59471. * Gets the input component
  59472. */
  59473. readonly input: NodeMaterialConnectionPoint;
  59474. /**
  59475. * Gets the output component
  59476. */
  59477. readonly output: NodeMaterialConnectionPoint;
  59478. protected _buildBlock(state: NodeMaterialBuildState): this;
  59479. }
  59480. }
  59481. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  59482. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59483. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59484. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59485. /**
  59486. * Block used to replace a color by another one
  59487. */
  59488. export class ReplaceColorBlock extends NodeMaterialBlock {
  59489. /**
  59490. * Creates a new ReplaceColorBlock
  59491. * @param name defines the block name
  59492. */
  59493. constructor(name: string);
  59494. /**
  59495. * Gets the current class name
  59496. * @returns the class name
  59497. */
  59498. getClassName(): string;
  59499. /**
  59500. * Gets the value input component
  59501. */
  59502. readonly value: NodeMaterialConnectionPoint;
  59503. /**
  59504. * Gets the reference input component
  59505. */
  59506. readonly reference: NodeMaterialConnectionPoint;
  59507. /**
  59508. * Gets the distance input component
  59509. */
  59510. readonly distance: NodeMaterialConnectionPoint;
  59511. /**
  59512. * Gets the replacement input component
  59513. */
  59514. readonly replacement: NodeMaterialConnectionPoint;
  59515. /**
  59516. * Gets the output component
  59517. */
  59518. readonly output: NodeMaterialConnectionPoint;
  59519. protected _buildBlock(state: NodeMaterialBuildState): this;
  59520. }
  59521. }
  59522. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  59523. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59524. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59525. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59526. /**
  59527. * Block used to posterize a value
  59528. * @see https://en.wikipedia.org/wiki/Posterization
  59529. */
  59530. export class PosterizeBlock extends NodeMaterialBlock {
  59531. /**
  59532. * Creates a new PosterizeBlock
  59533. * @param name defines the block name
  59534. */
  59535. constructor(name: string);
  59536. /**
  59537. * Gets the current class name
  59538. * @returns the class name
  59539. */
  59540. getClassName(): string;
  59541. /**
  59542. * Gets the value input component
  59543. */
  59544. readonly value: NodeMaterialConnectionPoint;
  59545. /**
  59546. * Gets the steps input component
  59547. */
  59548. readonly steps: NodeMaterialConnectionPoint;
  59549. /**
  59550. * Gets the output component
  59551. */
  59552. readonly output: NodeMaterialConnectionPoint;
  59553. protected _buildBlock(state: NodeMaterialBuildState): this;
  59554. }
  59555. }
  59556. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  59557. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59558. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59559. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59560. import { Scene } from "babylonjs/scene";
  59561. /**
  59562. * Operations supported by the Wave block
  59563. */
  59564. export enum WaveBlockKind {
  59565. /** SawTooth */
  59566. SawTooth = 0,
  59567. /** Square */
  59568. Square = 1,
  59569. /** Triangle */
  59570. Triangle = 2
  59571. }
  59572. /**
  59573. * Block used to apply wave operation to floats
  59574. */
  59575. export class WaveBlock extends NodeMaterialBlock {
  59576. /**
  59577. * Gets or sets the kibnd of wave to be applied by the block
  59578. */
  59579. kind: WaveBlockKind;
  59580. /**
  59581. * Creates a new WaveBlock
  59582. * @param name defines the block name
  59583. */
  59584. constructor(name: string);
  59585. /**
  59586. * Gets the current class name
  59587. * @returns the class name
  59588. */
  59589. getClassName(): string;
  59590. /**
  59591. * Gets the input component
  59592. */
  59593. readonly input: NodeMaterialConnectionPoint;
  59594. /**
  59595. * Gets the output component
  59596. */
  59597. readonly output: NodeMaterialConnectionPoint;
  59598. protected _buildBlock(state: NodeMaterialBuildState): this;
  59599. serialize(): any;
  59600. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59601. }
  59602. }
  59603. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  59604. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59605. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59606. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59607. import { Color3 } from "babylonjs/Maths/math.color";
  59608. import { Scene } from "babylonjs/scene";
  59609. /**
  59610. * Class used to store a color step for the GradientBlock
  59611. */
  59612. export class GradientBlockColorStep {
  59613. /**
  59614. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  59615. */
  59616. step: number;
  59617. /**
  59618. * Gets or sets the color associated with this step
  59619. */
  59620. color: Color3;
  59621. /**
  59622. * Creates a new GradientBlockColorStep
  59623. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  59624. * @param color defines the color associated with this step
  59625. */
  59626. constructor(
  59627. /**
  59628. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  59629. */
  59630. step: number,
  59631. /**
  59632. * Gets or sets the color associated with this step
  59633. */
  59634. color: Color3);
  59635. }
  59636. /**
  59637. * Block used to return a color from a gradient based on an input value between 0 and 1
  59638. */
  59639. export class GradientBlock extends NodeMaterialBlock {
  59640. /**
  59641. * Gets or sets the list of color steps
  59642. */
  59643. colorSteps: GradientBlockColorStep[];
  59644. /**
  59645. * Creates a new GradientBlock
  59646. * @param name defines the block name
  59647. */
  59648. constructor(name: string);
  59649. /**
  59650. * Gets the current class name
  59651. * @returns the class name
  59652. */
  59653. getClassName(): string;
  59654. /**
  59655. * Gets the gradient input component
  59656. */
  59657. readonly gradient: NodeMaterialConnectionPoint;
  59658. /**
  59659. * Gets the output component
  59660. */
  59661. readonly output: NodeMaterialConnectionPoint;
  59662. private _writeColorConstant;
  59663. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59664. serialize(): any;
  59665. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59666. protected _dumpPropertiesCode(): string;
  59667. }
  59668. }
  59669. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  59670. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59671. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59672. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59673. /**
  59674. * Block used to normalize lerp between 2 values
  59675. */
  59676. export class NLerpBlock extends NodeMaterialBlock {
  59677. /**
  59678. * Creates a new NLerpBlock
  59679. * @param name defines the block name
  59680. */
  59681. constructor(name: string);
  59682. /**
  59683. * Gets the current class name
  59684. * @returns the class name
  59685. */
  59686. getClassName(): string;
  59687. /**
  59688. * Gets the left operand input component
  59689. */
  59690. readonly left: NodeMaterialConnectionPoint;
  59691. /**
  59692. * Gets the right operand input component
  59693. */
  59694. readonly right: NodeMaterialConnectionPoint;
  59695. /**
  59696. * Gets the gradient operand input component
  59697. */
  59698. readonly gradient: NodeMaterialConnectionPoint;
  59699. /**
  59700. * Gets the output component
  59701. */
  59702. readonly output: NodeMaterialConnectionPoint;
  59703. protected _buildBlock(state: NodeMaterialBuildState): this;
  59704. }
  59705. }
  59706. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  59707. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59708. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59709. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59710. import { Scene } from "babylonjs/scene";
  59711. /**
  59712. * block used to Generate a Worley Noise 3D Noise Pattern
  59713. */
  59714. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  59715. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  59716. manhattanDistance: boolean;
  59717. /**
  59718. * Creates a new WorleyNoise3DBlock
  59719. * @param name defines the block name
  59720. */
  59721. constructor(name: string);
  59722. /**
  59723. * Gets the current class name
  59724. * @returns the class name
  59725. */
  59726. getClassName(): string;
  59727. /**
  59728. * Gets the seed input component
  59729. */
  59730. readonly seed: NodeMaterialConnectionPoint;
  59731. /**
  59732. * Gets the jitter input component
  59733. */
  59734. readonly jitter: NodeMaterialConnectionPoint;
  59735. /**
  59736. * Gets the output component
  59737. */
  59738. readonly output: NodeMaterialConnectionPoint;
  59739. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59740. /**
  59741. * Exposes the properties to the UI?
  59742. */
  59743. protected _dumpPropertiesCode(): string;
  59744. /**
  59745. * Exposes the properties to the Seralize?
  59746. */
  59747. serialize(): any;
  59748. /**
  59749. * Exposes the properties to the deseralize?
  59750. */
  59751. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59752. }
  59753. }
  59754. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  59755. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59756. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59757. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59758. /**
  59759. * block used to Generate a Simplex Perlin 3d Noise Pattern
  59760. */
  59761. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  59762. /**
  59763. * Creates a new SimplexPerlin3DBlock
  59764. * @param name defines the block name
  59765. */
  59766. constructor(name: string);
  59767. /**
  59768. * Gets the current class name
  59769. * @returns the class name
  59770. */
  59771. getClassName(): string;
  59772. /**
  59773. * Gets the seed operand input component
  59774. */
  59775. readonly seed: NodeMaterialConnectionPoint;
  59776. /**
  59777. * Gets the output component
  59778. */
  59779. readonly output: NodeMaterialConnectionPoint;
  59780. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59781. }
  59782. }
  59783. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  59784. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59785. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59786. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59787. /**
  59788. * Block used to blend normals
  59789. */
  59790. export class NormalBlendBlock extends NodeMaterialBlock {
  59791. /**
  59792. * Creates a new NormalBlendBlock
  59793. * @param name defines the block name
  59794. */
  59795. constructor(name: string);
  59796. /**
  59797. * Gets the current class name
  59798. * @returns the class name
  59799. */
  59800. getClassName(): string;
  59801. /**
  59802. * Gets the first input component
  59803. */
  59804. readonly normalMap0: NodeMaterialConnectionPoint;
  59805. /**
  59806. * Gets the second input component
  59807. */
  59808. readonly normalMap1: NodeMaterialConnectionPoint;
  59809. /**
  59810. * Gets the output component
  59811. */
  59812. readonly output: NodeMaterialConnectionPoint;
  59813. protected _buildBlock(state: NodeMaterialBuildState): this;
  59814. }
  59815. }
  59816. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  59817. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59818. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59819. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59820. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  59821. /**
  59822. * Block used to rotate a 2d vector by a given angle
  59823. */
  59824. export class Rotate2dBlock extends NodeMaterialBlock {
  59825. /**
  59826. * Creates a new Rotate2dBlock
  59827. * @param name defines the block name
  59828. */
  59829. constructor(name: string);
  59830. /**
  59831. * Gets the current class name
  59832. * @returns the class name
  59833. */
  59834. getClassName(): string;
  59835. /**
  59836. * Gets the input vector
  59837. */
  59838. readonly input: NodeMaterialConnectionPoint;
  59839. /**
  59840. * Gets the input angle
  59841. */
  59842. readonly angle: NodeMaterialConnectionPoint;
  59843. /**
  59844. * Gets the output component
  59845. */
  59846. readonly output: NodeMaterialConnectionPoint;
  59847. autoConfigure(material: NodeMaterial): void;
  59848. protected _buildBlock(state: NodeMaterialBuildState): this;
  59849. }
  59850. }
  59851. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  59852. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59853. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59854. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59855. /**
  59856. * Block used to get the reflected vector from a direction and a normal
  59857. */
  59858. export class ReflectBlock extends NodeMaterialBlock {
  59859. /**
  59860. * Creates a new ReflectBlock
  59861. * @param name defines the block name
  59862. */
  59863. constructor(name: string);
  59864. /**
  59865. * Gets the current class name
  59866. * @returns the class name
  59867. */
  59868. getClassName(): string;
  59869. /**
  59870. * Gets the incident component
  59871. */
  59872. readonly incident: NodeMaterialConnectionPoint;
  59873. /**
  59874. * Gets the normal component
  59875. */
  59876. readonly normal: NodeMaterialConnectionPoint;
  59877. /**
  59878. * Gets the output component
  59879. */
  59880. readonly output: NodeMaterialConnectionPoint;
  59881. protected _buildBlock(state: NodeMaterialBuildState): this;
  59882. }
  59883. }
  59884. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  59885. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59886. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59887. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59888. /**
  59889. * Block used to get the refracted vector from a direction and a normal
  59890. */
  59891. export class RefractBlock extends NodeMaterialBlock {
  59892. /**
  59893. * Creates a new RefractBlock
  59894. * @param name defines the block name
  59895. */
  59896. constructor(name: string);
  59897. /**
  59898. * Gets the current class name
  59899. * @returns the class name
  59900. */
  59901. getClassName(): string;
  59902. /**
  59903. * Gets the incident component
  59904. */
  59905. readonly incident: NodeMaterialConnectionPoint;
  59906. /**
  59907. * Gets the normal component
  59908. */
  59909. readonly normal: NodeMaterialConnectionPoint;
  59910. /**
  59911. * Gets the index of refraction component
  59912. */
  59913. readonly ior: NodeMaterialConnectionPoint;
  59914. /**
  59915. * Gets the output component
  59916. */
  59917. readonly output: NodeMaterialConnectionPoint;
  59918. protected _buildBlock(state: NodeMaterialBuildState): this;
  59919. }
  59920. }
  59921. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  59922. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59923. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59924. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59925. /**
  59926. * Block used to desaturate a color
  59927. */
  59928. export class DesaturateBlock extends NodeMaterialBlock {
  59929. /**
  59930. * Creates a new DesaturateBlock
  59931. * @param name defines the block name
  59932. */
  59933. constructor(name: string);
  59934. /**
  59935. * Gets the current class name
  59936. * @returns the class name
  59937. */
  59938. getClassName(): string;
  59939. /**
  59940. * Gets the color operand input component
  59941. */
  59942. readonly color: NodeMaterialConnectionPoint;
  59943. /**
  59944. * Gets the level operand input component
  59945. */
  59946. readonly level: NodeMaterialConnectionPoint;
  59947. /**
  59948. * Gets the output component
  59949. */
  59950. readonly output: NodeMaterialConnectionPoint;
  59951. protected _buildBlock(state: NodeMaterialBuildState): this;
  59952. }
  59953. }
  59954. declare module "babylonjs/Materials/Node/Blocks/index" {
  59955. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  59956. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  59957. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  59958. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  59959. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  59960. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  59961. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  59962. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  59963. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  59964. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  59965. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  59966. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  59967. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  59968. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  59969. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  59970. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  59971. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  59972. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  59973. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  59974. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  59975. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  59976. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  59977. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  59978. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  59979. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  59980. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  59981. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  59982. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  59983. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  59984. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  59985. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  59986. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  59987. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  59988. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  59989. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  59990. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  59991. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  59992. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  59993. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  59994. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  59995. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  59996. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  59997. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  59998. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  59999. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  60000. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  60001. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  60002. }
  60003. declare module "babylonjs/Materials/Node/Optimizers/index" {
  60004. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  60005. }
  60006. declare module "babylonjs/Materials/Node/index" {
  60007. export * from "babylonjs/Materials/Node/Enums/index";
  60008. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60009. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  60010. export * from "babylonjs/Materials/Node/nodeMaterial";
  60011. export * from "babylonjs/Materials/Node/Blocks/index";
  60012. export * from "babylonjs/Materials/Node/Optimizers/index";
  60013. }
  60014. declare module "babylonjs/Materials/effectRenderer" {
  60015. import { Nullable } from "babylonjs/types";
  60016. import { Texture } from "babylonjs/Materials/Textures/texture";
  60017. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  60018. import { Viewport } from "babylonjs/Maths/math.viewport";
  60019. import { Observable } from "babylonjs/Misc/observable";
  60020. import { Effect } from "babylonjs/Materials/effect";
  60021. import "babylonjs/Engines/Extensions/engine.renderTarget";
  60022. import "babylonjs/Shaders/postprocess.vertex";
  60023. /**
  60024. * Effect Render Options
  60025. */
  60026. export interface IEffectRendererOptions {
  60027. /**
  60028. * Defines the vertices positions.
  60029. */
  60030. positions?: number[];
  60031. /**
  60032. * Defines the indices.
  60033. */
  60034. indices?: number[];
  60035. }
  60036. /**
  60037. * Helper class to render one or more effects
  60038. */
  60039. export class EffectRenderer {
  60040. private engine;
  60041. private static _DefaultOptions;
  60042. private _vertexBuffers;
  60043. private _indexBuffer;
  60044. private _ringBufferIndex;
  60045. private _ringScreenBuffer;
  60046. private _fullscreenViewport;
  60047. private _getNextFrameBuffer;
  60048. /**
  60049. * Creates an effect renderer
  60050. * @param engine the engine to use for rendering
  60051. * @param options defines the options of the effect renderer
  60052. */
  60053. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  60054. /**
  60055. * Sets the current viewport in normalized coordinates 0-1
  60056. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  60057. */
  60058. setViewport(viewport?: Viewport): void;
  60059. /**
  60060. * Binds the embedded attributes buffer to the effect.
  60061. * @param effect Defines the effect to bind the attributes for
  60062. */
  60063. bindBuffers(effect: Effect): void;
  60064. /**
  60065. * Sets the current effect wrapper to use during draw.
  60066. * The effect needs to be ready before calling this api.
  60067. * This also sets the default full screen position attribute.
  60068. * @param effectWrapper Defines the effect to draw with
  60069. */
  60070. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  60071. /**
  60072. * Draws a full screen quad.
  60073. */
  60074. draw(): void;
  60075. /**
  60076. * renders one or more effects to a specified texture
  60077. * @param effectWrappers list of effects to renderer
  60078. * @param outputTexture texture to draw to, if null it will render to the screen
  60079. */
  60080. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  60081. /**
  60082. * Disposes of the effect renderer
  60083. */
  60084. dispose(): void;
  60085. }
  60086. /**
  60087. * Options to create an EffectWrapper
  60088. */
  60089. interface EffectWrapperCreationOptions {
  60090. /**
  60091. * Engine to use to create the effect
  60092. */
  60093. engine: ThinEngine;
  60094. /**
  60095. * Fragment shader for the effect
  60096. */
  60097. fragmentShader: string;
  60098. /**
  60099. * Vertex shader for the effect
  60100. */
  60101. vertexShader?: string;
  60102. /**
  60103. * Attributes to use in the shader
  60104. */
  60105. attributeNames?: Array<string>;
  60106. /**
  60107. * Uniforms to use in the shader
  60108. */
  60109. uniformNames?: Array<string>;
  60110. /**
  60111. * Texture sampler names to use in the shader
  60112. */
  60113. samplerNames?: Array<string>;
  60114. /**
  60115. * The friendly name of the effect displayed in Spector.
  60116. */
  60117. name?: string;
  60118. }
  60119. /**
  60120. * Wraps an effect to be used for rendering
  60121. */
  60122. export class EffectWrapper {
  60123. /**
  60124. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  60125. */
  60126. onApplyObservable: Observable<{}>;
  60127. /**
  60128. * The underlying effect
  60129. */
  60130. effect: Effect;
  60131. /**
  60132. * Creates an effect to be renderer
  60133. * @param creationOptions options to create the effect
  60134. */
  60135. constructor(creationOptions: EffectWrapperCreationOptions);
  60136. /**
  60137. * Disposes of the effect wrapper
  60138. */
  60139. dispose(): void;
  60140. }
  60141. }
  60142. declare module "babylonjs/Materials/index" {
  60143. export * from "babylonjs/Materials/Background/index";
  60144. export * from "babylonjs/Materials/colorCurves";
  60145. export * from "babylonjs/Materials/iEffectFallbacks";
  60146. export * from "babylonjs/Materials/effectFallbacks";
  60147. export * from "babylonjs/Materials/effect";
  60148. export * from "babylonjs/Materials/fresnelParameters";
  60149. export * from "babylonjs/Materials/imageProcessingConfiguration";
  60150. export * from "babylonjs/Materials/material";
  60151. export * from "babylonjs/Materials/materialDefines";
  60152. export * from "babylonjs/Materials/materialHelper";
  60153. export * from "babylonjs/Materials/multiMaterial";
  60154. export * from "babylonjs/Materials/PBR/index";
  60155. export * from "babylonjs/Materials/pushMaterial";
  60156. export * from "babylonjs/Materials/shaderMaterial";
  60157. export * from "babylonjs/Materials/standardMaterial";
  60158. export * from "babylonjs/Materials/Textures/index";
  60159. export * from "babylonjs/Materials/uniformBuffer";
  60160. export * from "babylonjs/Materials/materialFlags";
  60161. export * from "babylonjs/Materials/Node/index";
  60162. export * from "babylonjs/Materials/effectRenderer";
  60163. }
  60164. declare module "babylonjs/Maths/index" {
  60165. export * from "babylonjs/Maths/math.scalar";
  60166. export * from "babylonjs/Maths/math";
  60167. export * from "babylonjs/Maths/sphericalPolynomial";
  60168. }
  60169. declare module "babylonjs/Misc/workerPool" {
  60170. import { IDisposable } from "babylonjs/scene";
  60171. /**
  60172. * Helper class to push actions to a pool of workers.
  60173. */
  60174. export class WorkerPool implements IDisposable {
  60175. private _workerInfos;
  60176. private _pendingActions;
  60177. /**
  60178. * Constructor
  60179. * @param workers Array of workers to use for actions
  60180. */
  60181. constructor(workers: Array<Worker>);
  60182. /**
  60183. * Terminates all workers and clears any pending actions.
  60184. */
  60185. dispose(): void;
  60186. /**
  60187. * Pushes an action to the worker pool. If all the workers are active, the action will be
  60188. * pended until a worker has completed its action.
  60189. * @param action The action to perform. Call onComplete when the action is complete.
  60190. */
  60191. push(action: (worker: Worker, onComplete: () => void) => void): void;
  60192. private _execute;
  60193. }
  60194. }
  60195. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  60196. import { IDisposable } from "babylonjs/scene";
  60197. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  60198. /**
  60199. * Configuration for Draco compression
  60200. */
  60201. export interface IDracoCompressionConfiguration {
  60202. /**
  60203. * Configuration for the decoder.
  60204. */
  60205. decoder: {
  60206. /**
  60207. * The url to the WebAssembly module.
  60208. */
  60209. wasmUrl?: string;
  60210. /**
  60211. * The url to the WebAssembly binary.
  60212. */
  60213. wasmBinaryUrl?: string;
  60214. /**
  60215. * The url to the fallback JavaScript module.
  60216. */
  60217. fallbackUrl?: string;
  60218. };
  60219. }
  60220. /**
  60221. * Draco compression (https://google.github.io/draco/)
  60222. *
  60223. * This class wraps the Draco module.
  60224. *
  60225. * **Encoder**
  60226. *
  60227. * The encoder is not currently implemented.
  60228. *
  60229. * **Decoder**
  60230. *
  60231. * 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.
  60232. *
  60233. * To update the configuration, use the following code:
  60234. * ```javascript
  60235. * DracoCompression.Configuration = {
  60236. * decoder: {
  60237. * wasmUrl: "<url to the WebAssembly library>",
  60238. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  60239. * fallbackUrl: "<url to the fallback JavaScript library>",
  60240. * }
  60241. * };
  60242. * ```
  60243. *
  60244. * 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.
  60245. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  60246. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  60247. *
  60248. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  60249. * ```javascript
  60250. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  60251. * ```
  60252. *
  60253. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  60254. */
  60255. export class DracoCompression implements IDisposable {
  60256. private _workerPoolPromise?;
  60257. private _decoderModulePromise?;
  60258. /**
  60259. * The configuration. Defaults to the following urls:
  60260. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  60261. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  60262. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  60263. */
  60264. static Configuration: IDracoCompressionConfiguration;
  60265. /**
  60266. * Returns true if the decoder configuration is available.
  60267. */
  60268. static readonly DecoderAvailable: boolean;
  60269. /**
  60270. * Default number of workers to create when creating the draco compression object.
  60271. */
  60272. static DefaultNumWorkers: number;
  60273. private static GetDefaultNumWorkers;
  60274. private static _Default;
  60275. /**
  60276. * Default instance for the draco compression object.
  60277. */
  60278. static readonly Default: DracoCompression;
  60279. /**
  60280. * Constructor
  60281. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  60282. */
  60283. constructor(numWorkers?: number);
  60284. /**
  60285. * Stop all async operations and release resources.
  60286. */
  60287. dispose(): void;
  60288. /**
  60289. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  60290. * @returns a promise that resolves when ready
  60291. */
  60292. whenReadyAsync(): Promise<void>;
  60293. /**
  60294. * Decode Draco compressed mesh data to vertex data.
  60295. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  60296. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  60297. * @returns A promise that resolves with the decoded vertex data
  60298. */
  60299. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  60300. [kind: string]: number;
  60301. }): Promise<VertexData>;
  60302. }
  60303. }
  60304. declare module "babylonjs/Meshes/Compression/index" {
  60305. export * from "babylonjs/Meshes/Compression/dracoCompression";
  60306. }
  60307. declare module "babylonjs/Meshes/csg" {
  60308. import { Nullable } from "babylonjs/types";
  60309. import { Scene } from "babylonjs/scene";
  60310. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  60311. import { Mesh } from "babylonjs/Meshes/mesh";
  60312. import { Material } from "babylonjs/Materials/material";
  60313. /**
  60314. * Class for building Constructive Solid Geometry
  60315. */
  60316. export class CSG {
  60317. private polygons;
  60318. /**
  60319. * The world matrix
  60320. */
  60321. matrix: Matrix;
  60322. /**
  60323. * Stores the position
  60324. */
  60325. position: Vector3;
  60326. /**
  60327. * Stores the rotation
  60328. */
  60329. rotation: Vector3;
  60330. /**
  60331. * Stores the rotation quaternion
  60332. */
  60333. rotationQuaternion: Nullable<Quaternion>;
  60334. /**
  60335. * Stores the scaling vector
  60336. */
  60337. scaling: Vector3;
  60338. /**
  60339. * Convert the Mesh to CSG
  60340. * @param mesh The Mesh to convert to CSG
  60341. * @returns A new CSG from the Mesh
  60342. */
  60343. static FromMesh(mesh: Mesh): CSG;
  60344. /**
  60345. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  60346. * @param polygons Polygons used to construct a CSG solid
  60347. */
  60348. private static FromPolygons;
  60349. /**
  60350. * Clones, or makes a deep copy, of the CSG
  60351. * @returns A new CSG
  60352. */
  60353. clone(): CSG;
  60354. /**
  60355. * Unions this CSG with another CSG
  60356. * @param csg The CSG to union against this CSG
  60357. * @returns The unioned CSG
  60358. */
  60359. union(csg: CSG): CSG;
  60360. /**
  60361. * Unions this CSG with another CSG in place
  60362. * @param csg The CSG to union against this CSG
  60363. */
  60364. unionInPlace(csg: CSG): void;
  60365. /**
  60366. * Subtracts this CSG with another CSG
  60367. * @param csg The CSG to subtract against this CSG
  60368. * @returns A new CSG
  60369. */
  60370. subtract(csg: CSG): CSG;
  60371. /**
  60372. * Subtracts this CSG with another CSG in place
  60373. * @param csg The CSG to subtact against this CSG
  60374. */
  60375. subtractInPlace(csg: CSG): void;
  60376. /**
  60377. * Intersect this CSG with another CSG
  60378. * @param csg The CSG to intersect against this CSG
  60379. * @returns A new CSG
  60380. */
  60381. intersect(csg: CSG): CSG;
  60382. /**
  60383. * Intersects this CSG with another CSG in place
  60384. * @param csg The CSG to intersect against this CSG
  60385. */
  60386. intersectInPlace(csg: CSG): void;
  60387. /**
  60388. * Return a new CSG solid with solid and empty space switched. This solid is
  60389. * not modified.
  60390. * @returns A new CSG solid with solid and empty space switched
  60391. */
  60392. inverse(): CSG;
  60393. /**
  60394. * Inverses the CSG in place
  60395. */
  60396. inverseInPlace(): void;
  60397. /**
  60398. * This is used to keep meshes transformations so they can be restored
  60399. * when we build back a Babylon Mesh
  60400. * NB : All CSG operations are performed in world coordinates
  60401. * @param csg The CSG to copy the transform attributes from
  60402. * @returns This CSG
  60403. */
  60404. copyTransformAttributes(csg: CSG): CSG;
  60405. /**
  60406. * Build Raw mesh from CSG
  60407. * Coordinates here are in world space
  60408. * @param name The name of the mesh geometry
  60409. * @param scene The Scene
  60410. * @param keepSubMeshes Specifies if the submeshes should be kept
  60411. * @returns A new Mesh
  60412. */
  60413. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  60414. /**
  60415. * Build Mesh from CSG taking material and transforms into account
  60416. * @param name The name of the Mesh
  60417. * @param material The material of the Mesh
  60418. * @param scene The Scene
  60419. * @param keepSubMeshes Specifies if submeshes should be kept
  60420. * @returns The new Mesh
  60421. */
  60422. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  60423. }
  60424. }
  60425. declare module "babylonjs/Meshes/trailMesh" {
  60426. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60427. import { Mesh } from "babylonjs/Meshes/mesh";
  60428. import { Scene } from "babylonjs/scene";
  60429. /**
  60430. * Class used to create a trail following a mesh
  60431. */
  60432. export class TrailMesh extends Mesh {
  60433. private _generator;
  60434. private _autoStart;
  60435. private _running;
  60436. private _diameter;
  60437. private _length;
  60438. private _sectionPolygonPointsCount;
  60439. private _sectionVectors;
  60440. private _sectionNormalVectors;
  60441. private _beforeRenderObserver;
  60442. /**
  60443. * @constructor
  60444. * @param name The value used by scene.getMeshByName() to do a lookup.
  60445. * @param generator The mesh to generate a trail.
  60446. * @param scene The scene to add this mesh to.
  60447. * @param diameter Diameter of trailing mesh. Default is 1.
  60448. * @param length Length of trailing mesh. Default is 60.
  60449. * @param autoStart Automatically start trailing mesh. Default true.
  60450. */
  60451. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  60452. /**
  60453. * "TrailMesh"
  60454. * @returns "TrailMesh"
  60455. */
  60456. getClassName(): string;
  60457. private _createMesh;
  60458. /**
  60459. * Start trailing mesh.
  60460. */
  60461. start(): void;
  60462. /**
  60463. * Stop trailing mesh.
  60464. */
  60465. stop(): void;
  60466. /**
  60467. * Update trailing mesh geometry.
  60468. */
  60469. update(): void;
  60470. /**
  60471. * Returns a new TrailMesh object.
  60472. * @param name is a string, the name given to the new mesh
  60473. * @param newGenerator use new generator object for cloned trail mesh
  60474. * @returns a new mesh
  60475. */
  60476. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  60477. /**
  60478. * Serializes this trail mesh
  60479. * @param serializationObject object to write serialization to
  60480. */
  60481. serialize(serializationObject: any): void;
  60482. /**
  60483. * Parses a serialized trail mesh
  60484. * @param parsedMesh the serialized mesh
  60485. * @param scene the scene to create the trail mesh in
  60486. * @returns the created trail mesh
  60487. */
  60488. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  60489. }
  60490. }
  60491. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  60492. import { Nullable } from "babylonjs/types";
  60493. import { Scene } from "babylonjs/scene";
  60494. import { Vector4 } from "babylonjs/Maths/math.vector";
  60495. import { Color4 } from "babylonjs/Maths/math.color";
  60496. import { Mesh } from "babylonjs/Meshes/mesh";
  60497. /**
  60498. * Class containing static functions to help procedurally build meshes
  60499. */
  60500. export class TiledBoxBuilder {
  60501. /**
  60502. * Creates a box mesh
  60503. * 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)
  60504. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60505. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60506. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60507. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60508. * @param name defines the name of the mesh
  60509. * @param options defines the options used to create the mesh
  60510. * @param scene defines the hosting scene
  60511. * @returns the box mesh
  60512. */
  60513. static CreateTiledBox(name: string, options: {
  60514. pattern?: number;
  60515. width?: number;
  60516. height?: number;
  60517. depth?: number;
  60518. tileSize?: number;
  60519. tileWidth?: number;
  60520. tileHeight?: number;
  60521. alignHorizontal?: number;
  60522. alignVertical?: number;
  60523. faceUV?: Vector4[];
  60524. faceColors?: Color4[];
  60525. sideOrientation?: number;
  60526. updatable?: boolean;
  60527. }, scene?: Nullable<Scene>): Mesh;
  60528. }
  60529. }
  60530. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  60531. import { Vector4 } from "babylonjs/Maths/math.vector";
  60532. import { Mesh } from "babylonjs/Meshes/mesh";
  60533. /**
  60534. * Class containing static functions to help procedurally build meshes
  60535. */
  60536. export class TorusKnotBuilder {
  60537. /**
  60538. * Creates a torus knot mesh
  60539. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  60540. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  60541. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  60542. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  60543. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60544. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60545. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60546. * @param name defines the name of the mesh
  60547. * @param options defines the options used to create the mesh
  60548. * @param scene defines the hosting scene
  60549. * @returns the torus knot mesh
  60550. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  60551. */
  60552. static CreateTorusKnot(name: string, options: {
  60553. radius?: number;
  60554. tube?: number;
  60555. radialSegments?: number;
  60556. tubularSegments?: number;
  60557. p?: number;
  60558. q?: number;
  60559. updatable?: boolean;
  60560. sideOrientation?: number;
  60561. frontUVs?: Vector4;
  60562. backUVs?: Vector4;
  60563. }, scene: any): Mesh;
  60564. }
  60565. }
  60566. declare module "babylonjs/Meshes/polygonMesh" {
  60567. import { Scene } from "babylonjs/scene";
  60568. import { Vector2 } from "babylonjs/Maths/math.vector";
  60569. import { Mesh } from "babylonjs/Meshes/mesh";
  60570. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  60571. import { Path2 } from "babylonjs/Maths/math.path";
  60572. /**
  60573. * Polygon
  60574. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  60575. */
  60576. export class Polygon {
  60577. /**
  60578. * Creates a rectangle
  60579. * @param xmin bottom X coord
  60580. * @param ymin bottom Y coord
  60581. * @param xmax top X coord
  60582. * @param ymax top Y coord
  60583. * @returns points that make the resulting rectation
  60584. */
  60585. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  60586. /**
  60587. * Creates a circle
  60588. * @param radius radius of circle
  60589. * @param cx scale in x
  60590. * @param cy scale in y
  60591. * @param numberOfSides number of sides that make up the circle
  60592. * @returns points that make the resulting circle
  60593. */
  60594. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  60595. /**
  60596. * Creates a polygon from input string
  60597. * @param input Input polygon data
  60598. * @returns the parsed points
  60599. */
  60600. static Parse(input: string): Vector2[];
  60601. /**
  60602. * Starts building a polygon from x and y coordinates
  60603. * @param x x coordinate
  60604. * @param y y coordinate
  60605. * @returns the started path2
  60606. */
  60607. static StartingAt(x: number, y: number): Path2;
  60608. }
  60609. /**
  60610. * Builds a polygon
  60611. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  60612. */
  60613. export class PolygonMeshBuilder {
  60614. private _points;
  60615. private _outlinepoints;
  60616. private _holes;
  60617. private _name;
  60618. private _scene;
  60619. private _epoints;
  60620. private _eholes;
  60621. private _addToepoint;
  60622. /**
  60623. * Babylon reference to the earcut plugin.
  60624. */
  60625. bjsEarcut: any;
  60626. /**
  60627. * Creates a PolygonMeshBuilder
  60628. * @param name name of the builder
  60629. * @param contours Path of the polygon
  60630. * @param scene scene to add to when creating the mesh
  60631. * @param earcutInjection can be used to inject your own earcut reference
  60632. */
  60633. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  60634. /**
  60635. * Adds a whole within the polygon
  60636. * @param hole Array of points defining the hole
  60637. * @returns this
  60638. */
  60639. addHole(hole: Vector2[]): PolygonMeshBuilder;
  60640. /**
  60641. * Creates the polygon
  60642. * @param updatable If the mesh should be updatable
  60643. * @param depth The depth of the mesh created
  60644. * @returns the created mesh
  60645. */
  60646. build(updatable?: boolean, depth?: number): Mesh;
  60647. /**
  60648. * Creates the polygon
  60649. * @param depth The depth of the mesh created
  60650. * @returns the created VertexData
  60651. */
  60652. buildVertexData(depth?: number): VertexData;
  60653. /**
  60654. * Adds a side to the polygon
  60655. * @param positions points that make the polygon
  60656. * @param normals normals of the polygon
  60657. * @param uvs uvs of the polygon
  60658. * @param indices indices of the polygon
  60659. * @param bounds bounds of the polygon
  60660. * @param points points of the polygon
  60661. * @param depth depth of the polygon
  60662. * @param flip flip of the polygon
  60663. */
  60664. private addSide;
  60665. }
  60666. }
  60667. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  60668. import { Scene } from "babylonjs/scene";
  60669. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  60670. import { Color4 } from "babylonjs/Maths/math.color";
  60671. import { Mesh } from "babylonjs/Meshes/mesh";
  60672. import { Nullable } from "babylonjs/types";
  60673. /**
  60674. * Class containing static functions to help procedurally build meshes
  60675. */
  60676. export class PolygonBuilder {
  60677. /**
  60678. * Creates a polygon mesh
  60679. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  60680. * * 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
  60681. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60682. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60683. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  60684. * * Remember you can only change the shape positions, not their number when updating a polygon
  60685. * @param name defines the name of the mesh
  60686. * @param options defines the options used to create the mesh
  60687. * @param scene defines the hosting scene
  60688. * @param earcutInjection can be used to inject your own earcut reference
  60689. * @returns the polygon mesh
  60690. */
  60691. static CreatePolygon(name: string, options: {
  60692. shape: Vector3[];
  60693. holes?: Vector3[][];
  60694. depth?: number;
  60695. faceUV?: Vector4[];
  60696. faceColors?: Color4[];
  60697. updatable?: boolean;
  60698. sideOrientation?: number;
  60699. frontUVs?: Vector4;
  60700. backUVs?: Vector4;
  60701. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60702. /**
  60703. * Creates an extruded polygon mesh, with depth in the Y direction.
  60704. * * 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)
  60705. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60706. * @param name defines the name of the mesh
  60707. * @param options defines the options used to create the mesh
  60708. * @param scene defines the hosting scene
  60709. * @param earcutInjection can be used to inject your own earcut reference
  60710. * @returns the polygon mesh
  60711. */
  60712. static ExtrudePolygon(name: string, options: {
  60713. shape: Vector3[];
  60714. holes?: Vector3[][];
  60715. depth?: number;
  60716. faceUV?: Vector4[];
  60717. faceColors?: Color4[];
  60718. updatable?: boolean;
  60719. sideOrientation?: number;
  60720. frontUVs?: Vector4;
  60721. backUVs?: Vector4;
  60722. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60723. }
  60724. }
  60725. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  60726. import { Scene } from "babylonjs/scene";
  60727. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  60728. import { Mesh } from "babylonjs/Meshes/mesh";
  60729. import { Nullable } from "babylonjs/types";
  60730. /**
  60731. * Class containing static functions to help procedurally build meshes
  60732. */
  60733. export class LatheBuilder {
  60734. /**
  60735. * Creates lathe mesh.
  60736. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  60737. * * 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
  60738. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  60739. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  60740. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  60741. * * 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
  60742. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  60743. * * 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
  60744. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60745. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60746. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60747. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60748. * @param name defines the name of the mesh
  60749. * @param options defines the options used to create the mesh
  60750. * @param scene defines the hosting scene
  60751. * @returns the lathe mesh
  60752. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  60753. */
  60754. static CreateLathe(name: string, options: {
  60755. shape: Vector3[];
  60756. radius?: number;
  60757. tessellation?: number;
  60758. clip?: number;
  60759. arc?: number;
  60760. closed?: boolean;
  60761. updatable?: boolean;
  60762. sideOrientation?: number;
  60763. frontUVs?: Vector4;
  60764. backUVs?: Vector4;
  60765. cap?: number;
  60766. invertUV?: boolean;
  60767. }, scene?: Nullable<Scene>): Mesh;
  60768. }
  60769. }
  60770. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  60771. import { Nullable } from "babylonjs/types";
  60772. import { Scene } from "babylonjs/scene";
  60773. import { Vector4 } from "babylonjs/Maths/math.vector";
  60774. import { Mesh } from "babylonjs/Meshes/mesh";
  60775. /**
  60776. * Class containing static functions to help procedurally build meshes
  60777. */
  60778. export class TiledPlaneBuilder {
  60779. /**
  60780. * Creates a tiled plane mesh
  60781. * * The parameter `pattern` will, depending on value, do nothing or
  60782. * * * flip (reflect about central vertical) alternate tiles across and up
  60783. * * * flip every tile on alternate rows
  60784. * * * rotate (180 degs) alternate tiles across and up
  60785. * * * rotate every tile on alternate rows
  60786. * * * flip and rotate alternate tiles across and up
  60787. * * * flip and rotate every tile on alternate rows
  60788. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  60789. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  60790. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60791. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60792. * * 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)
  60793. * * 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)
  60794. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  60795. * @param name defines the name of the mesh
  60796. * @param options defines the options used to create the mesh
  60797. * @param scene defines the hosting scene
  60798. * @returns the box mesh
  60799. */
  60800. static CreateTiledPlane(name: string, options: {
  60801. pattern?: number;
  60802. tileSize?: number;
  60803. tileWidth?: number;
  60804. tileHeight?: number;
  60805. size?: number;
  60806. width?: number;
  60807. height?: number;
  60808. alignHorizontal?: number;
  60809. alignVertical?: number;
  60810. sideOrientation?: number;
  60811. frontUVs?: Vector4;
  60812. backUVs?: Vector4;
  60813. updatable?: boolean;
  60814. }, scene?: Nullable<Scene>): Mesh;
  60815. }
  60816. }
  60817. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  60818. import { Nullable } from "babylonjs/types";
  60819. import { Scene } from "babylonjs/scene";
  60820. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  60821. import { Mesh } from "babylonjs/Meshes/mesh";
  60822. /**
  60823. * Class containing static functions to help procedurally build meshes
  60824. */
  60825. export class TubeBuilder {
  60826. /**
  60827. * Creates a tube mesh.
  60828. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60829. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  60830. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  60831. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  60832. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  60833. * * 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)
  60834. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  60835. * * 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
  60836. * * 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
  60837. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60838. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60839. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60840. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60841. * @param name defines the name of the mesh
  60842. * @param options defines the options used to create the mesh
  60843. * @param scene defines the hosting scene
  60844. * @returns the tube mesh
  60845. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60846. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  60847. */
  60848. static CreateTube(name: string, options: {
  60849. path: Vector3[];
  60850. radius?: number;
  60851. tessellation?: number;
  60852. radiusFunction?: {
  60853. (i: number, distance: number): number;
  60854. };
  60855. cap?: number;
  60856. arc?: number;
  60857. updatable?: boolean;
  60858. sideOrientation?: number;
  60859. frontUVs?: Vector4;
  60860. backUVs?: Vector4;
  60861. instance?: Mesh;
  60862. invertUV?: boolean;
  60863. }, scene?: Nullable<Scene>): Mesh;
  60864. }
  60865. }
  60866. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  60867. import { Scene } from "babylonjs/scene";
  60868. import { Vector4 } from "babylonjs/Maths/math.vector";
  60869. import { Mesh } from "babylonjs/Meshes/mesh";
  60870. import { Nullable } from "babylonjs/types";
  60871. /**
  60872. * Class containing static functions to help procedurally build meshes
  60873. */
  60874. export class IcoSphereBuilder {
  60875. /**
  60876. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  60877. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  60878. * * 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`)
  60879. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  60880. * * 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
  60881. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60882. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60883. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60884. * @param name defines the name of the mesh
  60885. * @param options defines the options used to create the mesh
  60886. * @param scene defines the hosting scene
  60887. * @returns the icosahedron mesh
  60888. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  60889. */
  60890. static CreateIcoSphere(name: string, options: {
  60891. radius?: number;
  60892. radiusX?: number;
  60893. radiusY?: number;
  60894. radiusZ?: number;
  60895. flat?: boolean;
  60896. subdivisions?: number;
  60897. sideOrientation?: number;
  60898. frontUVs?: Vector4;
  60899. backUVs?: Vector4;
  60900. updatable?: boolean;
  60901. }, scene?: Nullable<Scene>): Mesh;
  60902. }
  60903. }
  60904. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  60905. import { Vector3 } from "babylonjs/Maths/math.vector";
  60906. import { Mesh } from "babylonjs/Meshes/mesh";
  60907. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60908. /**
  60909. * Class containing static functions to help procedurally build meshes
  60910. */
  60911. export class DecalBuilder {
  60912. /**
  60913. * Creates a decal mesh.
  60914. * 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
  60915. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  60916. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  60917. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  60918. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  60919. * @param name defines the name of the mesh
  60920. * @param sourceMesh defines the mesh where the decal must be applied
  60921. * @param options defines the options used to create the mesh
  60922. * @param scene defines the hosting scene
  60923. * @returns the decal mesh
  60924. * @see https://doc.babylonjs.com/how_to/decals
  60925. */
  60926. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  60927. position?: Vector3;
  60928. normal?: Vector3;
  60929. size?: Vector3;
  60930. angle?: number;
  60931. }): Mesh;
  60932. }
  60933. }
  60934. declare module "babylonjs/Meshes/meshBuilder" {
  60935. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  60936. import { Nullable } from "babylonjs/types";
  60937. import { Scene } from "babylonjs/scene";
  60938. import { Mesh } from "babylonjs/Meshes/mesh";
  60939. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  60940. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  60941. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60942. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  60943. import { Plane } from "babylonjs/Maths/math.plane";
  60944. /**
  60945. * Class containing static functions to help procedurally build meshes
  60946. */
  60947. export class MeshBuilder {
  60948. /**
  60949. * Creates a box mesh
  60950. * * The parameter `size` sets the size (float) of each box side (default 1)
  60951. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  60952. * * 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)
  60953. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60954. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60955. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60956. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60957. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  60958. * @param name defines the name of the mesh
  60959. * @param options defines the options used to create the mesh
  60960. * @param scene defines the hosting scene
  60961. * @returns the box mesh
  60962. */
  60963. static CreateBox(name: string, options: {
  60964. size?: number;
  60965. width?: number;
  60966. height?: number;
  60967. depth?: number;
  60968. faceUV?: Vector4[];
  60969. faceColors?: Color4[];
  60970. sideOrientation?: number;
  60971. frontUVs?: Vector4;
  60972. backUVs?: Vector4;
  60973. updatable?: boolean;
  60974. }, scene?: Nullable<Scene>): Mesh;
  60975. /**
  60976. * Creates a tiled box mesh
  60977. * * faceTiles sets the pattern, tile size and number of tiles for a face
  60978. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60979. * @param name defines the name of the mesh
  60980. * @param options defines the options used to create the mesh
  60981. * @param scene defines the hosting scene
  60982. * @returns the tiled box mesh
  60983. */
  60984. static CreateTiledBox(name: string, options: {
  60985. pattern?: number;
  60986. size?: number;
  60987. width?: number;
  60988. height?: number;
  60989. depth: number;
  60990. tileSize?: number;
  60991. tileWidth?: number;
  60992. tileHeight?: number;
  60993. faceUV?: Vector4[];
  60994. faceColors?: Color4[];
  60995. alignHorizontal?: number;
  60996. alignVertical?: number;
  60997. sideOrientation?: number;
  60998. updatable?: boolean;
  60999. }, scene?: Nullable<Scene>): Mesh;
  61000. /**
  61001. * Creates a sphere mesh
  61002. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  61003. * * 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`)
  61004. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  61005. * * 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
  61006. * * 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)
  61007. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61008. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61009. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61010. * @param name defines the name of the mesh
  61011. * @param options defines the options used to create the mesh
  61012. * @param scene defines the hosting scene
  61013. * @returns the sphere mesh
  61014. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  61015. */
  61016. static CreateSphere(name: string, options: {
  61017. segments?: number;
  61018. diameter?: number;
  61019. diameterX?: number;
  61020. diameterY?: number;
  61021. diameterZ?: number;
  61022. arc?: number;
  61023. slice?: number;
  61024. sideOrientation?: number;
  61025. frontUVs?: Vector4;
  61026. backUVs?: Vector4;
  61027. updatable?: boolean;
  61028. }, scene?: Nullable<Scene>): Mesh;
  61029. /**
  61030. * Creates a plane polygonal mesh. By default, this is a disc
  61031. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  61032. * * 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
  61033. * * 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
  61034. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61035. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61036. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61037. * @param name defines the name of the mesh
  61038. * @param options defines the options used to create the mesh
  61039. * @param scene defines the hosting scene
  61040. * @returns the plane polygonal mesh
  61041. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  61042. */
  61043. static CreateDisc(name: string, options: {
  61044. radius?: number;
  61045. tessellation?: number;
  61046. arc?: number;
  61047. updatable?: boolean;
  61048. sideOrientation?: number;
  61049. frontUVs?: Vector4;
  61050. backUVs?: Vector4;
  61051. }, scene?: Nullable<Scene>): Mesh;
  61052. /**
  61053. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  61054. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  61055. * * 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`)
  61056. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  61057. * * 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
  61058. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61059. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61060. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61061. * @param name defines the name of the mesh
  61062. * @param options defines the options used to create the mesh
  61063. * @param scene defines the hosting scene
  61064. * @returns the icosahedron mesh
  61065. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  61066. */
  61067. static CreateIcoSphere(name: string, options: {
  61068. radius?: number;
  61069. radiusX?: number;
  61070. radiusY?: number;
  61071. radiusZ?: number;
  61072. flat?: boolean;
  61073. subdivisions?: number;
  61074. sideOrientation?: number;
  61075. frontUVs?: Vector4;
  61076. backUVs?: Vector4;
  61077. updatable?: boolean;
  61078. }, scene?: Nullable<Scene>): Mesh;
  61079. /**
  61080. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61081. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  61082. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  61083. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  61084. * * 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
  61085. * * 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
  61086. * * 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
  61087. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61088. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61089. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61090. * * 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
  61091. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  61092. * * 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
  61093. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  61094. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61095. * @param name defines the name of the mesh
  61096. * @param options defines the options used to create the mesh
  61097. * @param scene defines the hosting scene
  61098. * @returns the ribbon mesh
  61099. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  61100. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61101. */
  61102. static CreateRibbon(name: string, options: {
  61103. pathArray: Vector3[][];
  61104. closeArray?: boolean;
  61105. closePath?: boolean;
  61106. offset?: number;
  61107. updatable?: boolean;
  61108. sideOrientation?: number;
  61109. frontUVs?: Vector4;
  61110. backUVs?: Vector4;
  61111. instance?: Mesh;
  61112. invertUV?: boolean;
  61113. uvs?: Vector2[];
  61114. colors?: Color4[];
  61115. }, scene?: Nullable<Scene>): Mesh;
  61116. /**
  61117. * Creates a cylinder or a cone mesh
  61118. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  61119. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  61120. * * 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.
  61121. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  61122. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  61123. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  61124. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  61125. * * 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).
  61126. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  61127. * * 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).
  61128. * * 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
  61129. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  61130. * * 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
  61131. * * 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.
  61132. * * If `enclose` is false, a ring surface is one element.
  61133. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  61134. * * 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
  61135. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61136. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61137. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61138. * @param name defines the name of the mesh
  61139. * @param options defines the options used to create the mesh
  61140. * @param scene defines the hosting scene
  61141. * @returns the cylinder mesh
  61142. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  61143. */
  61144. static CreateCylinder(name: string, options: {
  61145. height?: number;
  61146. diameterTop?: number;
  61147. diameterBottom?: number;
  61148. diameter?: number;
  61149. tessellation?: number;
  61150. subdivisions?: number;
  61151. arc?: number;
  61152. faceColors?: Color4[];
  61153. faceUV?: Vector4[];
  61154. updatable?: boolean;
  61155. hasRings?: boolean;
  61156. enclose?: boolean;
  61157. cap?: number;
  61158. sideOrientation?: number;
  61159. frontUVs?: Vector4;
  61160. backUVs?: Vector4;
  61161. }, scene?: Nullable<Scene>): Mesh;
  61162. /**
  61163. * Creates a torus mesh
  61164. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  61165. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  61166. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  61167. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61168. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61169. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61170. * @param name defines the name of the mesh
  61171. * @param options defines the options used to create the mesh
  61172. * @param scene defines the hosting scene
  61173. * @returns the torus mesh
  61174. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  61175. */
  61176. static CreateTorus(name: string, options: {
  61177. diameter?: number;
  61178. thickness?: number;
  61179. tessellation?: number;
  61180. updatable?: boolean;
  61181. sideOrientation?: number;
  61182. frontUVs?: Vector4;
  61183. backUVs?: Vector4;
  61184. }, scene?: Nullable<Scene>): Mesh;
  61185. /**
  61186. * Creates a torus knot mesh
  61187. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  61188. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  61189. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  61190. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  61191. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61192. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61193. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61194. * @param name defines the name of the mesh
  61195. * @param options defines the options used to create the mesh
  61196. * @param scene defines the hosting scene
  61197. * @returns the torus knot mesh
  61198. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  61199. */
  61200. static CreateTorusKnot(name: string, options: {
  61201. radius?: number;
  61202. tube?: number;
  61203. radialSegments?: number;
  61204. tubularSegments?: number;
  61205. p?: number;
  61206. q?: number;
  61207. updatable?: boolean;
  61208. sideOrientation?: number;
  61209. frontUVs?: Vector4;
  61210. backUVs?: Vector4;
  61211. }, scene?: Nullable<Scene>): Mesh;
  61212. /**
  61213. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  61214. * * 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
  61215. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  61216. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  61217. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  61218. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  61219. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  61220. * * 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
  61221. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  61222. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61223. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  61224. * @param name defines the name of the new line system
  61225. * @param options defines the options used to create the line system
  61226. * @param scene defines the hosting scene
  61227. * @returns a new line system mesh
  61228. */
  61229. static CreateLineSystem(name: string, options: {
  61230. lines: Vector3[][];
  61231. updatable?: boolean;
  61232. instance?: Nullable<LinesMesh>;
  61233. colors?: Nullable<Color4[][]>;
  61234. useVertexAlpha?: boolean;
  61235. }, scene: Nullable<Scene>): LinesMesh;
  61236. /**
  61237. * Creates a line mesh
  61238. * 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
  61239. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61240. * * The parameter `points` is an array successive Vector3
  61241. * * 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
  61242. * * The optional parameter `colors` is an array of successive Color4, one per line point
  61243. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  61244. * * When updating an instance, remember that only point positions can change, not the number of points
  61245. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61246. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  61247. * @param name defines the name of the new line system
  61248. * @param options defines the options used to create the line system
  61249. * @param scene defines the hosting scene
  61250. * @returns a new line mesh
  61251. */
  61252. static CreateLines(name: string, options: {
  61253. points: Vector3[];
  61254. updatable?: boolean;
  61255. instance?: Nullable<LinesMesh>;
  61256. colors?: Color4[];
  61257. useVertexAlpha?: boolean;
  61258. }, scene?: Nullable<Scene>): LinesMesh;
  61259. /**
  61260. * Creates a dashed line mesh
  61261. * * 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
  61262. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61263. * * The parameter `points` is an array successive Vector3
  61264. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  61265. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  61266. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  61267. * * 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
  61268. * * When updating an instance, remember that only point positions can change, not the number of points
  61269. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61270. * @param name defines the name of the mesh
  61271. * @param options defines the options used to create the mesh
  61272. * @param scene defines the hosting scene
  61273. * @returns the dashed line mesh
  61274. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  61275. */
  61276. static CreateDashedLines(name: string, options: {
  61277. points: Vector3[];
  61278. dashSize?: number;
  61279. gapSize?: number;
  61280. dashNb?: number;
  61281. updatable?: boolean;
  61282. instance?: LinesMesh;
  61283. }, scene?: Nullable<Scene>): LinesMesh;
  61284. /**
  61285. * 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.
  61286. * * 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.
  61287. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61288. * * 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.
  61289. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  61290. * * 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
  61291. * * 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
  61292. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  61293. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61294. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61295. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  61296. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61297. * @param name defines the name of the mesh
  61298. * @param options defines the options used to create the mesh
  61299. * @param scene defines the hosting scene
  61300. * @returns the extruded shape mesh
  61301. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61302. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61303. */
  61304. static ExtrudeShape(name: string, options: {
  61305. shape: Vector3[];
  61306. path: Vector3[];
  61307. scale?: number;
  61308. rotation?: number;
  61309. cap?: number;
  61310. updatable?: boolean;
  61311. sideOrientation?: number;
  61312. frontUVs?: Vector4;
  61313. backUVs?: Vector4;
  61314. instance?: Mesh;
  61315. invertUV?: boolean;
  61316. }, scene?: Nullable<Scene>): Mesh;
  61317. /**
  61318. * Creates an custom extruded shape mesh.
  61319. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  61320. * * 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.
  61321. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61322. * * 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
  61323. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  61324. * * 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
  61325. * * It must returns a float value that will be the scale value applied to the shape on each path point
  61326. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  61327. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  61328. * * 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
  61329. * * 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
  61330. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  61331. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61332. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61333. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61334. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61335. * @param name defines the name of the mesh
  61336. * @param options defines the options used to create the mesh
  61337. * @param scene defines the hosting scene
  61338. * @returns the custom extruded shape mesh
  61339. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  61340. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61341. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61342. */
  61343. static ExtrudeShapeCustom(name: string, options: {
  61344. shape: Vector3[];
  61345. path: Vector3[];
  61346. scaleFunction?: any;
  61347. rotationFunction?: any;
  61348. ribbonCloseArray?: boolean;
  61349. ribbonClosePath?: boolean;
  61350. cap?: number;
  61351. updatable?: boolean;
  61352. sideOrientation?: number;
  61353. frontUVs?: Vector4;
  61354. backUVs?: Vector4;
  61355. instance?: Mesh;
  61356. invertUV?: boolean;
  61357. }, scene?: Nullable<Scene>): Mesh;
  61358. /**
  61359. * Creates lathe mesh.
  61360. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  61361. * * 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
  61362. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  61363. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  61364. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  61365. * * 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
  61366. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  61367. * * 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
  61368. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61369. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61370. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61371. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61372. * @param name defines the name of the mesh
  61373. * @param options defines the options used to create the mesh
  61374. * @param scene defines the hosting scene
  61375. * @returns the lathe mesh
  61376. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  61377. */
  61378. static CreateLathe(name: string, options: {
  61379. shape: Vector3[];
  61380. radius?: number;
  61381. tessellation?: number;
  61382. clip?: number;
  61383. arc?: number;
  61384. closed?: boolean;
  61385. updatable?: boolean;
  61386. sideOrientation?: number;
  61387. frontUVs?: Vector4;
  61388. backUVs?: Vector4;
  61389. cap?: number;
  61390. invertUV?: boolean;
  61391. }, scene?: Nullable<Scene>): Mesh;
  61392. /**
  61393. * Creates a tiled plane mesh
  61394. * * You can set a limited pattern arrangement with the tiles
  61395. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61396. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61397. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61398. * @param name defines the name of the mesh
  61399. * @param options defines the options used to create the mesh
  61400. * @param scene defines the hosting scene
  61401. * @returns the plane mesh
  61402. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  61403. */
  61404. static CreateTiledPlane(name: string, options: {
  61405. pattern?: number;
  61406. tileSize?: number;
  61407. tileWidth?: number;
  61408. tileHeight?: number;
  61409. size?: number;
  61410. width?: number;
  61411. height?: number;
  61412. alignHorizontal?: number;
  61413. alignVertical?: number;
  61414. sideOrientation?: number;
  61415. frontUVs?: Vector4;
  61416. backUVs?: Vector4;
  61417. updatable?: boolean;
  61418. }, scene?: Nullable<Scene>): Mesh;
  61419. /**
  61420. * Creates a plane mesh
  61421. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  61422. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  61423. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  61424. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61425. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61426. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61427. * @param name defines the name of the mesh
  61428. * @param options defines the options used to create the mesh
  61429. * @param scene defines the hosting scene
  61430. * @returns the plane mesh
  61431. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  61432. */
  61433. static CreatePlane(name: string, options: {
  61434. size?: number;
  61435. width?: number;
  61436. height?: number;
  61437. sideOrientation?: number;
  61438. frontUVs?: Vector4;
  61439. backUVs?: Vector4;
  61440. updatable?: boolean;
  61441. sourcePlane?: Plane;
  61442. }, scene?: Nullable<Scene>): Mesh;
  61443. /**
  61444. * Creates a ground mesh
  61445. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  61446. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  61447. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61448. * @param name defines the name of the mesh
  61449. * @param options defines the options used to create the mesh
  61450. * @param scene defines the hosting scene
  61451. * @returns the ground mesh
  61452. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  61453. */
  61454. static CreateGround(name: string, options: {
  61455. width?: number;
  61456. height?: number;
  61457. subdivisions?: number;
  61458. subdivisionsX?: number;
  61459. subdivisionsY?: number;
  61460. updatable?: boolean;
  61461. }, scene?: Nullable<Scene>): Mesh;
  61462. /**
  61463. * Creates a tiled ground mesh
  61464. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  61465. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  61466. * * 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
  61467. * * 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
  61468. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61469. * @param name defines the name of the mesh
  61470. * @param options defines the options used to create the mesh
  61471. * @param scene defines the hosting scene
  61472. * @returns the tiled ground mesh
  61473. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  61474. */
  61475. static CreateTiledGround(name: string, options: {
  61476. xmin: number;
  61477. zmin: number;
  61478. xmax: number;
  61479. zmax: number;
  61480. subdivisions?: {
  61481. w: number;
  61482. h: number;
  61483. };
  61484. precision?: {
  61485. w: number;
  61486. h: number;
  61487. };
  61488. updatable?: boolean;
  61489. }, scene?: Nullable<Scene>): Mesh;
  61490. /**
  61491. * Creates a ground mesh from a height map
  61492. * * The parameter `url` sets the URL of the height map image resource.
  61493. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  61494. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  61495. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  61496. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  61497. * * 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.
  61498. * * 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).
  61499. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  61500. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61501. * @param name defines the name of the mesh
  61502. * @param url defines the url to the height map
  61503. * @param options defines the options used to create the mesh
  61504. * @param scene defines the hosting scene
  61505. * @returns the ground mesh
  61506. * @see https://doc.babylonjs.com/babylon101/height_map
  61507. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  61508. */
  61509. static CreateGroundFromHeightMap(name: string, url: string, options: {
  61510. width?: number;
  61511. height?: number;
  61512. subdivisions?: number;
  61513. minHeight?: number;
  61514. maxHeight?: number;
  61515. colorFilter?: Color3;
  61516. alphaFilter?: number;
  61517. updatable?: boolean;
  61518. onReady?: (mesh: GroundMesh) => void;
  61519. }, scene?: Nullable<Scene>): GroundMesh;
  61520. /**
  61521. * Creates a polygon mesh
  61522. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  61523. * * 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
  61524. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61525. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61526. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  61527. * * Remember you can only change the shape positions, not their number when updating a polygon
  61528. * @param name defines the name of the mesh
  61529. * @param options defines the options used to create the mesh
  61530. * @param scene defines the hosting scene
  61531. * @param earcutInjection can be used to inject your own earcut reference
  61532. * @returns the polygon mesh
  61533. */
  61534. static CreatePolygon(name: string, options: {
  61535. shape: Vector3[];
  61536. holes?: Vector3[][];
  61537. depth?: number;
  61538. faceUV?: Vector4[];
  61539. faceColors?: Color4[];
  61540. updatable?: boolean;
  61541. sideOrientation?: number;
  61542. frontUVs?: Vector4;
  61543. backUVs?: Vector4;
  61544. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61545. /**
  61546. * Creates an extruded polygon mesh, with depth in the Y direction.
  61547. * * 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)
  61548. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61549. * @param name defines the name of the mesh
  61550. * @param options defines the options used to create the mesh
  61551. * @param scene defines the hosting scene
  61552. * @param earcutInjection can be used to inject your own earcut reference
  61553. * @returns the polygon mesh
  61554. */
  61555. static ExtrudePolygon(name: string, options: {
  61556. shape: Vector3[];
  61557. holes?: Vector3[][];
  61558. depth?: number;
  61559. faceUV?: Vector4[];
  61560. faceColors?: Color4[];
  61561. updatable?: boolean;
  61562. sideOrientation?: number;
  61563. frontUVs?: Vector4;
  61564. backUVs?: Vector4;
  61565. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61566. /**
  61567. * Creates a tube mesh.
  61568. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61569. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  61570. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  61571. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  61572. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  61573. * * 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)
  61574. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  61575. * * 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
  61576. * * 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
  61577. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61578. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61579. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61580. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61581. * @param name defines the name of the mesh
  61582. * @param options defines the options used to create the mesh
  61583. * @param scene defines the hosting scene
  61584. * @returns the tube mesh
  61585. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61586. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  61587. */
  61588. static CreateTube(name: string, options: {
  61589. path: Vector3[];
  61590. radius?: number;
  61591. tessellation?: number;
  61592. radiusFunction?: {
  61593. (i: number, distance: number): number;
  61594. };
  61595. cap?: number;
  61596. arc?: number;
  61597. updatable?: boolean;
  61598. sideOrientation?: number;
  61599. frontUVs?: Vector4;
  61600. backUVs?: Vector4;
  61601. instance?: Mesh;
  61602. invertUV?: boolean;
  61603. }, scene?: Nullable<Scene>): Mesh;
  61604. /**
  61605. * Creates a polyhedron mesh
  61606. * * 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
  61607. * * The parameter `size` (positive float, default 1) sets the polygon size
  61608. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  61609. * * 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`
  61610. * * 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
  61611. * * 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)`)
  61612. * * 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
  61613. * * 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
  61614. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61615. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61616. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61617. * @param name defines the name of the mesh
  61618. * @param options defines the options used to create the mesh
  61619. * @param scene defines the hosting scene
  61620. * @returns the polyhedron mesh
  61621. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  61622. */
  61623. static CreatePolyhedron(name: string, options: {
  61624. type?: number;
  61625. size?: number;
  61626. sizeX?: number;
  61627. sizeY?: number;
  61628. sizeZ?: number;
  61629. custom?: any;
  61630. faceUV?: Vector4[];
  61631. faceColors?: Color4[];
  61632. flat?: boolean;
  61633. updatable?: boolean;
  61634. sideOrientation?: number;
  61635. frontUVs?: Vector4;
  61636. backUVs?: Vector4;
  61637. }, scene?: Nullable<Scene>): Mesh;
  61638. /**
  61639. * Creates a decal mesh.
  61640. * 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
  61641. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  61642. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  61643. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  61644. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  61645. * @param name defines the name of the mesh
  61646. * @param sourceMesh defines the mesh where the decal must be applied
  61647. * @param options defines the options used to create the mesh
  61648. * @param scene defines the hosting scene
  61649. * @returns the decal mesh
  61650. * @see https://doc.babylonjs.com/how_to/decals
  61651. */
  61652. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  61653. position?: Vector3;
  61654. normal?: Vector3;
  61655. size?: Vector3;
  61656. angle?: number;
  61657. }): Mesh;
  61658. }
  61659. }
  61660. declare module "babylonjs/Meshes/meshSimplification" {
  61661. import { Mesh } from "babylonjs/Meshes/mesh";
  61662. /**
  61663. * A simplifier interface for future simplification implementations
  61664. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61665. */
  61666. export interface ISimplifier {
  61667. /**
  61668. * Simplification of a given mesh according to the given settings.
  61669. * Since this requires computation, it is assumed that the function runs async.
  61670. * @param settings The settings of the simplification, including quality and distance
  61671. * @param successCallback A callback that will be called after the mesh was simplified.
  61672. * @param errorCallback in case of an error, this callback will be called. optional.
  61673. */
  61674. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  61675. }
  61676. /**
  61677. * Expected simplification settings.
  61678. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  61679. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61680. */
  61681. export interface ISimplificationSettings {
  61682. /**
  61683. * Gets or sets the expected quality
  61684. */
  61685. quality: number;
  61686. /**
  61687. * Gets or sets the distance when this optimized version should be used
  61688. */
  61689. distance: number;
  61690. /**
  61691. * Gets an already optimized mesh
  61692. */
  61693. optimizeMesh?: boolean;
  61694. }
  61695. /**
  61696. * Class used to specify simplification options
  61697. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61698. */
  61699. export class SimplificationSettings implements ISimplificationSettings {
  61700. /** expected quality */
  61701. quality: number;
  61702. /** distance when this optimized version should be used */
  61703. distance: number;
  61704. /** already optimized mesh */
  61705. optimizeMesh?: boolean | undefined;
  61706. /**
  61707. * Creates a SimplificationSettings
  61708. * @param quality expected quality
  61709. * @param distance distance when this optimized version should be used
  61710. * @param optimizeMesh already optimized mesh
  61711. */
  61712. constructor(
  61713. /** expected quality */
  61714. quality: number,
  61715. /** distance when this optimized version should be used */
  61716. distance: number,
  61717. /** already optimized mesh */
  61718. optimizeMesh?: boolean | undefined);
  61719. }
  61720. /**
  61721. * Interface used to define a simplification task
  61722. */
  61723. export interface ISimplificationTask {
  61724. /**
  61725. * Array of settings
  61726. */
  61727. settings: Array<ISimplificationSettings>;
  61728. /**
  61729. * Simplification type
  61730. */
  61731. simplificationType: SimplificationType;
  61732. /**
  61733. * Mesh to simplify
  61734. */
  61735. mesh: Mesh;
  61736. /**
  61737. * Callback called on success
  61738. */
  61739. successCallback?: () => void;
  61740. /**
  61741. * Defines if parallel processing can be used
  61742. */
  61743. parallelProcessing: boolean;
  61744. }
  61745. /**
  61746. * Queue used to order the simplification tasks
  61747. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61748. */
  61749. export class SimplificationQueue {
  61750. private _simplificationArray;
  61751. /**
  61752. * Gets a boolean indicating that the process is still running
  61753. */
  61754. running: boolean;
  61755. /**
  61756. * Creates a new queue
  61757. */
  61758. constructor();
  61759. /**
  61760. * Adds a new simplification task
  61761. * @param task defines a task to add
  61762. */
  61763. addTask(task: ISimplificationTask): void;
  61764. /**
  61765. * Execute next task
  61766. */
  61767. executeNext(): void;
  61768. /**
  61769. * Execute a simplification task
  61770. * @param task defines the task to run
  61771. */
  61772. runSimplification(task: ISimplificationTask): void;
  61773. private getSimplifier;
  61774. }
  61775. /**
  61776. * The implemented types of simplification
  61777. * At the moment only Quadratic Error Decimation is implemented
  61778. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61779. */
  61780. export enum SimplificationType {
  61781. /** Quadratic error decimation */
  61782. QUADRATIC = 0
  61783. }
  61784. }
  61785. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  61786. import { Scene } from "babylonjs/scene";
  61787. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  61788. import { ISceneComponent } from "babylonjs/sceneComponent";
  61789. module "babylonjs/scene" {
  61790. interface Scene {
  61791. /** @hidden (Backing field) */
  61792. _simplificationQueue: SimplificationQueue;
  61793. /**
  61794. * Gets or sets the simplification queue attached to the scene
  61795. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61796. */
  61797. simplificationQueue: SimplificationQueue;
  61798. }
  61799. }
  61800. module "babylonjs/Meshes/mesh" {
  61801. interface Mesh {
  61802. /**
  61803. * Simplify the mesh according to the given array of settings.
  61804. * Function will return immediately and will simplify async
  61805. * @param settings a collection of simplification settings
  61806. * @param parallelProcessing should all levels calculate parallel or one after the other
  61807. * @param simplificationType the type of simplification to run
  61808. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  61809. * @returns the current mesh
  61810. */
  61811. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  61812. }
  61813. }
  61814. /**
  61815. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  61816. * created in a scene
  61817. */
  61818. export class SimplicationQueueSceneComponent implements ISceneComponent {
  61819. /**
  61820. * The component name helpfull to identify the component in the list of scene components.
  61821. */
  61822. readonly name: string;
  61823. /**
  61824. * The scene the component belongs to.
  61825. */
  61826. scene: Scene;
  61827. /**
  61828. * Creates a new instance of the component for the given scene
  61829. * @param scene Defines the scene to register the component in
  61830. */
  61831. constructor(scene: Scene);
  61832. /**
  61833. * Registers the component in a given scene
  61834. */
  61835. register(): void;
  61836. /**
  61837. * Rebuilds the elements related to this component in case of
  61838. * context lost for instance.
  61839. */
  61840. rebuild(): void;
  61841. /**
  61842. * Disposes the component and the associated ressources
  61843. */
  61844. dispose(): void;
  61845. private _beforeCameraUpdate;
  61846. }
  61847. }
  61848. declare module "babylonjs/Meshes/Builders/index" {
  61849. export * from "babylonjs/Meshes/Builders/boxBuilder";
  61850. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  61851. export * from "babylonjs/Meshes/Builders/discBuilder";
  61852. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  61853. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  61854. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  61855. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  61856. export * from "babylonjs/Meshes/Builders/torusBuilder";
  61857. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  61858. export * from "babylonjs/Meshes/Builders/linesBuilder";
  61859. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  61860. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  61861. export * from "babylonjs/Meshes/Builders/latheBuilder";
  61862. export * from "babylonjs/Meshes/Builders/planeBuilder";
  61863. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  61864. export * from "babylonjs/Meshes/Builders/groundBuilder";
  61865. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  61866. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  61867. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  61868. export * from "babylonjs/Meshes/Builders/decalBuilder";
  61869. }
  61870. declare module "babylonjs/Meshes/index" {
  61871. export * from "babylonjs/Meshes/abstractMesh";
  61872. export * from "babylonjs/Meshes/buffer";
  61873. export * from "babylonjs/Meshes/Compression/index";
  61874. export * from "babylonjs/Meshes/csg";
  61875. export * from "babylonjs/Meshes/geometry";
  61876. export * from "babylonjs/Meshes/groundMesh";
  61877. export * from "babylonjs/Meshes/trailMesh";
  61878. export * from "babylonjs/Meshes/instancedMesh";
  61879. export * from "babylonjs/Meshes/linesMesh";
  61880. export * from "babylonjs/Meshes/mesh";
  61881. export * from "babylonjs/Meshes/mesh.vertexData";
  61882. export * from "babylonjs/Meshes/meshBuilder";
  61883. export * from "babylonjs/Meshes/meshSimplification";
  61884. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  61885. export * from "babylonjs/Meshes/polygonMesh";
  61886. export * from "babylonjs/Meshes/subMesh";
  61887. export * from "babylonjs/Meshes/meshLODLevel";
  61888. export * from "babylonjs/Meshes/transformNode";
  61889. export * from "babylonjs/Meshes/Builders/index";
  61890. export * from "babylonjs/Meshes/dataBuffer";
  61891. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  61892. }
  61893. declare module "babylonjs/Morph/index" {
  61894. export * from "babylonjs/Morph/morphTarget";
  61895. export * from "babylonjs/Morph/morphTargetManager";
  61896. }
  61897. declare module "babylonjs/Navigation/INavigationEngine" {
  61898. import { TransformNode } from "babylonjs/Meshes/transformNode";
  61899. import { Vector3 } from "babylonjs/Maths/math";
  61900. import { Mesh } from "babylonjs/Meshes/mesh";
  61901. import { Scene } from "babylonjs/scene";
  61902. /**
  61903. * Navigation plugin interface to add navigation constrained by a navigation mesh
  61904. */
  61905. export interface INavigationEnginePlugin {
  61906. /**
  61907. * plugin name
  61908. */
  61909. name: string;
  61910. /**
  61911. * Creates a navigation mesh
  61912. * @param meshes array of all the geometry used to compute the navigatio mesh
  61913. * @param parameters bunch of parameters used to filter geometry
  61914. */
  61915. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  61916. /**
  61917. * Create a navigation mesh debug mesh
  61918. * @param scene is where the mesh will be added
  61919. * @returns debug display mesh
  61920. */
  61921. createDebugNavMesh(scene: Scene): Mesh;
  61922. /**
  61923. * Get a navigation mesh constrained position, closest to the parameter position
  61924. * @param position world position
  61925. * @returns the closest point to position constrained by the navigation mesh
  61926. */
  61927. getClosestPoint(position: Vector3): Vector3;
  61928. /**
  61929. * Get a navigation mesh constrained position, within a particular radius
  61930. * @param position world position
  61931. * @param maxRadius the maximum distance to the constrained world position
  61932. * @returns the closest point to position constrained by the navigation mesh
  61933. */
  61934. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  61935. /**
  61936. * Compute the final position from a segment made of destination-position
  61937. * @param position world position
  61938. * @param destination world position
  61939. * @returns the resulting point along the navmesh
  61940. */
  61941. moveAlong(position: Vector3, destination: Vector3): Vector3;
  61942. /**
  61943. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  61944. * @param start world position
  61945. * @param end world position
  61946. * @returns array containing world position composing the path
  61947. */
  61948. computePath(start: Vector3, end: Vector3): Vector3[];
  61949. /**
  61950. * If this plugin is supported
  61951. * @returns true if plugin is supported
  61952. */
  61953. isSupported(): boolean;
  61954. /**
  61955. * Create a new Crowd so you can add agents
  61956. * @param maxAgents the maximum agent count in the crowd
  61957. * @param maxAgentRadius the maximum radius an agent can have
  61958. * @param scene to attach the crowd to
  61959. * @returns the crowd you can add agents to
  61960. */
  61961. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  61962. /**
  61963. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61964. * The queries will try to find a solution within those bounds
  61965. * default is (1,1,1)
  61966. * @param extent x,y,z value that define the extent around the queries point of reference
  61967. */
  61968. setDefaultQueryExtent(extent: Vector3): void;
  61969. /**
  61970. * Get the Bounding box extent specified by setDefaultQueryExtent
  61971. * @returns the box extent values
  61972. */
  61973. getDefaultQueryExtent(): Vector3;
  61974. /**
  61975. * Release all resources
  61976. */
  61977. dispose(): void;
  61978. }
  61979. /**
  61980. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  61981. */
  61982. export interface ICrowd {
  61983. /**
  61984. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  61985. * You can attach anything to that node. The node position is updated in the scene update tick.
  61986. * @param pos world position that will be constrained by the navigation mesh
  61987. * @param parameters agent parameters
  61988. * @param transform hooked to the agent that will be update by the scene
  61989. * @returns agent index
  61990. */
  61991. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  61992. /**
  61993. * Returns the agent position in world space
  61994. * @param index agent index returned by addAgent
  61995. * @returns world space position
  61996. */
  61997. getAgentPosition(index: number): Vector3;
  61998. /**
  61999. * Gets the agent velocity in world space
  62000. * @param index agent index returned by addAgent
  62001. * @returns world space velocity
  62002. */
  62003. getAgentVelocity(index: number): Vector3;
  62004. /**
  62005. * remove a particular agent previously created
  62006. * @param index agent index returned by addAgent
  62007. */
  62008. removeAgent(index: number): void;
  62009. /**
  62010. * get the list of all agents attached to this crowd
  62011. * @returns list of agent indices
  62012. */
  62013. getAgents(): number[];
  62014. /**
  62015. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  62016. * @param deltaTime in seconds
  62017. */
  62018. update(deltaTime: number): void;
  62019. /**
  62020. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62021. * @param index agent index returned by addAgent
  62022. * @param destination targeted world position
  62023. */
  62024. agentGoto(index: number, destination: Vector3): void;
  62025. /**
  62026. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62027. * The queries will try to find a solution within those bounds
  62028. * default is (1,1,1)
  62029. * @param extent x,y,z value that define the extent around the queries point of reference
  62030. */
  62031. setDefaultQueryExtent(extent: Vector3): void;
  62032. /**
  62033. * Get the Bounding box extent specified by setDefaultQueryExtent
  62034. * @returns the box extent values
  62035. */
  62036. getDefaultQueryExtent(): Vector3;
  62037. /**
  62038. * Release all resources
  62039. */
  62040. dispose(): void;
  62041. }
  62042. /**
  62043. * Configures an agent
  62044. */
  62045. export interface IAgentParameters {
  62046. /**
  62047. * Agent radius. [Limit: >= 0]
  62048. */
  62049. radius: number;
  62050. /**
  62051. * Agent height. [Limit: > 0]
  62052. */
  62053. height: number;
  62054. /**
  62055. * Maximum allowed acceleration. [Limit: >= 0]
  62056. */
  62057. maxAcceleration: number;
  62058. /**
  62059. * Maximum allowed speed. [Limit: >= 0]
  62060. */
  62061. maxSpeed: number;
  62062. /**
  62063. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  62064. */
  62065. collisionQueryRange: number;
  62066. /**
  62067. * The path visibility optimization range. [Limit: > 0]
  62068. */
  62069. pathOptimizationRange: number;
  62070. /**
  62071. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  62072. */
  62073. separationWeight: number;
  62074. }
  62075. /**
  62076. * Configures the navigation mesh creation
  62077. */
  62078. export interface INavMeshParameters {
  62079. /**
  62080. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  62081. */
  62082. cs: number;
  62083. /**
  62084. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  62085. */
  62086. ch: number;
  62087. /**
  62088. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  62089. */
  62090. walkableSlopeAngle: number;
  62091. /**
  62092. * Minimum floor to 'ceiling' height that will still allow the floor area to
  62093. * be considered walkable. [Limit: >= 3] [Units: vx]
  62094. */
  62095. walkableHeight: number;
  62096. /**
  62097. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  62098. */
  62099. walkableClimb: number;
  62100. /**
  62101. * The distance to erode/shrink the walkable area of the heightfield away from
  62102. * obstructions. [Limit: >=0] [Units: vx]
  62103. */
  62104. walkableRadius: number;
  62105. /**
  62106. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  62107. */
  62108. maxEdgeLen: number;
  62109. /**
  62110. * The maximum distance a simplfied contour's border edges should deviate
  62111. * the original raw contour. [Limit: >=0] [Units: vx]
  62112. */
  62113. maxSimplificationError: number;
  62114. /**
  62115. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  62116. */
  62117. minRegionArea: number;
  62118. /**
  62119. * Any regions with a span count smaller than this value will, if possible,
  62120. * be merged with larger regions. [Limit: >=0] [Units: vx]
  62121. */
  62122. mergeRegionArea: number;
  62123. /**
  62124. * The maximum number of vertices allowed for polygons generated during the
  62125. * contour to polygon conversion process. [Limit: >= 3]
  62126. */
  62127. maxVertsPerPoly: number;
  62128. /**
  62129. * Sets the sampling distance to use when generating the detail mesh.
  62130. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  62131. */
  62132. detailSampleDist: number;
  62133. /**
  62134. * The maximum distance the detail mesh surface should deviate from heightfield
  62135. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  62136. */
  62137. detailSampleMaxError: number;
  62138. }
  62139. }
  62140. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  62141. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  62142. import { Mesh } from "babylonjs/Meshes/mesh";
  62143. import { Scene } from "babylonjs/scene";
  62144. import { Vector3 } from "babylonjs/Maths/math";
  62145. import { TransformNode } from "babylonjs/Meshes/transformNode";
  62146. /**
  62147. * RecastJS navigation plugin
  62148. */
  62149. export class RecastJSPlugin implements INavigationEnginePlugin {
  62150. /**
  62151. * Reference to the Recast library
  62152. */
  62153. bjsRECAST: any;
  62154. /**
  62155. * plugin name
  62156. */
  62157. name: string;
  62158. /**
  62159. * the first navmesh created. We might extend this to support multiple navmeshes
  62160. */
  62161. navMesh: any;
  62162. /**
  62163. * Initializes the recastJS plugin
  62164. * @param recastInjection can be used to inject your own recast reference
  62165. */
  62166. constructor(recastInjection?: any);
  62167. /**
  62168. * Creates a navigation mesh
  62169. * @param meshes array of all the geometry used to compute the navigatio mesh
  62170. * @param parameters bunch of parameters used to filter geometry
  62171. */
  62172. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  62173. /**
  62174. * Create a navigation mesh debug mesh
  62175. * @param scene is where the mesh will be added
  62176. * @returns debug display mesh
  62177. */
  62178. createDebugNavMesh(scene: Scene): Mesh;
  62179. /**
  62180. * Get a navigation mesh constrained position, closest to the parameter position
  62181. * @param position world position
  62182. * @returns the closest point to position constrained by the navigation mesh
  62183. */
  62184. getClosestPoint(position: Vector3): Vector3;
  62185. /**
  62186. * Get a navigation mesh constrained position, within a particular radius
  62187. * @param position world position
  62188. * @param maxRadius the maximum distance to the constrained world position
  62189. * @returns the closest point to position constrained by the navigation mesh
  62190. */
  62191. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  62192. /**
  62193. * Compute the final position from a segment made of destination-position
  62194. * @param position world position
  62195. * @param destination world position
  62196. * @returns the resulting point along the navmesh
  62197. */
  62198. moveAlong(position: Vector3, destination: Vector3): Vector3;
  62199. /**
  62200. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  62201. * @param start world position
  62202. * @param end world position
  62203. * @returns array containing world position composing the path
  62204. */
  62205. computePath(start: Vector3, end: Vector3): Vector3[];
  62206. /**
  62207. * Create a new Crowd so you can add agents
  62208. * @param maxAgents the maximum agent count in the crowd
  62209. * @param maxAgentRadius the maximum radius an agent can have
  62210. * @param scene to attach the crowd to
  62211. * @returns the crowd you can add agents to
  62212. */
  62213. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  62214. /**
  62215. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62216. * The queries will try to find a solution within those bounds
  62217. * default is (1,1,1)
  62218. * @param extent x,y,z value that define the extent around the queries point of reference
  62219. */
  62220. setDefaultQueryExtent(extent: Vector3): void;
  62221. /**
  62222. * Get the Bounding box extent specified by setDefaultQueryExtent
  62223. * @returns the box extent values
  62224. */
  62225. getDefaultQueryExtent(): Vector3;
  62226. /**
  62227. * Disposes
  62228. */
  62229. dispose(): void;
  62230. /**
  62231. * If this plugin is supported
  62232. * @returns true if plugin is supported
  62233. */
  62234. isSupported(): boolean;
  62235. }
  62236. /**
  62237. * Recast detour crowd implementation
  62238. */
  62239. export class RecastJSCrowd implements ICrowd {
  62240. /**
  62241. * Recast/detour plugin
  62242. */
  62243. bjsRECASTPlugin: RecastJSPlugin;
  62244. /**
  62245. * Link to the detour crowd
  62246. */
  62247. recastCrowd: any;
  62248. /**
  62249. * One transform per agent
  62250. */
  62251. transforms: TransformNode[];
  62252. /**
  62253. * All agents created
  62254. */
  62255. agents: number[];
  62256. /**
  62257. * Link to the scene is kept to unregister the crowd from the scene
  62258. */
  62259. private _scene;
  62260. /**
  62261. * Observer for crowd updates
  62262. */
  62263. private _onBeforeAnimationsObserver;
  62264. /**
  62265. * Constructor
  62266. * @param plugin recastJS plugin
  62267. * @param maxAgents the maximum agent count in the crowd
  62268. * @param maxAgentRadius the maximum radius an agent can have
  62269. * @param scene to attach the crowd to
  62270. * @returns the crowd you can add agents to
  62271. */
  62272. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  62273. /**
  62274. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  62275. * You can attach anything to that node. The node position is updated in the scene update tick.
  62276. * @param pos world position that will be constrained by the navigation mesh
  62277. * @param parameters agent parameters
  62278. * @param transform hooked to the agent that will be update by the scene
  62279. * @returns agent index
  62280. */
  62281. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  62282. /**
  62283. * Returns the agent position in world space
  62284. * @param index agent index returned by addAgent
  62285. * @returns world space position
  62286. */
  62287. getAgentPosition(index: number): Vector3;
  62288. /**
  62289. * Returns the agent velocity in world space
  62290. * @param index agent index returned by addAgent
  62291. * @returns world space velocity
  62292. */
  62293. getAgentVelocity(index: number): Vector3;
  62294. /**
  62295. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62296. * @param index agent index returned by addAgent
  62297. * @param destination targeted world position
  62298. */
  62299. agentGoto(index: number, destination: Vector3): void;
  62300. /**
  62301. * remove a particular agent previously created
  62302. * @param index agent index returned by addAgent
  62303. */
  62304. removeAgent(index: number): void;
  62305. /**
  62306. * get the list of all agents attached to this crowd
  62307. * @returns list of agent indices
  62308. */
  62309. getAgents(): number[];
  62310. /**
  62311. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  62312. * @param deltaTime in seconds
  62313. */
  62314. update(deltaTime: number): void;
  62315. /**
  62316. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62317. * The queries will try to find a solution within those bounds
  62318. * default is (1,1,1)
  62319. * @param extent x,y,z value that define the extent around the queries point of reference
  62320. */
  62321. setDefaultQueryExtent(extent: Vector3): void;
  62322. /**
  62323. * Get the Bounding box extent specified by setDefaultQueryExtent
  62324. * @returns the box extent values
  62325. */
  62326. getDefaultQueryExtent(): Vector3;
  62327. /**
  62328. * Release all resources
  62329. */
  62330. dispose(): void;
  62331. }
  62332. }
  62333. declare module "babylonjs/Navigation/Plugins/index" {
  62334. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  62335. }
  62336. declare module "babylonjs/Navigation/index" {
  62337. export * from "babylonjs/Navigation/INavigationEngine";
  62338. export * from "babylonjs/Navigation/Plugins/index";
  62339. }
  62340. declare module "babylonjs/Offline/database" {
  62341. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  62342. /**
  62343. * Class used to enable access to IndexedDB
  62344. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  62345. */
  62346. export class Database implements IOfflineProvider {
  62347. private _callbackManifestChecked;
  62348. private _currentSceneUrl;
  62349. private _db;
  62350. private _enableSceneOffline;
  62351. private _enableTexturesOffline;
  62352. private _manifestVersionFound;
  62353. private _mustUpdateRessources;
  62354. private _hasReachedQuota;
  62355. private _isSupported;
  62356. private _idbFactory;
  62357. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  62358. private static IsUASupportingBlobStorage;
  62359. /**
  62360. * Gets a boolean indicating if Database storate is enabled (off by default)
  62361. */
  62362. static IDBStorageEnabled: boolean;
  62363. /**
  62364. * Gets a boolean indicating if scene must be saved in the database
  62365. */
  62366. readonly enableSceneOffline: boolean;
  62367. /**
  62368. * Gets a boolean indicating if textures must be saved in the database
  62369. */
  62370. readonly enableTexturesOffline: boolean;
  62371. /**
  62372. * Creates a new Database
  62373. * @param urlToScene defines the url to load the scene
  62374. * @param callbackManifestChecked defines the callback to use when manifest is checked
  62375. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  62376. */
  62377. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  62378. private static _ParseURL;
  62379. private static _ReturnFullUrlLocation;
  62380. private _checkManifestFile;
  62381. /**
  62382. * Open the database and make it available
  62383. * @param successCallback defines the callback to call on success
  62384. * @param errorCallback defines the callback to call on error
  62385. */
  62386. open(successCallback: () => void, errorCallback: () => void): void;
  62387. /**
  62388. * Loads an image from the database
  62389. * @param url defines the url to load from
  62390. * @param image defines the target DOM image
  62391. */
  62392. loadImage(url: string, image: HTMLImageElement): void;
  62393. private _loadImageFromDBAsync;
  62394. private _saveImageIntoDBAsync;
  62395. private _checkVersionFromDB;
  62396. private _loadVersionFromDBAsync;
  62397. private _saveVersionIntoDBAsync;
  62398. /**
  62399. * Loads a file from database
  62400. * @param url defines the URL to load from
  62401. * @param sceneLoaded defines a callback to call on success
  62402. * @param progressCallBack defines a callback to call when progress changed
  62403. * @param errorCallback defines a callback to call on error
  62404. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  62405. */
  62406. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  62407. private _loadFileAsync;
  62408. private _saveFileAsync;
  62409. /**
  62410. * Validates if xhr data is correct
  62411. * @param xhr defines the request to validate
  62412. * @param dataType defines the expected data type
  62413. * @returns true if data is correct
  62414. */
  62415. private static _ValidateXHRData;
  62416. }
  62417. }
  62418. declare module "babylonjs/Offline/index" {
  62419. export * from "babylonjs/Offline/database";
  62420. export * from "babylonjs/Offline/IOfflineProvider";
  62421. }
  62422. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  62423. /** @hidden */
  62424. export var gpuUpdateParticlesPixelShader: {
  62425. name: string;
  62426. shader: string;
  62427. };
  62428. }
  62429. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  62430. /** @hidden */
  62431. export var gpuUpdateParticlesVertexShader: {
  62432. name: string;
  62433. shader: string;
  62434. };
  62435. }
  62436. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  62437. /** @hidden */
  62438. export var clipPlaneFragmentDeclaration2: {
  62439. name: string;
  62440. shader: string;
  62441. };
  62442. }
  62443. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  62444. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  62445. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  62446. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62447. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  62448. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  62449. /** @hidden */
  62450. export var gpuRenderParticlesPixelShader: {
  62451. name: string;
  62452. shader: string;
  62453. };
  62454. }
  62455. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  62456. /** @hidden */
  62457. export var clipPlaneVertexDeclaration2: {
  62458. name: string;
  62459. shader: string;
  62460. };
  62461. }
  62462. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  62463. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  62464. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  62465. /** @hidden */
  62466. export var gpuRenderParticlesVertexShader: {
  62467. name: string;
  62468. shader: string;
  62469. };
  62470. }
  62471. declare module "babylonjs/Particles/gpuParticleSystem" {
  62472. import { Nullable } from "babylonjs/types";
  62473. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  62474. import { Observable } from "babylonjs/Misc/observable";
  62475. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  62476. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  62477. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  62478. import { Scene, IDisposable } from "babylonjs/scene";
  62479. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  62480. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  62481. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  62482. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  62483. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  62484. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  62485. /**
  62486. * This represents a GPU particle system in Babylon
  62487. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  62488. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  62489. */
  62490. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  62491. /**
  62492. * The layer mask we are rendering the particles through.
  62493. */
  62494. layerMask: number;
  62495. private _capacity;
  62496. private _activeCount;
  62497. private _currentActiveCount;
  62498. private _accumulatedCount;
  62499. private _renderEffect;
  62500. private _updateEffect;
  62501. private _buffer0;
  62502. private _buffer1;
  62503. private _spriteBuffer;
  62504. private _updateVAO;
  62505. private _renderVAO;
  62506. private _targetIndex;
  62507. private _sourceBuffer;
  62508. private _targetBuffer;
  62509. private _engine;
  62510. private _currentRenderId;
  62511. private _started;
  62512. private _stopped;
  62513. private _timeDelta;
  62514. private _randomTexture;
  62515. private _randomTexture2;
  62516. private _attributesStrideSize;
  62517. private _updateEffectOptions;
  62518. private _randomTextureSize;
  62519. private _actualFrame;
  62520. private readonly _rawTextureWidth;
  62521. /**
  62522. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  62523. */
  62524. static readonly IsSupported: boolean;
  62525. /**
  62526. * An event triggered when the system is disposed.
  62527. */
  62528. onDisposeObservable: Observable<GPUParticleSystem>;
  62529. /**
  62530. * Gets the maximum number of particles active at the same time.
  62531. * @returns The max number of active particles.
  62532. */
  62533. getCapacity(): number;
  62534. /**
  62535. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  62536. * to override the particles.
  62537. */
  62538. forceDepthWrite: boolean;
  62539. /**
  62540. * Gets or set the number of active particles
  62541. */
  62542. activeParticleCount: number;
  62543. private _preWarmDone;
  62544. /**
  62545. * Is this system ready to be used/rendered
  62546. * @return true if the system is ready
  62547. */
  62548. isReady(): boolean;
  62549. /**
  62550. * Gets if the system has been started. (Note: this will still be true after stop is called)
  62551. * @returns True if it has been started, otherwise false.
  62552. */
  62553. isStarted(): boolean;
  62554. /**
  62555. * Starts the particle system and begins to emit
  62556. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  62557. */
  62558. start(delay?: number): void;
  62559. /**
  62560. * Stops the particle system.
  62561. */
  62562. stop(): void;
  62563. /**
  62564. * Remove all active particles
  62565. */
  62566. reset(): void;
  62567. /**
  62568. * Returns the string "GPUParticleSystem"
  62569. * @returns a string containing the class name
  62570. */
  62571. getClassName(): string;
  62572. private _colorGradientsTexture;
  62573. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  62574. /**
  62575. * Adds a new color gradient
  62576. * @param gradient defines the gradient to use (between 0 and 1)
  62577. * @param color1 defines the color to affect to the specified gradient
  62578. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  62579. * @returns the current particle system
  62580. */
  62581. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  62582. /**
  62583. * Remove a specific color gradient
  62584. * @param gradient defines the gradient to remove
  62585. * @returns the current particle system
  62586. */
  62587. removeColorGradient(gradient: number): GPUParticleSystem;
  62588. private _angularSpeedGradientsTexture;
  62589. private _sizeGradientsTexture;
  62590. private _velocityGradientsTexture;
  62591. private _limitVelocityGradientsTexture;
  62592. private _dragGradientsTexture;
  62593. private _addFactorGradient;
  62594. /**
  62595. * Adds a new size gradient
  62596. * @param gradient defines the gradient to use (between 0 and 1)
  62597. * @param factor defines the size factor to affect to the specified gradient
  62598. * @returns the current particle system
  62599. */
  62600. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  62601. /**
  62602. * Remove a specific size gradient
  62603. * @param gradient defines the gradient to remove
  62604. * @returns the current particle system
  62605. */
  62606. removeSizeGradient(gradient: number): GPUParticleSystem;
  62607. /**
  62608. * Adds a new angular speed gradient
  62609. * @param gradient defines the gradient to use (between 0 and 1)
  62610. * @param factor defines the angular speed to affect to the specified gradient
  62611. * @returns the current particle system
  62612. */
  62613. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  62614. /**
  62615. * Remove a specific angular speed gradient
  62616. * @param gradient defines the gradient to remove
  62617. * @returns the current particle system
  62618. */
  62619. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  62620. /**
  62621. * Adds a new velocity gradient
  62622. * @param gradient defines the gradient to use (between 0 and 1)
  62623. * @param factor defines the velocity to affect to the specified gradient
  62624. * @returns the current particle system
  62625. */
  62626. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  62627. /**
  62628. * Remove a specific velocity gradient
  62629. * @param gradient defines the gradient to remove
  62630. * @returns the current particle system
  62631. */
  62632. removeVelocityGradient(gradient: number): GPUParticleSystem;
  62633. /**
  62634. * Adds a new limit velocity gradient
  62635. * @param gradient defines the gradient to use (between 0 and 1)
  62636. * @param factor defines the limit velocity value to affect to the specified gradient
  62637. * @returns the current particle system
  62638. */
  62639. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  62640. /**
  62641. * Remove a specific limit velocity gradient
  62642. * @param gradient defines the gradient to remove
  62643. * @returns the current particle system
  62644. */
  62645. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  62646. /**
  62647. * Adds a new drag gradient
  62648. * @param gradient defines the gradient to use (between 0 and 1)
  62649. * @param factor defines the drag value to affect to the specified gradient
  62650. * @returns the current particle system
  62651. */
  62652. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  62653. /**
  62654. * Remove a specific drag gradient
  62655. * @param gradient defines the gradient to remove
  62656. * @returns the current particle system
  62657. */
  62658. removeDragGradient(gradient: number): GPUParticleSystem;
  62659. /**
  62660. * Not supported by GPUParticleSystem
  62661. * @param gradient defines the gradient to use (between 0 and 1)
  62662. * @param factor defines the emit rate value to affect to the specified gradient
  62663. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62664. * @returns the current particle system
  62665. */
  62666. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62667. /**
  62668. * Not supported by GPUParticleSystem
  62669. * @param gradient defines the gradient to remove
  62670. * @returns the current particle system
  62671. */
  62672. removeEmitRateGradient(gradient: number): IParticleSystem;
  62673. /**
  62674. * Not supported by GPUParticleSystem
  62675. * @param gradient defines the gradient to use (between 0 and 1)
  62676. * @param factor defines the start size value to affect to the specified gradient
  62677. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62678. * @returns the current particle system
  62679. */
  62680. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62681. /**
  62682. * Not supported by GPUParticleSystem
  62683. * @param gradient defines the gradient to remove
  62684. * @returns the current particle system
  62685. */
  62686. removeStartSizeGradient(gradient: number): IParticleSystem;
  62687. /**
  62688. * Not supported by GPUParticleSystem
  62689. * @param gradient defines the gradient to use (between 0 and 1)
  62690. * @param min defines the color remap minimal range
  62691. * @param max defines the color remap maximal range
  62692. * @returns the current particle system
  62693. */
  62694. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  62695. /**
  62696. * Not supported by GPUParticleSystem
  62697. * @param gradient defines the gradient to remove
  62698. * @returns the current particle system
  62699. */
  62700. removeColorRemapGradient(): IParticleSystem;
  62701. /**
  62702. * Not supported by GPUParticleSystem
  62703. * @param gradient defines the gradient to use (between 0 and 1)
  62704. * @param min defines the alpha remap minimal range
  62705. * @param max defines the alpha remap maximal range
  62706. * @returns the current particle system
  62707. */
  62708. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  62709. /**
  62710. * Not supported by GPUParticleSystem
  62711. * @param gradient defines the gradient to remove
  62712. * @returns the current particle system
  62713. */
  62714. removeAlphaRemapGradient(): IParticleSystem;
  62715. /**
  62716. * Not supported by GPUParticleSystem
  62717. * @param gradient defines the gradient to use (between 0 and 1)
  62718. * @param color defines the color to affect to the specified gradient
  62719. * @returns the current particle system
  62720. */
  62721. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  62722. /**
  62723. * Not supported by GPUParticleSystem
  62724. * @param gradient defines the gradient to remove
  62725. * @returns the current particle system
  62726. */
  62727. removeRampGradient(): IParticleSystem;
  62728. /**
  62729. * Not supported by GPUParticleSystem
  62730. * @returns the list of ramp gradients
  62731. */
  62732. getRampGradients(): Nullable<Array<Color3Gradient>>;
  62733. /**
  62734. * Not supported by GPUParticleSystem
  62735. * Gets or sets a boolean indicating that ramp gradients must be used
  62736. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  62737. */
  62738. useRampGradients: boolean;
  62739. /**
  62740. * Not supported by GPUParticleSystem
  62741. * @param gradient defines the gradient to use (between 0 and 1)
  62742. * @param factor defines the life time factor to affect to the specified gradient
  62743. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62744. * @returns the current particle system
  62745. */
  62746. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62747. /**
  62748. * Not supported by GPUParticleSystem
  62749. * @param gradient defines the gradient to remove
  62750. * @returns the current particle system
  62751. */
  62752. removeLifeTimeGradient(gradient: number): IParticleSystem;
  62753. /**
  62754. * Instantiates a GPU particle system.
  62755. * 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.
  62756. * @param name The name of the particle system
  62757. * @param options The options used to create the system
  62758. * @param scene The scene the particle system belongs to
  62759. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  62760. */
  62761. constructor(name: string, options: Partial<{
  62762. capacity: number;
  62763. randomTextureSize: number;
  62764. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  62765. protected _reset(): void;
  62766. private _createUpdateVAO;
  62767. private _createRenderVAO;
  62768. private _initialize;
  62769. /** @hidden */
  62770. _recreateUpdateEffect(): void;
  62771. /** @hidden */
  62772. _recreateRenderEffect(): void;
  62773. /**
  62774. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  62775. * @param preWarm defines if we are in the pre-warmimg phase
  62776. */
  62777. animate(preWarm?: boolean): void;
  62778. private _createFactorGradientTexture;
  62779. private _createSizeGradientTexture;
  62780. private _createAngularSpeedGradientTexture;
  62781. private _createVelocityGradientTexture;
  62782. private _createLimitVelocityGradientTexture;
  62783. private _createDragGradientTexture;
  62784. private _createColorGradientTexture;
  62785. /**
  62786. * Renders the particle system in its current state
  62787. * @param preWarm defines if the system should only update the particles but not render them
  62788. * @returns the current number of particles
  62789. */
  62790. render(preWarm?: boolean): number;
  62791. /**
  62792. * Rebuilds the particle system
  62793. */
  62794. rebuild(): void;
  62795. private _releaseBuffers;
  62796. private _releaseVAOs;
  62797. /**
  62798. * Disposes the particle system and free the associated resources
  62799. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  62800. */
  62801. dispose(disposeTexture?: boolean): void;
  62802. /**
  62803. * Clones the particle system.
  62804. * @param name The name of the cloned object
  62805. * @param newEmitter The new emitter to use
  62806. * @returns the cloned particle system
  62807. */
  62808. clone(name: string, newEmitter: any): GPUParticleSystem;
  62809. /**
  62810. * Serializes the particle system to a JSON object.
  62811. * @returns the JSON object
  62812. */
  62813. serialize(): any;
  62814. /**
  62815. * Parses a JSON object to create a GPU particle system.
  62816. * @param parsedParticleSystem The JSON object to parse
  62817. * @param scene The scene to create the particle system in
  62818. * @param rootUrl The root url to use to load external dependencies like texture
  62819. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  62820. * @returns the parsed GPU particle system
  62821. */
  62822. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  62823. }
  62824. }
  62825. declare module "babylonjs/Particles/particleSystemSet" {
  62826. import { Nullable } from "babylonjs/types";
  62827. import { Color3 } from "babylonjs/Maths/math.color";
  62828. import { TransformNode } from "babylonjs/Meshes/transformNode";
  62829. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62830. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  62831. import { Scene, IDisposable } from "babylonjs/scene";
  62832. /**
  62833. * Represents a set of particle systems working together to create a specific effect
  62834. */
  62835. export class ParticleSystemSet implements IDisposable {
  62836. /**
  62837. * Gets or sets base Assets URL
  62838. */
  62839. static BaseAssetsUrl: string;
  62840. private _emitterCreationOptions;
  62841. private _emitterNode;
  62842. /**
  62843. * Gets the particle system list
  62844. */
  62845. systems: IParticleSystem[];
  62846. /**
  62847. * Gets the emitter node used with this set
  62848. */
  62849. readonly emitterNode: Nullable<TransformNode>;
  62850. /**
  62851. * Creates a new emitter mesh as a sphere
  62852. * @param options defines the options used to create the sphere
  62853. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  62854. * @param scene defines the hosting scene
  62855. */
  62856. setEmitterAsSphere(options: {
  62857. diameter: number;
  62858. segments: number;
  62859. color: Color3;
  62860. }, renderingGroupId: number, scene: Scene): void;
  62861. /**
  62862. * Starts all particle systems of the set
  62863. * @param emitter defines an optional mesh to use as emitter for the particle systems
  62864. */
  62865. start(emitter?: AbstractMesh): void;
  62866. /**
  62867. * Release all associated resources
  62868. */
  62869. dispose(): void;
  62870. /**
  62871. * Serialize the set into a JSON compatible object
  62872. * @returns a JSON compatible representation of the set
  62873. */
  62874. serialize(): any;
  62875. /**
  62876. * Parse a new ParticleSystemSet from a serialized source
  62877. * @param data defines a JSON compatible representation of the set
  62878. * @param scene defines the hosting scene
  62879. * @param gpu defines if we want GPU particles or CPU particles
  62880. * @returns a new ParticleSystemSet
  62881. */
  62882. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  62883. }
  62884. }
  62885. declare module "babylonjs/Particles/particleHelper" {
  62886. import { Nullable } from "babylonjs/types";
  62887. import { Scene } from "babylonjs/scene";
  62888. import { Vector3 } from "babylonjs/Maths/math.vector";
  62889. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62890. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  62891. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  62892. /**
  62893. * This class is made for on one-liner static method to help creating particle system set.
  62894. */
  62895. export class ParticleHelper {
  62896. /**
  62897. * Gets or sets base Assets URL
  62898. */
  62899. static BaseAssetsUrl: string;
  62900. /**
  62901. * Create a default particle system that you can tweak
  62902. * @param emitter defines the emitter to use
  62903. * @param capacity defines the system capacity (default is 500 particles)
  62904. * @param scene defines the hosting scene
  62905. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  62906. * @returns the new Particle system
  62907. */
  62908. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  62909. /**
  62910. * This is the main static method (one-liner) of this helper to create different particle systems
  62911. * @param type This string represents the type to the particle system to create
  62912. * @param scene The scene where the particle system should live
  62913. * @param gpu If the system will use gpu
  62914. * @returns the ParticleSystemSet created
  62915. */
  62916. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  62917. /**
  62918. * Static function used to export a particle system to a ParticleSystemSet variable.
  62919. * Please note that the emitter shape is not exported
  62920. * @param systems defines the particle systems to export
  62921. * @returns the created particle system set
  62922. */
  62923. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  62924. }
  62925. }
  62926. declare module "babylonjs/Particles/particleSystemComponent" {
  62927. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  62928. import { Effect } from "babylonjs/Materials/effect";
  62929. import "babylonjs/Shaders/particles.vertex";
  62930. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  62931. module "babylonjs/Engines/engine" {
  62932. interface Engine {
  62933. /**
  62934. * Create an effect to use with particle systems.
  62935. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  62936. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  62937. * @param uniformsNames defines a list of attribute names
  62938. * @param samplers defines an array of string used to represent textures
  62939. * @param defines defines the string containing the defines to use to compile the shaders
  62940. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  62941. * @param onCompiled defines a function to call when the effect creation is successful
  62942. * @param onError defines a function to call when the effect creation has failed
  62943. * @returns the new Effect
  62944. */
  62945. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  62946. }
  62947. }
  62948. module "babylonjs/Meshes/mesh" {
  62949. interface Mesh {
  62950. /**
  62951. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  62952. * @returns an array of IParticleSystem
  62953. */
  62954. getEmittedParticleSystems(): IParticleSystem[];
  62955. /**
  62956. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  62957. * @returns an array of IParticleSystem
  62958. */
  62959. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  62960. }
  62961. }
  62962. /**
  62963. * @hidden
  62964. */
  62965. export var _IDoNeedToBeInTheBuild: number;
  62966. }
  62967. declare module "babylonjs/Particles/pointsCloudSystem" {
  62968. import { Color4 } from "babylonjs/Maths/math";
  62969. import { Mesh } from "babylonjs/Meshes/mesh";
  62970. import { Scene, IDisposable } from "babylonjs/scene";
  62971. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  62972. /** Defines the 4 color options */
  62973. export enum PointColor {
  62974. /** color value */
  62975. Color = 2,
  62976. /** uv value */
  62977. UV = 1,
  62978. /** random value */
  62979. Random = 0,
  62980. /** stated value */
  62981. Stated = 3
  62982. }
  62983. /**
  62984. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  62985. * As it is just a mesh, the PointCloudSystem has all the same properties as any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  62986. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  62987. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  62988. *
  62989. * Full documentation here : TO BE ENTERED
  62990. */
  62991. export class PointsCloudSystem implements IDisposable {
  62992. /**
  62993. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  62994. * Example : var p = SPS.particles[i];
  62995. */
  62996. particles: CloudPoint[];
  62997. /**
  62998. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  62999. */
  63000. nbParticles: number;
  63001. /**
  63002. * This a counter for your own usage. It's not set by any SPS functions.
  63003. */
  63004. counter: number;
  63005. /**
  63006. * The PCS name. This name is also given to the underlying mesh.
  63007. */
  63008. name: string;
  63009. /**
  63010. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  63011. */
  63012. mesh: Mesh;
  63013. /**
  63014. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  63015. * Please read :
  63016. */
  63017. vars: any;
  63018. /**
  63019. * @hidden
  63020. */
  63021. _size: number;
  63022. private _scene;
  63023. private _promises;
  63024. private _positions;
  63025. private _indices;
  63026. private _normals;
  63027. private _colors;
  63028. private _uvs;
  63029. private _indices32;
  63030. private _positions32;
  63031. private _colors32;
  63032. private _uvs32;
  63033. private _updatable;
  63034. private _isVisibilityBoxLocked;
  63035. private _alwaysVisible;
  63036. private _groups;
  63037. private _groupCounter;
  63038. private _computeParticleColor;
  63039. private _computeParticleTexture;
  63040. private _computeParticleRotation;
  63041. private _computeBoundingBox;
  63042. private _isReady;
  63043. /**
  63044. * Creates a PCS (Points Cloud System) object
  63045. * @param name (String) is the PCS name, this will be the underlying mesh name
  63046. * @param pointSize (number) is the size for each point
  63047. * @param scene (Scene) is the scene in which the PCS is added
  63048. * @param options defines the options of the PCS e.g.
  63049. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  63050. */
  63051. constructor(name: string, pointSize: number, scene: Scene, options?: {
  63052. updatable?: boolean;
  63053. });
  63054. /**
  63055. * Builds the PCS underlying mesh. Returns a standard Mesh.
  63056. * If no points were added to the PCS, the returned mesh is just a single point.
  63057. * @returns a promise for the created mesh
  63058. */
  63059. buildMeshAsync(): Promise<Mesh>;
  63060. /**
  63061. * @hidden
  63062. */
  63063. private _buildMesh;
  63064. private _addParticle;
  63065. private _randomUnitVector;
  63066. private _getColorIndicesForCoord;
  63067. private _setPointsColorOrUV;
  63068. private _colorFromTexture;
  63069. private _calculateDensity;
  63070. /**
  63071. * Adds points to the PCS in random positions within a unit sphere
  63072. * @param nb (positive integer) the number of particles to be created from this model
  63073. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  63074. * @returns the number of groups in the system
  63075. */
  63076. addPoints(nb: number, pointFunction?: any): number;
  63077. /**
  63078. * Adds points to the PCS from the surface of the model shape
  63079. * @param mesh is any Mesh object that will be used as a surface model for the points
  63080. * @param nb (positive integer) the number of particles to be created from this model
  63081. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63082. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63083. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63084. * @returns the number of groups in the system
  63085. */
  63086. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63087. /**
  63088. * Adds points to the PCS inside the model shape
  63089. * @param mesh is any Mesh object that will be used as a surface model for the points
  63090. * @param nb (positive integer) the number of particles to be created from this model
  63091. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63092. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63093. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63094. * @returns the number of groups in the system
  63095. */
  63096. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63097. /**
  63098. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  63099. * This method calls `updateParticle()` for each particle of the SPS.
  63100. * For an animated SPS, it is usually called within the render loop.
  63101. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  63102. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  63103. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  63104. * @returns the PCS.
  63105. */
  63106. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  63107. /**
  63108. * Disposes the PCS.
  63109. */
  63110. dispose(): void;
  63111. /**
  63112. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  63113. * doc :
  63114. * @returns the PCS.
  63115. */
  63116. refreshVisibleSize(): PointsCloudSystem;
  63117. /**
  63118. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  63119. * @param size the size (float) of the visibility box
  63120. * note : this doesn't lock the PCS mesh bounding box.
  63121. * doc :
  63122. */
  63123. setVisibilityBox(size: number): void;
  63124. /**
  63125. * Gets whether the PCS is always visible or not
  63126. * doc :
  63127. */
  63128. /**
  63129. * Sets the PCS as always visible or not
  63130. * doc :
  63131. */
  63132. isAlwaysVisible: boolean;
  63133. /**
  63134. * Tells to `setParticles()` to compute the particle rotations or not
  63135. * Default value : false. The PCS is faster when it's set to false
  63136. * Note : particle rotations are only applied to parent particles
  63137. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  63138. */
  63139. computeParticleRotation: boolean;
  63140. /**
  63141. * Tells to `setParticles()` to compute the particle colors or not.
  63142. * Default value : true. The PCS is faster when it's set to false.
  63143. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63144. */
  63145. /**
  63146. * Gets if `setParticles()` computes the particle colors or not.
  63147. * Default value : false. The PCS is faster when it's set to false.
  63148. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63149. */
  63150. computeParticleColor: boolean;
  63151. /**
  63152. * Gets if `setParticles()` computes the particle textures or not.
  63153. * Default value : false. The PCS is faster when it's set to false.
  63154. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  63155. */
  63156. computeParticleTexture: boolean;
  63157. /**
  63158. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  63159. */
  63160. /**
  63161. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  63162. */
  63163. computeBoundingBox: boolean;
  63164. /**
  63165. * This function does nothing. It may be overwritten to set all the particle first values.
  63166. * The PCS doesn't call this function, you may have to call it by your own.
  63167. * doc :
  63168. */
  63169. initParticles(): void;
  63170. /**
  63171. * This function does nothing. It may be overwritten to recycle a particle
  63172. * The PCS doesn't call this function, you can to call it
  63173. * doc :
  63174. * @param particle The particle to recycle
  63175. * @returns the recycled particle
  63176. */
  63177. recycleParticle(particle: CloudPoint): CloudPoint;
  63178. /**
  63179. * Updates a particle : this function should be overwritten by the user.
  63180. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  63181. * doc :
  63182. * @example : just set a particle position or velocity and recycle conditions
  63183. * @param particle The particle to update
  63184. * @returns the updated particle
  63185. */
  63186. updateParticle(particle: CloudPoint): CloudPoint;
  63187. /**
  63188. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  63189. * This does nothing and may be overwritten by the user.
  63190. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63191. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63192. * @param update the boolean update value actually passed to setParticles()
  63193. */
  63194. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63195. /**
  63196. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  63197. * This will be passed three parameters.
  63198. * This does nothing and may be overwritten by the user.
  63199. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63200. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63201. * @param update the boolean update value actually passed to setParticles()
  63202. */
  63203. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63204. }
  63205. }
  63206. declare module "babylonjs/Particles/cloudPoint" {
  63207. import { Nullable } from "babylonjs/types";
  63208. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  63209. import { Mesh } from "babylonjs/Meshes/mesh";
  63210. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  63211. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  63212. /**
  63213. * Represents one particle of a points cloud system.
  63214. */
  63215. export class CloudPoint {
  63216. /**
  63217. * particle global index
  63218. */
  63219. idx: number;
  63220. /**
  63221. * The color of the particle
  63222. */
  63223. color: Nullable<Color4>;
  63224. /**
  63225. * The world space position of the particle.
  63226. */
  63227. position: Vector3;
  63228. /**
  63229. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  63230. */
  63231. rotation: Vector3;
  63232. /**
  63233. * The world space rotation quaternion of the particle.
  63234. */
  63235. rotationQuaternion: Nullable<Quaternion>;
  63236. /**
  63237. * The uv of the particle.
  63238. */
  63239. uv: Nullable<Vector2>;
  63240. /**
  63241. * The current speed of the particle.
  63242. */
  63243. velocity: Vector3;
  63244. /**
  63245. * The pivot point in the particle local space.
  63246. */
  63247. pivot: Vector3;
  63248. /**
  63249. * Must the particle be translated from its pivot point in its local space ?
  63250. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  63251. * Default : false
  63252. */
  63253. translateFromPivot: boolean;
  63254. /**
  63255. * Index of this particle in the global "positions" array (Internal use)
  63256. * @hidden
  63257. */
  63258. _pos: number;
  63259. /**
  63260. * @hidden Index of this particle in the global "indices" array (Internal use)
  63261. */
  63262. _ind: number;
  63263. /**
  63264. * Group this particle belongs to
  63265. */
  63266. _group: PointsGroup;
  63267. /**
  63268. * Group id of this particle
  63269. */
  63270. groupId: number;
  63271. /**
  63272. * Index of the particle in its group id (Internal use)
  63273. */
  63274. idxInGroup: number;
  63275. /**
  63276. * @hidden Particle BoundingInfo object (Internal use)
  63277. */
  63278. _boundingInfo: BoundingInfo;
  63279. /**
  63280. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  63281. */
  63282. _pcs: PointsCloudSystem;
  63283. /**
  63284. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  63285. */
  63286. _stillInvisible: boolean;
  63287. /**
  63288. * @hidden Last computed particle rotation matrix
  63289. */
  63290. _rotationMatrix: number[];
  63291. /**
  63292. * Parent particle Id, if any.
  63293. * Default null.
  63294. */
  63295. parentId: Nullable<number>;
  63296. /**
  63297. * @hidden Internal global position in the PCS.
  63298. */
  63299. _globalPosition: Vector3;
  63300. /**
  63301. * Creates a Point Cloud object.
  63302. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  63303. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  63304. * @param group (PointsGroup) is the group the particle belongs to
  63305. * @param groupId (integer) is the group identifier in the PCS.
  63306. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  63307. * @param pcs defines the PCS it is associated to
  63308. */
  63309. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  63310. /**
  63311. * get point size
  63312. */
  63313. /**
  63314. * Set point size
  63315. */
  63316. size: Vector3;
  63317. /**
  63318. * Legacy support, changed quaternion to rotationQuaternion
  63319. */
  63320. /**
  63321. * Legacy support, changed quaternion to rotationQuaternion
  63322. */
  63323. quaternion: Nullable<Quaternion>;
  63324. /**
  63325. * Returns a boolean. True if the particle intersects a mesh, else false
  63326. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  63327. * @param target is the object (point or mesh) what the intersection is computed against
  63328. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  63329. * @returns true if it intersects
  63330. */
  63331. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  63332. /**
  63333. * get the rotation matrix of the particle
  63334. * @hidden
  63335. */
  63336. getRotationMatrix(m: Matrix): void;
  63337. }
  63338. /**
  63339. * Represents a group of points in a points cloud system
  63340. * * PCS internal tool, don't use it manually.
  63341. */
  63342. export class PointsGroup {
  63343. /**
  63344. * The group id
  63345. * @hidden
  63346. */
  63347. groupID: number;
  63348. /**
  63349. * image data for group (internal use)
  63350. * @hidden
  63351. */
  63352. _groupImageData: Nullable<ArrayBufferView>;
  63353. /**
  63354. * Image Width (internal use)
  63355. * @hidden
  63356. */
  63357. _groupImgWidth: number;
  63358. /**
  63359. * Image Height (internal use)
  63360. * @hidden
  63361. */
  63362. _groupImgHeight: number;
  63363. /**
  63364. * Custom position function (internal use)
  63365. * @hidden
  63366. */
  63367. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  63368. /**
  63369. * density per facet for surface points
  63370. * @hidden
  63371. */
  63372. _groupDensity: number[];
  63373. /**
  63374. * Only when points are colored by texture carries pointer to texture list array
  63375. * @hidden
  63376. */
  63377. _textureNb: number;
  63378. /**
  63379. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  63380. * PCS internal tool, don't use it manually.
  63381. * @hidden
  63382. */
  63383. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  63384. }
  63385. }
  63386. declare module "babylonjs/Particles/index" {
  63387. export * from "babylonjs/Particles/baseParticleSystem";
  63388. export * from "babylonjs/Particles/EmitterTypes/index";
  63389. export * from "babylonjs/Particles/gpuParticleSystem";
  63390. export * from "babylonjs/Particles/IParticleSystem";
  63391. export * from "babylonjs/Particles/particle";
  63392. export * from "babylonjs/Particles/particleHelper";
  63393. export * from "babylonjs/Particles/particleSystem";
  63394. export * from "babylonjs/Particles/particleSystemComponent";
  63395. export * from "babylonjs/Particles/particleSystemSet";
  63396. export * from "babylonjs/Particles/solidParticle";
  63397. export * from "babylonjs/Particles/solidParticleSystem";
  63398. export * from "babylonjs/Particles/cloudPoint";
  63399. export * from "babylonjs/Particles/pointsCloudSystem";
  63400. export * from "babylonjs/Particles/subEmitter";
  63401. }
  63402. declare module "babylonjs/Physics/physicsEngineComponent" {
  63403. import { Nullable } from "babylonjs/types";
  63404. import { Observable, Observer } from "babylonjs/Misc/observable";
  63405. import { Vector3 } from "babylonjs/Maths/math.vector";
  63406. import { Mesh } from "babylonjs/Meshes/mesh";
  63407. import { ISceneComponent } from "babylonjs/sceneComponent";
  63408. import { Scene } from "babylonjs/scene";
  63409. import { Node } from "babylonjs/node";
  63410. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  63411. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63412. module "babylonjs/scene" {
  63413. interface Scene {
  63414. /** @hidden (Backing field) */
  63415. _physicsEngine: Nullable<IPhysicsEngine>;
  63416. /** @hidden */
  63417. _physicsTimeAccumulator: number;
  63418. /**
  63419. * Gets the current physics engine
  63420. * @returns a IPhysicsEngine or null if none attached
  63421. */
  63422. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  63423. /**
  63424. * Enables physics to the current scene
  63425. * @param gravity defines the scene's gravity for the physics engine
  63426. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  63427. * @return a boolean indicating if the physics engine was initialized
  63428. */
  63429. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  63430. /**
  63431. * Disables and disposes the physics engine associated with the scene
  63432. */
  63433. disablePhysicsEngine(): void;
  63434. /**
  63435. * Gets a boolean indicating if there is an active physics engine
  63436. * @returns a boolean indicating if there is an active physics engine
  63437. */
  63438. isPhysicsEnabled(): boolean;
  63439. /**
  63440. * Deletes a physics compound impostor
  63441. * @param compound defines the compound to delete
  63442. */
  63443. deleteCompoundImpostor(compound: any): void;
  63444. /**
  63445. * An event triggered when physic simulation is about to be run
  63446. */
  63447. onBeforePhysicsObservable: Observable<Scene>;
  63448. /**
  63449. * An event triggered when physic simulation has been done
  63450. */
  63451. onAfterPhysicsObservable: Observable<Scene>;
  63452. }
  63453. }
  63454. module "babylonjs/Meshes/abstractMesh" {
  63455. interface AbstractMesh {
  63456. /** @hidden */
  63457. _physicsImpostor: Nullable<PhysicsImpostor>;
  63458. /**
  63459. * Gets or sets impostor used for physic simulation
  63460. * @see http://doc.babylonjs.com/features/physics_engine
  63461. */
  63462. physicsImpostor: Nullable<PhysicsImpostor>;
  63463. /**
  63464. * Gets the current physics impostor
  63465. * @see http://doc.babylonjs.com/features/physics_engine
  63466. * @returns a physics impostor or null
  63467. */
  63468. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  63469. /** Apply a physic impulse to the mesh
  63470. * @param force defines the force to apply
  63471. * @param contactPoint defines where to apply the force
  63472. * @returns the current mesh
  63473. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  63474. */
  63475. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  63476. /**
  63477. * Creates a physic joint between two meshes
  63478. * @param otherMesh defines the other mesh to use
  63479. * @param pivot1 defines the pivot to use on this mesh
  63480. * @param pivot2 defines the pivot to use on the other mesh
  63481. * @param options defines additional options (can be plugin dependent)
  63482. * @returns the current mesh
  63483. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  63484. */
  63485. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  63486. /** @hidden */
  63487. _disposePhysicsObserver: Nullable<Observer<Node>>;
  63488. }
  63489. }
  63490. /**
  63491. * Defines the physics engine scene component responsible to manage a physics engine
  63492. */
  63493. export class PhysicsEngineSceneComponent implements ISceneComponent {
  63494. /**
  63495. * The component name helpful to identify the component in the list of scene components.
  63496. */
  63497. readonly name: string;
  63498. /**
  63499. * The scene the component belongs to.
  63500. */
  63501. scene: Scene;
  63502. /**
  63503. * Creates a new instance of the component for the given scene
  63504. * @param scene Defines the scene to register the component in
  63505. */
  63506. constructor(scene: Scene);
  63507. /**
  63508. * Registers the component in a given scene
  63509. */
  63510. register(): void;
  63511. /**
  63512. * Rebuilds the elements related to this component in case of
  63513. * context lost for instance.
  63514. */
  63515. rebuild(): void;
  63516. /**
  63517. * Disposes the component and the associated ressources
  63518. */
  63519. dispose(): void;
  63520. }
  63521. }
  63522. declare module "babylonjs/Physics/physicsHelper" {
  63523. import { Nullable } from "babylonjs/types";
  63524. import { Vector3 } from "babylonjs/Maths/math.vector";
  63525. import { Mesh } from "babylonjs/Meshes/mesh";
  63526. import { Scene } from "babylonjs/scene";
  63527. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63528. /**
  63529. * A helper for physics simulations
  63530. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63531. */
  63532. export class PhysicsHelper {
  63533. private _scene;
  63534. private _physicsEngine;
  63535. /**
  63536. * Initializes the Physics helper
  63537. * @param scene Babylon.js scene
  63538. */
  63539. constructor(scene: Scene);
  63540. /**
  63541. * Applies a radial explosion impulse
  63542. * @param origin the origin of the explosion
  63543. * @param radiusOrEventOptions the radius or the options of radial explosion
  63544. * @param strength the explosion strength
  63545. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63546. * @returns A physics radial explosion event, or null
  63547. */
  63548. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  63549. /**
  63550. * Applies a radial explosion force
  63551. * @param origin the origin of the explosion
  63552. * @param radiusOrEventOptions the radius or the options of radial explosion
  63553. * @param strength the explosion strength
  63554. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63555. * @returns A physics radial explosion event, or null
  63556. */
  63557. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  63558. /**
  63559. * Creates a gravitational field
  63560. * @param origin the origin of the explosion
  63561. * @param radiusOrEventOptions the radius or the options of radial explosion
  63562. * @param strength the explosion strength
  63563. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63564. * @returns A physics gravitational field event, or null
  63565. */
  63566. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  63567. /**
  63568. * Creates a physics updraft event
  63569. * @param origin the origin of the updraft
  63570. * @param radiusOrEventOptions the radius or the options of the updraft
  63571. * @param strength the strength of the updraft
  63572. * @param height the height of the updraft
  63573. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  63574. * @returns A physics updraft event, or null
  63575. */
  63576. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  63577. /**
  63578. * Creates a physics vortex event
  63579. * @param origin the of the vortex
  63580. * @param radiusOrEventOptions the radius or the options of the vortex
  63581. * @param strength the strength of the vortex
  63582. * @param height the height of the vortex
  63583. * @returns a Physics vortex event, or null
  63584. * A physics vortex event or null
  63585. */
  63586. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  63587. }
  63588. /**
  63589. * Represents a physics radial explosion event
  63590. */
  63591. class PhysicsRadialExplosionEvent {
  63592. private _scene;
  63593. private _options;
  63594. private _sphere;
  63595. private _dataFetched;
  63596. /**
  63597. * Initializes a radial explosioin event
  63598. * @param _scene BabylonJS scene
  63599. * @param _options The options for the vortex event
  63600. */
  63601. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  63602. /**
  63603. * Returns the data related to the radial explosion event (sphere).
  63604. * @returns The radial explosion event data
  63605. */
  63606. getData(): PhysicsRadialExplosionEventData;
  63607. /**
  63608. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  63609. * @param impostor A physics imposter
  63610. * @param origin the origin of the explosion
  63611. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  63612. */
  63613. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  63614. /**
  63615. * Triggers affecterd impostors callbacks
  63616. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  63617. */
  63618. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  63619. /**
  63620. * Disposes the sphere.
  63621. * @param force Specifies if the sphere should be disposed by force
  63622. */
  63623. dispose(force?: boolean): void;
  63624. /*** Helpers ***/
  63625. private _prepareSphere;
  63626. private _intersectsWithSphere;
  63627. }
  63628. /**
  63629. * Represents a gravitational field event
  63630. */
  63631. class PhysicsGravitationalFieldEvent {
  63632. private _physicsHelper;
  63633. private _scene;
  63634. private _origin;
  63635. private _options;
  63636. private _tickCallback;
  63637. private _sphere;
  63638. private _dataFetched;
  63639. /**
  63640. * Initializes the physics gravitational field event
  63641. * @param _physicsHelper A physics helper
  63642. * @param _scene BabylonJS scene
  63643. * @param _origin The origin position of the gravitational field event
  63644. * @param _options The options for the vortex event
  63645. */
  63646. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  63647. /**
  63648. * Returns the data related to the gravitational field event (sphere).
  63649. * @returns A gravitational field event
  63650. */
  63651. getData(): PhysicsGravitationalFieldEventData;
  63652. /**
  63653. * Enables the gravitational field.
  63654. */
  63655. enable(): void;
  63656. /**
  63657. * Disables the gravitational field.
  63658. */
  63659. disable(): void;
  63660. /**
  63661. * Disposes the sphere.
  63662. * @param force The force to dispose from the gravitational field event
  63663. */
  63664. dispose(force?: boolean): void;
  63665. private _tick;
  63666. }
  63667. /**
  63668. * Represents a physics updraft event
  63669. */
  63670. class PhysicsUpdraftEvent {
  63671. private _scene;
  63672. private _origin;
  63673. private _options;
  63674. private _physicsEngine;
  63675. private _originTop;
  63676. private _originDirection;
  63677. private _tickCallback;
  63678. private _cylinder;
  63679. private _cylinderPosition;
  63680. private _dataFetched;
  63681. /**
  63682. * Initializes the physics updraft event
  63683. * @param _scene BabylonJS scene
  63684. * @param _origin The origin position of the updraft
  63685. * @param _options The options for the updraft event
  63686. */
  63687. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  63688. /**
  63689. * Returns the data related to the updraft event (cylinder).
  63690. * @returns A physics updraft event
  63691. */
  63692. getData(): PhysicsUpdraftEventData;
  63693. /**
  63694. * Enables the updraft.
  63695. */
  63696. enable(): void;
  63697. /**
  63698. * Disables the updraft.
  63699. */
  63700. disable(): void;
  63701. /**
  63702. * Disposes the cylinder.
  63703. * @param force Specifies if the updraft should be disposed by force
  63704. */
  63705. dispose(force?: boolean): void;
  63706. private getImpostorHitData;
  63707. private _tick;
  63708. /*** Helpers ***/
  63709. private _prepareCylinder;
  63710. private _intersectsWithCylinder;
  63711. }
  63712. /**
  63713. * Represents a physics vortex event
  63714. */
  63715. class PhysicsVortexEvent {
  63716. private _scene;
  63717. private _origin;
  63718. private _options;
  63719. private _physicsEngine;
  63720. private _originTop;
  63721. private _tickCallback;
  63722. private _cylinder;
  63723. private _cylinderPosition;
  63724. private _dataFetched;
  63725. /**
  63726. * Initializes the physics vortex event
  63727. * @param _scene The BabylonJS scene
  63728. * @param _origin The origin position of the vortex
  63729. * @param _options The options for the vortex event
  63730. */
  63731. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  63732. /**
  63733. * Returns the data related to the vortex event (cylinder).
  63734. * @returns The physics vortex event data
  63735. */
  63736. getData(): PhysicsVortexEventData;
  63737. /**
  63738. * Enables the vortex.
  63739. */
  63740. enable(): void;
  63741. /**
  63742. * Disables the cortex.
  63743. */
  63744. disable(): void;
  63745. /**
  63746. * Disposes the sphere.
  63747. * @param force
  63748. */
  63749. dispose(force?: boolean): void;
  63750. private getImpostorHitData;
  63751. private _tick;
  63752. /*** Helpers ***/
  63753. private _prepareCylinder;
  63754. private _intersectsWithCylinder;
  63755. }
  63756. /**
  63757. * Options fot the radial explosion event
  63758. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63759. */
  63760. export class PhysicsRadialExplosionEventOptions {
  63761. /**
  63762. * The radius of the sphere for the radial explosion.
  63763. */
  63764. radius: number;
  63765. /**
  63766. * The strenth of the explosion.
  63767. */
  63768. strength: number;
  63769. /**
  63770. * The strenght of the force in correspondence to the distance of the affected object
  63771. */
  63772. falloff: PhysicsRadialImpulseFalloff;
  63773. /**
  63774. * Sphere options for the radial explosion.
  63775. */
  63776. sphere: {
  63777. segments: number;
  63778. diameter: number;
  63779. };
  63780. /**
  63781. * Sphere options for the radial explosion.
  63782. */
  63783. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  63784. }
  63785. /**
  63786. * Options fot the updraft event
  63787. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63788. */
  63789. export class PhysicsUpdraftEventOptions {
  63790. /**
  63791. * The radius of the cylinder for the vortex
  63792. */
  63793. radius: number;
  63794. /**
  63795. * The strenth of the updraft.
  63796. */
  63797. strength: number;
  63798. /**
  63799. * The height of the cylinder for the updraft.
  63800. */
  63801. height: number;
  63802. /**
  63803. * The mode for the the updraft.
  63804. */
  63805. updraftMode: PhysicsUpdraftMode;
  63806. }
  63807. /**
  63808. * Options fot the vortex event
  63809. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63810. */
  63811. export class PhysicsVortexEventOptions {
  63812. /**
  63813. * The radius of the cylinder for the vortex
  63814. */
  63815. radius: number;
  63816. /**
  63817. * The strenth of the vortex.
  63818. */
  63819. strength: number;
  63820. /**
  63821. * The height of the cylinder for the vortex.
  63822. */
  63823. height: number;
  63824. /**
  63825. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  63826. */
  63827. centripetalForceThreshold: number;
  63828. /**
  63829. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  63830. */
  63831. centripetalForceMultiplier: number;
  63832. /**
  63833. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  63834. */
  63835. centrifugalForceMultiplier: number;
  63836. /**
  63837. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  63838. */
  63839. updraftForceMultiplier: number;
  63840. }
  63841. /**
  63842. * The strenght of the force in correspondence to the distance of the affected object
  63843. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63844. */
  63845. export enum PhysicsRadialImpulseFalloff {
  63846. /** Defines that impulse is constant in strength across it's whole radius */
  63847. Constant = 0,
  63848. /** Defines that impulse gets weaker if it's further from the origin */
  63849. Linear = 1
  63850. }
  63851. /**
  63852. * The strength of the force in correspondence to the distance of the affected object
  63853. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63854. */
  63855. export enum PhysicsUpdraftMode {
  63856. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  63857. Center = 0,
  63858. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  63859. Perpendicular = 1
  63860. }
  63861. /**
  63862. * Interface for a physics hit data
  63863. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63864. */
  63865. export interface PhysicsHitData {
  63866. /**
  63867. * The force applied at the contact point
  63868. */
  63869. force: Vector3;
  63870. /**
  63871. * The contact point
  63872. */
  63873. contactPoint: Vector3;
  63874. /**
  63875. * The distance from the origin to the contact point
  63876. */
  63877. distanceFromOrigin: number;
  63878. }
  63879. /**
  63880. * Interface for radial explosion event data
  63881. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63882. */
  63883. export interface PhysicsRadialExplosionEventData {
  63884. /**
  63885. * A sphere used for the radial explosion event
  63886. */
  63887. sphere: Mesh;
  63888. }
  63889. /**
  63890. * Interface for gravitational field event data
  63891. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63892. */
  63893. export interface PhysicsGravitationalFieldEventData {
  63894. /**
  63895. * A sphere mesh used for the gravitational field event
  63896. */
  63897. sphere: Mesh;
  63898. }
  63899. /**
  63900. * Interface for updraft event data
  63901. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63902. */
  63903. export interface PhysicsUpdraftEventData {
  63904. /**
  63905. * A cylinder used for the updraft event
  63906. */
  63907. cylinder: Mesh;
  63908. }
  63909. /**
  63910. * Interface for vortex event data
  63911. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63912. */
  63913. export interface PhysicsVortexEventData {
  63914. /**
  63915. * A cylinder used for the vortex event
  63916. */
  63917. cylinder: Mesh;
  63918. }
  63919. /**
  63920. * Interface for an affected physics impostor
  63921. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63922. */
  63923. export interface PhysicsAffectedImpostorWithData {
  63924. /**
  63925. * The impostor affected by the effect
  63926. */
  63927. impostor: PhysicsImpostor;
  63928. /**
  63929. * The data about the hit/horce from the explosion
  63930. */
  63931. hitData: PhysicsHitData;
  63932. }
  63933. }
  63934. declare module "babylonjs/Physics/Plugins/index" {
  63935. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  63936. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  63937. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  63938. }
  63939. declare module "babylonjs/Physics/index" {
  63940. export * from "babylonjs/Physics/IPhysicsEngine";
  63941. export * from "babylonjs/Physics/physicsEngine";
  63942. export * from "babylonjs/Physics/physicsEngineComponent";
  63943. export * from "babylonjs/Physics/physicsHelper";
  63944. export * from "babylonjs/Physics/physicsImpostor";
  63945. export * from "babylonjs/Physics/physicsJoint";
  63946. export * from "babylonjs/Physics/Plugins/index";
  63947. }
  63948. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  63949. /** @hidden */
  63950. export var blackAndWhitePixelShader: {
  63951. name: string;
  63952. shader: string;
  63953. };
  63954. }
  63955. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  63956. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63957. import { Camera } from "babylonjs/Cameras/camera";
  63958. import { Engine } from "babylonjs/Engines/engine";
  63959. import "babylonjs/Shaders/blackAndWhite.fragment";
  63960. /**
  63961. * Post process used to render in black and white
  63962. */
  63963. export class BlackAndWhitePostProcess extends PostProcess {
  63964. /**
  63965. * Linear about to convert he result to black and white (default: 1)
  63966. */
  63967. degree: number;
  63968. /**
  63969. * Creates a black and white post process
  63970. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  63971. * @param name The name of the effect.
  63972. * @param options The required width/height ratio to downsize to before computing the render pass.
  63973. * @param camera The camera to apply the render pass to.
  63974. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63975. * @param engine The engine which the post process will be applied. (default: current engine)
  63976. * @param reusable If the post process can be reused on the same frame. (default: false)
  63977. */
  63978. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63979. }
  63980. }
  63981. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  63982. import { Nullable } from "babylonjs/types";
  63983. import { Camera } from "babylonjs/Cameras/camera";
  63984. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63985. import { Engine } from "babylonjs/Engines/engine";
  63986. /**
  63987. * This represents a set of one or more post processes in Babylon.
  63988. * A post process can be used to apply a shader to a texture after it is rendered.
  63989. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63990. */
  63991. export class PostProcessRenderEffect {
  63992. private _postProcesses;
  63993. private _getPostProcesses;
  63994. private _singleInstance;
  63995. private _cameras;
  63996. private _indicesForCamera;
  63997. /**
  63998. * Name of the effect
  63999. * @hidden
  64000. */
  64001. _name: string;
  64002. /**
  64003. * Instantiates a post process render effect.
  64004. * A post process can be used to apply a shader to a texture after it is rendered.
  64005. * @param engine The engine the effect is tied to
  64006. * @param name The name of the effect
  64007. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  64008. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  64009. */
  64010. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  64011. /**
  64012. * Checks if all the post processes in the effect are supported.
  64013. */
  64014. readonly isSupported: boolean;
  64015. /**
  64016. * Updates the current state of the effect
  64017. * @hidden
  64018. */
  64019. _update(): void;
  64020. /**
  64021. * Attaches the effect on cameras
  64022. * @param cameras The camera to attach to.
  64023. * @hidden
  64024. */
  64025. _attachCameras(cameras: Camera): void;
  64026. /**
  64027. * Attaches the effect on cameras
  64028. * @param cameras The camera to attach to.
  64029. * @hidden
  64030. */
  64031. _attachCameras(cameras: Camera[]): void;
  64032. /**
  64033. * Detaches the effect on cameras
  64034. * @param cameras The camera to detatch from.
  64035. * @hidden
  64036. */
  64037. _detachCameras(cameras: Camera): void;
  64038. /**
  64039. * Detatches the effect on cameras
  64040. * @param cameras The camera to detatch from.
  64041. * @hidden
  64042. */
  64043. _detachCameras(cameras: Camera[]): void;
  64044. /**
  64045. * Enables the effect on given cameras
  64046. * @param cameras The camera to enable.
  64047. * @hidden
  64048. */
  64049. _enable(cameras: Camera): void;
  64050. /**
  64051. * Enables the effect on given cameras
  64052. * @param cameras The camera to enable.
  64053. * @hidden
  64054. */
  64055. _enable(cameras: Nullable<Camera[]>): void;
  64056. /**
  64057. * Disables the effect on the given cameras
  64058. * @param cameras The camera to disable.
  64059. * @hidden
  64060. */
  64061. _disable(cameras: Camera): void;
  64062. /**
  64063. * Disables the effect on the given cameras
  64064. * @param cameras The camera to disable.
  64065. * @hidden
  64066. */
  64067. _disable(cameras: Nullable<Camera[]>): void;
  64068. /**
  64069. * Gets a list of the post processes contained in the effect.
  64070. * @param camera The camera to get the post processes on.
  64071. * @returns The list of the post processes in the effect.
  64072. */
  64073. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  64074. }
  64075. }
  64076. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  64077. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  64078. /** @hidden */
  64079. export var extractHighlightsPixelShader: {
  64080. name: string;
  64081. shader: string;
  64082. };
  64083. }
  64084. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  64085. import { Nullable } from "babylonjs/types";
  64086. import { Camera } from "babylonjs/Cameras/camera";
  64087. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64088. import { Engine } from "babylonjs/Engines/engine";
  64089. import "babylonjs/Shaders/extractHighlights.fragment";
  64090. /**
  64091. * 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.
  64092. */
  64093. export class ExtractHighlightsPostProcess extends PostProcess {
  64094. /**
  64095. * The luminance threshold, pixels below this value will be set to black.
  64096. */
  64097. threshold: number;
  64098. /** @hidden */
  64099. _exposure: number;
  64100. /**
  64101. * Post process which has the input texture to be used when performing highlight extraction
  64102. * @hidden
  64103. */
  64104. _inputPostProcess: Nullable<PostProcess>;
  64105. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64106. }
  64107. }
  64108. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  64109. /** @hidden */
  64110. export var bloomMergePixelShader: {
  64111. name: string;
  64112. shader: string;
  64113. };
  64114. }
  64115. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  64116. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64117. import { Nullable } from "babylonjs/types";
  64118. import { Engine } from "babylonjs/Engines/engine";
  64119. import { Camera } from "babylonjs/Cameras/camera";
  64120. import "babylonjs/Shaders/bloomMerge.fragment";
  64121. /**
  64122. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  64123. */
  64124. export class BloomMergePostProcess extends PostProcess {
  64125. /** Weight of the bloom to be added to the original input. */
  64126. weight: number;
  64127. /**
  64128. * Creates a new instance of @see BloomMergePostProcess
  64129. * @param name The name of the effect.
  64130. * @param originalFromInput Post process which's input will be used for the merge.
  64131. * @param blurred Blurred highlights post process which's output will be used.
  64132. * @param weight Weight of the bloom to be added to the original input.
  64133. * @param options The required width/height ratio to downsize to before computing the render pass.
  64134. * @param camera The camera to apply the render pass to.
  64135. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64136. * @param engine The engine which the post process will be applied. (default: current engine)
  64137. * @param reusable If the post process can be reused on the same frame. (default: false)
  64138. * @param textureType Type of textures used when performing the post process. (default: 0)
  64139. * @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)
  64140. */
  64141. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  64142. /** Weight of the bloom to be added to the original input. */
  64143. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64144. }
  64145. }
  64146. declare module "babylonjs/PostProcesses/bloomEffect" {
  64147. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  64148. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  64149. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  64150. import { Camera } from "babylonjs/Cameras/camera";
  64151. import { Scene } from "babylonjs/scene";
  64152. /**
  64153. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  64154. */
  64155. export class BloomEffect extends PostProcessRenderEffect {
  64156. private bloomScale;
  64157. /**
  64158. * @hidden Internal
  64159. */
  64160. _effects: Array<PostProcess>;
  64161. /**
  64162. * @hidden Internal
  64163. */
  64164. _downscale: ExtractHighlightsPostProcess;
  64165. private _blurX;
  64166. private _blurY;
  64167. private _merge;
  64168. /**
  64169. * The luminance threshold to find bright areas of the image to bloom.
  64170. */
  64171. threshold: number;
  64172. /**
  64173. * The strength of the bloom.
  64174. */
  64175. weight: number;
  64176. /**
  64177. * Specifies the size of the bloom blur kernel, relative to the final output size
  64178. */
  64179. kernel: number;
  64180. /**
  64181. * Creates a new instance of @see BloomEffect
  64182. * @param scene The scene the effect belongs to.
  64183. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  64184. * @param bloomKernel The size of the kernel to be used when applying the blur.
  64185. * @param bloomWeight The the strength of bloom.
  64186. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64187. * @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)
  64188. */
  64189. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  64190. /**
  64191. * Disposes each of the internal effects for a given camera.
  64192. * @param camera The camera to dispose the effect on.
  64193. */
  64194. disposeEffects(camera: Camera): void;
  64195. /**
  64196. * @hidden Internal
  64197. */
  64198. _updateEffects(): void;
  64199. /**
  64200. * Internal
  64201. * @returns if all the contained post processes are ready.
  64202. * @hidden
  64203. */
  64204. _isReady(): boolean;
  64205. }
  64206. }
  64207. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  64208. /** @hidden */
  64209. export var chromaticAberrationPixelShader: {
  64210. name: string;
  64211. shader: string;
  64212. };
  64213. }
  64214. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  64215. import { Vector2 } from "babylonjs/Maths/math.vector";
  64216. import { Nullable } from "babylonjs/types";
  64217. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64218. import { Camera } from "babylonjs/Cameras/camera";
  64219. import { Engine } from "babylonjs/Engines/engine";
  64220. import "babylonjs/Shaders/chromaticAberration.fragment";
  64221. /**
  64222. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  64223. */
  64224. export class ChromaticAberrationPostProcess extends PostProcess {
  64225. /**
  64226. * The amount of seperation of rgb channels (default: 30)
  64227. */
  64228. aberrationAmount: number;
  64229. /**
  64230. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  64231. */
  64232. radialIntensity: number;
  64233. /**
  64234. * 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))
  64235. */
  64236. direction: Vector2;
  64237. /**
  64238. * 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))
  64239. */
  64240. centerPosition: Vector2;
  64241. /**
  64242. * Creates a new instance ChromaticAberrationPostProcess
  64243. * @param name The name of the effect.
  64244. * @param screenWidth The width of the screen to apply the effect on.
  64245. * @param screenHeight The height of the screen to apply the effect on.
  64246. * @param options The required width/height ratio to downsize to before computing the render pass.
  64247. * @param camera The camera to apply the render pass to.
  64248. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64249. * @param engine The engine which the post process will be applied. (default: current engine)
  64250. * @param reusable If the post process can be reused on the same frame. (default: false)
  64251. * @param textureType Type of textures used when performing the post process. (default: 0)
  64252. * @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)
  64253. */
  64254. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64255. }
  64256. }
  64257. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  64258. /** @hidden */
  64259. export var circleOfConfusionPixelShader: {
  64260. name: string;
  64261. shader: string;
  64262. };
  64263. }
  64264. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  64265. import { Nullable } from "babylonjs/types";
  64266. import { Engine } from "babylonjs/Engines/engine";
  64267. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64268. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64269. import { Camera } from "babylonjs/Cameras/camera";
  64270. import "babylonjs/Shaders/circleOfConfusion.fragment";
  64271. /**
  64272. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  64273. */
  64274. export class CircleOfConfusionPostProcess extends PostProcess {
  64275. /**
  64276. * 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.
  64277. */
  64278. lensSize: number;
  64279. /**
  64280. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  64281. */
  64282. fStop: number;
  64283. /**
  64284. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  64285. */
  64286. focusDistance: number;
  64287. /**
  64288. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  64289. */
  64290. focalLength: number;
  64291. private _depthTexture;
  64292. /**
  64293. * Creates a new instance CircleOfConfusionPostProcess
  64294. * @param name The name of the effect.
  64295. * @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.
  64296. * @param options The required width/height ratio to downsize to before computing the render pass.
  64297. * @param camera The camera to apply the render pass to.
  64298. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64299. * @param engine The engine which the post process will be applied. (default: current engine)
  64300. * @param reusable If the post process can be reused on the same frame. (default: false)
  64301. * @param textureType Type of textures used when performing the post process. (default: 0)
  64302. * @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)
  64303. */
  64304. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64305. /**
  64306. * 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.
  64307. */
  64308. depthTexture: RenderTargetTexture;
  64309. }
  64310. }
  64311. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  64312. /** @hidden */
  64313. export var colorCorrectionPixelShader: {
  64314. name: string;
  64315. shader: string;
  64316. };
  64317. }
  64318. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  64319. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64320. import { Engine } from "babylonjs/Engines/engine";
  64321. import { Camera } from "babylonjs/Cameras/camera";
  64322. import "babylonjs/Shaders/colorCorrection.fragment";
  64323. /**
  64324. *
  64325. * This post-process allows the modification of rendered colors by using
  64326. * a 'look-up table' (LUT). This effect is also called Color Grading.
  64327. *
  64328. * The object needs to be provided an url to a texture containing the color
  64329. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  64330. * Use an image editing software to tweak the LUT to match your needs.
  64331. *
  64332. * For an example of a color LUT, see here:
  64333. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  64334. * For explanations on color grading, see here:
  64335. * @see http://udn.epicgames.com/Three/ColorGrading.html
  64336. *
  64337. */
  64338. export class ColorCorrectionPostProcess extends PostProcess {
  64339. private _colorTableTexture;
  64340. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64341. }
  64342. }
  64343. declare module "babylonjs/Shaders/convolution.fragment" {
  64344. /** @hidden */
  64345. export var convolutionPixelShader: {
  64346. name: string;
  64347. shader: string;
  64348. };
  64349. }
  64350. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  64351. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64352. import { Nullable } from "babylonjs/types";
  64353. import { Camera } from "babylonjs/Cameras/camera";
  64354. import { Engine } from "babylonjs/Engines/engine";
  64355. import "babylonjs/Shaders/convolution.fragment";
  64356. /**
  64357. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  64358. * input texture to perform effects such as edge detection or sharpening
  64359. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  64360. */
  64361. export class ConvolutionPostProcess extends PostProcess {
  64362. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64363. kernel: number[];
  64364. /**
  64365. * Creates a new instance ConvolutionPostProcess
  64366. * @param name The name of the effect.
  64367. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  64368. * @param options The required width/height ratio to downsize to before computing the render pass.
  64369. * @param camera The camera to apply the render pass to.
  64370. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64371. * @param engine The engine which the post process will be applied. (default: current engine)
  64372. * @param reusable If the post process can be reused on the same frame. (default: false)
  64373. * @param textureType Type of textures used when performing the post process. (default: 0)
  64374. */
  64375. constructor(name: string,
  64376. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64377. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64378. /**
  64379. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64380. */
  64381. static EdgeDetect0Kernel: number[];
  64382. /**
  64383. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64384. */
  64385. static EdgeDetect1Kernel: number[];
  64386. /**
  64387. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64388. */
  64389. static EdgeDetect2Kernel: number[];
  64390. /**
  64391. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64392. */
  64393. static SharpenKernel: number[];
  64394. /**
  64395. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64396. */
  64397. static EmbossKernel: number[];
  64398. /**
  64399. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64400. */
  64401. static GaussianKernel: number[];
  64402. }
  64403. }
  64404. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  64405. import { Nullable } from "babylonjs/types";
  64406. import { Vector2 } from "babylonjs/Maths/math.vector";
  64407. import { Camera } from "babylonjs/Cameras/camera";
  64408. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64409. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  64410. import { Engine } from "babylonjs/Engines/engine";
  64411. import { Scene } from "babylonjs/scene";
  64412. /**
  64413. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  64414. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  64415. * based on samples that have a large difference in distance than the center pixel.
  64416. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  64417. */
  64418. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  64419. direction: Vector2;
  64420. /**
  64421. * Creates a new instance CircleOfConfusionPostProcess
  64422. * @param name The name of the effect.
  64423. * @param scene The scene the effect belongs to.
  64424. * @param direction The direction the blur should be applied.
  64425. * @param kernel The size of the kernel used to blur.
  64426. * @param options The required width/height ratio to downsize to before computing the render pass.
  64427. * @param camera The camera to apply the render pass to.
  64428. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  64429. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  64430. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64431. * @param engine The engine which the post process will be applied. (default: current engine)
  64432. * @param reusable If the post process can be reused on the same frame. (default: false)
  64433. * @param textureType Type of textures used when performing the post process. (default: 0)
  64434. * @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)
  64435. */
  64436. 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);
  64437. }
  64438. }
  64439. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  64440. /** @hidden */
  64441. export var depthOfFieldMergePixelShader: {
  64442. name: string;
  64443. shader: string;
  64444. };
  64445. }
  64446. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  64447. import { Nullable } from "babylonjs/types";
  64448. import { Camera } from "babylonjs/Cameras/camera";
  64449. import { Effect } from "babylonjs/Materials/effect";
  64450. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64451. import { Engine } from "babylonjs/Engines/engine";
  64452. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  64453. /**
  64454. * Options to be set when merging outputs from the default pipeline.
  64455. */
  64456. export class DepthOfFieldMergePostProcessOptions {
  64457. /**
  64458. * The original image to merge on top of
  64459. */
  64460. originalFromInput: PostProcess;
  64461. /**
  64462. * Parameters to perform the merge of the depth of field effect
  64463. */
  64464. depthOfField?: {
  64465. circleOfConfusion: PostProcess;
  64466. blurSteps: Array<PostProcess>;
  64467. };
  64468. /**
  64469. * Parameters to perform the merge of bloom effect
  64470. */
  64471. bloom?: {
  64472. blurred: PostProcess;
  64473. weight: number;
  64474. };
  64475. }
  64476. /**
  64477. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  64478. */
  64479. export class DepthOfFieldMergePostProcess extends PostProcess {
  64480. private blurSteps;
  64481. /**
  64482. * Creates a new instance of DepthOfFieldMergePostProcess
  64483. * @param name The name of the effect.
  64484. * @param originalFromInput Post process which's input will be used for the merge.
  64485. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  64486. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  64487. * @param options The required width/height ratio to downsize to before computing the render pass.
  64488. * @param camera The camera to apply the render pass to.
  64489. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64490. * @param engine The engine which the post process will be applied. (default: current engine)
  64491. * @param reusable If the post process can be reused on the same frame. (default: false)
  64492. * @param textureType Type of textures used when performing the post process. (default: 0)
  64493. * @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)
  64494. */
  64495. 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);
  64496. /**
  64497. * Updates the effect with the current post process compile time values and recompiles the shader.
  64498. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  64499. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  64500. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  64501. * @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
  64502. * @param onCompiled Called when the shader has been compiled.
  64503. * @param onError Called if there is an error when compiling a shader.
  64504. */
  64505. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  64506. }
  64507. }
  64508. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  64509. import { Nullable } from "babylonjs/types";
  64510. import { Camera } from "babylonjs/Cameras/camera";
  64511. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64512. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  64513. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  64514. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  64515. import { Scene } from "babylonjs/scene";
  64516. /**
  64517. * Specifies the level of max blur that should be applied when using the depth of field effect
  64518. */
  64519. export enum DepthOfFieldEffectBlurLevel {
  64520. /**
  64521. * Subtle blur
  64522. */
  64523. Low = 0,
  64524. /**
  64525. * Medium blur
  64526. */
  64527. Medium = 1,
  64528. /**
  64529. * Large blur
  64530. */
  64531. High = 2
  64532. }
  64533. /**
  64534. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  64535. */
  64536. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  64537. private _circleOfConfusion;
  64538. /**
  64539. * @hidden Internal, blurs from high to low
  64540. */
  64541. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  64542. private _depthOfFieldBlurY;
  64543. private _dofMerge;
  64544. /**
  64545. * @hidden Internal post processes in depth of field effect
  64546. */
  64547. _effects: Array<PostProcess>;
  64548. /**
  64549. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  64550. */
  64551. focalLength: number;
  64552. /**
  64553. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  64554. */
  64555. fStop: number;
  64556. /**
  64557. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  64558. */
  64559. focusDistance: number;
  64560. /**
  64561. * 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.
  64562. */
  64563. lensSize: number;
  64564. /**
  64565. * Creates a new instance DepthOfFieldEffect
  64566. * @param scene The scene the effect belongs to.
  64567. * @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.
  64568. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64569. * @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)
  64570. */
  64571. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  64572. /**
  64573. * Get the current class name of the current effet
  64574. * @returns "DepthOfFieldEffect"
  64575. */
  64576. getClassName(): string;
  64577. /**
  64578. * 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.
  64579. */
  64580. depthTexture: RenderTargetTexture;
  64581. /**
  64582. * Disposes each of the internal effects for a given camera.
  64583. * @param camera The camera to dispose the effect on.
  64584. */
  64585. disposeEffects(camera: Camera): void;
  64586. /**
  64587. * @hidden Internal
  64588. */
  64589. _updateEffects(): void;
  64590. /**
  64591. * Internal
  64592. * @returns if all the contained post processes are ready.
  64593. * @hidden
  64594. */
  64595. _isReady(): boolean;
  64596. }
  64597. }
  64598. declare module "babylonjs/Shaders/displayPass.fragment" {
  64599. /** @hidden */
  64600. export var displayPassPixelShader: {
  64601. name: string;
  64602. shader: string;
  64603. };
  64604. }
  64605. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  64606. import { Nullable } from "babylonjs/types";
  64607. import { Camera } from "babylonjs/Cameras/camera";
  64608. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64609. import { Engine } from "babylonjs/Engines/engine";
  64610. import "babylonjs/Shaders/displayPass.fragment";
  64611. /**
  64612. * DisplayPassPostProcess which produces an output the same as it's input
  64613. */
  64614. export class DisplayPassPostProcess extends PostProcess {
  64615. /**
  64616. * Creates the DisplayPassPostProcess
  64617. * @param name The name of the effect.
  64618. * @param options The required width/height ratio to downsize to before computing the render pass.
  64619. * @param camera The camera to apply the render pass to.
  64620. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64621. * @param engine The engine which the post process will be applied. (default: current engine)
  64622. * @param reusable If the post process can be reused on the same frame. (default: false)
  64623. */
  64624. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64625. }
  64626. }
  64627. declare module "babylonjs/Shaders/filter.fragment" {
  64628. /** @hidden */
  64629. export var filterPixelShader: {
  64630. name: string;
  64631. shader: string;
  64632. };
  64633. }
  64634. declare module "babylonjs/PostProcesses/filterPostProcess" {
  64635. import { Nullable } from "babylonjs/types";
  64636. import { Matrix } from "babylonjs/Maths/math.vector";
  64637. import { Camera } from "babylonjs/Cameras/camera";
  64638. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64639. import { Engine } from "babylonjs/Engines/engine";
  64640. import "babylonjs/Shaders/filter.fragment";
  64641. /**
  64642. * Applies a kernel filter to the image
  64643. */
  64644. export class FilterPostProcess extends PostProcess {
  64645. /** The matrix to be applied to the image */
  64646. kernelMatrix: Matrix;
  64647. /**
  64648. *
  64649. * @param name The name of the effect.
  64650. * @param kernelMatrix The matrix to be applied to the image
  64651. * @param options The required width/height ratio to downsize to before computing the render pass.
  64652. * @param camera The camera to apply the render pass to.
  64653. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64654. * @param engine The engine which the post process will be applied. (default: current engine)
  64655. * @param reusable If the post process can be reused on the same frame. (default: false)
  64656. */
  64657. constructor(name: string,
  64658. /** The matrix to be applied to the image */
  64659. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64660. }
  64661. }
  64662. declare module "babylonjs/Shaders/fxaa.fragment" {
  64663. /** @hidden */
  64664. export var fxaaPixelShader: {
  64665. name: string;
  64666. shader: string;
  64667. };
  64668. }
  64669. declare module "babylonjs/Shaders/fxaa.vertex" {
  64670. /** @hidden */
  64671. export var fxaaVertexShader: {
  64672. name: string;
  64673. shader: string;
  64674. };
  64675. }
  64676. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  64677. import { Nullable } from "babylonjs/types";
  64678. import { Camera } from "babylonjs/Cameras/camera";
  64679. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64680. import { Engine } from "babylonjs/Engines/engine";
  64681. import "babylonjs/Shaders/fxaa.fragment";
  64682. import "babylonjs/Shaders/fxaa.vertex";
  64683. /**
  64684. * Fxaa post process
  64685. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  64686. */
  64687. export class FxaaPostProcess extends PostProcess {
  64688. /** @hidden */
  64689. texelWidth: number;
  64690. /** @hidden */
  64691. texelHeight: number;
  64692. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64693. private _getDefines;
  64694. }
  64695. }
  64696. declare module "babylonjs/Shaders/grain.fragment" {
  64697. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  64698. /** @hidden */
  64699. export var grainPixelShader: {
  64700. name: string;
  64701. shader: string;
  64702. };
  64703. }
  64704. declare module "babylonjs/PostProcesses/grainPostProcess" {
  64705. import { Nullable } from "babylonjs/types";
  64706. import { Camera } from "babylonjs/Cameras/camera";
  64707. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64708. import { Engine } from "babylonjs/Engines/engine";
  64709. import "babylonjs/Shaders/grain.fragment";
  64710. /**
  64711. * The GrainPostProcess adds noise to the image at mid luminance levels
  64712. */
  64713. export class GrainPostProcess extends PostProcess {
  64714. /**
  64715. * The intensity of the grain added (default: 30)
  64716. */
  64717. intensity: number;
  64718. /**
  64719. * If the grain should be randomized on every frame
  64720. */
  64721. animated: boolean;
  64722. /**
  64723. * Creates a new instance of @see GrainPostProcess
  64724. * @param name The name of the effect.
  64725. * @param options The required width/height ratio to downsize to before computing the render pass.
  64726. * @param camera The camera to apply the render pass to.
  64727. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64728. * @param engine The engine which the post process will be applied. (default: current engine)
  64729. * @param reusable If the post process can be reused on the same frame. (default: false)
  64730. * @param textureType Type of textures used when performing the post process. (default: 0)
  64731. * @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)
  64732. */
  64733. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64734. }
  64735. }
  64736. declare module "babylonjs/Shaders/highlights.fragment" {
  64737. /** @hidden */
  64738. export var highlightsPixelShader: {
  64739. name: string;
  64740. shader: string;
  64741. };
  64742. }
  64743. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  64744. import { Nullable } from "babylonjs/types";
  64745. import { Camera } from "babylonjs/Cameras/camera";
  64746. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64747. import { Engine } from "babylonjs/Engines/engine";
  64748. import "babylonjs/Shaders/highlights.fragment";
  64749. /**
  64750. * Extracts highlights from the image
  64751. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  64752. */
  64753. export class HighlightsPostProcess extends PostProcess {
  64754. /**
  64755. * Extracts highlights from the image
  64756. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  64757. * @param name The name of the effect.
  64758. * @param options The required width/height ratio to downsize to before computing the render pass.
  64759. * @param camera The camera to apply the render pass to.
  64760. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64761. * @param engine The engine which the post process will be applied. (default: current engine)
  64762. * @param reusable If the post process can be reused on the same frame. (default: false)
  64763. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  64764. */
  64765. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64766. }
  64767. }
  64768. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  64769. /** @hidden */
  64770. export var mrtFragmentDeclaration: {
  64771. name: string;
  64772. shader: string;
  64773. };
  64774. }
  64775. declare module "babylonjs/Shaders/geometry.fragment" {
  64776. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  64777. /** @hidden */
  64778. export var geometryPixelShader: {
  64779. name: string;
  64780. shader: string;
  64781. };
  64782. }
  64783. declare module "babylonjs/Shaders/geometry.vertex" {
  64784. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64785. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64786. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64787. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  64788. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  64789. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  64790. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64791. /** @hidden */
  64792. export var geometryVertexShader: {
  64793. name: string;
  64794. shader: string;
  64795. };
  64796. }
  64797. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  64798. import { Matrix } from "babylonjs/Maths/math.vector";
  64799. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64800. import { Mesh } from "babylonjs/Meshes/mesh";
  64801. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  64802. import { Effect } from "babylonjs/Materials/effect";
  64803. import { Scene } from "babylonjs/scene";
  64804. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64805. import "babylonjs/Shaders/geometry.fragment";
  64806. import "babylonjs/Shaders/geometry.vertex";
  64807. /** @hidden */
  64808. interface ISavedTransformationMatrix {
  64809. world: Matrix;
  64810. viewProjection: Matrix;
  64811. }
  64812. /**
  64813. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  64814. */
  64815. export class GeometryBufferRenderer {
  64816. /**
  64817. * Constant used to retrieve the position texture index in the G-Buffer textures array
  64818. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  64819. */
  64820. static readonly POSITION_TEXTURE_TYPE: number;
  64821. /**
  64822. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  64823. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  64824. */
  64825. static readonly VELOCITY_TEXTURE_TYPE: number;
  64826. /**
  64827. * Dictionary used to store the previous transformation matrices of each rendered mesh
  64828. * in order to compute objects velocities when enableVelocity is set to "true"
  64829. * @hidden
  64830. */
  64831. _previousTransformationMatrices: {
  64832. [index: number]: ISavedTransformationMatrix;
  64833. };
  64834. /**
  64835. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  64836. * in order to compute objects velocities when enableVelocity is set to "true"
  64837. * @hidden
  64838. */
  64839. _previousBonesTransformationMatrices: {
  64840. [index: number]: Float32Array;
  64841. };
  64842. /**
  64843. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  64844. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  64845. */
  64846. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  64847. private _scene;
  64848. private _multiRenderTarget;
  64849. private _ratio;
  64850. private _enablePosition;
  64851. private _enableVelocity;
  64852. private _positionIndex;
  64853. private _velocityIndex;
  64854. protected _effect: Effect;
  64855. protected _cachedDefines: string;
  64856. /**
  64857. * Set the render list (meshes to be rendered) used in the G buffer.
  64858. */
  64859. renderList: Mesh[];
  64860. /**
  64861. * Gets wether or not G buffer are supported by the running hardware.
  64862. * This requires draw buffer supports
  64863. */
  64864. readonly isSupported: boolean;
  64865. /**
  64866. * Returns the index of the given texture type in the G-Buffer textures array
  64867. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  64868. * @returns the index of the given texture type in the G-Buffer textures array
  64869. */
  64870. getTextureIndex(textureType: number): number;
  64871. /**
  64872. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  64873. */
  64874. /**
  64875. * Sets whether or not objects positions are enabled for the G buffer.
  64876. */
  64877. enablePosition: boolean;
  64878. /**
  64879. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  64880. */
  64881. /**
  64882. * Sets wether or not objects velocities are enabled for the G buffer.
  64883. */
  64884. enableVelocity: boolean;
  64885. /**
  64886. * Gets the scene associated with the buffer.
  64887. */
  64888. readonly scene: Scene;
  64889. /**
  64890. * Gets the ratio used by the buffer during its creation.
  64891. * How big is the buffer related to the main canvas.
  64892. */
  64893. readonly ratio: number;
  64894. /** @hidden */
  64895. static _SceneComponentInitialization: (scene: Scene) => void;
  64896. /**
  64897. * Creates a new G Buffer for the scene
  64898. * @param scene The scene the buffer belongs to
  64899. * @param ratio How big is the buffer related to the main canvas.
  64900. */
  64901. constructor(scene: Scene, ratio?: number);
  64902. /**
  64903. * Checks wether everything is ready to render a submesh to the G buffer.
  64904. * @param subMesh the submesh to check readiness for
  64905. * @param useInstances is the mesh drawn using instance or not
  64906. * @returns true if ready otherwise false
  64907. */
  64908. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64909. /**
  64910. * Gets the current underlying G Buffer.
  64911. * @returns the buffer
  64912. */
  64913. getGBuffer(): MultiRenderTarget;
  64914. /**
  64915. * Gets the number of samples used to render the buffer (anti aliasing).
  64916. */
  64917. /**
  64918. * Sets the number of samples used to render the buffer (anti aliasing).
  64919. */
  64920. samples: number;
  64921. /**
  64922. * Disposes the renderer and frees up associated resources.
  64923. */
  64924. dispose(): void;
  64925. protected _createRenderTargets(): void;
  64926. private _copyBonesTransformationMatrices;
  64927. }
  64928. }
  64929. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  64930. import { Nullable } from "babylonjs/types";
  64931. import { Scene } from "babylonjs/scene";
  64932. import { ISceneComponent } from "babylonjs/sceneComponent";
  64933. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  64934. module "babylonjs/scene" {
  64935. interface Scene {
  64936. /** @hidden (Backing field) */
  64937. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  64938. /**
  64939. * Gets or Sets the current geometry buffer associated to the scene.
  64940. */
  64941. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  64942. /**
  64943. * Enables a GeometryBufferRender and associates it with the scene
  64944. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  64945. * @returns the GeometryBufferRenderer
  64946. */
  64947. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  64948. /**
  64949. * Disables the GeometryBufferRender associated with the scene
  64950. */
  64951. disableGeometryBufferRenderer(): void;
  64952. }
  64953. }
  64954. /**
  64955. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  64956. * in several rendering techniques.
  64957. */
  64958. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  64959. /**
  64960. * The component name helpful to identify the component in the list of scene components.
  64961. */
  64962. readonly name: string;
  64963. /**
  64964. * The scene the component belongs to.
  64965. */
  64966. scene: Scene;
  64967. /**
  64968. * Creates a new instance of the component for the given scene
  64969. * @param scene Defines the scene to register the component in
  64970. */
  64971. constructor(scene: Scene);
  64972. /**
  64973. * Registers the component in a given scene
  64974. */
  64975. register(): void;
  64976. /**
  64977. * Rebuilds the elements related to this component in case of
  64978. * context lost for instance.
  64979. */
  64980. rebuild(): void;
  64981. /**
  64982. * Disposes the component and the associated ressources
  64983. */
  64984. dispose(): void;
  64985. private _gatherRenderTargets;
  64986. }
  64987. }
  64988. declare module "babylonjs/Shaders/motionBlur.fragment" {
  64989. /** @hidden */
  64990. export var motionBlurPixelShader: {
  64991. name: string;
  64992. shader: string;
  64993. };
  64994. }
  64995. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  64996. import { Nullable } from "babylonjs/types";
  64997. import { Camera } from "babylonjs/Cameras/camera";
  64998. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64999. import { Scene } from "babylonjs/scene";
  65000. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65001. import "babylonjs/Animations/animatable";
  65002. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  65003. import "babylonjs/Shaders/motionBlur.fragment";
  65004. import { Engine } from "babylonjs/Engines/engine";
  65005. /**
  65006. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  65007. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  65008. * As an example, all you have to do is to create the post-process:
  65009. * var mb = new BABYLON.MotionBlurPostProcess(
  65010. * 'mb', // The name of the effect.
  65011. * scene, // The scene containing the objects to blur according to their velocity.
  65012. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  65013. * camera // The camera to apply the render pass to.
  65014. * );
  65015. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  65016. */
  65017. export class MotionBlurPostProcess extends PostProcess {
  65018. /**
  65019. * Defines how much the image is blurred by the movement. Default value is equal to 1
  65020. */
  65021. motionStrength: number;
  65022. /**
  65023. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  65024. */
  65025. /**
  65026. * Sets the number of iterations to be used for motion blur quality
  65027. */
  65028. motionBlurSamples: number;
  65029. private _motionBlurSamples;
  65030. private _geometryBufferRenderer;
  65031. /**
  65032. * Creates a new instance MotionBlurPostProcess
  65033. * @param name The name of the effect.
  65034. * @param scene The scene containing the objects to blur according to their velocity.
  65035. * @param options The required width/height ratio to downsize to before computing the render pass.
  65036. * @param camera The camera to apply the render pass to.
  65037. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65038. * @param engine The engine which the post process will be applied. (default: current engine)
  65039. * @param reusable If the post process can be reused on the same frame. (default: false)
  65040. * @param textureType Type of textures used when performing the post process. (default: 0)
  65041. * @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)
  65042. */
  65043. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65044. /**
  65045. * Excludes the given skinned mesh from computing bones velocities.
  65046. * 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.
  65047. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  65048. */
  65049. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  65050. /**
  65051. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  65052. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  65053. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  65054. */
  65055. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  65056. /**
  65057. * Disposes the post process.
  65058. * @param camera The camera to dispose the post process on.
  65059. */
  65060. dispose(camera?: Camera): void;
  65061. }
  65062. }
  65063. declare module "babylonjs/Shaders/refraction.fragment" {
  65064. /** @hidden */
  65065. export var refractionPixelShader: {
  65066. name: string;
  65067. shader: string;
  65068. };
  65069. }
  65070. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  65071. import { Color3 } from "babylonjs/Maths/math.color";
  65072. import { Camera } from "babylonjs/Cameras/camera";
  65073. import { Texture } from "babylonjs/Materials/Textures/texture";
  65074. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65075. import { Engine } from "babylonjs/Engines/engine";
  65076. import "babylonjs/Shaders/refraction.fragment";
  65077. /**
  65078. * Post process which applies a refractin texture
  65079. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  65080. */
  65081. export class RefractionPostProcess extends PostProcess {
  65082. /** the base color of the refraction (used to taint the rendering) */
  65083. color: Color3;
  65084. /** simulated refraction depth */
  65085. depth: number;
  65086. /** the coefficient of the base color (0 to remove base color tainting) */
  65087. colorLevel: number;
  65088. private _refTexture;
  65089. private _ownRefractionTexture;
  65090. /**
  65091. * Gets or sets the refraction texture
  65092. * Please note that you are responsible for disposing the texture if you set it manually
  65093. */
  65094. refractionTexture: Texture;
  65095. /**
  65096. * Initializes the RefractionPostProcess
  65097. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  65098. * @param name The name of the effect.
  65099. * @param refractionTextureUrl Url of the refraction texture to use
  65100. * @param color the base color of the refraction (used to taint the rendering)
  65101. * @param depth simulated refraction depth
  65102. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  65103. * @param camera The camera to apply the render pass to.
  65104. * @param options The required width/height ratio to downsize to before computing the render pass.
  65105. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65106. * @param engine The engine which the post process will be applied. (default: current engine)
  65107. * @param reusable If the post process can be reused on the same frame. (default: false)
  65108. */
  65109. constructor(name: string, refractionTextureUrl: string,
  65110. /** the base color of the refraction (used to taint the rendering) */
  65111. color: Color3,
  65112. /** simulated refraction depth */
  65113. depth: number,
  65114. /** the coefficient of the base color (0 to remove base color tainting) */
  65115. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65116. /**
  65117. * Disposes of the post process
  65118. * @param camera Camera to dispose post process on
  65119. */
  65120. dispose(camera: Camera): void;
  65121. }
  65122. }
  65123. declare module "babylonjs/Shaders/sharpen.fragment" {
  65124. /** @hidden */
  65125. export var sharpenPixelShader: {
  65126. name: string;
  65127. shader: string;
  65128. };
  65129. }
  65130. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  65131. import { Nullable } from "babylonjs/types";
  65132. import { Camera } from "babylonjs/Cameras/camera";
  65133. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65134. import "babylonjs/Shaders/sharpen.fragment";
  65135. import { Engine } from "babylonjs/Engines/engine";
  65136. /**
  65137. * The SharpenPostProcess applies a sharpen kernel to every pixel
  65138. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  65139. */
  65140. export class SharpenPostProcess extends PostProcess {
  65141. /**
  65142. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  65143. */
  65144. colorAmount: number;
  65145. /**
  65146. * How much sharpness should be applied (default: 0.3)
  65147. */
  65148. edgeAmount: number;
  65149. /**
  65150. * Creates a new instance ConvolutionPostProcess
  65151. * @param name The name of the effect.
  65152. * @param options The required width/height ratio to downsize to before computing the render pass.
  65153. * @param camera The camera to apply the render pass to.
  65154. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65155. * @param engine The engine which the post process will be applied. (default: current engine)
  65156. * @param reusable If the post process can be reused on the same frame. (default: false)
  65157. * @param textureType Type of textures used when performing the post process. (default: 0)
  65158. * @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)
  65159. */
  65160. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65161. }
  65162. }
  65163. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  65164. import { Nullable } from "babylonjs/types";
  65165. import { Camera } from "babylonjs/Cameras/camera";
  65166. import { Engine } from "babylonjs/Engines/engine";
  65167. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  65168. import { IInspectable } from "babylonjs/Misc/iInspectable";
  65169. /**
  65170. * PostProcessRenderPipeline
  65171. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65172. */
  65173. export class PostProcessRenderPipeline {
  65174. private engine;
  65175. private _renderEffects;
  65176. private _renderEffectsForIsolatedPass;
  65177. /**
  65178. * List of inspectable custom properties (used by the Inspector)
  65179. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  65180. */
  65181. inspectableCustomProperties: IInspectable[];
  65182. /**
  65183. * @hidden
  65184. */
  65185. protected _cameras: Camera[];
  65186. /** @hidden */
  65187. _name: string;
  65188. /**
  65189. * Gets pipeline name
  65190. */
  65191. readonly name: string;
  65192. /** Gets the list of attached cameras */
  65193. readonly cameras: Camera[];
  65194. /**
  65195. * Initializes a PostProcessRenderPipeline
  65196. * @param engine engine to add the pipeline to
  65197. * @param name name of the pipeline
  65198. */
  65199. constructor(engine: Engine, name: string);
  65200. /**
  65201. * Gets the class name
  65202. * @returns "PostProcessRenderPipeline"
  65203. */
  65204. getClassName(): string;
  65205. /**
  65206. * If all the render effects in the pipeline are supported
  65207. */
  65208. readonly isSupported: boolean;
  65209. /**
  65210. * Adds an effect to the pipeline
  65211. * @param renderEffect the effect to add
  65212. */
  65213. addEffect(renderEffect: PostProcessRenderEffect): void;
  65214. /** @hidden */
  65215. _rebuild(): void;
  65216. /** @hidden */
  65217. _enableEffect(renderEffectName: string, cameras: Camera): void;
  65218. /** @hidden */
  65219. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  65220. /** @hidden */
  65221. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65222. /** @hidden */
  65223. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65224. /** @hidden */
  65225. _attachCameras(cameras: Camera, unique: boolean): void;
  65226. /** @hidden */
  65227. _attachCameras(cameras: Camera[], unique: boolean): void;
  65228. /** @hidden */
  65229. _detachCameras(cameras: Camera): void;
  65230. /** @hidden */
  65231. _detachCameras(cameras: Nullable<Camera[]>): void;
  65232. /** @hidden */
  65233. _update(): void;
  65234. /** @hidden */
  65235. _reset(): void;
  65236. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  65237. /**
  65238. * Disposes of the pipeline
  65239. */
  65240. dispose(): void;
  65241. }
  65242. }
  65243. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  65244. import { Camera } from "babylonjs/Cameras/camera";
  65245. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65246. /**
  65247. * PostProcessRenderPipelineManager class
  65248. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65249. */
  65250. export class PostProcessRenderPipelineManager {
  65251. private _renderPipelines;
  65252. /**
  65253. * Initializes a PostProcessRenderPipelineManager
  65254. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65255. */
  65256. constructor();
  65257. /**
  65258. * Gets the list of supported render pipelines
  65259. */
  65260. readonly supportedPipelines: PostProcessRenderPipeline[];
  65261. /**
  65262. * Adds a pipeline to the manager
  65263. * @param renderPipeline The pipeline to add
  65264. */
  65265. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  65266. /**
  65267. * Attaches a camera to the pipeline
  65268. * @param renderPipelineName The name of the pipeline to attach to
  65269. * @param cameras the camera to attach
  65270. * @param unique if the camera can be attached multiple times to the pipeline
  65271. */
  65272. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  65273. /**
  65274. * Detaches a camera from the pipeline
  65275. * @param renderPipelineName The name of the pipeline to detach from
  65276. * @param cameras the camera to detach
  65277. */
  65278. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  65279. /**
  65280. * Enables an effect by name on a pipeline
  65281. * @param renderPipelineName the name of the pipeline to enable the effect in
  65282. * @param renderEffectName the name of the effect to enable
  65283. * @param cameras the cameras that the effect should be enabled on
  65284. */
  65285. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65286. /**
  65287. * Disables an effect by name on a pipeline
  65288. * @param renderPipelineName the name of the pipeline to disable the effect in
  65289. * @param renderEffectName the name of the effect to disable
  65290. * @param cameras the cameras that the effect should be disabled on
  65291. */
  65292. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65293. /**
  65294. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  65295. */
  65296. update(): void;
  65297. /** @hidden */
  65298. _rebuild(): void;
  65299. /**
  65300. * Disposes of the manager and pipelines
  65301. */
  65302. dispose(): void;
  65303. }
  65304. }
  65305. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  65306. import { ISceneComponent } from "babylonjs/sceneComponent";
  65307. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  65308. import { Scene } from "babylonjs/scene";
  65309. module "babylonjs/scene" {
  65310. interface Scene {
  65311. /** @hidden (Backing field) */
  65312. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65313. /**
  65314. * Gets the postprocess render pipeline manager
  65315. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65316. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65317. */
  65318. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65319. }
  65320. }
  65321. /**
  65322. * Defines the Render Pipeline scene component responsible to rendering pipelines
  65323. */
  65324. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  65325. /**
  65326. * The component name helpfull to identify the component in the list of scene components.
  65327. */
  65328. readonly name: string;
  65329. /**
  65330. * The scene the component belongs to.
  65331. */
  65332. scene: Scene;
  65333. /**
  65334. * Creates a new instance of the component for the given scene
  65335. * @param scene Defines the scene to register the component in
  65336. */
  65337. constructor(scene: Scene);
  65338. /**
  65339. * Registers the component in a given scene
  65340. */
  65341. register(): void;
  65342. /**
  65343. * Rebuilds the elements related to this component in case of
  65344. * context lost for instance.
  65345. */
  65346. rebuild(): void;
  65347. /**
  65348. * Disposes the component and the associated ressources
  65349. */
  65350. dispose(): void;
  65351. private _gatherRenderTargets;
  65352. }
  65353. }
  65354. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  65355. import { Nullable } from "babylonjs/types";
  65356. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  65357. import { Camera } from "babylonjs/Cameras/camera";
  65358. import { IDisposable } from "babylonjs/scene";
  65359. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  65360. import { Scene } from "babylonjs/scene";
  65361. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  65362. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  65363. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  65364. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  65365. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  65366. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65367. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  65368. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65369. import { Animation } from "babylonjs/Animations/animation";
  65370. /**
  65371. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  65372. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65373. */
  65374. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  65375. private _scene;
  65376. private _camerasToBeAttached;
  65377. /**
  65378. * ID of the sharpen post process,
  65379. */
  65380. private readonly SharpenPostProcessId;
  65381. /**
  65382. * @ignore
  65383. * ID of the image processing post process;
  65384. */
  65385. readonly ImageProcessingPostProcessId: string;
  65386. /**
  65387. * @ignore
  65388. * ID of the Fast Approximate Anti-Aliasing post process;
  65389. */
  65390. readonly FxaaPostProcessId: string;
  65391. /**
  65392. * ID of the chromatic aberration post process,
  65393. */
  65394. private readonly ChromaticAberrationPostProcessId;
  65395. /**
  65396. * ID of the grain post process
  65397. */
  65398. private readonly GrainPostProcessId;
  65399. /**
  65400. * Sharpen post process which will apply a sharpen convolution to enhance edges
  65401. */
  65402. sharpen: SharpenPostProcess;
  65403. private _sharpenEffect;
  65404. private bloom;
  65405. /**
  65406. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  65407. */
  65408. depthOfField: DepthOfFieldEffect;
  65409. /**
  65410. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  65411. */
  65412. fxaa: FxaaPostProcess;
  65413. /**
  65414. * Image post processing pass used to perform operations such as tone mapping or color grading.
  65415. */
  65416. imageProcessing: ImageProcessingPostProcess;
  65417. /**
  65418. * Chromatic aberration post process which will shift rgb colors in the image
  65419. */
  65420. chromaticAberration: ChromaticAberrationPostProcess;
  65421. private _chromaticAberrationEffect;
  65422. /**
  65423. * Grain post process which add noise to the image
  65424. */
  65425. grain: GrainPostProcess;
  65426. private _grainEffect;
  65427. /**
  65428. * Glow post process which adds a glow to emissive areas of the image
  65429. */
  65430. private _glowLayer;
  65431. /**
  65432. * Animations which can be used to tweak settings over a period of time
  65433. */
  65434. animations: Animation[];
  65435. private _imageProcessingConfigurationObserver;
  65436. private _sharpenEnabled;
  65437. private _bloomEnabled;
  65438. private _depthOfFieldEnabled;
  65439. private _depthOfFieldBlurLevel;
  65440. private _fxaaEnabled;
  65441. private _imageProcessingEnabled;
  65442. private _defaultPipelineTextureType;
  65443. private _bloomScale;
  65444. private _chromaticAberrationEnabled;
  65445. private _grainEnabled;
  65446. private _buildAllowed;
  65447. /**
  65448. * Gets active scene
  65449. */
  65450. readonly scene: Scene;
  65451. /**
  65452. * Enable or disable the sharpen process from the pipeline
  65453. */
  65454. sharpenEnabled: boolean;
  65455. private _resizeObserver;
  65456. private _hardwareScaleLevel;
  65457. private _bloomKernel;
  65458. /**
  65459. * Specifies the size of the bloom blur kernel, relative to the final output size
  65460. */
  65461. bloomKernel: number;
  65462. /**
  65463. * Specifies the weight of the bloom in the final rendering
  65464. */
  65465. private _bloomWeight;
  65466. /**
  65467. * Specifies the luma threshold for the area that will be blurred by the bloom
  65468. */
  65469. private _bloomThreshold;
  65470. private _hdr;
  65471. /**
  65472. * The strength of the bloom.
  65473. */
  65474. bloomWeight: number;
  65475. /**
  65476. * The strength of the bloom.
  65477. */
  65478. bloomThreshold: number;
  65479. /**
  65480. * The scale of the bloom, lower value will provide better performance.
  65481. */
  65482. bloomScale: number;
  65483. /**
  65484. * Enable or disable the bloom from the pipeline
  65485. */
  65486. bloomEnabled: boolean;
  65487. private _rebuildBloom;
  65488. /**
  65489. * If the depth of field is enabled.
  65490. */
  65491. depthOfFieldEnabled: boolean;
  65492. /**
  65493. * Blur level of the depth of field effect. (Higher blur will effect performance)
  65494. */
  65495. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  65496. /**
  65497. * If the anti aliasing is enabled.
  65498. */
  65499. fxaaEnabled: boolean;
  65500. private _samples;
  65501. /**
  65502. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  65503. */
  65504. samples: number;
  65505. /**
  65506. * If image processing is enabled.
  65507. */
  65508. imageProcessingEnabled: boolean;
  65509. /**
  65510. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  65511. */
  65512. glowLayerEnabled: boolean;
  65513. /**
  65514. * Gets the glow layer (or null if not defined)
  65515. */
  65516. readonly glowLayer: Nullable<GlowLayer>;
  65517. /**
  65518. * Enable or disable the chromaticAberration process from the pipeline
  65519. */
  65520. chromaticAberrationEnabled: boolean;
  65521. /**
  65522. * Enable or disable the grain process from the pipeline
  65523. */
  65524. grainEnabled: boolean;
  65525. /**
  65526. * @constructor
  65527. * @param name - The rendering pipeline name (default: "")
  65528. * @param hdr - If high dynamic range textures should be used (default: true)
  65529. * @param scene - The scene linked to this pipeline (default: the last created scene)
  65530. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  65531. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  65532. */
  65533. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  65534. /**
  65535. * Get the class name
  65536. * @returns "DefaultRenderingPipeline"
  65537. */
  65538. getClassName(): string;
  65539. /**
  65540. * Force the compilation of the entire pipeline.
  65541. */
  65542. prepare(): void;
  65543. private _hasCleared;
  65544. private _prevPostProcess;
  65545. private _prevPrevPostProcess;
  65546. private _setAutoClearAndTextureSharing;
  65547. private _depthOfFieldSceneObserver;
  65548. private _buildPipeline;
  65549. private _disposePostProcesses;
  65550. /**
  65551. * Adds a camera to the pipeline
  65552. * @param camera the camera to be added
  65553. */
  65554. addCamera(camera: Camera): void;
  65555. /**
  65556. * Removes a camera from the pipeline
  65557. * @param camera the camera to remove
  65558. */
  65559. removeCamera(camera: Camera): void;
  65560. /**
  65561. * Dispose of the pipeline and stop all post processes
  65562. */
  65563. dispose(): void;
  65564. /**
  65565. * Serialize the rendering pipeline (Used when exporting)
  65566. * @returns the serialized object
  65567. */
  65568. serialize(): any;
  65569. /**
  65570. * Parse the serialized pipeline
  65571. * @param source Source pipeline.
  65572. * @param scene The scene to load the pipeline to.
  65573. * @param rootUrl The URL of the serialized pipeline.
  65574. * @returns An instantiated pipeline from the serialized object.
  65575. */
  65576. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  65577. }
  65578. }
  65579. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  65580. /** @hidden */
  65581. export var lensHighlightsPixelShader: {
  65582. name: string;
  65583. shader: string;
  65584. };
  65585. }
  65586. declare module "babylonjs/Shaders/depthOfField.fragment" {
  65587. /** @hidden */
  65588. export var depthOfFieldPixelShader: {
  65589. name: string;
  65590. shader: string;
  65591. };
  65592. }
  65593. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  65594. import { Camera } from "babylonjs/Cameras/camera";
  65595. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65596. import { Scene } from "babylonjs/scene";
  65597. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65598. import "babylonjs/Shaders/chromaticAberration.fragment";
  65599. import "babylonjs/Shaders/lensHighlights.fragment";
  65600. import "babylonjs/Shaders/depthOfField.fragment";
  65601. /**
  65602. * BABYLON.JS Chromatic Aberration GLSL Shader
  65603. * Author: Olivier Guyot
  65604. * Separates very slightly R, G and B colors on the edges of the screen
  65605. * Inspired by Francois Tarlier & Martins Upitis
  65606. */
  65607. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  65608. /**
  65609. * @ignore
  65610. * The chromatic aberration PostProcess id in the pipeline
  65611. */
  65612. LensChromaticAberrationEffect: string;
  65613. /**
  65614. * @ignore
  65615. * The highlights enhancing PostProcess id in the pipeline
  65616. */
  65617. HighlightsEnhancingEffect: string;
  65618. /**
  65619. * @ignore
  65620. * The depth-of-field PostProcess id in the pipeline
  65621. */
  65622. LensDepthOfFieldEffect: string;
  65623. private _scene;
  65624. private _depthTexture;
  65625. private _grainTexture;
  65626. private _chromaticAberrationPostProcess;
  65627. private _highlightsPostProcess;
  65628. private _depthOfFieldPostProcess;
  65629. private _edgeBlur;
  65630. private _grainAmount;
  65631. private _chromaticAberration;
  65632. private _distortion;
  65633. private _highlightsGain;
  65634. private _highlightsThreshold;
  65635. private _dofDistance;
  65636. private _dofAperture;
  65637. private _dofDarken;
  65638. private _dofPentagon;
  65639. private _blurNoise;
  65640. /**
  65641. * @constructor
  65642. *
  65643. * Effect parameters are as follow:
  65644. * {
  65645. * chromatic_aberration: number; // from 0 to x (1 for realism)
  65646. * edge_blur: number; // from 0 to x (1 for realism)
  65647. * distortion: number; // from 0 to x (1 for realism)
  65648. * grain_amount: number; // from 0 to 1
  65649. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  65650. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  65651. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  65652. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  65653. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  65654. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  65655. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  65656. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  65657. * }
  65658. * Note: if an effect parameter is unset, effect is disabled
  65659. *
  65660. * @param name The rendering pipeline name
  65661. * @param parameters - An object containing all parameters (see above)
  65662. * @param scene The scene linked to this pipeline
  65663. * @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)
  65664. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65665. */
  65666. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  65667. /**
  65668. * Get the class name
  65669. * @returns "LensRenderingPipeline"
  65670. */
  65671. getClassName(): string;
  65672. /**
  65673. * Gets associated scene
  65674. */
  65675. readonly scene: Scene;
  65676. /**
  65677. * Gets or sets the edge blur
  65678. */
  65679. edgeBlur: number;
  65680. /**
  65681. * Gets or sets the grain amount
  65682. */
  65683. grainAmount: number;
  65684. /**
  65685. * Gets or sets the chromatic aberration amount
  65686. */
  65687. chromaticAberration: number;
  65688. /**
  65689. * Gets or sets the depth of field aperture
  65690. */
  65691. dofAperture: number;
  65692. /**
  65693. * Gets or sets the edge distortion
  65694. */
  65695. edgeDistortion: number;
  65696. /**
  65697. * Gets or sets the depth of field distortion
  65698. */
  65699. dofDistortion: number;
  65700. /**
  65701. * Gets or sets the darken out of focus amount
  65702. */
  65703. darkenOutOfFocus: number;
  65704. /**
  65705. * Gets or sets a boolean indicating if blur noise is enabled
  65706. */
  65707. blurNoise: boolean;
  65708. /**
  65709. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  65710. */
  65711. pentagonBokeh: boolean;
  65712. /**
  65713. * Gets or sets the highlight grain amount
  65714. */
  65715. highlightsGain: number;
  65716. /**
  65717. * Gets or sets the highlight threshold
  65718. */
  65719. highlightsThreshold: number;
  65720. /**
  65721. * Sets the amount of blur at the edges
  65722. * @param amount blur amount
  65723. */
  65724. setEdgeBlur(amount: number): void;
  65725. /**
  65726. * Sets edge blur to 0
  65727. */
  65728. disableEdgeBlur(): void;
  65729. /**
  65730. * Sets the amout of grain
  65731. * @param amount Amount of grain
  65732. */
  65733. setGrainAmount(amount: number): void;
  65734. /**
  65735. * Set grain amount to 0
  65736. */
  65737. disableGrain(): void;
  65738. /**
  65739. * Sets the chromatic aberration amount
  65740. * @param amount amount of chromatic aberration
  65741. */
  65742. setChromaticAberration(amount: number): void;
  65743. /**
  65744. * Sets chromatic aberration amount to 0
  65745. */
  65746. disableChromaticAberration(): void;
  65747. /**
  65748. * Sets the EdgeDistortion amount
  65749. * @param amount amount of EdgeDistortion
  65750. */
  65751. setEdgeDistortion(amount: number): void;
  65752. /**
  65753. * Sets edge distortion to 0
  65754. */
  65755. disableEdgeDistortion(): void;
  65756. /**
  65757. * Sets the FocusDistance amount
  65758. * @param amount amount of FocusDistance
  65759. */
  65760. setFocusDistance(amount: number): void;
  65761. /**
  65762. * Disables depth of field
  65763. */
  65764. disableDepthOfField(): void;
  65765. /**
  65766. * Sets the Aperture amount
  65767. * @param amount amount of Aperture
  65768. */
  65769. setAperture(amount: number): void;
  65770. /**
  65771. * Sets the DarkenOutOfFocus amount
  65772. * @param amount amount of DarkenOutOfFocus
  65773. */
  65774. setDarkenOutOfFocus(amount: number): void;
  65775. private _pentagonBokehIsEnabled;
  65776. /**
  65777. * Creates a pentagon bokeh effect
  65778. */
  65779. enablePentagonBokeh(): void;
  65780. /**
  65781. * Disables the pentagon bokeh effect
  65782. */
  65783. disablePentagonBokeh(): void;
  65784. /**
  65785. * Enables noise blur
  65786. */
  65787. enableNoiseBlur(): void;
  65788. /**
  65789. * Disables noise blur
  65790. */
  65791. disableNoiseBlur(): void;
  65792. /**
  65793. * Sets the HighlightsGain amount
  65794. * @param amount amount of HighlightsGain
  65795. */
  65796. setHighlightsGain(amount: number): void;
  65797. /**
  65798. * Sets the HighlightsThreshold amount
  65799. * @param amount amount of HighlightsThreshold
  65800. */
  65801. setHighlightsThreshold(amount: number): void;
  65802. /**
  65803. * Disables highlights
  65804. */
  65805. disableHighlights(): void;
  65806. /**
  65807. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  65808. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  65809. */
  65810. dispose(disableDepthRender?: boolean): void;
  65811. private _createChromaticAberrationPostProcess;
  65812. private _createHighlightsPostProcess;
  65813. private _createDepthOfFieldPostProcess;
  65814. private _createGrainTexture;
  65815. }
  65816. }
  65817. declare module "babylonjs/Shaders/ssao2.fragment" {
  65818. /** @hidden */
  65819. export var ssao2PixelShader: {
  65820. name: string;
  65821. shader: string;
  65822. };
  65823. }
  65824. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  65825. /** @hidden */
  65826. export var ssaoCombinePixelShader: {
  65827. name: string;
  65828. shader: string;
  65829. };
  65830. }
  65831. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  65832. import { Camera } from "babylonjs/Cameras/camera";
  65833. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65834. import { Scene } from "babylonjs/scene";
  65835. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65836. import "babylonjs/Shaders/ssao2.fragment";
  65837. import "babylonjs/Shaders/ssaoCombine.fragment";
  65838. /**
  65839. * Render pipeline to produce ssao effect
  65840. */
  65841. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  65842. /**
  65843. * @ignore
  65844. * The PassPostProcess id in the pipeline that contains the original scene color
  65845. */
  65846. SSAOOriginalSceneColorEffect: string;
  65847. /**
  65848. * @ignore
  65849. * The SSAO PostProcess id in the pipeline
  65850. */
  65851. SSAORenderEffect: string;
  65852. /**
  65853. * @ignore
  65854. * The horizontal blur PostProcess id in the pipeline
  65855. */
  65856. SSAOBlurHRenderEffect: string;
  65857. /**
  65858. * @ignore
  65859. * The vertical blur PostProcess id in the pipeline
  65860. */
  65861. SSAOBlurVRenderEffect: string;
  65862. /**
  65863. * @ignore
  65864. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  65865. */
  65866. SSAOCombineRenderEffect: string;
  65867. /**
  65868. * The output strength of the SSAO post-process. Default value is 1.0.
  65869. */
  65870. totalStrength: number;
  65871. /**
  65872. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  65873. */
  65874. maxZ: number;
  65875. /**
  65876. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  65877. */
  65878. minZAspect: number;
  65879. private _samples;
  65880. /**
  65881. * Number of samples used for the SSAO calculations. Default value is 8
  65882. */
  65883. samples: number;
  65884. private _textureSamples;
  65885. /**
  65886. * Number of samples to use for antialiasing
  65887. */
  65888. textureSamples: number;
  65889. /**
  65890. * Ratio object used for SSAO ratio and blur ratio
  65891. */
  65892. private _ratio;
  65893. /**
  65894. * Dynamically generated sphere sampler.
  65895. */
  65896. private _sampleSphere;
  65897. /**
  65898. * Blur filter offsets
  65899. */
  65900. private _samplerOffsets;
  65901. private _expensiveBlur;
  65902. /**
  65903. * If bilateral blur should be used
  65904. */
  65905. expensiveBlur: boolean;
  65906. /**
  65907. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  65908. */
  65909. radius: number;
  65910. /**
  65911. * The base color of the SSAO post-process
  65912. * The final result is "base + ssao" between [0, 1]
  65913. */
  65914. base: number;
  65915. /**
  65916. * Support test.
  65917. */
  65918. static readonly IsSupported: boolean;
  65919. private _scene;
  65920. private _depthTexture;
  65921. private _normalTexture;
  65922. private _randomTexture;
  65923. private _originalColorPostProcess;
  65924. private _ssaoPostProcess;
  65925. private _blurHPostProcess;
  65926. private _blurVPostProcess;
  65927. private _ssaoCombinePostProcess;
  65928. /**
  65929. * Gets active scene
  65930. */
  65931. readonly scene: Scene;
  65932. /**
  65933. * @constructor
  65934. * @param name The rendering pipeline name
  65935. * @param scene The scene linked to this pipeline
  65936. * @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 }
  65937. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65938. */
  65939. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  65940. /**
  65941. * Get the class name
  65942. * @returns "SSAO2RenderingPipeline"
  65943. */
  65944. getClassName(): string;
  65945. /**
  65946. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  65947. */
  65948. dispose(disableGeometryBufferRenderer?: boolean): void;
  65949. private _createBlurPostProcess;
  65950. /** @hidden */
  65951. _rebuild(): void;
  65952. private _bits;
  65953. private _radicalInverse_VdC;
  65954. private _hammersley;
  65955. private _hemisphereSample_uniform;
  65956. private _generateHemisphere;
  65957. private _createSSAOPostProcess;
  65958. private _createSSAOCombinePostProcess;
  65959. private _createRandomTexture;
  65960. /**
  65961. * Serialize the rendering pipeline (Used when exporting)
  65962. * @returns the serialized object
  65963. */
  65964. serialize(): any;
  65965. /**
  65966. * Parse the serialized pipeline
  65967. * @param source Source pipeline.
  65968. * @param scene The scene to load the pipeline to.
  65969. * @param rootUrl The URL of the serialized pipeline.
  65970. * @returns An instantiated pipeline from the serialized object.
  65971. */
  65972. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  65973. }
  65974. }
  65975. declare module "babylonjs/Shaders/ssao.fragment" {
  65976. /** @hidden */
  65977. export var ssaoPixelShader: {
  65978. name: string;
  65979. shader: string;
  65980. };
  65981. }
  65982. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  65983. import { Camera } from "babylonjs/Cameras/camera";
  65984. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65985. import { Scene } from "babylonjs/scene";
  65986. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65987. import "babylonjs/Shaders/ssao.fragment";
  65988. import "babylonjs/Shaders/ssaoCombine.fragment";
  65989. /**
  65990. * Render pipeline to produce ssao effect
  65991. */
  65992. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  65993. /**
  65994. * @ignore
  65995. * The PassPostProcess id in the pipeline that contains the original scene color
  65996. */
  65997. SSAOOriginalSceneColorEffect: string;
  65998. /**
  65999. * @ignore
  66000. * The SSAO PostProcess id in the pipeline
  66001. */
  66002. SSAORenderEffect: string;
  66003. /**
  66004. * @ignore
  66005. * The horizontal blur PostProcess id in the pipeline
  66006. */
  66007. SSAOBlurHRenderEffect: string;
  66008. /**
  66009. * @ignore
  66010. * The vertical blur PostProcess id in the pipeline
  66011. */
  66012. SSAOBlurVRenderEffect: string;
  66013. /**
  66014. * @ignore
  66015. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  66016. */
  66017. SSAOCombineRenderEffect: string;
  66018. /**
  66019. * The output strength of the SSAO post-process. Default value is 1.0.
  66020. */
  66021. totalStrength: number;
  66022. /**
  66023. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  66024. */
  66025. radius: number;
  66026. /**
  66027. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  66028. * Must not be equal to fallOff and superior to fallOff.
  66029. * Default value is 0.0075
  66030. */
  66031. area: number;
  66032. /**
  66033. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  66034. * Must not be equal to area and inferior to area.
  66035. * Default value is 0.000001
  66036. */
  66037. fallOff: number;
  66038. /**
  66039. * The base color of the SSAO post-process
  66040. * The final result is "base + ssao" between [0, 1]
  66041. */
  66042. base: number;
  66043. private _scene;
  66044. private _depthTexture;
  66045. private _randomTexture;
  66046. private _originalColorPostProcess;
  66047. private _ssaoPostProcess;
  66048. private _blurHPostProcess;
  66049. private _blurVPostProcess;
  66050. private _ssaoCombinePostProcess;
  66051. private _firstUpdate;
  66052. /**
  66053. * Gets active scene
  66054. */
  66055. readonly scene: Scene;
  66056. /**
  66057. * @constructor
  66058. * @param name - The rendering pipeline name
  66059. * @param scene - The scene linked to this pipeline
  66060. * @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 }
  66061. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  66062. */
  66063. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  66064. /**
  66065. * Get the class name
  66066. * @returns "SSAORenderingPipeline"
  66067. */
  66068. getClassName(): string;
  66069. /**
  66070. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  66071. */
  66072. dispose(disableDepthRender?: boolean): void;
  66073. private _createBlurPostProcess;
  66074. /** @hidden */
  66075. _rebuild(): void;
  66076. private _createSSAOPostProcess;
  66077. private _createSSAOCombinePostProcess;
  66078. private _createRandomTexture;
  66079. }
  66080. }
  66081. declare module "babylonjs/Shaders/standard.fragment" {
  66082. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  66083. /** @hidden */
  66084. export var standardPixelShader: {
  66085. name: string;
  66086. shader: string;
  66087. };
  66088. }
  66089. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  66090. import { Nullable } from "babylonjs/types";
  66091. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  66092. import { Camera } from "babylonjs/Cameras/camera";
  66093. import { Texture } from "babylonjs/Materials/Textures/texture";
  66094. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  66095. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  66096. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  66097. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  66098. import { IDisposable } from "babylonjs/scene";
  66099. import { SpotLight } from "babylonjs/Lights/spotLight";
  66100. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  66101. import { Scene } from "babylonjs/scene";
  66102. import { Animation } from "babylonjs/Animations/animation";
  66103. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  66104. import "babylonjs/Shaders/standard.fragment";
  66105. /**
  66106. * Standard rendering pipeline
  66107. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  66108. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  66109. */
  66110. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  66111. /**
  66112. * Public members
  66113. */
  66114. /**
  66115. * Post-process which contains the original scene color before the pipeline applies all the effects
  66116. */
  66117. originalPostProcess: Nullable<PostProcess>;
  66118. /**
  66119. * Post-process used to down scale an image x4
  66120. */
  66121. downSampleX4PostProcess: Nullable<PostProcess>;
  66122. /**
  66123. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  66124. */
  66125. brightPassPostProcess: Nullable<PostProcess>;
  66126. /**
  66127. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  66128. */
  66129. blurHPostProcesses: PostProcess[];
  66130. /**
  66131. * Post-process array storing all the vertical blur post-processes used by the pipeline
  66132. */
  66133. blurVPostProcesses: PostProcess[];
  66134. /**
  66135. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  66136. */
  66137. textureAdderPostProcess: Nullable<PostProcess>;
  66138. /**
  66139. * Post-process used to create volumetric lighting effect
  66140. */
  66141. volumetricLightPostProcess: Nullable<PostProcess>;
  66142. /**
  66143. * Post-process used to smooth the previous volumetric light post-process on the X axis
  66144. */
  66145. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  66146. /**
  66147. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  66148. */
  66149. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  66150. /**
  66151. * Post-process used to merge the volumetric light effect and the real scene color
  66152. */
  66153. volumetricLightMergePostProces: Nullable<PostProcess>;
  66154. /**
  66155. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  66156. */
  66157. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  66158. /**
  66159. * Base post-process used to calculate the average luminance of the final image for HDR
  66160. */
  66161. luminancePostProcess: Nullable<PostProcess>;
  66162. /**
  66163. * Post-processes used to create down sample post-processes in order to get
  66164. * the average luminance of the final image for HDR
  66165. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  66166. */
  66167. luminanceDownSamplePostProcesses: PostProcess[];
  66168. /**
  66169. * Post-process used to create a HDR effect (light adaptation)
  66170. */
  66171. hdrPostProcess: Nullable<PostProcess>;
  66172. /**
  66173. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  66174. */
  66175. textureAdderFinalPostProcess: Nullable<PostProcess>;
  66176. /**
  66177. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  66178. */
  66179. lensFlareFinalPostProcess: Nullable<PostProcess>;
  66180. /**
  66181. * Post-process used to merge the final HDR post-process and the real scene color
  66182. */
  66183. hdrFinalPostProcess: Nullable<PostProcess>;
  66184. /**
  66185. * Post-process used to create a lens flare effect
  66186. */
  66187. lensFlarePostProcess: Nullable<PostProcess>;
  66188. /**
  66189. * Post-process that merges the result of the lens flare post-process and the real scene color
  66190. */
  66191. lensFlareComposePostProcess: Nullable<PostProcess>;
  66192. /**
  66193. * Post-process used to create a motion blur effect
  66194. */
  66195. motionBlurPostProcess: Nullable<PostProcess>;
  66196. /**
  66197. * Post-process used to create a depth of field effect
  66198. */
  66199. depthOfFieldPostProcess: Nullable<PostProcess>;
  66200. /**
  66201. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  66202. */
  66203. fxaaPostProcess: Nullable<FxaaPostProcess>;
  66204. /**
  66205. * Represents the brightness threshold in order to configure the illuminated surfaces
  66206. */
  66207. brightThreshold: number;
  66208. /**
  66209. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  66210. */
  66211. blurWidth: number;
  66212. /**
  66213. * Sets if the blur for highlighted surfaces must be only horizontal
  66214. */
  66215. horizontalBlur: boolean;
  66216. /**
  66217. * Gets the overall exposure used by the pipeline
  66218. */
  66219. /**
  66220. * Sets the overall exposure used by the pipeline
  66221. */
  66222. exposure: number;
  66223. /**
  66224. * Texture used typically to simulate "dirty" on camera lens
  66225. */
  66226. lensTexture: Nullable<Texture>;
  66227. /**
  66228. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  66229. */
  66230. volumetricLightCoefficient: number;
  66231. /**
  66232. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  66233. */
  66234. volumetricLightPower: number;
  66235. /**
  66236. * Used the set the blur intensity to smooth the volumetric lights
  66237. */
  66238. volumetricLightBlurScale: number;
  66239. /**
  66240. * Light (spot or directional) used to generate the volumetric lights rays
  66241. * The source light must have a shadow generate so the pipeline can get its
  66242. * depth map
  66243. */
  66244. sourceLight: Nullable<SpotLight | DirectionalLight>;
  66245. /**
  66246. * For eye adaptation, represents the minimum luminance the eye can see
  66247. */
  66248. hdrMinimumLuminance: number;
  66249. /**
  66250. * For eye adaptation, represents the decrease luminance speed
  66251. */
  66252. hdrDecreaseRate: number;
  66253. /**
  66254. * For eye adaptation, represents the increase luminance speed
  66255. */
  66256. hdrIncreaseRate: number;
  66257. /**
  66258. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66259. */
  66260. /**
  66261. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66262. */
  66263. hdrAutoExposure: boolean;
  66264. /**
  66265. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  66266. */
  66267. lensColorTexture: Nullable<Texture>;
  66268. /**
  66269. * The overall strengh for the lens flare effect
  66270. */
  66271. lensFlareStrength: number;
  66272. /**
  66273. * Dispersion coefficient for lens flare ghosts
  66274. */
  66275. lensFlareGhostDispersal: number;
  66276. /**
  66277. * Main lens flare halo width
  66278. */
  66279. lensFlareHaloWidth: number;
  66280. /**
  66281. * Based on the lens distortion effect, defines how much the lens flare result
  66282. * is distorted
  66283. */
  66284. lensFlareDistortionStrength: number;
  66285. /**
  66286. * Configures the blur intensity used for for lens flare (halo)
  66287. */
  66288. lensFlareBlurWidth: number;
  66289. /**
  66290. * Lens star texture must be used to simulate rays on the flares and is available
  66291. * in the documentation
  66292. */
  66293. lensStarTexture: Nullable<Texture>;
  66294. /**
  66295. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  66296. * flare effect by taking account of the dirt texture
  66297. */
  66298. lensFlareDirtTexture: Nullable<Texture>;
  66299. /**
  66300. * Represents the focal length for the depth of field effect
  66301. */
  66302. depthOfFieldDistance: number;
  66303. /**
  66304. * Represents the blur intensity for the blurred part of the depth of field effect
  66305. */
  66306. depthOfFieldBlurWidth: number;
  66307. /**
  66308. * Gets how much the image is blurred by the movement while using the motion blur post-process
  66309. */
  66310. /**
  66311. * Sets how much the image is blurred by the movement while using the motion blur post-process
  66312. */
  66313. motionStrength: number;
  66314. /**
  66315. * Gets wether or not the motion blur post-process is object based or screen based.
  66316. */
  66317. /**
  66318. * Sets wether or not the motion blur post-process should be object based or screen based
  66319. */
  66320. objectBasedMotionBlur: boolean;
  66321. /**
  66322. * List of animations for the pipeline (IAnimatable implementation)
  66323. */
  66324. animations: Animation[];
  66325. /**
  66326. * Private members
  66327. */
  66328. private _scene;
  66329. private _currentDepthOfFieldSource;
  66330. private _basePostProcess;
  66331. private _fixedExposure;
  66332. private _currentExposure;
  66333. private _hdrAutoExposure;
  66334. private _hdrCurrentLuminance;
  66335. private _motionStrength;
  66336. private _isObjectBasedMotionBlur;
  66337. private _floatTextureType;
  66338. private _camerasToBeAttached;
  66339. private _ratio;
  66340. private _bloomEnabled;
  66341. private _depthOfFieldEnabled;
  66342. private _vlsEnabled;
  66343. private _lensFlareEnabled;
  66344. private _hdrEnabled;
  66345. private _motionBlurEnabled;
  66346. private _fxaaEnabled;
  66347. private _motionBlurSamples;
  66348. private _volumetricLightStepsCount;
  66349. private _samples;
  66350. /**
  66351. * @ignore
  66352. * Specifies if the bloom pipeline is enabled
  66353. */
  66354. BloomEnabled: boolean;
  66355. /**
  66356. * @ignore
  66357. * Specifies if the depth of field pipeline is enabed
  66358. */
  66359. DepthOfFieldEnabled: boolean;
  66360. /**
  66361. * @ignore
  66362. * Specifies if the lens flare pipeline is enabed
  66363. */
  66364. LensFlareEnabled: boolean;
  66365. /**
  66366. * @ignore
  66367. * Specifies if the HDR pipeline is enabled
  66368. */
  66369. HDREnabled: boolean;
  66370. /**
  66371. * @ignore
  66372. * Specifies if the volumetric lights scattering effect is enabled
  66373. */
  66374. VLSEnabled: boolean;
  66375. /**
  66376. * @ignore
  66377. * Specifies if the motion blur effect is enabled
  66378. */
  66379. MotionBlurEnabled: boolean;
  66380. /**
  66381. * Specifies if anti-aliasing is enabled
  66382. */
  66383. fxaaEnabled: boolean;
  66384. /**
  66385. * Specifies the number of steps used to calculate the volumetric lights
  66386. * Typically in interval [50, 200]
  66387. */
  66388. volumetricLightStepsCount: number;
  66389. /**
  66390. * Specifies the number of samples used for the motion blur effect
  66391. * Typically in interval [16, 64]
  66392. */
  66393. motionBlurSamples: number;
  66394. /**
  66395. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  66396. */
  66397. samples: number;
  66398. /**
  66399. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  66400. * @constructor
  66401. * @param name The rendering pipeline name
  66402. * @param scene The scene linked to this pipeline
  66403. * @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)
  66404. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  66405. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66406. */
  66407. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  66408. private _buildPipeline;
  66409. private _createDownSampleX4PostProcess;
  66410. private _createBrightPassPostProcess;
  66411. private _createBlurPostProcesses;
  66412. private _createTextureAdderPostProcess;
  66413. private _createVolumetricLightPostProcess;
  66414. private _createLuminancePostProcesses;
  66415. private _createHdrPostProcess;
  66416. private _createLensFlarePostProcess;
  66417. private _createDepthOfFieldPostProcess;
  66418. private _createMotionBlurPostProcess;
  66419. private _getDepthTexture;
  66420. private _disposePostProcesses;
  66421. /**
  66422. * Dispose of the pipeline and stop all post processes
  66423. */
  66424. dispose(): void;
  66425. /**
  66426. * Serialize the rendering pipeline (Used when exporting)
  66427. * @returns the serialized object
  66428. */
  66429. serialize(): any;
  66430. /**
  66431. * Parse the serialized pipeline
  66432. * @param source Source pipeline.
  66433. * @param scene The scene to load the pipeline to.
  66434. * @param rootUrl The URL of the serialized pipeline.
  66435. * @returns An instantiated pipeline from the serialized object.
  66436. */
  66437. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  66438. /**
  66439. * Luminance steps
  66440. */
  66441. static LuminanceSteps: number;
  66442. }
  66443. }
  66444. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  66445. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  66446. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  66447. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  66448. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  66449. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  66450. }
  66451. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  66452. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  66453. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  66454. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  66455. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  66456. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  66457. }
  66458. declare module "babylonjs/Shaders/tonemap.fragment" {
  66459. /** @hidden */
  66460. export var tonemapPixelShader: {
  66461. name: string;
  66462. shader: string;
  66463. };
  66464. }
  66465. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  66466. import { Camera } from "babylonjs/Cameras/camera";
  66467. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  66468. import "babylonjs/Shaders/tonemap.fragment";
  66469. import { Engine } from "babylonjs/Engines/engine";
  66470. /** Defines operator used for tonemapping */
  66471. export enum TonemappingOperator {
  66472. /** Hable */
  66473. Hable = 0,
  66474. /** Reinhard */
  66475. Reinhard = 1,
  66476. /** HejiDawson */
  66477. HejiDawson = 2,
  66478. /** Photographic */
  66479. Photographic = 3
  66480. }
  66481. /**
  66482. * Defines a post process to apply tone mapping
  66483. */
  66484. export class TonemapPostProcess extends PostProcess {
  66485. private _operator;
  66486. /** Defines the required exposure adjustement */
  66487. exposureAdjustment: number;
  66488. /**
  66489. * Creates a new TonemapPostProcess
  66490. * @param name defines the name of the postprocess
  66491. * @param _operator defines the operator to use
  66492. * @param exposureAdjustment defines the required exposure adjustement
  66493. * @param camera defines the camera to use (can be null)
  66494. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  66495. * @param engine defines the hosting engine (can be ignore if camera is set)
  66496. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  66497. */
  66498. constructor(name: string, _operator: TonemappingOperator,
  66499. /** Defines the required exposure adjustement */
  66500. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  66501. }
  66502. }
  66503. declare module "babylonjs/Shaders/depth.vertex" {
  66504. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  66505. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  66506. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  66507. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  66508. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  66509. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  66510. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  66511. /** @hidden */
  66512. export var depthVertexShader: {
  66513. name: string;
  66514. shader: string;
  66515. };
  66516. }
  66517. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  66518. /** @hidden */
  66519. export var volumetricLightScatteringPixelShader: {
  66520. name: string;
  66521. shader: string;
  66522. };
  66523. }
  66524. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  66525. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  66526. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  66527. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  66528. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  66529. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  66530. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  66531. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  66532. /** @hidden */
  66533. export var volumetricLightScatteringPassVertexShader: {
  66534. name: string;
  66535. shader: string;
  66536. };
  66537. }
  66538. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  66539. /** @hidden */
  66540. export var volumetricLightScatteringPassPixelShader: {
  66541. name: string;
  66542. shader: string;
  66543. };
  66544. }
  66545. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  66546. import { Vector3 } from "babylonjs/Maths/math.vector";
  66547. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66548. import { Mesh } from "babylonjs/Meshes/mesh";
  66549. import { Camera } from "babylonjs/Cameras/camera";
  66550. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  66551. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  66552. import { Scene } from "babylonjs/scene";
  66553. import "babylonjs/Meshes/Builders/planeBuilder";
  66554. import "babylonjs/Shaders/depth.vertex";
  66555. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  66556. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  66557. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  66558. import { Engine } from "babylonjs/Engines/engine";
  66559. /**
  66560. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  66561. */
  66562. export class VolumetricLightScatteringPostProcess extends PostProcess {
  66563. private _volumetricLightScatteringPass;
  66564. private _volumetricLightScatteringRTT;
  66565. private _viewPort;
  66566. private _screenCoordinates;
  66567. private _cachedDefines;
  66568. /**
  66569. * If not undefined, the mesh position is computed from the attached node position
  66570. */
  66571. attachedNode: {
  66572. position: Vector3;
  66573. };
  66574. /**
  66575. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  66576. */
  66577. customMeshPosition: Vector3;
  66578. /**
  66579. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  66580. */
  66581. useCustomMeshPosition: boolean;
  66582. /**
  66583. * If the post-process should inverse the light scattering direction
  66584. */
  66585. invert: boolean;
  66586. /**
  66587. * The internal mesh used by the post-process
  66588. */
  66589. mesh: Mesh;
  66590. /**
  66591. * @hidden
  66592. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  66593. */
  66594. useDiffuseColor: boolean;
  66595. /**
  66596. * Array containing the excluded meshes not rendered in the internal pass
  66597. */
  66598. excludedMeshes: AbstractMesh[];
  66599. /**
  66600. * Controls the overall intensity of the post-process
  66601. */
  66602. exposure: number;
  66603. /**
  66604. * Dissipates each sample's contribution in range [0, 1]
  66605. */
  66606. decay: number;
  66607. /**
  66608. * Controls the overall intensity of each sample
  66609. */
  66610. weight: number;
  66611. /**
  66612. * Controls the density of each sample
  66613. */
  66614. density: number;
  66615. /**
  66616. * @constructor
  66617. * @param name The post-process name
  66618. * @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)
  66619. * @param camera The camera that the post-process will be attached to
  66620. * @param mesh The mesh used to create the light scattering
  66621. * @param samples The post-process quality, default 100
  66622. * @param samplingModeThe post-process filtering mode
  66623. * @param engine The babylon engine
  66624. * @param reusable If the post-process is reusable
  66625. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  66626. */
  66627. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  66628. /**
  66629. * Returns the string "VolumetricLightScatteringPostProcess"
  66630. * @returns "VolumetricLightScatteringPostProcess"
  66631. */
  66632. getClassName(): string;
  66633. private _isReady;
  66634. /**
  66635. * Sets the new light position for light scattering effect
  66636. * @param position The new custom light position
  66637. */
  66638. setCustomMeshPosition(position: Vector3): void;
  66639. /**
  66640. * Returns the light position for light scattering effect
  66641. * @return Vector3 The custom light position
  66642. */
  66643. getCustomMeshPosition(): Vector3;
  66644. /**
  66645. * Disposes the internal assets and detaches the post-process from the camera
  66646. */
  66647. dispose(camera: Camera): void;
  66648. /**
  66649. * Returns the render target texture used by the post-process
  66650. * @return the render target texture used by the post-process
  66651. */
  66652. getPass(): RenderTargetTexture;
  66653. private _meshExcluded;
  66654. private _createPass;
  66655. private _updateMeshScreenCoordinates;
  66656. /**
  66657. * Creates a default mesh for the Volumeric Light Scattering post-process
  66658. * @param name The mesh name
  66659. * @param scene The scene where to create the mesh
  66660. * @return the default mesh
  66661. */
  66662. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  66663. }
  66664. }
  66665. declare module "babylonjs/PostProcesses/index" {
  66666. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  66667. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  66668. export * from "babylonjs/PostProcesses/bloomEffect";
  66669. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  66670. export * from "babylonjs/PostProcesses/blurPostProcess";
  66671. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  66672. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  66673. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  66674. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  66675. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  66676. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  66677. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  66678. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  66679. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  66680. export * from "babylonjs/PostProcesses/filterPostProcess";
  66681. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  66682. export * from "babylonjs/PostProcesses/grainPostProcess";
  66683. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  66684. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  66685. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  66686. export * from "babylonjs/PostProcesses/passPostProcess";
  66687. export * from "babylonjs/PostProcesses/postProcess";
  66688. export * from "babylonjs/PostProcesses/postProcessManager";
  66689. export * from "babylonjs/PostProcesses/refractionPostProcess";
  66690. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  66691. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  66692. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  66693. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  66694. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  66695. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  66696. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  66697. }
  66698. declare module "babylonjs/Probes/index" {
  66699. export * from "babylonjs/Probes/reflectionProbe";
  66700. }
  66701. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  66702. import { Scene } from "babylonjs/scene";
  66703. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66704. import { SmartArray } from "babylonjs/Misc/smartArray";
  66705. import { ISceneComponent } from "babylonjs/sceneComponent";
  66706. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  66707. import "babylonjs/Meshes/Builders/boxBuilder";
  66708. import "babylonjs/Shaders/color.fragment";
  66709. import "babylonjs/Shaders/color.vertex";
  66710. import { Color3 } from "babylonjs/Maths/math.color";
  66711. module "babylonjs/scene" {
  66712. interface Scene {
  66713. /** @hidden (Backing field) */
  66714. _boundingBoxRenderer: BoundingBoxRenderer;
  66715. /** @hidden (Backing field) */
  66716. _forceShowBoundingBoxes: boolean;
  66717. /**
  66718. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  66719. */
  66720. forceShowBoundingBoxes: boolean;
  66721. /**
  66722. * Gets the bounding box renderer associated with the scene
  66723. * @returns a BoundingBoxRenderer
  66724. */
  66725. getBoundingBoxRenderer(): BoundingBoxRenderer;
  66726. }
  66727. }
  66728. module "babylonjs/Meshes/abstractMesh" {
  66729. interface AbstractMesh {
  66730. /** @hidden (Backing field) */
  66731. _showBoundingBox: boolean;
  66732. /**
  66733. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  66734. */
  66735. showBoundingBox: boolean;
  66736. }
  66737. }
  66738. /**
  66739. * Component responsible of rendering the bounding box of the meshes in a scene.
  66740. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  66741. */
  66742. export class BoundingBoxRenderer implements ISceneComponent {
  66743. /**
  66744. * The component name helpfull to identify the component in the list of scene components.
  66745. */
  66746. readonly name: string;
  66747. /**
  66748. * The scene the component belongs to.
  66749. */
  66750. scene: Scene;
  66751. /**
  66752. * Color of the bounding box lines placed in front of an object
  66753. */
  66754. frontColor: Color3;
  66755. /**
  66756. * Color of the bounding box lines placed behind an object
  66757. */
  66758. backColor: Color3;
  66759. /**
  66760. * Defines if the renderer should show the back lines or not
  66761. */
  66762. showBackLines: boolean;
  66763. /**
  66764. * @hidden
  66765. */
  66766. renderList: SmartArray<BoundingBox>;
  66767. private _colorShader;
  66768. private _vertexBuffers;
  66769. private _indexBuffer;
  66770. private _fillIndexBuffer;
  66771. private _fillIndexData;
  66772. /**
  66773. * Instantiates a new bounding box renderer in a scene.
  66774. * @param scene the scene the renderer renders in
  66775. */
  66776. constructor(scene: Scene);
  66777. /**
  66778. * Registers the component in a given scene
  66779. */
  66780. register(): void;
  66781. private _evaluateSubMesh;
  66782. private _activeMesh;
  66783. private _prepareRessources;
  66784. private _createIndexBuffer;
  66785. /**
  66786. * Rebuilds the elements related to this component in case of
  66787. * context lost for instance.
  66788. */
  66789. rebuild(): void;
  66790. /**
  66791. * @hidden
  66792. */
  66793. reset(): void;
  66794. /**
  66795. * Render the bounding boxes of a specific rendering group
  66796. * @param renderingGroupId defines the rendering group to render
  66797. */
  66798. render(renderingGroupId: number): void;
  66799. /**
  66800. * In case of occlusion queries, we can render the occlusion bounding box through this method
  66801. * @param mesh Define the mesh to render the occlusion bounding box for
  66802. */
  66803. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  66804. /**
  66805. * Dispose and release the resources attached to this renderer.
  66806. */
  66807. dispose(): void;
  66808. }
  66809. }
  66810. declare module "babylonjs/Shaders/depth.fragment" {
  66811. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  66812. /** @hidden */
  66813. export var depthPixelShader: {
  66814. name: string;
  66815. shader: string;
  66816. };
  66817. }
  66818. declare module "babylonjs/Rendering/depthRenderer" {
  66819. import { Nullable } from "babylonjs/types";
  66820. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66821. import { Scene } from "babylonjs/scene";
  66822. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  66823. import { Camera } from "babylonjs/Cameras/camera";
  66824. import "babylonjs/Shaders/depth.fragment";
  66825. import "babylonjs/Shaders/depth.vertex";
  66826. /**
  66827. * This represents a depth renderer in Babylon.
  66828. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  66829. */
  66830. export class DepthRenderer {
  66831. private _scene;
  66832. private _depthMap;
  66833. private _effect;
  66834. private readonly _storeNonLinearDepth;
  66835. private readonly _clearColor;
  66836. /** Get if the depth renderer is using packed depth or not */
  66837. readonly isPacked: boolean;
  66838. private _cachedDefines;
  66839. private _camera;
  66840. /**
  66841. * Specifiess that the depth renderer will only be used within
  66842. * the camera it is created for.
  66843. * This can help forcing its rendering during the camera processing.
  66844. */
  66845. useOnlyInActiveCamera: boolean;
  66846. /** @hidden */
  66847. static _SceneComponentInitialization: (scene: Scene) => void;
  66848. /**
  66849. * Instantiates a depth renderer
  66850. * @param scene The scene the renderer belongs to
  66851. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  66852. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  66853. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  66854. */
  66855. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  66856. /**
  66857. * Creates the depth rendering effect and checks if the effect is ready.
  66858. * @param subMesh The submesh to be used to render the depth map of
  66859. * @param useInstances If multiple world instances should be used
  66860. * @returns if the depth renderer is ready to render the depth map
  66861. */
  66862. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66863. /**
  66864. * Gets the texture which the depth map will be written to.
  66865. * @returns The depth map texture
  66866. */
  66867. getDepthMap(): RenderTargetTexture;
  66868. /**
  66869. * Disposes of the depth renderer.
  66870. */
  66871. dispose(): void;
  66872. }
  66873. }
  66874. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  66875. import { Nullable } from "babylonjs/types";
  66876. import { Scene } from "babylonjs/scene";
  66877. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  66878. import { Camera } from "babylonjs/Cameras/camera";
  66879. import { ISceneComponent } from "babylonjs/sceneComponent";
  66880. module "babylonjs/scene" {
  66881. interface Scene {
  66882. /** @hidden (Backing field) */
  66883. _depthRenderer: {
  66884. [id: string]: DepthRenderer;
  66885. };
  66886. /**
  66887. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  66888. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  66889. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  66890. * @returns the created depth renderer
  66891. */
  66892. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  66893. /**
  66894. * Disables a depth renderer for a given camera
  66895. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  66896. */
  66897. disableDepthRenderer(camera?: Nullable<Camera>): void;
  66898. }
  66899. }
  66900. /**
  66901. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  66902. * in several rendering techniques.
  66903. */
  66904. export class DepthRendererSceneComponent implements ISceneComponent {
  66905. /**
  66906. * The component name helpfull to identify the component in the list of scene components.
  66907. */
  66908. readonly name: string;
  66909. /**
  66910. * The scene the component belongs to.
  66911. */
  66912. scene: Scene;
  66913. /**
  66914. * Creates a new instance of the component for the given scene
  66915. * @param scene Defines the scene to register the component in
  66916. */
  66917. constructor(scene: Scene);
  66918. /**
  66919. * Registers the component in a given scene
  66920. */
  66921. register(): void;
  66922. /**
  66923. * Rebuilds the elements related to this component in case of
  66924. * context lost for instance.
  66925. */
  66926. rebuild(): void;
  66927. /**
  66928. * Disposes the component and the associated ressources
  66929. */
  66930. dispose(): void;
  66931. private _gatherRenderTargets;
  66932. private _gatherActiveCameraRenderTargets;
  66933. }
  66934. }
  66935. declare module "babylonjs/Shaders/outline.fragment" {
  66936. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  66937. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  66938. /** @hidden */
  66939. export var outlinePixelShader: {
  66940. name: string;
  66941. shader: string;
  66942. };
  66943. }
  66944. declare module "babylonjs/Shaders/outline.vertex" {
  66945. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  66946. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  66947. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  66948. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  66949. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  66950. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  66951. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  66952. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  66953. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  66954. /** @hidden */
  66955. export var outlineVertexShader: {
  66956. name: string;
  66957. shader: string;
  66958. };
  66959. }
  66960. declare module "babylonjs/Rendering/outlineRenderer" {
  66961. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66962. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  66963. import { Scene } from "babylonjs/scene";
  66964. import { ISceneComponent } from "babylonjs/sceneComponent";
  66965. import "babylonjs/Shaders/outline.fragment";
  66966. import "babylonjs/Shaders/outline.vertex";
  66967. module "babylonjs/scene" {
  66968. interface Scene {
  66969. /** @hidden */
  66970. _outlineRenderer: OutlineRenderer;
  66971. /**
  66972. * Gets the outline renderer associated with the scene
  66973. * @returns a OutlineRenderer
  66974. */
  66975. getOutlineRenderer(): OutlineRenderer;
  66976. }
  66977. }
  66978. module "babylonjs/Meshes/abstractMesh" {
  66979. interface AbstractMesh {
  66980. /** @hidden (Backing field) */
  66981. _renderOutline: boolean;
  66982. /**
  66983. * Gets or sets a boolean indicating if the outline must be rendered as well
  66984. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  66985. */
  66986. renderOutline: boolean;
  66987. /** @hidden (Backing field) */
  66988. _renderOverlay: boolean;
  66989. /**
  66990. * Gets or sets a boolean indicating if the overlay must be rendered as well
  66991. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  66992. */
  66993. renderOverlay: boolean;
  66994. }
  66995. }
  66996. /**
  66997. * This class is responsible to draw bothe outline/overlay of meshes.
  66998. * It should not be used directly but through the available method on mesh.
  66999. */
  67000. export class OutlineRenderer implements ISceneComponent {
  67001. /**
  67002. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  67003. */
  67004. private static _StencilReference;
  67005. /**
  67006. * The name of the component. Each component must have a unique name.
  67007. */
  67008. name: string;
  67009. /**
  67010. * The scene the component belongs to.
  67011. */
  67012. scene: Scene;
  67013. /**
  67014. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  67015. */
  67016. zOffset: number;
  67017. private _engine;
  67018. private _effect;
  67019. private _cachedDefines;
  67020. private _savedDepthWrite;
  67021. /**
  67022. * Instantiates a new outline renderer. (There could be only one per scene).
  67023. * @param scene Defines the scene it belongs to
  67024. */
  67025. constructor(scene: Scene);
  67026. /**
  67027. * Register the component to one instance of a scene.
  67028. */
  67029. register(): void;
  67030. /**
  67031. * Rebuilds the elements related to this component in case of
  67032. * context lost for instance.
  67033. */
  67034. rebuild(): void;
  67035. /**
  67036. * Disposes the component and the associated ressources.
  67037. */
  67038. dispose(): void;
  67039. /**
  67040. * Renders the outline in the canvas.
  67041. * @param subMesh Defines the sumesh to render
  67042. * @param batch Defines the batch of meshes in case of instances
  67043. * @param useOverlay Defines if the rendering is for the overlay or the outline
  67044. */
  67045. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  67046. /**
  67047. * Returns whether or not the outline renderer is ready for a given submesh.
  67048. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  67049. * @param subMesh Defines the submesh to check readyness for
  67050. * @param useInstances Defines wheter wee are trying to render instances or not
  67051. * @returns true if ready otherwise false
  67052. */
  67053. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  67054. private _beforeRenderingMesh;
  67055. private _afterRenderingMesh;
  67056. }
  67057. }
  67058. declare module "babylonjs/Rendering/index" {
  67059. export * from "babylonjs/Rendering/boundingBoxRenderer";
  67060. export * from "babylonjs/Rendering/depthRenderer";
  67061. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  67062. export * from "babylonjs/Rendering/edgesRenderer";
  67063. export * from "babylonjs/Rendering/geometryBufferRenderer";
  67064. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  67065. export * from "babylonjs/Rendering/outlineRenderer";
  67066. export * from "babylonjs/Rendering/renderingGroup";
  67067. export * from "babylonjs/Rendering/renderingManager";
  67068. export * from "babylonjs/Rendering/utilityLayerRenderer";
  67069. }
  67070. declare module "babylonjs/Sprites/ISprites" {
  67071. /**
  67072. * Defines the basic options interface of a Sprite Frame Source Size.
  67073. */
  67074. export interface ISpriteJSONSpriteSourceSize {
  67075. /**
  67076. * number of the original width of the Frame
  67077. */
  67078. w: number;
  67079. /**
  67080. * number of the original height of the Frame
  67081. */
  67082. h: number;
  67083. }
  67084. /**
  67085. * Defines the basic options interface of a Sprite Frame Data.
  67086. */
  67087. export interface ISpriteJSONSpriteFrameData {
  67088. /**
  67089. * number of the x offset of the Frame
  67090. */
  67091. x: number;
  67092. /**
  67093. * number of the y offset of the Frame
  67094. */
  67095. y: number;
  67096. /**
  67097. * number of the width of the Frame
  67098. */
  67099. w: number;
  67100. /**
  67101. * number of the height of the Frame
  67102. */
  67103. h: number;
  67104. }
  67105. /**
  67106. * Defines the basic options interface of a JSON Sprite.
  67107. */
  67108. export interface ISpriteJSONSprite {
  67109. /**
  67110. * string name of the Frame
  67111. */
  67112. filename: string;
  67113. /**
  67114. * ISpriteJSONSpriteFrame basic object of the frame data
  67115. */
  67116. frame: ISpriteJSONSpriteFrameData;
  67117. /**
  67118. * boolean to flag is the frame was rotated.
  67119. */
  67120. rotated: boolean;
  67121. /**
  67122. * boolean to flag is the frame was trimmed.
  67123. */
  67124. trimmed: boolean;
  67125. /**
  67126. * ISpriteJSONSpriteFrame basic object of the source data
  67127. */
  67128. spriteSourceSize: ISpriteJSONSpriteFrameData;
  67129. /**
  67130. * ISpriteJSONSpriteFrame basic object of the source data
  67131. */
  67132. sourceSize: ISpriteJSONSpriteSourceSize;
  67133. }
  67134. /**
  67135. * Defines the basic options interface of a JSON atlas.
  67136. */
  67137. export interface ISpriteJSONAtlas {
  67138. /**
  67139. * Array of objects that contain the frame data.
  67140. */
  67141. frames: Array<ISpriteJSONSprite>;
  67142. /**
  67143. * object basic object containing the sprite meta data.
  67144. */
  67145. meta?: object;
  67146. }
  67147. }
  67148. declare module "babylonjs/Shaders/spriteMap.fragment" {
  67149. /** @hidden */
  67150. export var spriteMapPixelShader: {
  67151. name: string;
  67152. shader: string;
  67153. };
  67154. }
  67155. declare module "babylonjs/Shaders/spriteMap.vertex" {
  67156. /** @hidden */
  67157. export var spriteMapVertexShader: {
  67158. name: string;
  67159. shader: string;
  67160. };
  67161. }
  67162. declare module "babylonjs/Sprites/spriteMap" {
  67163. import { IDisposable, Scene } from "babylonjs/scene";
  67164. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  67165. import { Texture } from "babylonjs/Materials/Textures/texture";
  67166. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  67167. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  67168. import "babylonjs/Meshes/Builders/planeBuilder";
  67169. import "babylonjs/Shaders/spriteMap.fragment";
  67170. import "babylonjs/Shaders/spriteMap.vertex";
  67171. /**
  67172. * Defines the basic options interface of a SpriteMap
  67173. */
  67174. export interface ISpriteMapOptions {
  67175. /**
  67176. * Vector2 of the number of cells in the grid.
  67177. */
  67178. stageSize?: Vector2;
  67179. /**
  67180. * Vector2 of the size of the output plane in World Units.
  67181. */
  67182. outputSize?: Vector2;
  67183. /**
  67184. * Vector3 of the position of the output plane in World Units.
  67185. */
  67186. outputPosition?: Vector3;
  67187. /**
  67188. * number of layers that the system will reserve in resources.
  67189. */
  67190. layerCount?: number;
  67191. /**
  67192. * number of max animation frames a single cell will reserve in resources.
  67193. */
  67194. maxAnimationFrames?: number;
  67195. /**
  67196. * number cell index of the base tile when the system compiles.
  67197. */
  67198. baseTile?: number;
  67199. /**
  67200. * boolean flip the sprite after its been repositioned by the framing data.
  67201. */
  67202. flipU?: boolean;
  67203. /**
  67204. * Vector3 scalar of the global RGB values of the SpriteMap.
  67205. */
  67206. colorMultiply?: Vector3;
  67207. }
  67208. /**
  67209. * Defines the IDisposable interface in order to be cleanable from resources.
  67210. */
  67211. export interface ISpriteMap extends IDisposable {
  67212. /**
  67213. * String name of the SpriteMap.
  67214. */
  67215. name: string;
  67216. /**
  67217. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  67218. */
  67219. atlasJSON: ISpriteJSONAtlas;
  67220. /**
  67221. * Texture of the SpriteMap.
  67222. */
  67223. spriteSheet: Texture;
  67224. /**
  67225. * The parameters to initialize the SpriteMap with.
  67226. */
  67227. options: ISpriteMapOptions;
  67228. }
  67229. /**
  67230. * Class used to manage a grid restricted sprite deployment on an Output plane.
  67231. */
  67232. export class SpriteMap implements ISpriteMap {
  67233. /** The Name of the spriteMap */
  67234. name: string;
  67235. /** The JSON file with the frame and meta data */
  67236. atlasJSON: ISpriteJSONAtlas;
  67237. /** The systems Sprite Sheet Texture */
  67238. spriteSheet: Texture;
  67239. /** Arguments passed with the Constructor */
  67240. options: ISpriteMapOptions;
  67241. /** Public Sprite Storage array, parsed from atlasJSON */
  67242. sprites: Array<ISpriteJSONSprite>;
  67243. /** Returns the Number of Sprites in the System */
  67244. readonly spriteCount: number;
  67245. /** Returns the Position of Output Plane*/
  67246. /** Returns the Position of Output Plane*/
  67247. position: Vector3;
  67248. /** Sets the AnimationMap*/
  67249. /** Sets the AnimationMap*/
  67250. animationMap: RawTexture;
  67251. /** Scene that the SpriteMap was created in */
  67252. private _scene;
  67253. /** Texture Buffer of Float32 that holds tile frame data*/
  67254. private _frameMap;
  67255. /** Texture Buffers of Float32 that holds tileMap data*/
  67256. private _tileMaps;
  67257. /** Texture Buffer of Float32 that holds Animation Data*/
  67258. private _animationMap;
  67259. /** Custom ShaderMaterial Central to the System*/
  67260. private _material;
  67261. /** Custom ShaderMaterial Central to the System*/
  67262. private _output;
  67263. /** Systems Time Ticker*/
  67264. private _time;
  67265. /**
  67266. * Creates a new SpriteMap
  67267. * @param name defines the SpriteMaps Name
  67268. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  67269. * @param spriteSheet is the Texture that the Sprites are on.
  67270. * @param options a basic deployment configuration
  67271. * @param scene The Scene that the map is deployed on
  67272. */
  67273. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  67274. /**
  67275. * Returns tileID location
  67276. * @returns Vector2 the cell position ID
  67277. */
  67278. getTileID(): Vector2;
  67279. /**
  67280. * Gets the UV location of the mouse over the SpriteMap.
  67281. * @returns Vector2 the UV position of the mouse interaction
  67282. */
  67283. getMousePosition(): Vector2;
  67284. /**
  67285. * Creates the "frame" texture Buffer
  67286. * -------------------------------------
  67287. * Structure of frames
  67288. * "filename": "Falling-Water-2.png",
  67289. * "frame": {"x":69,"y":103,"w":24,"h":32},
  67290. * "rotated": true,
  67291. * "trimmed": true,
  67292. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  67293. * "sourceSize": {"w":32,"h":32}
  67294. * @returns RawTexture of the frameMap
  67295. */
  67296. private _createFrameBuffer;
  67297. /**
  67298. * Creates the tileMap texture Buffer
  67299. * @param buffer normally and array of numbers, or a false to generate from scratch
  67300. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  67301. * @returns RawTexture of the tileMap
  67302. */
  67303. private _createTileBuffer;
  67304. /**
  67305. * Modifies the data of the tileMaps
  67306. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  67307. * @param pos is the iVector2 Coordinates of the Tile
  67308. * @param tile The SpriteIndex of the new Tile
  67309. */
  67310. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  67311. /**
  67312. * Creates the animationMap texture Buffer
  67313. * @param buffer normally and array of numbers, or a false to generate from scratch
  67314. * @returns RawTexture of the animationMap
  67315. */
  67316. private _createTileAnimationBuffer;
  67317. /**
  67318. * Modifies the data of the animationMap
  67319. * @param cellID is the Index of the Sprite
  67320. * @param _frame is the target Animation frame
  67321. * @param toCell is the Target Index of the next frame of the animation
  67322. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  67323. * @param speed is a global scalar of the time variable on the map.
  67324. */
  67325. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  67326. /**
  67327. * Exports the .tilemaps file
  67328. */
  67329. saveTileMaps(): void;
  67330. /**
  67331. * Imports the .tilemaps file
  67332. * @param url of the .tilemaps file
  67333. */
  67334. loadTileMaps(url: string): void;
  67335. /**
  67336. * Release associated resources
  67337. */
  67338. dispose(): void;
  67339. }
  67340. }
  67341. declare module "babylonjs/Sprites/spritePackedManager" {
  67342. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  67343. import { Scene } from "babylonjs/scene";
  67344. /**
  67345. * Class used to manage multiple sprites of different sizes on the same spritesheet
  67346. * @see http://doc.babylonjs.com/babylon101/sprites
  67347. */
  67348. export class SpritePackedManager extends SpriteManager {
  67349. /** defines the packed manager's name */
  67350. name: string;
  67351. /**
  67352. * Creates a new sprite manager from a packed sprite sheet
  67353. * @param name defines the manager's name
  67354. * @param imgUrl defines the sprite sheet url
  67355. * @param capacity defines the maximum allowed number of sprites
  67356. * @param scene defines the hosting scene
  67357. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  67358. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  67359. * @param samplingMode defines the smapling mode to use with spritesheet
  67360. * @param fromPacked set to true; do not alter
  67361. */
  67362. constructor(
  67363. /** defines the packed manager's name */
  67364. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  67365. }
  67366. }
  67367. declare module "babylonjs/Sprites/index" {
  67368. export * from "babylonjs/Sprites/sprite";
  67369. export * from "babylonjs/Sprites/ISprites";
  67370. export * from "babylonjs/Sprites/spriteManager";
  67371. export * from "babylonjs/Sprites/spriteMap";
  67372. export * from "babylonjs/Sprites/spritePackedManager";
  67373. export * from "babylonjs/Sprites/spriteSceneComponent";
  67374. }
  67375. declare module "babylonjs/States/index" {
  67376. export * from "babylonjs/States/alphaCullingState";
  67377. export * from "babylonjs/States/depthCullingState";
  67378. export * from "babylonjs/States/stencilState";
  67379. }
  67380. declare module "babylonjs/Misc/assetsManager" {
  67381. import { Scene } from "babylonjs/scene";
  67382. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67383. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  67384. import { Skeleton } from "babylonjs/Bones/skeleton";
  67385. import { Observable } from "babylonjs/Misc/observable";
  67386. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  67387. import { Texture } from "babylonjs/Materials/Textures/texture";
  67388. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  67389. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  67390. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  67391. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  67392. /**
  67393. * Defines the list of states available for a task inside a AssetsManager
  67394. */
  67395. export enum AssetTaskState {
  67396. /**
  67397. * Initialization
  67398. */
  67399. INIT = 0,
  67400. /**
  67401. * Running
  67402. */
  67403. RUNNING = 1,
  67404. /**
  67405. * Done
  67406. */
  67407. DONE = 2,
  67408. /**
  67409. * Error
  67410. */
  67411. ERROR = 3
  67412. }
  67413. /**
  67414. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  67415. */
  67416. export abstract class AbstractAssetTask {
  67417. /**
  67418. * Task name
  67419. */ name: string;
  67420. /**
  67421. * Callback called when the task is successful
  67422. */
  67423. onSuccess: (task: any) => void;
  67424. /**
  67425. * Callback called when the task is not successful
  67426. */
  67427. onError: (task: any, message?: string, exception?: any) => void;
  67428. /**
  67429. * Creates a new AssetsManager
  67430. * @param name defines the name of the task
  67431. */
  67432. constructor(
  67433. /**
  67434. * Task name
  67435. */ name: string);
  67436. private _isCompleted;
  67437. private _taskState;
  67438. private _errorObject;
  67439. /**
  67440. * Get if the task is completed
  67441. */
  67442. readonly isCompleted: boolean;
  67443. /**
  67444. * Gets the current state of the task
  67445. */
  67446. readonly taskState: AssetTaskState;
  67447. /**
  67448. * Gets the current error object (if task is in error)
  67449. */
  67450. readonly errorObject: {
  67451. message?: string;
  67452. exception?: any;
  67453. };
  67454. /**
  67455. * Internal only
  67456. * @hidden
  67457. */
  67458. _setErrorObject(message?: string, exception?: any): void;
  67459. /**
  67460. * Execute the current task
  67461. * @param scene defines the scene where you want your assets to be loaded
  67462. * @param onSuccess is a callback called when the task is successfully executed
  67463. * @param onError is a callback called if an error occurs
  67464. */
  67465. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67466. /**
  67467. * Execute the current task
  67468. * @param scene defines the scene where you want your assets to be loaded
  67469. * @param onSuccess is a callback called when the task is successfully executed
  67470. * @param onError is a callback called if an error occurs
  67471. */
  67472. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67473. /**
  67474. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  67475. * This can be used with failed tasks that have the reason for failure fixed.
  67476. */
  67477. reset(): void;
  67478. private onErrorCallback;
  67479. private onDoneCallback;
  67480. }
  67481. /**
  67482. * Define the interface used by progress events raised during assets loading
  67483. */
  67484. export interface IAssetsProgressEvent {
  67485. /**
  67486. * Defines the number of remaining tasks to process
  67487. */
  67488. remainingCount: number;
  67489. /**
  67490. * Defines the total number of tasks
  67491. */
  67492. totalCount: number;
  67493. /**
  67494. * Defines the task that was just processed
  67495. */
  67496. task: AbstractAssetTask;
  67497. }
  67498. /**
  67499. * Class used to share progress information about assets loading
  67500. */
  67501. export class AssetsProgressEvent implements IAssetsProgressEvent {
  67502. /**
  67503. * Defines the number of remaining tasks to process
  67504. */
  67505. remainingCount: number;
  67506. /**
  67507. * Defines the total number of tasks
  67508. */
  67509. totalCount: number;
  67510. /**
  67511. * Defines the task that was just processed
  67512. */
  67513. task: AbstractAssetTask;
  67514. /**
  67515. * Creates a AssetsProgressEvent
  67516. * @param remainingCount defines the number of remaining tasks to process
  67517. * @param totalCount defines the total number of tasks
  67518. * @param task defines the task that was just processed
  67519. */
  67520. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  67521. }
  67522. /**
  67523. * Define a task used by AssetsManager to load meshes
  67524. */
  67525. export class MeshAssetTask extends AbstractAssetTask {
  67526. /**
  67527. * Defines the name of the task
  67528. */
  67529. name: string;
  67530. /**
  67531. * Defines the list of mesh's names you want to load
  67532. */
  67533. meshesNames: any;
  67534. /**
  67535. * Defines the root url to use as a base to load your meshes and associated resources
  67536. */
  67537. rootUrl: string;
  67538. /**
  67539. * Defines the filename of the scene to load from
  67540. */
  67541. sceneFilename: string;
  67542. /**
  67543. * Gets the list of loaded meshes
  67544. */
  67545. loadedMeshes: Array<AbstractMesh>;
  67546. /**
  67547. * Gets the list of loaded particle systems
  67548. */
  67549. loadedParticleSystems: Array<IParticleSystem>;
  67550. /**
  67551. * Gets the list of loaded skeletons
  67552. */
  67553. loadedSkeletons: Array<Skeleton>;
  67554. /**
  67555. * Gets the list of loaded animation groups
  67556. */
  67557. loadedAnimationGroups: Array<AnimationGroup>;
  67558. /**
  67559. * Callback called when the task is successful
  67560. */
  67561. onSuccess: (task: MeshAssetTask) => void;
  67562. /**
  67563. * Callback called when the task is successful
  67564. */
  67565. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  67566. /**
  67567. * Creates a new MeshAssetTask
  67568. * @param name defines the name of the task
  67569. * @param meshesNames defines the list of mesh's names you want to load
  67570. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  67571. * @param sceneFilename defines the filename of the scene to load from
  67572. */
  67573. constructor(
  67574. /**
  67575. * Defines the name of the task
  67576. */
  67577. name: string,
  67578. /**
  67579. * Defines the list of mesh's names you want to load
  67580. */
  67581. meshesNames: any,
  67582. /**
  67583. * Defines the root url to use as a base to load your meshes and associated resources
  67584. */
  67585. rootUrl: string,
  67586. /**
  67587. * Defines the filename of the scene to load from
  67588. */
  67589. sceneFilename: string);
  67590. /**
  67591. * Execute the current task
  67592. * @param scene defines the scene where you want your assets to be loaded
  67593. * @param onSuccess is a callback called when the task is successfully executed
  67594. * @param onError is a callback called if an error occurs
  67595. */
  67596. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67597. }
  67598. /**
  67599. * Define a task used by AssetsManager to load text content
  67600. */
  67601. export class TextFileAssetTask extends AbstractAssetTask {
  67602. /**
  67603. * Defines the name of the task
  67604. */
  67605. name: string;
  67606. /**
  67607. * Defines the location of the file to load
  67608. */
  67609. url: string;
  67610. /**
  67611. * Gets the loaded text string
  67612. */
  67613. text: string;
  67614. /**
  67615. * Callback called when the task is successful
  67616. */
  67617. onSuccess: (task: TextFileAssetTask) => void;
  67618. /**
  67619. * Callback called when the task is successful
  67620. */
  67621. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  67622. /**
  67623. * Creates a new TextFileAssetTask object
  67624. * @param name defines the name of the task
  67625. * @param url defines the location of the file to load
  67626. */
  67627. constructor(
  67628. /**
  67629. * Defines the name of the task
  67630. */
  67631. name: string,
  67632. /**
  67633. * Defines the location of the file to load
  67634. */
  67635. url: string);
  67636. /**
  67637. * Execute the current task
  67638. * @param scene defines the scene where you want your assets to be loaded
  67639. * @param onSuccess is a callback called when the task is successfully executed
  67640. * @param onError is a callback called if an error occurs
  67641. */
  67642. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67643. }
  67644. /**
  67645. * Define a task used by AssetsManager to load binary data
  67646. */
  67647. export class BinaryFileAssetTask extends AbstractAssetTask {
  67648. /**
  67649. * Defines the name of the task
  67650. */
  67651. name: string;
  67652. /**
  67653. * Defines the location of the file to load
  67654. */
  67655. url: string;
  67656. /**
  67657. * Gets the lodaded data (as an array buffer)
  67658. */
  67659. data: ArrayBuffer;
  67660. /**
  67661. * Callback called when the task is successful
  67662. */
  67663. onSuccess: (task: BinaryFileAssetTask) => void;
  67664. /**
  67665. * Callback called when the task is successful
  67666. */
  67667. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  67668. /**
  67669. * Creates a new BinaryFileAssetTask object
  67670. * @param name defines the name of the new task
  67671. * @param url defines the location of the file to load
  67672. */
  67673. constructor(
  67674. /**
  67675. * Defines the name of the task
  67676. */
  67677. name: string,
  67678. /**
  67679. * Defines the location of the file to load
  67680. */
  67681. url: string);
  67682. /**
  67683. * Execute the current task
  67684. * @param scene defines the scene where you want your assets to be loaded
  67685. * @param onSuccess is a callback called when the task is successfully executed
  67686. * @param onError is a callback called if an error occurs
  67687. */
  67688. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67689. }
  67690. /**
  67691. * Define a task used by AssetsManager to load images
  67692. */
  67693. export class ImageAssetTask extends AbstractAssetTask {
  67694. /**
  67695. * Defines the name of the task
  67696. */
  67697. name: string;
  67698. /**
  67699. * Defines the location of the image to load
  67700. */
  67701. url: string;
  67702. /**
  67703. * Gets the loaded images
  67704. */
  67705. image: HTMLImageElement;
  67706. /**
  67707. * Callback called when the task is successful
  67708. */
  67709. onSuccess: (task: ImageAssetTask) => void;
  67710. /**
  67711. * Callback called when the task is successful
  67712. */
  67713. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  67714. /**
  67715. * Creates a new ImageAssetTask
  67716. * @param name defines the name of the task
  67717. * @param url defines the location of the image to load
  67718. */
  67719. constructor(
  67720. /**
  67721. * Defines the name of the task
  67722. */
  67723. name: string,
  67724. /**
  67725. * Defines the location of the image to load
  67726. */
  67727. url: string);
  67728. /**
  67729. * Execute the current task
  67730. * @param scene defines the scene where you want your assets to be loaded
  67731. * @param onSuccess is a callback called when the task is successfully executed
  67732. * @param onError is a callback called if an error occurs
  67733. */
  67734. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67735. }
  67736. /**
  67737. * Defines the interface used by texture loading tasks
  67738. */
  67739. export interface ITextureAssetTask<TEX extends BaseTexture> {
  67740. /**
  67741. * Gets the loaded texture
  67742. */
  67743. texture: TEX;
  67744. }
  67745. /**
  67746. * Define a task used by AssetsManager to load 2D textures
  67747. */
  67748. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  67749. /**
  67750. * Defines the name of the task
  67751. */
  67752. name: string;
  67753. /**
  67754. * Defines the location of the file to load
  67755. */
  67756. url: string;
  67757. /**
  67758. * Defines if mipmap should not be generated (default is false)
  67759. */
  67760. noMipmap?: boolean | undefined;
  67761. /**
  67762. * Defines if texture must be inverted on Y axis (default is false)
  67763. */
  67764. invertY?: boolean | undefined;
  67765. /**
  67766. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67767. */
  67768. samplingMode: number;
  67769. /**
  67770. * Gets the loaded texture
  67771. */
  67772. texture: Texture;
  67773. /**
  67774. * Callback called when the task is successful
  67775. */
  67776. onSuccess: (task: TextureAssetTask) => void;
  67777. /**
  67778. * Callback called when the task is successful
  67779. */
  67780. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  67781. /**
  67782. * Creates a new TextureAssetTask object
  67783. * @param name defines the name of the task
  67784. * @param url defines the location of the file to load
  67785. * @param noMipmap defines if mipmap should not be generated (default is false)
  67786. * @param invertY defines if texture must be inverted on Y axis (default is false)
  67787. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67788. */
  67789. constructor(
  67790. /**
  67791. * Defines the name of the task
  67792. */
  67793. name: string,
  67794. /**
  67795. * Defines the location of the file to load
  67796. */
  67797. url: string,
  67798. /**
  67799. * Defines if mipmap should not be generated (default is false)
  67800. */
  67801. noMipmap?: boolean | undefined,
  67802. /**
  67803. * Defines if texture must be inverted on Y axis (default is false)
  67804. */
  67805. invertY?: boolean | undefined,
  67806. /**
  67807. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67808. */
  67809. samplingMode?: number);
  67810. /**
  67811. * Execute the current task
  67812. * @param scene defines the scene where you want your assets to be loaded
  67813. * @param onSuccess is a callback called when the task is successfully executed
  67814. * @param onError is a callback called if an error occurs
  67815. */
  67816. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67817. }
  67818. /**
  67819. * Define a task used by AssetsManager to load cube textures
  67820. */
  67821. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  67822. /**
  67823. * Defines the name of the task
  67824. */
  67825. name: string;
  67826. /**
  67827. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67828. */
  67829. url: string;
  67830. /**
  67831. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67832. */
  67833. extensions?: string[] | undefined;
  67834. /**
  67835. * Defines if mipmaps should not be generated (default is false)
  67836. */
  67837. noMipmap?: boolean | undefined;
  67838. /**
  67839. * Defines the explicit list of files (undefined by default)
  67840. */
  67841. files?: string[] | undefined;
  67842. /**
  67843. * Gets the loaded texture
  67844. */
  67845. texture: CubeTexture;
  67846. /**
  67847. * Callback called when the task is successful
  67848. */
  67849. onSuccess: (task: CubeTextureAssetTask) => void;
  67850. /**
  67851. * Callback called when the task is successful
  67852. */
  67853. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  67854. /**
  67855. * Creates a new CubeTextureAssetTask
  67856. * @param name defines the name of the task
  67857. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67858. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67859. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67860. * @param files defines the explicit list of files (undefined by default)
  67861. */
  67862. constructor(
  67863. /**
  67864. * Defines the name of the task
  67865. */
  67866. name: string,
  67867. /**
  67868. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67869. */
  67870. url: string,
  67871. /**
  67872. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67873. */
  67874. extensions?: string[] | undefined,
  67875. /**
  67876. * Defines if mipmaps should not be generated (default is false)
  67877. */
  67878. noMipmap?: boolean | undefined,
  67879. /**
  67880. * Defines the explicit list of files (undefined by default)
  67881. */
  67882. files?: string[] | undefined);
  67883. /**
  67884. * Execute the current task
  67885. * @param scene defines the scene where you want your assets to be loaded
  67886. * @param onSuccess is a callback called when the task is successfully executed
  67887. * @param onError is a callback called if an error occurs
  67888. */
  67889. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67890. }
  67891. /**
  67892. * Define a task used by AssetsManager to load HDR cube textures
  67893. */
  67894. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  67895. /**
  67896. * Defines the name of the task
  67897. */
  67898. name: string;
  67899. /**
  67900. * Defines the location of the file to load
  67901. */
  67902. url: string;
  67903. /**
  67904. * Defines the desired size (the more it increases the longer the generation will be)
  67905. */
  67906. size: number;
  67907. /**
  67908. * Defines if mipmaps should not be generated (default is false)
  67909. */
  67910. noMipmap: boolean;
  67911. /**
  67912. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67913. */
  67914. generateHarmonics: boolean;
  67915. /**
  67916. * 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)
  67917. */
  67918. gammaSpace: boolean;
  67919. /**
  67920. * Internal Use Only
  67921. */
  67922. reserved: boolean;
  67923. /**
  67924. * Gets the loaded texture
  67925. */
  67926. texture: HDRCubeTexture;
  67927. /**
  67928. * Callback called when the task is successful
  67929. */
  67930. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  67931. /**
  67932. * Callback called when the task is successful
  67933. */
  67934. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  67935. /**
  67936. * Creates a new HDRCubeTextureAssetTask object
  67937. * @param name defines the name of the task
  67938. * @param url defines the location of the file to load
  67939. * @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.
  67940. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67941. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67942. * @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)
  67943. * @param reserved Internal use only
  67944. */
  67945. constructor(
  67946. /**
  67947. * Defines the name of the task
  67948. */
  67949. name: string,
  67950. /**
  67951. * Defines the location of the file to load
  67952. */
  67953. url: string,
  67954. /**
  67955. * Defines the desired size (the more it increases the longer the generation will be)
  67956. */
  67957. size: number,
  67958. /**
  67959. * Defines if mipmaps should not be generated (default is false)
  67960. */
  67961. noMipmap?: boolean,
  67962. /**
  67963. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67964. */
  67965. generateHarmonics?: boolean,
  67966. /**
  67967. * 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)
  67968. */
  67969. gammaSpace?: boolean,
  67970. /**
  67971. * Internal Use Only
  67972. */
  67973. reserved?: boolean);
  67974. /**
  67975. * Execute the current task
  67976. * @param scene defines the scene where you want your assets to be loaded
  67977. * @param onSuccess is a callback called when the task is successfully executed
  67978. * @param onError is a callback called if an error occurs
  67979. */
  67980. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67981. }
  67982. /**
  67983. * Define a task used by AssetsManager to load Equirectangular cube textures
  67984. */
  67985. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  67986. /**
  67987. * Defines the name of the task
  67988. */
  67989. name: string;
  67990. /**
  67991. * Defines the location of the file to load
  67992. */
  67993. url: string;
  67994. /**
  67995. * Defines the desired size (the more it increases the longer the generation will be)
  67996. */
  67997. size: number;
  67998. /**
  67999. * Defines if mipmaps should not be generated (default is false)
  68000. */
  68001. noMipmap: boolean;
  68002. /**
  68003. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  68004. * but the standard material would require them in Gamma space) (default is true)
  68005. */
  68006. gammaSpace: boolean;
  68007. /**
  68008. * Gets the loaded texture
  68009. */
  68010. texture: EquiRectangularCubeTexture;
  68011. /**
  68012. * Callback called when the task is successful
  68013. */
  68014. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  68015. /**
  68016. * Callback called when the task is successful
  68017. */
  68018. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  68019. /**
  68020. * Creates a new EquiRectangularCubeTextureAssetTask object
  68021. * @param name defines the name of the task
  68022. * @param url defines the location of the file to load
  68023. * @param size defines the desired size (the more it increases the longer the generation will be)
  68024. * If the size is omitted this implies you are using a preprocessed cubemap.
  68025. * @param noMipmap defines if mipmaps should not be generated (default is false)
  68026. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  68027. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  68028. * (default is true)
  68029. */
  68030. constructor(
  68031. /**
  68032. * Defines the name of the task
  68033. */
  68034. name: string,
  68035. /**
  68036. * Defines the location of the file to load
  68037. */
  68038. url: string,
  68039. /**
  68040. * Defines the desired size (the more it increases the longer the generation will be)
  68041. */
  68042. size: number,
  68043. /**
  68044. * Defines if mipmaps should not be generated (default is false)
  68045. */
  68046. noMipmap?: boolean,
  68047. /**
  68048. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  68049. * but the standard material would require them in Gamma space) (default is true)
  68050. */
  68051. gammaSpace?: boolean);
  68052. /**
  68053. * Execute the current task
  68054. * @param scene defines the scene where you want your assets to be loaded
  68055. * @param onSuccess is a callback called when the task is successfully executed
  68056. * @param onError is a callback called if an error occurs
  68057. */
  68058. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68059. }
  68060. /**
  68061. * This class can be used to easily import assets into a scene
  68062. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  68063. */
  68064. export class AssetsManager {
  68065. private _scene;
  68066. private _isLoading;
  68067. protected _tasks: AbstractAssetTask[];
  68068. protected _waitingTasksCount: number;
  68069. protected _totalTasksCount: number;
  68070. /**
  68071. * Callback called when all tasks are processed
  68072. */
  68073. onFinish: (tasks: AbstractAssetTask[]) => void;
  68074. /**
  68075. * Callback called when a task is successful
  68076. */
  68077. onTaskSuccess: (task: AbstractAssetTask) => void;
  68078. /**
  68079. * Callback called when a task had an error
  68080. */
  68081. onTaskError: (task: AbstractAssetTask) => void;
  68082. /**
  68083. * Callback called when a task is done (whatever the result is)
  68084. */
  68085. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  68086. /**
  68087. * Observable called when all tasks are processed
  68088. */
  68089. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  68090. /**
  68091. * Observable called when a task had an error
  68092. */
  68093. onTaskErrorObservable: Observable<AbstractAssetTask>;
  68094. /**
  68095. * Observable called when all tasks were executed
  68096. */
  68097. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  68098. /**
  68099. * Observable called when a task is done (whatever the result is)
  68100. */
  68101. onProgressObservable: Observable<IAssetsProgressEvent>;
  68102. /**
  68103. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  68104. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  68105. */
  68106. useDefaultLoadingScreen: boolean;
  68107. /**
  68108. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  68109. * when all assets have been downloaded.
  68110. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  68111. */
  68112. autoHideLoadingUI: boolean;
  68113. /**
  68114. * Creates a new AssetsManager
  68115. * @param scene defines the scene to work on
  68116. */
  68117. constructor(scene: Scene);
  68118. /**
  68119. * Add a MeshAssetTask to the list of active tasks
  68120. * @param taskName defines the name of the new task
  68121. * @param meshesNames defines the name of meshes to load
  68122. * @param rootUrl defines the root url to use to locate files
  68123. * @param sceneFilename defines the filename of the scene file
  68124. * @returns a new MeshAssetTask object
  68125. */
  68126. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  68127. /**
  68128. * Add a TextFileAssetTask to the list of active tasks
  68129. * @param taskName defines the name of the new task
  68130. * @param url defines the url of the file to load
  68131. * @returns a new TextFileAssetTask object
  68132. */
  68133. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  68134. /**
  68135. * Add a BinaryFileAssetTask to the list of active tasks
  68136. * @param taskName defines the name of the new task
  68137. * @param url defines the url of the file to load
  68138. * @returns a new BinaryFileAssetTask object
  68139. */
  68140. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  68141. /**
  68142. * Add a ImageAssetTask to the list of active tasks
  68143. * @param taskName defines the name of the new task
  68144. * @param url defines the url of the file to load
  68145. * @returns a new ImageAssetTask object
  68146. */
  68147. addImageTask(taskName: string, url: string): ImageAssetTask;
  68148. /**
  68149. * Add a TextureAssetTask to the list of active tasks
  68150. * @param taskName defines the name of the new task
  68151. * @param url defines the url of the file to load
  68152. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68153. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  68154. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  68155. * @returns a new TextureAssetTask object
  68156. */
  68157. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  68158. /**
  68159. * Add a CubeTextureAssetTask to the list of active tasks
  68160. * @param taskName defines the name of the new task
  68161. * @param url defines the url of the file to load
  68162. * @param extensions defines the extension to use to load the cube map (can be null)
  68163. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68164. * @param files defines the list of files to load (can be null)
  68165. * @returns a new CubeTextureAssetTask object
  68166. */
  68167. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  68168. /**
  68169. *
  68170. * Add a HDRCubeTextureAssetTask to the list of active tasks
  68171. * @param taskName defines the name of the new task
  68172. * @param url defines the url of the file to load
  68173. * @param size defines the size you want for the cubemap (can be null)
  68174. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68175. * @param generateHarmonics defines if you want to automatically generate (true by default)
  68176. * @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)
  68177. * @param reserved Internal use only
  68178. * @returns a new HDRCubeTextureAssetTask object
  68179. */
  68180. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  68181. /**
  68182. *
  68183. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  68184. * @param taskName defines the name of the new task
  68185. * @param url defines the url of the file to load
  68186. * @param size defines the size you want for the cubemap (can be null)
  68187. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68188. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  68189. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  68190. * @returns a new EquiRectangularCubeTextureAssetTask object
  68191. */
  68192. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  68193. /**
  68194. * Remove a task from the assets manager.
  68195. * @param task the task to remove
  68196. */
  68197. removeTask(task: AbstractAssetTask): void;
  68198. private _decreaseWaitingTasksCount;
  68199. private _runTask;
  68200. /**
  68201. * Reset the AssetsManager and remove all tasks
  68202. * @return the current instance of the AssetsManager
  68203. */
  68204. reset(): AssetsManager;
  68205. /**
  68206. * Start the loading process
  68207. * @return the current instance of the AssetsManager
  68208. */
  68209. load(): AssetsManager;
  68210. /**
  68211. * Start the loading process as an async operation
  68212. * @return a promise returning the list of failed tasks
  68213. */
  68214. loadAsync(): Promise<void>;
  68215. }
  68216. }
  68217. declare module "babylonjs/Misc/deferred" {
  68218. /**
  68219. * Wrapper class for promise with external resolve and reject.
  68220. */
  68221. export class Deferred<T> {
  68222. /**
  68223. * The promise associated with this deferred object.
  68224. */
  68225. readonly promise: Promise<T>;
  68226. private _resolve;
  68227. private _reject;
  68228. /**
  68229. * The resolve method of the promise associated with this deferred object.
  68230. */
  68231. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  68232. /**
  68233. * The reject method of the promise associated with this deferred object.
  68234. */
  68235. readonly reject: (reason?: any) => void;
  68236. /**
  68237. * Constructor for this deferred object.
  68238. */
  68239. constructor();
  68240. }
  68241. }
  68242. declare module "babylonjs/Misc/meshExploder" {
  68243. import { Mesh } from "babylonjs/Meshes/mesh";
  68244. /**
  68245. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  68246. */
  68247. export class MeshExploder {
  68248. private _centerMesh;
  68249. private _meshes;
  68250. private _meshesOrigins;
  68251. private _toCenterVectors;
  68252. private _scaledDirection;
  68253. private _newPosition;
  68254. private _centerPosition;
  68255. /**
  68256. * Explodes meshes from a center mesh.
  68257. * @param meshes The meshes to explode.
  68258. * @param centerMesh The mesh to be center of explosion.
  68259. */
  68260. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  68261. private _setCenterMesh;
  68262. /**
  68263. * Get class name
  68264. * @returns "MeshExploder"
  68265. */
  68266. getClassName(): string;
  68267. /**
  68268. * "Exploded meshes"
  68269. * @returns Array of meshes with the centerMesh at index 0.
  68270. */
  68271. getMeshes(): Array<Mesh>;
  68272. /**
  68273. * Explodes meshes giving a specific direction
  68274. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  68275. */
  68276. explode(direction?: number): void;
  68277. }
  68278. }
  68279. declare module "babylonjs/Misc/filesInput" {
  68280. import { Engine } from "babylonjs/Engines/engine";
  68281. import { Scene } from "babylonjs/scene";
  68282. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  68283. /**
  68284. * Class used to help managing file picking and drag'n'drop
  68285. */
  68286. export class FilesInput {
  68287. /**
  68288. * List of files ready to be loaded
  68289. */
  68290. static readonly FilesToLoad: {
  68291. [key: string]: File;
  68292. };
  68293. /**
  68294. * Callback called when a file is processed
  68295. */
  68296. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  68297. private _engine;
  68298. private _currentScene;
  68299. private _sceneLoadedCallback;
  68300. private _progressCallback;
  68301. private _additionalRenderLoopLogicCallback;
  68302. private _textureLoadingCallback;
  68303. private _startingProcessingFilesCallback;
  68304. private _onReloadCallback;
  68305. private _errorCallback;
  68306. private _elementToMonitor;
  68307. private _sceneFileToLoad;
  68308. private _filesToLoad;
  68309. /**
  68310. * Creates a new FilesInput
  68311. * @param engine defines the rendering engine
  68312. * @param scene defines the hosting scene
  68313. * @param sceneLoadedCallback callback called when scene is loaded
  68314. * @param progressCallback callback called to track progress
  68315. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  68316. * @param textureLoadingCallback callback called when a texture is loading
  68317. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  68318. * @param onReloadCallback callback called when a reload is requested
  68319. * @param errorCallback callback call if an error occurs
  68320. */
  68321. 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);
  68322. private _dragEnterHandler;
  68323. private _dragOverHandler;
  68324. private _dropHandler;
  68325. /**
  68326. * Calls this function to listen to drag'n'drop events on a specific DOM element
  68327. * @param elementToMonitor defines the DOM element to track
  68328. */
  68329. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  68330. /**
  68331. * Release all associated resources
  68332. */
  68333. dispose(): void;
  68334. private renderFunction;
  68335. private drag;
  68336. private drop;
  68337. private _traverseFolder;
  68338. private _processFiles;
  68339. /**
  68340. * Load files from a drop event
  68341. * @param event defines the drop event to use as source
  68342. */
  68343. loadFiles(event: any): void;
  68344. private _processReload;
  68345. /**
  68346. * Reload the current scene from the loaded files
  68347. */
  68348. reload(): void;
  68349. }
  68350. }
  68351. declare module "babylonjs/Misc/HighDynamicRange/index" {
  68352. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  68353. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  68354. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  68355. }
  68356. declare module "babylonjs/Misc/sceneOptimizer" {
  68357. import { Scene, IDisposable } from "babylonjs/scene";
  68358. import { Observable } from "babylonjs/Misc/observable";
  68359. /**
  68360. * Defines the root class used to create scene optimization to use with SceneOptimizer
  68361. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68362. */
  68363. export class SceneOptimization {
  68364. /**
  68365. * Defines the priority of this optimization (0 by default which means first in the list)
  68366. */
  68367. priority: number;
  68368. /**
  68369. * Gets a string describing the action executed by the current optimization
  68370. * @returns description string
  68371. */
  68372. getDescription(): string;
  68373. /**
  68374. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68375. * @param scene defines the current scene where to apply this optimization
  68376. * @param optimizer defines the current optimizer
  68377. * @returns true if everything that can be done was applied
  68378. */
  68379. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68380. /**
  68381. * Creates the SceneOptimization object
  68382. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68383. * @param desc defines the description associated with the optimization
  68384. */
  68385. constructor(
  68386. /**
  68387. * Defines the priority of this optimization (0 by default which means first in the list)
  68388. */
  68389. priority?: number);
  68390. }
  68391. /**
  68392. * Defines an optimization used to reduce the size of render target textures
  68393. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68394. */
  68395. export class TextureOptimization extends SceneOptimization {
  68396. /**
  68397. * Defines the priority of this optimization (0 by default which means first in the list)
  68398. */
  68399. priority: number;
  68400. /**
  68401. * 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
  68402. */
  68403. maximumSize: number;
  68404. /**
  68405. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68406. */
  68407. step: number;
  68408. /**
  68409. * Gets a string describing the action executed by the current optimization
  68410. * @returns description string
  68411. */
  68412. getDescription(): string;
  68413. /**
  68414. * Creates the TextureOptimization object
  68415. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68416. * @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
  68417. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68418. */
  68419. constructor(
  68420. /**
  68421. * Defines the priority of this optimization (0 by default which means first in the list)
  68422. */
  68423. priority?: number,
  68424. /**
  68425. * 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
  68426. */
  68427. maximumSize?: number,
  68428. /**
  68429. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68430. */
  68431. step?: number);
  68432. /**
  68433. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68434. * @param scene defines the current scene where to apply this optimization
  68435. * @param optimizer defines the current optimizer
  68436. * @returns true if everything that can be done was applied
  68437. */
  68438. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68439. }
  68440. /**
  68441. * Defines an optimization used to increase or decrease the rendering resolution
  68442. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68443. */
  68444. export class HardwareScalingOptimization extends SceneOptimization {
  68445. /**
  68446. * Defines the priority of this optimization (0 by default which means first in the list)
  68447. */
  68448. priority: number;
  68449. /**
  68450. * Defines the maximum scale to use (2 by default)
  68451. */
  68452. maximumScale: number;
  68453. /**
  68454. * Defines the step to use between two passes (0.5 by default)
  68455. */
  68456. step: number;
  68457. private _currentScale;
  68458. private _directionOffset;
  68459. /**
  68460. * Gets a string describing the action executed by the current optimization
  68461. * @return description string
  68462. */
  68463. getDescription(): string;
  68464. /**
  68465. * Creates the HardwareScalingOptimization object
  68466. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68467. * @param maximumScale defines the maximum scale to use (2 by default)
  68468. * @param step defines the step to use between two passes (0.5 by default)
  68469. */
  68470. constructor(
  68471. /**
  68472. * Defines the priority of this optimization (0 by default which means first in the list)
  68473. */
  68474. priority?: number,
  68475. /**
  68476. * Defines the maximum scale to use (2 by default)
  68477. */
  68478. maximumScale?: number,
  68479. /**
  68480. * Defines the step to use between two passes (0.5 by default)
  68481. */
  68482. step?: number);
  68483. /**
  68484. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68485. * @param scene defines the current scene where to apply this optimization
  68486. * @param optimizer defines the current optimizer
  68487. * @returns true if everything that can be done was applied
  68488. */
  68489. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68490. }
  68491. /**
  68492. * Defines an optimization used to remove shadows
  68493. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68494. */
  68495. export class ShadowsOptimization extends SceneOptimization {
  68496. /**
  68497. * Gets a string describing the action executed by the current optimization
  68498. * @return description string
  68499. */
  68500. getDescription(): string;
  68501. /**
  68502. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68503. * @param scene defines the current scene where to apply this optimization
  68504. * @param optimizer defines the current optimizer
  68505. * @returns true if everything that can be done was applied
  68506. */
  68507. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68508. }
  68509. /**
  68510. * Defines an optimization used to turn post-processes off
  68511. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68512. */
  68513. export class PostProcessesOptimization extends SceneOptimization {
  68514. /**
  68515. * Gets a string describing the action executed by the current optimization
  68516. * @return description string
  68517. */
  68518. getDescription(): string;
  68519. /**
  68520. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68521. * @param scene defines the current scene where to apply this optimization
  68522. * @param optimizer defines the current optimizer
  68523. * @returns true if everything that can be done was applied
  68524. */
  68525. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68526. }
  68527. /**
  68528. * Defines an optimization used to turn lens flares off
  68529. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68530. */
  68531. export class LensFlaresOptimization extends SceneOptimization {
  68532. /**
  68533. * Gets a string describing the action executed by the current optimization
  68534. * @return description string
  68535. */
  68536. getDescription(): string;
  68537. /**
  68538. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68539. * @param scene defines the current scene where to apply this optimization
  68540. * @param optimizer defines the current optimizer
  68541. * @returns true if everything that can be done was applied
  68542. */
  68543. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68544. }
  68545. /**
  68546. * Defines an optimization based on user defined callback.
  68547. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68548. */
  68549. export class CustomOptimization extends SceneOptimization {
  68550. /**
  68551. * Callback called to apply the custom optimization.
  68552. */
  68553. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  68554. /**
  68555. * Callback called to get custom description
  68556. */
  68557. onGetDescription: () => string;
  68558. /**
  68559. * Gets a string describing the action executed by the current optimization
  68560. * @returns description string
  68561. */
  68562. getDescription(): string;
  68563. /**
  68564. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68565. * @param scene defines the current scene where to apply this optimization
  68566. * @param optimizer defines the current optimizer
  68567. * @returns true if everything that can be done was applied
  68568. */
  68569. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68570. }
  68571. /**
  68572. * Defines an optimization used to turn particles off
  68573. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68574. */
  68575. export class ParticlesOptimization extends SceneOptimization {
  68576. /**
  68577. * Gets a string describing the action executed by the current optimization
  68578. * @return description string
  68579. */
  68580. getDescription(): string;
  68581. /**
  68582. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68583. * @param scene defines the current scene where to apply this optimization
  68584. * @param optimizer defines the current optimizer
  68585. * @returns true if everything that can be done was applied
  68586. */
  68587. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68588. }
  68589. /**
  68590. * Defines an optimization used to turn render targets off
  68591. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68592. */
  68593. export class RenderTargetsOptimization extends SceneOptimization {
  68594. /**
  68595. * Gets a string describing the action executed by the current optimization
  68596. * @return description string
  68597. */
  68598. getDescription(): string;
  68599. /**
  68600. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68601. * @param scene defines the current scene where to apply this optimization
  68602. * @param optimizer defines the current optimizer
  68603. * @returns true if everything that can be done was applied
  68604. */
  68605. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68606. }
  68607. /**
  68608. * Defines an optimization used to merge meshes with compatible materials
  68609. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68610. */
  68611. export class MergeMeshesOptimization extends SceneOptimization {
  68612. private static _UpdateSelectionTree;
  68613. /**
  68614. * Gets or sets a boolean which defines if optimization octree has to be updated
  68615. */
  68616. /**
  68617. * Gets or sets a boolean which defines if optimization octree has to be updated
  68618. */
  68619. static UpdateSelectionTree: boolean;
  68620. /**
  68621. * Gets a string describing the action executed by the current optimization
  68622. * @return description string
  68623. */
  68624. getDescription(): string;
  68625. private _canBeMerged;
  68626. /**
  68627. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68628. * @param scene defines the current scene where to apply this optimization
  68629. * @param optimizer defines the current optimizer
  68630. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  68631. * @returns true if everything that can be done was applied
  68632. */
  68633. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  68634. }
  68635. /**
  68636. * Defines a list of options used by SceneOptimizer
  68637. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68638. */
  68639. export class SceneOptimizerOptions {
  68640. /**
  68641. * Defines the target frame rate to reach (60 by default)
  68642. */
  68643. targetFrameRate: number;
  68644. /**
  68645. * Defines the interval between two checkes (2000ms by default)
  68646. */
  68647. trackerDuration: number;
  68648. /**
  68649. * Gets the list of optimizations to apply
  68650. */
  68651. optimizations: SceneOptimization[];
  68652. /**
  68653. * Creates a new list of options used by SceneOptimizer
  68654. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  68655. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  68656. */
  68657. constructor(
  68658. /**
  68659. * Defines the target frame rate to reach (60 by default)
  68660. */
  68661. targetFrameRate?: number,
  68662. /**
  68663. * Defines the interval between two checkes (2000ms by default)
  68664. */
  68665. trackerDuration?: number);
  68666. /**
  68667. * Add a new optimization
  68668. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  68669. * @returns the current SceneOptimizerOptions
  68670. */
  68671. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  68672. /**
  68673. * Add a new custom optimization
  68674. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  68675. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  68676. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68677. * @returns the current SceneOptimizerOptions
  68678. */
  68679. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  68680. /**
  68681. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  68682. * @param targetFrameRate defines the target frame rate (60 by default)
  68683. * @returns a SceneOptimizerOptions object
  68684. */
  68685. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68686. /**
  68687. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  68688. * @param targetFrameRate defines the target frame rate (60 by default)
  68689. * @returns a SceneOptimizerOptions object
  68690. */
  68691. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68692. /**
  68693. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  68694. * @param targetFrameRate defines the target frame rate (60 by default)
  68695. * @returns a SceneOptimizerOptions object
  68696. */
  68697. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68698. }
  68699. /**
  68700. * Class used to run optimizations in order to reach a target frame rate
  68701. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68702. */
  68703. export class SceneOptimizer implements IDisposable {
  68704. private _isRunning;
  68705. private _options;
  68706. private _scene;
  68707. private _currentPriorityLevel;
  68708. private _targetFrameRate;
  68709. private _trackerDuration;
  68710. private _currentFrameRate;
  68711. private _sceneDisposeObserver;
  68712. private _improvementMode;
  68713. /**
  68714. * Defines an observable called when the optimizer reaches the target frame rate
  68715. */
  68716. onSuccessObservable: Observable<SceneOptimizer>;
  68717. /**
  68718. * Defines an observable called when the optimizer enables an optimization
  68719. */
  68720. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  68721. /**
  68722. * Defines an observable called when the optimizer is not able to reach the target frame rate
  68723. */
  68724. onFailureObservable: Observable<SceneOptimizer>;
  68725. /**
  68726. * Gets a boolean indicating if the optimizer is in improvement mode
  68727. */
  68728. readonly isInImprovementMode: boolean;
  68729. /**
  68730. * Gets the current priority level (0 at start)
  68731. */
  68732. readonly currentPriorityLevel: number;
  68733. /**
  68734. * Gets the current frame rate checked by the SceneOptimizer
  68735. */
  68736. readonly currentFrameRate: number;
  68737. /**
  68738. * Gets or sets the current target frame rate (60 by default)
  68739. */
  68740. /**
  68741. * Gets or sets the current target frame rate (60 by default)
  68742. */
  68743. targetFrameRate: number;
  68744. /**
  68745. * Gets or sets the current interval between two checks (every 2000ms by default)
  68746. */
  68747. /**
  68748. * Gets or sets the current interval between two checks (every 2000ms by default)
  68749. */
  68750. trackerDuration: number;
  68751. /**
  68752. * Gets the list of active optimizations
  68753. */
  68754. readonly optimizations: SceneOptimization[];
  68755. /**
  68756. * Creates a new SceneOptimizer
  68757. * @param scene defines the scene to work on
  68758. * @param options defines the options to use with the SceneOptimizer
  68759. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  68760. * @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)
  68761. */
  68762. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  68763. /**
  68764. * Stops the current optimizer
  68765. */
  68766. stop(): void;
  68767. /**
  68768. * Reset the optimizer to initial step (current priority level = 0)
  68769. */
  68770. reset(): void;
  68771. /**
  68772. * Start the optimizer. By default it will try to reach a specific framerate
  68773. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  68774. */
  68775. start(): void;
  68776. private _checkCurrentState;
  68777. /**
  68778. * Release all resources
  68779. */
  68780. dispose(): void;
  68781. /**
  68782. * Helper function to create a SceneOptimizer with one single line of code
  68783. * @param scene defines the scene to work on
  68784. * @param options defines the options to use with the SceneOptimizer
  68785. * @param onSuccess defines a callback to call on success
  68786. * @param onFailure defines a callback to call on failure
  68787. * @returns the new SceneOptimizer object
  68788. */
  68789. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  68790. }
  68791. }
  68792. declare module "babylonjs/Misc/sceneSerializer" {
  68793. import { Scene } from "babylonjs/scene";
  68794. /**
  68795. * Class used to serialize a scene into a string
  68796. */
  68797. export class SceneSerializer {
  68798. /**
  68799. * Clear cache used by a previous serialization
  68800. */
  68801. static ClearCache(): void;
  68802. /**
  68803. * Serialize a scene into a JSON compatible object
  68804. * @param scene defines the scene to serialize
  68805. * @returns a JSON compatible object
  68806. */
  68807. static Serialize(scene: Scene): any;
  68808. /**
  68809. * Serialize a mesh into a JSON compatible object
  68810. * @param toSerialize defines the mesh to serialize
  68811. * @param withParents defines if parents must be serialized as well
  68812. * @param withChildren defines if children must be serialized as well
  68813. * @returns a JSON compatible object
  68814. */
  68815. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  68816. }
  68817. }
  68818. declare module "babylonjs/Misc/textureTools" {
  68819. import { Texture } from "babylonjs/Materials/Textures/texture";
  68820. /**
  68821. * Class used to host texture specific utilities
  68822. */
  68823. export class TextureTools {
  68824. /**
  68825. * Uses the GPU to create a copy texture rescaled at a given size
  68826. * @param texture Texture to copy from
  68827. * @param width defines the desired width
  68828. * @param height defines the desired height
  68829. * @param useBilinearMode defines if bilinear mode has to be used
  68830. * @return the generated texture
  68831. */
  68832. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  68833. }
  68834. }
  68835. declare module "babylonjs/Misc/videoRecorder" {
  68836. import { Nullable } from "babylonjs/types";
  68837. import { Engine } from "babylonjs/Engines/engine";
  68838. /**
  68839. * This represents the different options available for the video capture.
  68840. */
  68841. export interface VideoRecorderOptions {
  68842. /** Defines the mime type of the video. */
  68843. mimeType: string;
  68844. /** Defines the FPS the video should be recorded at. */
  68845. fps: number;
  68846. /** Defines the chunk size for the recording data. */
  68847. recordChunckSize: number;
  68848. /** The audio tracks to attach to the recording. */
  68849. audioTracks?: MediaStreamTrack[];
  68850. }
  68851. /**
  68852. * This can help with recording videos from BabylonJS.
  68853. * This is based on the available WebRTC functionalities of the browser.
  68854. *
  68855. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  68856. */
  68857. export class VideoRecorder {
  68858. private static readonly _defaultOptions;
  68859. /**
  68860. * Returns whether or not the VideoRecorder is available in your browser.
  68861. * @param engine Defines the Babylon Engine.
  68862. * @returns true if supported otherwise false.
  68863. */
  68864. static IsSupported(engine: Engine): boolean;
  68865. private readonly _options;
  68866. private _canvas;
  68867. private _mediaRecorder;
  68868. private _recordedChunks;
  68869. private _fileName;
  68870. private _resolve;
  68871. private _reject;
  68872. /**
  68873. * True when a recording is already in progress.
  68874. */
  68875. readonly isRecording: boolean;
  68876. /**
  68877. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  68878. * @param engine Defines the BabylonJS Engine you wish to record.
  68879. * @param options Defines options that can be used to customize the capture.
  68880. */
  68881. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  68882. /**
  68883. * Stops the current recording before the default capture timeout passed in the startRecording function.
  68884. */
  68885. stopRecording(): void;
  68886. /**
  68887. * Starts recording the canvas for a max duration specified in parameters.
  68888. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  68889. * If null no automatic download will start and you can rely on the promise to get the data back.
  68890. * @param maxDuration Defines the maximum recording time in seconds.
  68891. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  68892. * @return A promise callback at the end of the recording with the video data in Blob.
  68893. */
  68894. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  68895. /**
  68896. * Releases internal resources used during the recording.
  68897. */
  68898. dispose(): void;
  68899. private _handleDataAvailable;
  68900. private _handleError;
  68901. private _handleStop;
  68902. }
  68903. }
  68904. declare module "babylonjs/Misc/screenshotTools" {
  68905. import { Camera } from "babylonjs/Cameras/camera";
  68906. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  68907. import { Engine } from "babylonjs/Engines/engine";
  68908. /**
  68909. * Class containing a set of static utilities functions for screenshots
  68910. */
  68911. export class ScreenshotTools {
  68912. /**
  68913. * Captures a screenshot of the current rendering
  68914. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68915. * @param engine defines the rendering engine
  68916. * @param camera defines the source camera
  68917. * @param size This parameter can be set to a single number or to an object with the
  68918. * following (optional) properties: precision, width, height. If a single number is passed,
  68919. * it will be used for both width and height. If an object is passed, the screenshot size
  68920. * will be derived from the parameters. The precision property is a multiplier allowing
  68921. * rendering at a higher or lower resolution
  68922. * @param successCallback defines the callback receives a single parameter which contains the
  68923. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  68924. * src parameter of an <img> to display it
  68925. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  68926. * Check your browser for supported MIME types
  68927. */
  68928. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  68929. /**
  68930. * Captures a screenshot of the current rendering
  68931. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68932. * @param engine defines the rendering engine
  68933. * @param camera defines the source camera
  68934. * @param size This parameter can be set to a single number or to an object with the
  68935. * following (optional) properties: precision, width, height. If a single number is passed,
  68936. * it will be used for both width and height. If an object is passed, the screenshot size
  68937. * will be derived from the parameters. The precision property is a multiplier allowing
  68938. * rendering at a higher or lower resolution
  68939. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  68940. * Check your browser for supported MIME types
  68941. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  68942. * to the src parameter of an <img> to display it
  68943. */
  68944. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  68945. /**
  68946. * Generates an image screenshot from the specified camera.
  68947. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68948. * @param engine The engine to use for rendering
  68949. * @param camera The camera to use for rendering
  68950. * @param size This parameter can be set to a single number or to an object with the
  68951. * following (optional) properties: precision, width, height. If a single number is passed,
  68952. * it will be used for both width and height. If an object is passed, the screenshot size
  68953. * will be derived from the parameters. The precision property is a multiplier allowing
  68954. * rendering at a higher or lower resolution
  68955. * @param successCallback The callback receives a single parameter which contains the
  68956. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  68957. * src parameter of an <img> to display it
  68958. * @param mimeType The MIME type of the screenshot image (default: image/png).
  68959. * Check your browser for supported MIME types
  68960. * @param samples Texture samples (default: 1)
  68961. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  68962. * @param fileName A name for for the downloaded file.
  68963. */
  68964. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  68965. /**
  68966. * Generates an image screenshot from the specified camera.
  68967. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68968. * @param engine The engine to use for rendering
  68969. * @param camera The camera to use for rendering
  68970. * @param size This parameter can be set to a single number or to an object with the
  68971. * following (optional) properties: precision, width, height. If a single number is passed,
  68972. * it will be used for both width and height. If an object is passed, the screenshot size
  68973. * will be derived from the parameters. The precision property is a multiplier allowing
  68974. * rendering at a higher or lower resolution
  68975. * @param mimeType The MIME type of the screenshot image (default: image/png).
  68976. * Check your browser for supported MIME types
  68977. * @param samples Texture samples (default: 1)
  68978. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  68979. * @param fileName A name for for the downloaded file.
  68980. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  68981. * to the src parameter of an <img> to display it
  68982. */
  68983. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  68984. /**
  68985. * Gets height and width for screenshot size
  68986. * @private
  68987. */
  68988. private static _getScreenshotSize;
  68989. }
  68990. }
  68991. declare module "babylonjs/Misc/dataReader" {
  68992. /**
  68993. * Interface for a data buffer
  68994. */
  68995. export interface IDataBuffer {
  68996. /**
  68997. * Reads bytes from the data buffer.
  68998. * @param byteOffset The byte offset to read
  68999. * @param byteLength The byte length to read
  69000. * @returns A promise that resolves when the bytes are read
  69001. */
  69002. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  69003. /**
  69004. * The byte length of the buffer.
  69005. */
  69006. readonly byteLength: number;
  69007. }
  69008. /**
  69009. * Utility class for reading from a data buffer
  69010. */
  69011. export class DataReader {
  69012. /**
  69013. * The data buffer associated with this data reader.
  69014. */
  69015. readonly buffer: IDataBuffer;
  69016. /**
  69017. * The current byte offset from the beginning of the data buffer.
  69018. */
  69019. byteOffset: number;
  69020. private _dataView;
  69021. private _dataByteOffset;
  69022. /**
  69023. * Constructor
  69024. * @param buffer The buffer to read
  69025. */
  69026. constructor(buffer: IDataBuffer);
  69027. /**
  69028. * Loads the given byte length.
  69029. * @param byteLength The byte length to load
  69030. * @returns A promise that resolves when the load is complete
  69031. */
  69032. loadAsync(byteLength: number): Promise<void>;
  69033. /**
  69034. * Read a unsigned 32-bit integer from the currently loaded data range.
  69035. * @returns The 32-bit integer read
  69036. */
  69037. readUint32(): number;
  69038. /**
  69039. * Read a byte array from the currently loaded data range.
  69040. * @param byteLength The byte length to read
  69041. * @returns The byte array read
  69042. */
  69043. readUint8Array(byteLength: number): Uint8Array;
  69044. /**
  69045. * Read a string from the currently loaded data range.
  69046. * @param byteLength The byte length to read
  69047. * @returns The string read
  69048. */
  69049. readString(byteLength: number): string;
  69050. /**
  69051. * Skips the given byte length the currently loaded data range.
  69052. * @param byteLength The byte length to skip
  69053. */
  69054. skipBytes(byteLength: number): void;
  69055. }
  69056. }
  69057. declare module "babylonjs/Misc/index" {
  69058. export * from "babylonjs/Misc/andOrNotEvaluator";
  69059. export * from "babylonjs/Misc/assetsManager";
  69060. export * from "babylonjs/Misc/basis";
  69061. export * from "babylonjs/Misc/dds";
  69062. export * from "babylonjs/Misc/decorators";
  69063. export * from "babylonjs/Misc/deferred";
  69064. export * from "babylonjs/Misc/environmentTextureTools";
  69065. export * from "babylonjs/Misc/meshExploder";
  69066. export * from "babylonjs/Misc/filesInput";
  69067. export * from "babylonjs/Misc/HighDynamicRange/index";
  69068. export * from "babylonjs/Misc/khronosTextureContainer";
  69069. export * from "babylonjs/Misc/observable";
  69070. export * from "babylonjs/Misc/performanceMonitor";
  69071. export * from "babylonjs/Misc/promise";
  69072. export * from "babylonjs/Misc/sceneOptimizer";
  69073. export * from "babylonjs/Misc/sceneSerializer";
  69074. export * from "babylonjs/Misc/smartArray";
  69075. export * from "babylonjs/Misc/stringDictionary";
  69076. export * from "babylonjs/Misc/tags";
  69077. export * from "babylonjs/Misc/textureTools";
  69078. export * from "babylonjs/Misc/tga";
  69079. export * from "babylonjs/Misc/tools";
  69080. export * from "babylonjs/Misc/videoRecorder";
  69081. export * from "babylonjs/Misc/virtualJoystick";
  69082. export * from "babylonjs/Misc/workerPool";
  69083. export * from "babylonjs/Misc/logger";
  69084. export * from "babylonjs/Misc/typeStore";
  69085. export * from "babylonjs/Misc/filesInputStore";
  69086. export * from "babylonjs/Misc/deepCopier";
  69087. export * from "babylonjs/Misc/pivotTools";
  69088. export * from "babylonjs/Misc/precisionDate";
  69089. export * from "babylonjs/Misc/screenshotTools";
  69090. export * from "babylonjs/Misc/typeStore";
  69091. export * from "babylonjs/Misc/webRequest";
  69092. export * from "babylonjs/Misc/iInspectable";
  69093. export * from "babylonjs/Misc/brdfTextureTools";
  69094. export * from "babylonjs/Misc/rgbdTextureTools";
  69095. export * from "babylonjs/Misc/gradients";
  69096. export * from "babylonjs/Misc/perfCounter";
  69097. export * from "babylonjs/Misc/fileRequest";
  69098. export * from "babylonjs/Misc/customAnimationFrameRequester";
  69099. export * from "babylonjs/Misc/retryStrategy";
  69100. export * from "babylonjs/Misc/interfaces/screenshotSize";
  69101. export * from "babylonjs/Misc/canvasGenerator";
  69102. export * from "babylonjs/Misc/fileTools";
  69103. export * from "babylonjs/Misc/stringTools";
  69104. export * from "babylonjs/Misc/dataReader";
  69105. }
  69106. declare module "babylonjs/index" {
  69107. export * from "babylonjs/abstractScene";
  69108. export * from "babylonjs/Actions/index";
  69109. export * from "babylonjs/Animations/index";
  69110. export * from "babylonjs/assetContainer";
  69111. export * from "babylonjs/Audio/index";
  69112. export * from "babylonjs/Behaviors/index";
  69113. export * from "babylonjs/Bones/index";
  69114. export * from "babylonjs/Cameras/index";
  69115. export * from "babylonjs/Collisions/index";
  69116. export * from "babylonjs/Culling/index";
  69117. export * from "babylonjs/Debug/index";
  69118. export * from "babylonjs/Engines/index";
  69119. export * from "babylonjs/Events/index";
  69120. export * from "babylonjs/Gamepads/index";
  69121. export * from "babylonjs/Gizmos/index";
  69122. export * from "babylonjs/Helpers/index";
  69123. export * from "babylonjs/Instrumentation/index";
  69124. export * from "babylonjs/Layers/index";
  69125. export * from "babylonjs/LensFlares/index";
  69126. export * from "babylonjs/Lights/index";
  69127. export * from "babylonjs/Loading/index";
  69128. export * from "babylonjs/Materials/index";
  69129. export * from "babylonjs/Maths/index";
  69130. export * from "babylonjs/Meshes/index";
  69131. export * from "babylonjs/Morph/index";
  69132. export * from "babylonjs/Navigation/index";
  69133. export * from "babylonjs/node";
  69134. export * from "babylonjs/Offline/index";
  69135. export * from "babylonjs/Particles/index";
  69136. export * from "babylonjs/Physics/index";
  69137. export * from "babylonjs/PostProcesses/index";
  69138. export * from "babylonjs/Probes/index";
  69139. export * from "babylonjs/Rendering/index";
  69140. export * from "babylonjs/scene";
  69141. export * from "babylonjs/sceneComponent";
  69142. export * from "babylonjs/Sprites/index";
  69143. export * from "babylonjs/States/index";
  69144. export * from "babylonjs/Misc/index";
  69145. export * from "babylonjs/types";
  69146. }
  69147. declare module "babylonjs/Animations/pathCursor" {
  69148. import { Vector3 } from "babylonjs/Maths/math.vector";
  69149. import { Path2 } from "babylonjs/Maths/math.path";
  69150. /**
  69151. * A cursor which tracks a point on a path
  69152. */
  69153. export class PathCursor {
  69154. private path;
  69155. /**
  69156. * Stores path cursor callbacks for when an onchange event is triggered
  69157. */
  69158. private _onchange;
  69159. /**
  69160. * The value of the path cursor
  69161. */
  69162. value: number;
  69163. /**
  69164. * The animation array of the path cursor
  69165. */
  69166. animations: Animation[];
  69167. /**
  69168. * Initializes the path cursor
  69169. * @param path The path to track
  69170. */
  69171. constructor(path: Path2);
  69172. /**
  69173. * Gets the cursor point on the path
  69174. * @returns A point on the path cursor at the cursor location
  69175. */
  69176. getPoint(): Vector3;
  69177. /**
  69178. * Moves the cursor ahead by the step amount
  69179. * @param step The amount to move the cursor forward
  69180. * @returns This path cursor
  69181. */
  69182. moveAhead(step?: number): PathCursor;
  69183. /**
  69184. * Moves the cursor behind by the step amount
  69185. * @param step The amount to move the cursor back
  69186. * @returns This path cursor
  69187. */
  69188. moveBack(step?: number): PathCursor;
  69189. /**
  69190. * Moves the cursor by the step amount
  69191. * If the step amount is greater than one, an exception is thrown
  69192. * @param step The amount to move the cursor
  69193. * @returns This path cursor
  69194. */
  69195. move(step: number): PathCursor;
  69196. /**
  69197. * Ensures that the value is limited between zero and one
  69198. * @returns This path cursor
  69199. */
  69200. private ensureLimits;
  69201. /**
  69202. * Runs onchange callbacks on change (used by the animation engine)
  69203. * @returns This path cursor
  69204. */
  69205. private raiseOnChange;
  69206. /**
  69207. * Executes a function on change
  69208. * @param f A path cursor onchange callback
  69209. * @returns This path cursor
  69210. */
  69211. onchange(f: (cursor: PathCursor) => void): PathCursor;
  69212. }
  69213. }
  69214. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  69215. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  69216. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  69217. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  69218. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  69219. }
  69220. declare module "babylonjs/Engines/Processors/Expressions/index" {
  69221. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  69222. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  69223. }
  69224. declare module "babylonjs/Engines/Processors/index" {
  69225. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  69226. export * from "babylonjs/Engines/Processors/Expressions/index";
  69227. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  69228. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  69229. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  69230. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  69231. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  69232. export * from "babylonjs/Engines/Processors/shaderProcessor";
  69233. }
  69234. declare module "babylonjs/Legacy/legacy" {
  69235. import * as Babylon from "babylonjs/index";
  69236. export * from "babylonjs/index";
  69237. }
  69238. declare module "babylonjs/Shaders/blur.fragment" {
  69239. /** @hidden */
  69240. export var blurPixelShader: {
  69241. name: string;
  69242. shader: string;
  69243. };
  69244. }
  69245. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  69246. /** @hidden */
  69247. export var pointCloudVertexDeclaration: {
  69248. name: string;
  69249. shader: string;
  69250. };
  69251. }
  69252. declare module "babylonjs" {
  69253. export * from "babylonjs/Legacy/legacy";
  69254. }
  69255. declare module BABYLON {
  69256. /** Alias type for value that can be null */
  69257. export type Nullable<T> = T | null;
  69258. /**
  69259. * Alias type for number that are floats
  69260. * @ignorenaming
  69261. */
  69262. export type float = number;
  69263. /**
  69264. * Alias type for number that are doubles.
  69265. * @ignorenaming
  69266. */
  69267. export type double = number;
  69268. /**
  69269. * Alias type for number that are integer
  69270. * @ignorenaming
  69271. */
  69272. export type int = number;
  69273. /** Alias type for number array or Float32Array */
  69274. export type FloatArray = number[] | Float32Array;
  69275. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  69276. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  69277. /**
  69278. * Alias for types that can be used by a Buffer or VertexBuffer.
  69279. */
  69280. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  69281. /**
  69282. * Alias type for primitive types
  69283. * @ignorenaming
  69284. */
  69285. type Primitive = undefined | null | boolean | string | number | Function;
  69286. /**
  69287. * Type modifier to make all the properties of an object Readonly
  69288. */
  69289. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  69290. /**
  69291. * Type modifier to make all the properties of an object Readonly recursively
  69292. */
  69293. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  69294. /**
  69295. * Type modifier to make object properties readonly.
  69296. */
  69297. export type DeepImmutableObject<T> = {
  69298. readonly [K in keyof T]: DeepImmutable<T[K]>;
  69299. };
  69300. /** @hidden */
  69301. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  69302. }
  69303. }
  69304. declare module BABYLON {
  69305. /**
  69306. * A class serves as a medium between the observable and its observers
  69307. */
  69308. export class EventState {
  69309. /**
  69310. * Create a new EventState
  69311. * @param mask defines the mask associated with this state
  69312. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  69313. * @param target defines the original target of the state
  69314. * @param currentTarget defines the current target of the state
  69315. */
  69316. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  69317. /**
  69318. * Initialize the current event state
  69319. * @param mask defines the mask associated with this state
  69320. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  69321. * @param target defines the original target of the state
  69322. * @param currentTarget defines the current target of the state
  69323. * @returns the current event state
  69324. */
  69325. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  69326. /**
  69327. * An Observer can set this property to true to prevent subsequent observers of being notified
  69328. */
  69329. skipNextObservers: boolean;
  69330. /**
  69331. * Get the mask value that were used to trigger the event corresponding to this EventState object
  69332. */
  69333. mask: number;
  69334. /**
  69335. * The object that originally notified the event
  69336. */
  69337. target?: any;
  69338. /**
  69339. * The current object in the bubbling phase
  69340. */
  69341. currentTarget?: any;
  69342. /**
  69343. * This will be populated with the return value of the last function that was executed.
  69344. * If it is the first function in the callback chain it will be the event data.
  69345. */
  69346. lastReturnValue?: any;
  69347. }
  69348. /**
  69349. * Represent an Observer registered to a given Observable object.
  69350. */
  69351. export class Observer<T> {
  69352. /**
  69353. * Defines the callback to call when the observer is notified
  69354. */
  69355. callback: (eventData: T, eventState: EventState) => void;
  69356. /**
  69357. * Defines the mask of the observer (used to filter notifications)
  69358. */
  69359. mask: number;
  69360. /**
  69361. * Defines the current scope used to restore the JS context
  69362. */
  69363. scope: any;
  69364. /** @hidden */
  69365. _willBeUnregistered: boolean;
  69366. /**
  69367. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  69368. */
  69369. unregisterOnNextCall: boolean;
  69370. /**
  69371. * Creates a new observer
  69372. * @param callback defines the callback to call when the observer is notified
  69373. * @param mask defines the mask of the observer (used to filter notifications)
  69374. * @param scope defines the current scope used to restore the JS context
  69375. */
  69376. constructor(
  69377. /**
  69378. * Defines the callback to call when the observer is notified
  69379. */
  69380. callback: (eventData: T, eventState: EventState) => void,
  69381. /**
  69382. * Defines the mask of the observer (used to filter notifications)
  69383. */
  69384. mask: number,
  69385. /**
  69386. * Defines the current scope used to restore the JS context
  69387. */
  69388. scope?: any);
  69389. }
  69390. /**
  69391. * Represent a list of observers registered to multiple Observables object.
  69392. */
  69393. export class MultiObserver<T> {
  69394. private _observers;
  69395. private _observables;
  69396. /**
  69397. * Release associated resources
  69398. */
  69399. dispose(): void;
  69400. /**
  69401. * Raise a callback when one of the observable will notify
  69402. * @param observables defines a list of observables to watch
  69403. * @param callback defines the callback to call on notification
  69404. * @param mask defines the mask used to filter notifications
  69405. * @param scope defines the current scope used to restore the JS context
  69406. * @returns the new MultiObserver
  69407. */
  69408. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  69409. }
  69410. /**
  69411. * The Observable class is a simple implementation of the Observable pattern.
  69412. *
  69413. * 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.
  69414. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  69415. * 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).
  69416. * 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.
  69417. */
  69418. export class Observable<T> {
  69419. private _observers;
  69420. private _eventState;
  69421. private _onObserverAdded;
  69422. /**
  69423. * Gets the list of observers
  69424. */
  69425. readonly observers: Array<Observer<T>>;
  69426. /**
  69427. * Creates a new observable
  69428. * @param onObserverAdded defines a callback to call when a new observer is added
  69429. */
  69430. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  69431. /**
  69432. * Create a new Observer with the specified callback
  69433. * @param callback the callback that will be executed for that Observer
  69434. * @param mask the mask used to filter observers
  69435. * @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.
  69436. * @param scope optional scope for the callback to be called from
  69437. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  69438. * @returns the new observer created for the callback
  69439. */
  69440. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  69441. /**
  69442. * Create a new Observer with the specified callback and unregisters after the next notification
  69443. * @param callback the callback that will be executed for that Observer
  69444. * @returns the new observer created for the callback
  69445. */
  69446. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  69447. /**
  69448. * Remove an Observer from the Observable object
  69449. * @param observer the instance of the Observer to remove
  69450. * @returns false if it doesn't belong to this Observable
  69451. */
  69452. remove(observer: Nullable<Observer<T>>): boolean;
  69453. /**
  69454. * Remove a callback from the Observable object
  69455. * @param callback the callback to remove
  69456. * @param scope optional scope. If used only the callbacks with this scope will be removed
  69457. * @returns false if it doesn't belong to this Observable
  69458. */
  69459. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  69460. private _deferUnregister;
  69461. private _remove;
  69462. /**
  69463. * Moves the observable to the top of the observer list making it get called first when notified
  69464. * @param observer the observer to move
  69465. */
  69466. makeObserverTopPriority(observer: Observer<T>): void;
  69467. /**
  69468. * Moves the observable to the bottom of the observer list making it get called last when notified
  69469. * @param observer the observer to move
  69470. */
  69471. makeObserverBottomPriority(observer: Observer<T>): void;
  69472. /**
  69473. * Notify all Observers by calling their respective callback with the given data
  69474. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  69475. * @param eventData defines the data to send to all observers
  69476. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  69477. * @param target defines the original target of the state
  69478. * @param currentTarget defines the current target of the state
  69479. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  69480. */
  69481. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  69482. /**
  69483. * Calling this will execute each callback, expecting it to be a promise or return a value.
  69484. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  69485. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  69486. * and it is crucial that all callbacks will be executed.
  69487. * The order of the callbacks is kept, callbacks are not executed parallel.
  69488. *
  69489. * @param eventData The data to be sent to each callback
  69490. * @param mask is used to filter observers defaults to -1
  69491. * @param target defines the callback target (see EventState)
  69492. * @param currentTarget defines he current object in the bubbling phase
  69493. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  69494. */
  69495. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  69496. /**
  69497. * Notify a specific observer
  69498. * @param observer defines the observer to notify
  69499. * @param eventData defines the data to be sent to each callback
  69500. * @param mask is used to filter observers defaults to -1
  69501. */
  69502. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  69503. /**
  69504. * Gets a boolean indicating if the observable has at least one observer
  69505. * @returns true is the Observable has at least one Observer registered
  69506. */
  69507. hasObservers(): boolean;
  69508. /**
  69509. * Clear the list of observers
  69510. */
  69511. clear(): void;
  69512. /**
  69513. * Clone the current observable
  69514. * @returns a new observable
  69515. */
  69516. clone(): Observable<T>;
  69517. /**
  69518. * Does this observable handles observer registered with a given mask
  69519. * @param mask defines the mask to be tested
  69520. * @return whether or not one observer registered with the given mask is handeled
  69521. **/
  69522. hasSpecificMask(mask?: number): boolean;
  69523. }
  69524. }
  69525. declare module BABYLON {
  69526. /**
  69527. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  69528. * Babylon.js
  69529. */
  69530. export class DomManagement {
  69531. /**
  69532. * Checks if the window object exists
  69533. * @returns true if the window object exists
  69534. */
  69535. static IsWindowObjectExist(): boolean;
  69536. /**
  69537. * Checks if the navigator object exists
  69538. * @returns true if the navigator object exists
  69539. */
  69540. static IsNavigatorAvailable(): boolean;
  69541. /**
  69542. * Extracts text content from a DOM element hierarchy
  69543. * @param element defines the root element
  69544. * @returns a string
  69545. */
  69546. static GetDOMTextContent(element: HTMLElement): string;
  69547. }
  69548. }
  69549. declare module BABYLON {
  69550. /**
  69551. * Logger used througouht the application to allow configuration of
  69552. * the log level required for the messages.
  69553. */
  69554. export class Logger {
  69555. /**
  69556. * No log
  69557. */
  69558. static readonly NoneLogLevel: number;
  69559. /**
  69560. * Only message logs
  69561. */
  69562. static readonly MessageLogLevel: number;
  69563. /**
  69564. * Only warning logs
  69565. */
  69566. static readonly WarningLogLevel: number;
  69567. /**
  69568. * Only error logs
  69569. */
  69570. static readonly ErrorLogLevel: number;
  69571. /**
  69572. * All logs
  69573. */
  69574. static readonly AllLogLevel: number;
  69575. private static _LogCache;
  69576. /**
  69577. * Gets a value indicating the number of loading errors
  69578. * @ignorenaming
  69579. */
  69580. static errorsCount: number;
  69581. /**
  69582. * Callback called when a new log is added
  69583. */
  69584. static OnNewCacheEntry: (entry: string) => void;
  69585. private static _AddLogEntry;
  69586. private static _FormatMessage;
  69587. private static _LogDisabled;
  69588. private static _LogEnabled;
  69589. private static _WarnDisabled;
  69590. private static _WarnEnabled;
  69591. private static _ErrorDisabled;
  69592. private static _ErrorEnabled;
  69593. /**
  69594. * Log a message to the console
  69595. */
  69596. static Log: (message: string) => void;
  69597. /**
  69598. * Write a warning message to the console
  69599. */
  69600. static Warn: (message: string) => void;
  69601. /**
  69602. * Write an error message to the console
  69603. */
  69604. static Error: (message: string) => void;
  69605. /**
  69606. * Gets current log cache (list of logs)
  69607. */
  69608. static readonly LogCache: string;
  69609. /**
  69610. * Clears the log cache
  69611. */
  69612. static ClearLogCache(): void;
  69613. /**
  69614. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  69615. */
  69616. static LogLevels: number;
  69617. }
  69618. }
  69619. declare module BABYLON {
  69620. /** @hidden */
  69621. export class _TypeStore {
  69622. /** @hidden */
  69623. static RegisteredTypes: {
  69624. [key: string]: Object;
  69625. };
  69626. /** @hidden */
  69627. static GetClass(fqdn: string): any;
  69628. }
  69629. }
  69630. declare module BABYLON {
  69631. /**
  69632. * Helper to manipulate strings
  69633. */
  69634. export class StringTools {
  69635. /**
  69636. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  69637. * @param str Source string
  69638. * @param suffix Suffix to search for in the source string
  69639. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  69640. */
  69641. static EndsWith(str: string, suffix: string): boolean;
  69642. /**
  69643. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  69644. * @param str Source string
  69645. * @param suffix Suffix to search for in the source string
  69646. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  69647. */
  69648. static StartsWith(str: string, suffix: string): boolean;
  69649. /**
  69650. * Decodes a buffer into a string
  69651. * @param buffer The buffer to decode
  69652. * @returns The decoded string
  69653. */
  69654. static Decode(buffer: Uint8Array | Uint16Array): string;
  69655. /**
  69656. * Encode a buffer to a base64 string
  69657. * @param buffer defines the buffer to encode
  69658. * @returns the encoded string
  69659. */
  69660. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  69661. }
  69662. }
  69663. declare module BABYLON {
  69664. /**
  69665. * Class containing a set of static utilities functions for deep copy.
  69666. */
  69667. export class DeepCopier {
  69668. /**
  69669. * Tries to copy an object by duplicating every property
  69670. * @param source defines the source object
  69671. * @param destination defines the target object
  69672. * @param doNotCopyList defines a list of properties to avoid
  69673. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  69674. */
  69675. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  69676. }
  69677. }
  69678. declare module BABYLON {
  69679. /**
  69680. * Class containing a set of static utilities functions for precision date
  69681. */
  69682. export class PrecisionDate {
  69683. /**
  69684. * Gets either window.performance.now() if supported or Date.now() else
  69685. */
  69686. static readonly Now: number;
  69687. }
  69688. }
  69689. declare module BABYLON {
  69690. /** @hidden */
  69691. export class _DevTools {
  69692. static WarnImport(name: string): string;
  69693. }
  69694. }
  69695. declare module BABYLON {
  69696. /**
  69697. * Interface used to define the mechanism to get data from the network
  69698. */
  69699. export interface IWebRequest {
  69700. /**
  69701. * Returns client's response url
  69702. */
  69703. responseURL: string;
  69704. /**
  69705. * Returns client's status
  69706. */
  69707. status: number;
  69708. /**
  69709. * Returns client's status as a text
  69710. */
  69711. statusText: string;
  69712. }
  69713. }
  69714. declare module BABYLON {
  69715. /**
  69716. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  69717. */
  69718. export class WebRequest implements IWebRequest {
  69719. private _xhr;
  69720. /**
  69721. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  69722. * i.e. when loading files, where the server/service expects an Authorization header
  69723. */
  69724. static CustomRequestHeaders: {
  69725. [key: string]: string;
  69726. };
  69727. /**
  69728. * Add callback functions in this array to update all the requests before they get sent to the network
  69729. */
  69730. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  69731. private _injectCustomRequestHeaders;
  69732. /**
  69733. * Gets or sets a function to be called when loading progress changes
  69734. */
  69735. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  69736. /**
  69737. * Returns client's state
  69738. */
  69739. readonly readyState: number;
  69740. /**
  69741. * Returns client's status
  69742. */
  69743. readonly status: number;
  69744. /**
  69745. * Returns client's status as a text
  69746. */
  69747. readonly statusText: string;
  69748. /**
  69749. * Returns client's response
  69750. */
  69751. readonly response: any;
  69752. /**
  69753. * Returns client's response url
  69754. */
  69755. readonly responseURL: string;
  69756. /**
  69757. * Returns client's response as text
  69758. */
  69759. readonly responseText: string;
  69760. /**
  69761. * Gets or sets the expected response type
  69762. */
  69763. responseType: XMLHttpRequestResponseType;
  69764. /** @hidden */
  69765. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  69766. /** @hidden */
  69767. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  69768. /**
  69769. * Cancels any network activity
  69770. */
  69771. abort(): void;
  69772. /**
  69773. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  69774. * @param body defines an optional request body
  69775. */
  69776. send(body?: Document | BodyInit | null): void;
  69777. /**
  69778. * Sets the request method, request URL
  69779. * @param method defines the method to use (GET, POST, etc..)
  69780. * @param url defines the url to connect with
  69781. */
  69782. open(method: string, url: string): void;
  69783. /**
  69784. * Sets the value of a request header.
  69785. * @param name The name of the header whose value is to be set
  69786. * @param value The value to set as the body of the header
  69787. */
  69788. setRequestHeader(name: string, value: string): void;
  69789. /**
  69790. * Get the string containing the text of a particular header's value.
  69791. * @param name The name of the header
  69792. * @returns The string containing the text of the given header name
  69793. */
  69794. getResponseHeader(name: string): Nullable<string>;
  69795. }
  69796. }
  69797. declare module BABYLON {
  69798. /**
  69799. * File request interface
  69800. */
  69801. export interface IFileRequest {
  69802. /**
  69803. * Raised when the request is complete (success or error).
  69804. */
  69805. onCompleteObservable: Observable<IFileRequest>;
  69806. /**
  69807. * Aborts the request for a file.
  69808. */
  69809. abort: () => void;
  69810. }
  69811. }
  69812. declare module BABYLON {
  69813. /**
  69814. * Define options used to create a render target texture
  69815. */
  69816. export class RenderTargetCreationOptions {
  69817. /**
  69818. * Specifies is mipmaps must be generated
  69819. */
  69820. generateMipMaps?: boolean;
  69821. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  69822. generateDepthBuffer?: boolean;
  69823. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  69824. generateStencilBuffer?: boolean;
  69825. /** Defines texture type (int by default) */
  69826. type?: number;
  69827. /** Defines sampling mode (trilinear by default) */
  69828. samplingMode?: number;
  69829. /** Defines format (RGBA by default) */
  69830. format?: number;
  69831. }
  69832. }
  69833. declare module BABYLON {
  69834. /**
  69835. * @hidden
  69836. **/
  69837. export class _TimeToken {
  69838. _startTimeQuery: Nullable<WebGLQuery>;
  69839. _endTimeQuery: Nullable<WebGLQuery>;
  69840. _timeElapsedQuery: Nullable<WebGLQuery>;
  69841. _timeElapsedQueryEnded: boolean;
  69842. }
  69843. }
  69844. declare module BABYLON {
  69845. /** Defines the cross module used constants to avoid circular dependncies */
  69846. export class Constants {
  69847. /** Defines that alpha blending is disabled */
  69848. static readonly ALPHA_DISABLE: number;
  69849. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  69850. static readonly ALPHA_ADD: number;
  69851. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  69852. static readonly ALPHA_COMBINE: number;
  69853. /** Defines that alpha blending to DEST - SRC * DEST */
  69854. static readonly ALPHA_SUBTRACT: number;
  69855. /** Defines that alpha blending to SRC * DEST */
  69856. static readonly ALPHA_MULTIPLY: number;
  69857. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  69858. static readonly ALPHA_MAXIMIZED: number;
  69859. /** Defines that alpha blending to SRC + DEST */
  69860. static readonly ALPHA_ONEONE: number;
  69861. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  69862. static readonly ALPHA_PREMULTIPLIED: number;
  69863. /**
  69864. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  69865. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  69866. */
  69867. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  69868. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  69869. static readonly ALPHA_INTERPOLATE: number;
  69870. /**
  69871. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  69872. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  69873. */
  69874. static readonly ALPHA_SCREENMODE: number;
  69875. /**
  69876. * Defines that alpha blending to SRC + DST
  69877. * Alpha will be set to SRC ALPHA + DST ALPHA
  69878. */
  69879. static readonly ALPHA_ONEONE_ONEONE: number;
  69880. /**
  69881. * Defines that alpha blending to SRC * DST ALPHA + DST
  69882. * Alpha will be set to 0
  69883. */
  69884. static readonly ALPHA_ALPHATOCOLOR: number;
  69885. /**
  69886. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  69887. */
  69888. static readonly ALPHA_REVERSEONEMINUS: number;
  69889. /**
  69890. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  69891. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  69892. */
  69893. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  69894. /**
  69895. * Defines that alpha blending to SRC + DST
  69896. * Alpha will be set to SRC ALPHA
  69897. */
  69898. static readonly ALPHA_ONEONE_ONEZERO: number;
  69899. /** Defines that alpha blending equation a SUM */
  69900. static readonly ALPHA_EQUATION_ADD: number;
  69901. /** Defines that alpha blending equation a SUBSTRACTION */
  69902. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  69903. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  69904. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  69905. /** Defines that alpha blending equation a MAX operation */
  69906. static readonly ALPHA_EQUATION_MAX: number;
  69907. /** Defines that alpha blending equation a MIN operation */
  69908. static readonly ALPHA_EQUATION_MIN: number;
  69909. /**
  69910. * Defines that alpha blending equation a DARKEN operation:
  69911. * It takes the min of the src and sums the alpha channels.
  69912. */
  69913. static readonly ALPHA_EQUATION_DARKEN: number;
  69914. /** Defines that the ressource is not delayed*/
  69915. static readonly DELAYLOADSTATE_NONE: number;
  69916. /** Defines that the ressource was successfully delay loaded */
  69917. static readonly DELAYLOADSTATE_LOADED: number;
  69918. /** Defines that the ressource is currently delay loading */
  69919. static readonly DELAYLOADSTATE_LOADING: number;
  69920. /** Defines that the ressource is delayed and has not started loading */
  69921. static readonly DELAYLOADSTATE_NOTLOADED: number;
  69922. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  69923. static readonly NEVER: number;
  69924. /** 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 */
  69925. static readonly ALWAYS: number;
  69926. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  69927. static readonly LESS: number;
  69928. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  69929. static readonly EQUAL: number;
  69930. /** 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 */
  69931. static readonly LEQUAL: number;
  69932. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  69933. static readonly GREATER: number;
  69934. /** 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 */
  69935. static readonly GEQUAL: number;
  69936. /** 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 */
  69937. static readonly NOTEQUAL: number;
  69938. /** Passed to stencilOperation to specify that stencil value must be kept */
  69939. static readonly KEEP: number;
  69940. /** Passed to stencilOperation to specify that stencil value must be replaced */
  69941. static readonly REPLACE: number;
  69942. /** Passed to stencilOperation to specify that stencil value must be incremented */
  69943. static readonly INCR: number;
  69944. /** Passed to stencilOperation to specify that stencil value must be decremented */
  69945. static readonly DECR: number;
  69946. /** Passed to stencilOperation to specify that stencil value must be inverted */
  69947. static readonly INVERT: number;
  69948. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  69949. static readonly INCR_WRAP: number;
  69950. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  69951. static readonly DECR_WRAP: number;
  69952. /** Texture is not repeating outside of 0..1 UVs */
  69953. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  69954. /** Texture is repeating outside of 0..1 UVs */
  69955. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  69956. /** Texture is repeating and mirrored */
  69957. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  69958. /** ALPHA */
  69959. static readonly TEXTUREFORMAT_ALPHA: number;
  69960. /** LUMINANCE */
  69961. static readonly TEXTUREFORMAT_LUMINANCE: number;
  69962. /** LUMINANCE_ALPHA */
  69963. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  69964. /** RGB */
  69965. static readonly TEXTUREFORMAT_RGB: number;
  69966. /** RGBA */
  69967. static readonly TEXTUREFORMAT_RGBA: number;
  69968. /** RED */
  69969. static readonly TEXTUREFORMAT_RED: number;
  69970. /** RED (2nd reference) */
  69971. static readonly TEXTUREFORMAT_R: number;
  69972. /** RG */
  69973. static readonly TEXTUREFORMAT_RG: number;
  69974. /** RED_INTEGER */
  69975. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  69976. /** RED_INTEGER (2nd reference) */
  69977. static readonly TEXTUREFORMAT_R_INTEGER: number;
  69978. /** RG_INTEGER */
  69979. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  69980. /** RGB_INTEGER */
  69981. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  69982. /** RGBA_INTEGER */
  69983. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  69984. /** UNSIGNED_BYTE */
  69985. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  69986. /** UNSIGNED_BYTE (2nd reference) */
  69987. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  69988. /** FLOAT */
  69989. static readonly TEXTURETYPE_FLOAT: number;
  69990. /** HALF_FLOAT */
  69991. static readonly TEXTURETYPE_HALF_FLOAT: number;
  69992. /** BYTE */
  69993. static readonly TEXTURETYPE_BYTE: number;
  69994. /** SHORT */
  69995. static readonly TEXTURETYPE_SHORT: number;
  69996. /** UNSIGNED_SHORT */
  69997. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  69998. /** INT */
  69999. static readonly TEXTURETYPE_INT: number;
  70000. /** UNSIGNED_INT */
  70001. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  70002. /** UNSIGNED_SHORT_4_4_4_4 */
  70003. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  70004. /** UNSIGNED_SHORT_5_5_5_1 */
  70005. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  70006. /** UNSIGNED_SHORT_5_6_5 */
  70007. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  70008. /** UNSIGNED_INT_2_10_10_10_REV */
  70009. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  70010. /** UNSIGNED_INT_24_8 */
  70011. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  70012. /** UNSIGNED_INT_10F_11F_11F_REV */
  70013. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  70014. /** UNSIGNED_INT_5_9_9_9_REV */
  70015. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  70016. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  70017. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  70018. /** nearest is mag = nearest and min = nearest and mip = nearest */
  70019. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  70020. /** Bilinear is mag = linear and min = linear and mip = nearest */
  70021. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  70022. /** Trilinear is mag = linear and min = linear and mip = linear */
  70023. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  70024. /** nearest is mag = nearest and min = nearest and mip = linear */
  70025. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  70026. /** Bilinear is mag = linear and min = linear and mip = nearest */
  70027. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  70028. /** Trilinear is mag = linear and min = linear and mip = linear */
  70029. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  70030. /** mag = nearest and min = nearest and mip = nearest */
  70031. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  70032. /** mag = nearest and min = linear and mip = nearest */
  70033. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  70034. /** mag = nearest and min = linear and mip = linear */
  70035. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  70036. /** mag = nearest and min = linear and mip = none */
  70037. static readonly TEXTURE_NEAREST_LINEAR: number;
  70038. /** mag = nearest and min = nearest and mip = none */
  70039. static readonly TEXTURE_NEAREST_NEAREST: number;
  70040. /** mag = linear and min = nearest and mip = nearest */
  70041. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  70042. /** mag = linear and min = nearest and mip = linear */
  70043. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  70044. /** mag = linear and min = linear and mip = none */
  70045. static readonly TEXTURE_LINEAR_LINEAR: number;
  70046. /** mag = linear and min = nearest and mip = none */
  70047. static readonly TEXTURE_LINEAR_NEAREST: number;
  70048. /** Explicit coordinates mode */
  70049. static readonly TEXTURE_EXPLICIT_MODE: number;
  70050. /** Spherical coordinates mode */
  70051. static readonly TEXTURE_SPHERICAL_MODE: number;
  70052. /** Planar coordinates mode */
  70053. static readonly TEXTURE_PLANAR_MODE: number;
  70054. /** Cubic coordinates mode */
  70055. static readonly TEXTURE_CUBIC_MODE: number;
  70056. /** Projection coordinates mode */
  70057. static readonly TEXTURE_PROJECTION_MODE: number;
  70058. /** Skybox coordinates mode */
  70059. static readonly TEXTURE_SKYBOX_MODE: number;
  70060. /** Inverse Cubic coordinates mode */
  70061. static readonly TEXTURE_INVCUBIC_MODE: number;
  70062. /** Equirectangular coordinates mode */
  70063. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  70064. /** Equirectangular Fixed coordinates mode */
  70065. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  70066. /** Equirectangular Fixed Mirrored coordinates mode */
  70067. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  70068. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  70069. static readonly SCALEMODE_FLOOR: number;
  70070. /** Defines that texture rescaling will look for the nearest power of 2 size */
  70071. static readonly SCALEMODE_NEAREST: number;
  70072. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  70073. static readonly SCALEMODE_CEILING: number;
  70074. /**
  70075. * The dirty texture flag value
  70076. */
  70077. static readonly MATERIAL_TextureDirtyFlag: number;
  70078. /**
  70079. * The dirty light flag value
  70080. */
  70081. static readonly MATERIAL_LightDirtyFlag: number;
  70082. /**
  70083. * The dirty fresnel flag value
  70084. */
  70085. static readonly MATERIAL_FresnelDirtyFlag: number;
  70086. /**
  70087. * The dirty attribute flag value
  70088. */
  70089. static readonly MATERIAL_AttributesDirtyFlag: number;
  70090. /**
  70091. * The dirty misc flag value
  70092. */
  70093. static readonly MATERIAL_MiscDirtyFlag: number;
  70094. /**
  70095. * The all dirty flag value
  70096. */
  70097. static readonly MATERIAL_AllDirtyFlag: number;
  70098. /**
  70099. * Returns the triangle fill mode
  70100. */
  70101. static readonly MATERIAL_TriangleFillMode: number;
  70102. /**
  70103. * Returns the wireframe mode
  70104. */
  70105. static readonly MATERIAL_WireFrameFillMode: number;
  70106. /**
  70107. * Returns the point fill mode
  70108. */
  70109. static readonly MATERIAL_PointFillMode: number;
  70110. /**
  70111. * Returns the point list draw mode
  70112. */
  70113. static readonly MATERIAL_PointListDrawMode: number;
  70114. /**
  70115. * Returns the line list draw mode
  70116. */
  70117. static readonly MATERIAL_LineListDrawMode: number;
  70118. /**
  70119. * Returns the line loop draw mode
  70120. */
  70121. static readonly MATERIAL_LineLoopDrawMode: number;
  70122. /**
  70123. * Returns the line strip draw mode
  70124. */
  70125. static readonly MATERIAL_LineStripDrawMode: number;
  70126. /**
  70127. * Returns the triangle strip draw mode
  70128. */
  70129. static readonly MATERIAL_TriangleStripDrawMode: number;
  70130. /**
  70131. * Returns the triangle fan draw mode
  70132. */
  70133. static readonly MATERIAL_TriangleFanDrawMode: number;
  70134. /**
  70135. * Stores the clock-wise side orientation
  70136. */
  70137. static readonly MATERIAL_ClockWiseSideOrientation: number;
  70138. /**
  70139. * Stores the counter clock-wise side orientation
  70140. */
  70141. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  70142. /**
  70143. * Nothing
  70144. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70145. */
  70146. static readonly ACTION_NothingTrigger: number;
  70147. /**
  70148. * On pick
  70149. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70150. */
  70151. static readonly ACTION_OnPickTrigger: number;
  70152. /**
  70153. * On left pick
  70154. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70155. */
  70156. static readonly ACTION_OnLeftPickTrigger: number;
  70157. /**
  70158. * On right pick
  70159. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70160. */
  70161. static readonly ACTION_OnRightPickTrigger: number;
  70162. /**
  70163. * On center pick
  70164. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70165. */
  70166. static readonly ACTION_OnCenterPickTrigger: number;
  70167. /**
  70168. * On pick down
  70169. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70170. */
  70171. static readonly ACTION_OnPickDownTrigger: number;
  70172. /**
  70173. * On double pick
  70174. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70175. */
  70176. static readonly ACTION_OnDoublePickTrigger: number;
  70177. /**
  70178. * On pick up
  70179. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70180. */
  70181. static readonly ACTION_OnPickUpTrigger: number;
  70182. /**
  70183. * On pick out.
  70184. * This trigger will only be raised if you also declared a OnPickDown
  70185. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70186. */
  70187. static readonly ACTION_OnPickOutTrigger: number;
  70188. /**
  70189. * On long press
  70190. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70191. */
  70192. static readonly ACTION_OnLongPressTrigger: number;
  70193. /**
  70194. * On pointer over
  70195. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70196. */
  70197. static readonly ACTION_OnPointerOverTrigger: number;
  70198. /**
  70199. * On pointer out
  70200. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70201. */
  70202. static readonly ACTION_OnPointerOutTrigger: number;
  70203. /**
  70204. * On every frame
  70205. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70206. */
  70207. static readonly ACTION_OnEveryFrameTrigger: number;
  70208. /**
  70209. * On intersection enter
  70210. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70211. */
  70212. static readonly ACTION_OnIntersectionEnterTrigger: number;
  70213. /**
  70214. * On intersection exit
  70215. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70216. */
  70217. static readonly ACTION_OnIntersectionExitTrigger: number;
  70218. /**
  70219. * On key down
  70220. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70221. */
  70222. static readonly ACTION_OnKeyDownTrigger: number;
  70223. /**
  70224. * On key up
  70225. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70226. */
  70227. static readonly ACTION_OnKeyUpTrigger: number;
  70228. /**
  70229. * Billboard mode will only apply to Y axis
  70230. */
  70231. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  70232. /**
  70233. * Billboard mode will apply to all axes
  70234. */
  70235. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  70236. /**
  70237. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  70238. */
  70239. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  70240. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  70241. * Test order :
  70242. * Is the bounding sphere outside the frustum ?
  70243. * If not, are the bounding box vertices outside the frustum ?
  70244. * It not, then the cullable object is in the frustum.
  70245. */
  70246. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  70247. /** Culling strategy : Bounding Sphere Only.
  70248. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  70249. * It's also less accurate than the standard because some not visible objects can still be selected.
  70250. * Test : is the bounding sphere outside the frustum ?
  70251. * If not, then the cullable object is in the frustum.
  70252. */
  70253. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  70254. /** Culling strategy : Optimistic Inclusion.
  70255. * This in an inclusion test first, then the standard exclusion test.
  70256. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  70257. * 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.
  70258. * Anyway, it's as accurate as the standard strategy.
  70259. * Test :
  70260. * Is the cullable object bounding sphere center in the frustum ?
  70261. * If not, apply the default culling strategy.
  70262. */
  70263. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  70264. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  70265. * This in an inclusion test first, then the bounding sphere only exclusion test.
  70266. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  70267. * 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.
  70268. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  70269. * Test :
  70270. * Is the cullable object bounding sphere center in the frustum ?
  70271. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  70272. */
  70273. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  70274. /**
  70275. * No logging while loading
  70276. */
  70277. static readonly SCENELOADER_NO_LOGGING: number;
  70278. /**
  70279. * Minimal logging while loading
  70280. */
  70281. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  70282. /**
  70283. * Summary logging while loading
  70284. */
  70285. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  70286. /**
  70287. * Detailled logging while loading
  70288. */
  70289. static readonly SCENELOADER_DETAILED_LOGGING: number;
  70290. }
  70291. }
  70292. declare module BABYLON {
  70293. /**
  70294. * This represents the required contract to create a new type of texture loader.
  70295. */
  70296. export interface IInternalTextureLoader {
  70297. /**
  70298. * Defines wether the loader supports cascade loading the different faces.
  70299. */
  70300. supportCascades: boolean;
  70301. /**
  70302. * This returns if the loader support the current file information.
  70303. * @param extension defines the file extension of the file being loaded
  70304. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70305. * @param fallback defines the fallback internal texture if any
  70306. * @param isBase64 defines whether the texture is encoded as a base64
  70307. * @param isBuffer defines whether the texture data are stored as a buffer
  70308. * @returns true if the loader can load the specified file
  70309. */
  70310. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  70311. /**
  70312. * Transform the url before loading if required.
  70313. * @param rootUrl the url of the texture
  70314. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70315. * @returns the transformed texture
  70316. */
  70317. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  70318. /**
  70319. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  70320. * @param rootUrl the url of the texture
  70321. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70322. * @returns the fallback texture
  70323. */
  70324. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  70325. /**
  70326. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  70327. * @param data contains the texture data
  70328. * @param texture defines the BabylonJS internal texture
  70329. * @param createPolynomials will be true if polynomials have been requested
  70330. * @param onLoad defines the callback to trigger once the texture is ready
  70331. * @param onError defines the callback to trigger in case of error
  70332. */
  70333. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  70334. /**
  70335. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  70336. * @param data contains the texture data
  70337. * @param texture defines the BabylonJS internal texture
  70338. * @param callback defines the method to call once ready to upload
  70339. */
  70340. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  70341. }
  70342. }
  70343. declare module BABYLON {
  70344. /**
  70345. * Class used to store and describe the pipeline context associated with an effect
  70346. */
  70347. export interface IPipelineContext {
  70348. /**
  70349. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  70350. */
  70351. isAsync: boolean;
  70352. /**
  70353. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  70354. */
  70355. isReady: boolean;
  70356. /** @hidden */
  70357. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  70358. }
  70359. }
  70360. declare module BABYLON {
  70361. /**
  70362. * Class used to store gfx data (like WebGLBuffer)
  70363. */
  70364. export class DataBuffer {
  70365. /**
  70366. * Gets or sets the number of objects referencing this buffer
  70367. */
  70368. references: number;
  70369. /** Gets or sets the size of the underlying buffer */
  70370. capacity: number;
  70371. /**
  70372. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  70373. */
  70374. is32Bits: boolean;
  70375. /**
  70376. * Gets the underlying buffer
  70377. */
  70378. readonly underlyingResource: any;
  70379. }
  70380. }
  70381. declare module BABYLON {
  70382. /** @hidden */
  70383. export interface IShaderProcessor {
  70384. attributeProcessor?: (attribute: string) => string;
  70385. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  70386. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  70387. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  70388. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  70389. lineProcessor?: (line: string, isFragment: boolean) => string;
  70390. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  70391. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  70392. }
  70393. }
  70394. declare module BABYLON {
  70395. /** @hidden */
  70396. export interface ProcessingOptions {
  70397. defines: string[];
  70398. indexParameters: any;
  70399. isFragment: boolean;
  70400. shouldUseHighPrecisionShader: boolean;
  70401. supportsUniformBuffers: boolean;
  70402. shadersRepository: string;
  70403. includesShadersStore: {
  70404. [key: string]: string;
  70405. };
  70406. processor?: IShaderProcessor;
  70407. version: string;
  70408. platformName: string;
  70409. lookForClosingBracketForUniformBuffer?: boolean;
  70410. }
  70411. }
  70412. declare module BABYLON {
  70413. /** @hidden */
  70414. export class ShaderCodeNode {
  70415. line: string;
  70416. children: ShaderCodeNode[];
  70417. additionalDefineKey?: string;
  70418. additionalDefineValue?: string;
  70419. isValid(preprocessors: {
  70420. [key: string]: string;
  70421. }): boolean;
  70422. process(preprocessors: {
  70423. [key: string]: string;
  70424. }, options: ProcessingOptions): string;
  70425. }
  70426. }
  70427. declare module BABYLON {
  70428. /** @hidden */
  70429. export class ShaderCodeCursor {
  70430. private _lines;
  70431. lineIndex: number;
  70432. readonly currentLine: string;
  70433. readonly canRead: boolean;
  70434. lines: string[];
  70435. }
  70436. }
  70437. declare module BABYLON {
  70438. /** @hidden */
  70439. export class ShaderCodeConditionNode extends ShaderCodeNode {
  70440. process(preprocessors: {
  70441. [key: string]: string;
  70442. }, options: ProcessingOptions): string;
  70443. }
  70444. }
  70445. declare module BABYLON {
  70446. /** @hidden */
  70447. export class ShaderDefineExpression {
  70448. isTrue(preprocessors: {
  70449. [key: string]: string;
  70450. }): boolean;
  70451. }
  70452. }
  70453. declare module BABYLON {
  70454. /** @hidden */
  70455. export class ShaderCodeTestNode extends ShaderCodeNode {
  70456. testExpression: ShaderDefineExpression;
  70457. isValid(preprocessors: {
  70458. [key: string]: string;
  70459. }): boolean;
  70460. }
  70461. }
  70462. declare module BABYLON {
  70463. /** @hidden */
  70464. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  70465. define: string;
  70466. not: boolean;
  70467. constructor(define: string, not?: boolean);
  70468. isTrue(preprocessors: {
  70469. [key: string]: string;
  70470. }): boolean;
  70471. }
  70472. }
  70473. declare module BABYLON {
  70474. /** @hidden */
  70475. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  70476. leftOperand: ShaderDefineExpression;
  70477. rightOperand: ShaderDefineExpression;
  70478. isTrue(preprocessors: {
  70479. [key: string]: string;
  70480. }): boolean;
  70481. }
  70482. }
  70483. declare module BABYLON {
  70484. /** @hidden */
  70485. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  70486. leftOperand: ShaderDefineExpression;
  70487. rightOperand: ShaderDefineExpression;
  70488. isTrue(preprocessors: {
  70489. [key: string]: string;
  70490. }): boolean;
  70491. }
  70492. }
  70493. declare module BABYLON {
  70494. /** @hidden */
  70495. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  70496. define: string;
  70497. operand: string;
  70498. testValue: string;
  70499. constructor(define: string, operand: string, testValue: string);
  70500. isTrue(preprocessors: {
  70501. [key: string]: string;
  70502. }): boolean;
  70503. }
  70504. }
  70505. declare module BABYLON {
  70506. /**
  70507. * Class used to enable access to offline support
  70508. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  70509. */
  70510. export interface IOfflineProvider {
  70511. /**
  70512. * Gets a boolean indicating if scene must be saved in the database
  70513. */
  70514. enableSceneOffline: boolean;
  70515. /**
  70516. * Gets a boolean indicating if textures must be saved in the database
  70517. */
  70518. enableTexturesOffline: boolean;
  70519. /**
  70520. * Open the offline support and make it available
  70521. * @param successCallback defines the callback to call on success
  70522. * @param errorCallback defines the callback to call on error
  70523. */
  70524. open(successCallback: () => void, errorCallback: () => void): void;
  70525. /**
  70526. * Loads an image from the offline support
  70527. * @param url defines the url to load from
  70528. * @param image defines the target DOM image
  70529. */
  70530. loadImage(url: string, image: HTMLImageElement): void;
  70531. /**
  70532. * Loads a file from offline support
  70533. * @param url defines the URL to load from
  70534. * @param sceneLoaded defines a callback to call on success
  70535. * @param progressCallBack defines a callback to call when progress changed
  70536. * @param errorCallback defines a callback to call on error
  70537. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  70538. */
  70539. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  70540. }
  70541. }
  70542. declare module BABYLON {
  70543. /**
  70544. * Class used to help managing file picking and drag'n'drop
  70545. * File Storage
  70546. */
  70547. export class FilesInputStore {
  70548. /**
  70549. * List of files ready to be loaded
  70550. */
  70551. static FilesToLoad: {
  70552. [key: string]: File;
  70553. };
  70554. }
  70555. }
  70556. declare module BABYLON {
  70557. /**
  70558. * Class used to define a retry strategy when error happens while loading assets
  70559. */
  70560. export class RetryStrategy {
  70561. /**
  70562. * Function used to defines an exponential back off strategy
  70563. * @param maxRetries defines the maximum number of retries (3 by default)
  70564. * @param baseInterval defines the interval between retries
  70565. * @returns the strategy function to use
  70566. */
  70567. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  70568. }
  70569. }
  70570. declare module BABYLON {
  70571. /**
  70572. * @ignore
  70573. * Application error to support additional information when loading a file
  70574. */
  70575. export abstract class BaseError extends Error {
  70576. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  70577. }
  70578. }
  70579. declare module BABYLON {
  70580. /** @ignore */
  70581. export class LoadFileError extends BaseError {
  70582. request?: WebRequest;
  70583. file?: File;
  70584. /**
  70585. * Creates a new LoadFileError
  70586. * @param message defines the message of the error
  70587. * @param request defines the optional web request
  70588. * @param file defines the optional file
  70589. */
  70590. constructor(message: string, object?: WebRequest | File);
  70591. }
  70592. /** @ignore */
  70593. export class RequestFileError extends BaseError {
  70594. request: WebRequest;
  70595. /**
  70596. * Creates a new LoadFileError
  70597. * @param message defines the message of the error
  70598. * @param request defines the optional web request
  70599. */
  70600. constructor(message: string, request: WebRequest);
  70601. }
  70602. /** @ignore */
  70603. export class ReadFileError extends BaseError {
  70604. file: File;
  70605. /**
  70606. * Creates a new ReadFileError
  70607. * @param message defines the message of the error
  70608. * @param file defines the optional file
  70609. */
  70610. constructor(message: string, file: File);
  70611. }
  70612. /**
  70613. * @hidden
  70614. */
  70615. export class FileTools {
  70616. /**
  70617. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  70618. */
  70619. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  70620. /**
  70621. * Gets or sets the base URL to use to load assets
  70622. */
  70623. static BaseUrl: string;
  70624. /**
  70625. * Default behaviour for cors in the application.
  70626. * It can be a string if the expected behavior is identical in the entire app.
  70627. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  70628. */
  70629. static CorsBehavior: string | ((url: string | string[]) => string);
  70630. /**
  70631. * Gets or sets a function used to pre-process url before using them to load assets
  70632. */
  70633. static PreprocessUrl: (url: string) => string;
  70634. /**
  70635. * Removes unwanted characters from an url
  70636. * @param url defines the url to clean
  70637. * @returns the cleaned url
  70638. */
  70639. private static _CleanUrl;
  70640. /**
  70641. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  70642. * @param url define the url we are trying
  70643. * @param element define the dom element where to configure the cors policy
  70644. */
  70645. static SetCorsBehavior(url: string | string[], element: {
  70646. crossOrigin: string | null;
  70647. }): void;
  70648. /**
  70649. * Loads an image as an HTMLImageElement.
  70650. * @param input url string, ArrayBuffer, or Blob to load
  70651. * @param onLoad callback called when the image successfully loads
  70652. * @param onError callback called when the image fails to load
  70653. * @param offlineProvider offline provider for caching
  70654. * @param mimeType optional mime type
  70655. * @returns the HTMLImageElement of the loaded image
  70656. */
  70657. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  70658. /**
  70659. * Reads a file from a File object
  70660. * @param file defines the file to load
  70661. * @param onSuccess defines the callback to call when data is loaded
  70662. * @param onProgress defines the callback to call during loading process
  70663. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  70664. * @param onError defines the callback to call when an error occurs
  70665. * @returns a file request object
  70666. */
  70667. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  70668. /**
  70669. * Loads a file from a url
  70670. * @param url url to load
  70671. * @param onSuccess callback called when the file successfully loads
  70672. * @param onProgress callback called while file is loading (if the server supports this mode)
  70673. * @param offlineProvider defines the offline provider for caching
  70674. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  70675. * @param onError callback called when the file fails to load
  70676. * @returns a file request object
  70677. */
  70678. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  70679. /**
  70680. * Loads a file
  70681. * @param url url to load
  70682. * @param onSuccess callback called when the file successfully loads
  70683. * @param onProgress callback called while file is loading (if the server supports this mode)
  70684. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  70685. * @param onError callback called when the file fails to load
  70686. * @param onOpened callback called when the web request is opened
  70687. * @returns a file request object
  70688. */
  70689. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  70690. /**
  70691. * Checks if the loaded document was accessed via `file:`-Protocol.
  70692. * @returns boolean
  70693. */
  70694. static IsFileURL(): boolean;
  70695. }
  70696. }
  70697. declare module BABYLON {
  70698. /** @hidden */
  70699. export class ShaderProcessor {
  70700. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  70701. private static _ProcessPrecision;
  70702. private static _ExtractOperation;
  70703. private static _BuildSubExpression;
  70704. private static _BuildExpression;
  70705. private static _MoveCursorWithinIf;
  70706. private static _MoveCursor;
  70707. private static _EvaluatePreProcessors;
  70708. private static _PreparePreProcessors;
  70709. private static _ProcessShaderConversion;
  70710. private static _ProcessIncludes;
  70711. }
  70712. }
  70713. declare module BABYLON {
  70714. /**
  70715. * @hidden
  70716. */
  70717. export interface IColor4Like {
  70718. r: float;
  70719. g: float;
  70720. b: float;
  70721. a: float;
  70722. }
  70723. /**
  70724. * @hidden
  70725. */
  70726. export interface IColor3Like {
  70727. r: float;
  70728. g: float;
  70729. b: float;
  70730. }
  70731. /**
  70732. * @hidden
  70733. */
  70734. export interface IVector4Like {
  70735. x: float;
  70736. y: float;
  70737. z: float;
  70738. w: float;
  70739. }
  70740. /**
  70741. * @hidden
  70742. */
  70743. export interface IVector3Like {
  70744. x: float;
  70745. y: float;
  70746. z: float;
  70747. }
  70748. /**
  70749. * @hidden
  70750. */
  70751. export interface IVector2Like {
  70752. x: float;
  70753. y: float;
  70754. }
  70755. /**
  70756. * @hidden
  70757. */
  70758. export interface IMatrixLike {
  70759. toArray(): DeepImmutable<Float32Array>;
  70760. updateFlag: int;
  70761. }
  70762. /**
  70763. * @hidden
  70764. */
  70765. export interface IViewportLike {
  70766. x: float;
  70767. y: float;
  70768. width: float;
  70769. height: float;
  70770. }
  70771. /**
  70772. * @hidden
  70773. */
  70774. export interface IPlaneLike {
  70775. normal: IVector3Like;
  70776. d: float;
  70777. normalize(): void;
  70778. }
  70779. }
  70780. declare module BABYLON {
  70781. /**
  70782. * Interface used to define common properties for effect fallbacks
  70783. */
  70784. export interface IEffectFallbacks {
  70785. /**
  70786. * Removes the defines that should be removed when falling back.
  70787. * @param currentDefines defines the current define statements for the shader.
  70788. * @param effect defines the current effect we try to compile
  70789. * @returns The resulting defines with defines of the current rank removed.
  70790. */
  70791. reduce(currentDefines: string, effect: Effect): string;
  70792. /**
  70793. * Removes the fallback from the bound mesh.
  70794. */
  70795. unBindMesh(): void;
  70796. /**
  70797. * Checks to see if more fallbacks are still availible.
  70798. */
  70799. hasMoreFallbacks: boolean;
  70800. }
  70801. }
  70802. declare module BABYLON {
  70803. /**
  70804. * Class used to evalaute queries containing `and` and `or` operators
  70805. */
  70806. export class AndOrNotEvaluator {
  70807. /**
  70808. * Evaluate a query
  70809. * @param query defines the query to evaluate
  70810. * @param evaluateCallback defines the callback used to filter result
  70811. * @returns true if the query matches
  70812. */
  70813. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  70814. private static _HandleParenthesisContent;
  70815. private static _SimplifyNegation;
  70816. }
  70817. }
  70818. declare module BABYLON {
  70819. /**
  70820. * Class used to store custom tags
  70821. */
  70822. export class Tags {
  70823. /**
  70824. * Adds support for tags on the given object
  70825. * @param obj defines the object to use
  70826. */
  70827. static EnableFor(obj: any): void;
  70828. /**
  70829. * Removes tags support
  70830. * @param obj defines the object to use
  70831. */
  70832. static DisableFor(obj: any): void;
  70833. /**
  70834. * Gets a boolean indicating if the given object has tags
  70835. * @param obj defines the object to use
  70836. * @returns a boolean
  70837. */
  70838. static HasTags(obj: any): boolean;
  70839. /**
  70840. * Gets the tags available on a given object
  70841. * @param obj defines the object to use
  70842. * @param asString defines if the tags must be returned as a string instead of an array of strings
  70843. * @returns the tags
  70844. */
  70845. static GetTags(obj: any, asString?: boolean): any;
  70846. /**
  70847. * Adds tags to an object
  70848. * @param obj defines the object to use
  70849. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  70850. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  70851. */
  70852. static AddTagsTo(obj: any, tagsString: string): void;
  70853. /**
  70854. * @hidden
  70855. */
  70856. static _AddTagTo(obj: any, tag: string): void;
  70857. /**
  70858. * Removes specific tags from a specific object
  70859. * @param obj defines the object to use
  70860. * @param tagsString defines the tags to remove
  70861. */
  70862. static RemoveTagsFrom(obj: any, tagsString: string): void;
  70863. /**
  70864. * @hidden
  70865. */
  70866. static _RemoveTagFrom(obj: any, tag: string): void;
  70867. /**
  70868. * Defines if tags hosted on an object match a given query
  70869. * @param obj defines the object to use
  70870. * @param tagsQuery defines the tag query
  70871. * @returns a boolean
  70872. */
  70873. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  70874. }
  70875. }
  70876. declare module BABYLON {
  70877. /**
  70878. * Scalar computation library
  70879. */
  70880. export class Scalar {
  70881. /**
  70882. * Two pi constants convenient for computation.
  70883. */
  70884. static TwoPi: number;
  70885. /**
  70886. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  70887. * @param a number
  70888. * @param b number
  70889. * @param epsilon (default = 1.401298E-45)
  70890. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  70891. */
  70892. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  70893. /**
  70894. * Returns a string : the upper case translation of the number i to hexadecimal.
  70895. * @param i number
  70896. * @returns the upper case translation of the number i to hexadecimal.
  70897. */
  70898. static ToHex(i: number): string;
  70899. /**
  70900. * Returns -1 if value is negative and +1 is value is positive.
  70901. * @param value the value
  70902. * @returns the value itself if it's equal to zero.
  70903. */
  70904. static Sign(value: number): number;
  70905. /**
  70906. * Returns the value itself if it's between min and max.
  70907. * Returns min if the value is lower than min.
  70908. * Returns max if the value is greater than max.
  70909. * @param value the value to clmap
  70910. * @param min the min value to clamp to (default: 0)
  70911. * @param max the max value to clamp to (default: 1)
  70912. * @returns the clamped value
  70913. */
  70914. static Clamp(value: number, min?: number, max?: number): number;
  70915. /**
  70916. * the log2 of value.
  70917. * @param value the value to compute log2 of
  70918. * @returns the log2 of value.
  70919. */
  70920. static Log2(value: number): number;
  70921. /**
  70922. * Loops the value, so that it is never larger than length and never smaller than 0.
  70923. *
  70924. * This is similar to the modulo operator but it works with floating point numbers.
  70925. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  70926. * With t = 5 and length = 2.5, the result would be 0.0.
  70927. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  70928. * @param value the value
  70929. * @param length the length
  70930. * @returns the looped value
  70931. */
  70932. static Repeat(value: number, length: number): number;
  70933. /**
  70934. * Normalize the value between 0.0 and 1.0 using min and max values
  70935. * @param value value to normalize
  70936. * @param min max to normalize between
  70937. * @param max min to normalize between
  70938. * @returns the normalized value
  70939. */
  70940. static Normalize(value: number, min: number, max: number): number;
  70941. /**
  70942. * Denormalize the value from 0.0 and 1.0 using min and max values
  70943. * @param normalized value to denormalize
  70944. * @param min max to denormalize between
  70945. * @param max min to denormalize between
  70946. * @returns the denormalized value
  70947. */
  70948. static Denormalize(normalized: number, min: number, max: number): number;
  70949. /**
  70950. * Calculates the shortest difference between two given angles given in degrees.
  70951. * @param current current angle in degrees
  70952. * @param target target angle in degrees
  70953. * @returns the delta
  70954. */
  70955. static DeltaAngle(current: number, target: number): number;
  70956. /**
  70957. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  70958. * @param tx value
  70959. * @param length length
  70960. * @returns The returned value will move back and forth between 0 and length
  70961. */
  70962. static PingPong(tx: number, length: number): number;
  70963. /**
  70964. * Interpolates between min and max with smoothing at the limits.
  70965. *
  70966. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  70967. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  70968. * @param from from
  70969. * @param to to
  70970. * @param tx value
  70971. * @returns the smooth stepped value
  70972. */
  70973. static SmoothStep(from: number, to: number, tx: number): number;
  70974. /**
  70975. * Moves a value current towards target.
  70976. *
  70977. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  70978. * Negative values of maxDelta pushes the value away from target.
  70979. * @param current current value
  70980. * @param target target value
  70981. * @param maxDelta max distance to move
  70982. * @returns resulting value
  70983. */
  70984. static MoveTowards(current: number, target: number, maxDelta: number): number;
  70985. /**
  70986. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  70987. *
  70988. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  70989. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  70990. * @param current current value
  70991. * @param target target value
  70992. * @param maxDelta max distance to move
  70993. * @returns resulting angle
  70994. */
  70995. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  70996. /**
  70997. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  70998. * @param start start value
  70999. * @param end target value
  71000. * @param amount amount to lerp between
  71001. * @returns the lerped value
  71002. */
  71003. static Lerp(start: number, end: number, amount: number): number;
  71004. /**
  71005. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  71006. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  71007. * @param start start value
  71008. * @param end target value
  71009. * @param amount amount to lerp between
  71010. * @returns the lerped value
  71011. */
  71012. static LerpAngle(start: number, end: number, amount: number): number;
  71013. /**
  71014. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  71015. * @param a start value
  71016. * @param b target value
  71017. * @param value value between a and b
  71018. * @returns the inverseLerp value
  71019. */
  71020. static InverseLerp(a: number, b: number, value: number): number;
  71021. /**
  71022. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  71023. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  71024. * @param value1 spline value
  71025. * @param tangent1 spline value
  71026. * @param value2 spline value
  71027. * @param tangent2 spline value
  71028. * @param amount input value
  71029. * @returns hermite result
  71030. */
  71031. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  71032. /**
  71033. * Returns a random float number between and min and max values
  71034. * @param min min value of random
  71035. * @param max max value of random
  71036. * @returns random value
  71037. */
  71038. static RandomRange(min: number, max: number): number;
  71039. /**
  71040. * This function returns percentage of a number in a given range.
  71041. *
  71042. * RangeToPercent(40,20,60) will return 0.5 (50%)
  71043. * RangeToPercent(34,0,100) will return 0.34 (34%)
  71044. * @param number to convert to percentage
  71045. * @param min min range
  71046. * @param max max range
  71047. * @returns the percentage
  71048. */
  71049. static RangeToPercent(number: number, min: number, max: number): number;
  71050. /**
  71051. * This function returns number that corresponds to the percentage in a given range.
  71052. *
  71053. * PercentToRange(0.34,0,100) will return 34.
  71054. * @param percent to convert to number
  71055. * @param min min range
  71056. * @param max max range
  71057. * @returns the number
  71058. */
  71059. static PercentToRange(percent: number, min: number, max: number): number;
  71060. /**
  71061. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  71062. * @param angle The angle to normalize in radian.
  71063. * @return The converted angle.
  71064. */
  71065. static NormalizeRadians(angle: number): number;
  71066. }
  71067. }
  71068. declare module BABYLON {
  71069. /**
  71070. * Constant used to convert a value to gamma space
  71071. * @ignorenaming
  71072. */
  71073. export const ToGammaSpace: number;
  71074. /**
  71075. * Constant used to convert a value to linear space
  71076. * @ignorenaming
  71077. */
  71078. export const ToLinearSpace = 2.2;
  71079. /**
  71080. * Constant used to define the minimal number value in Babylon.js
  71081. * @ignorenaming
  71082. */
  71083. let Epsilon: number;
  71084. }
  71085. declare module BABYLON {
  71086. /**
  71087. * Class used to represent a viewport on screen
  71088. */
  71089. export class Viewport {
  71090. /** viewport left coordinate */
  71091. x: number;
  71092. /** viewport top coordinate */
  71093. y: number;
  71094. /**viewport width */
  71095. width: number;
  71096. /** viewport height */
  71097. height: number;
  71098. /**
  71099. * Creates a Viewport object located at (x, y) and sized (width, height)
  71100. * @param x defines viewport left coordinate
  71101. * @param y defines viewport top coordinate
  71102. * @param width defines the viewport width
  71103. * @param height defines the viewport height
  71104. */
  71105. constructor(
  71106. /** viewport left coordinate */
  71107. x: number,
  71108. /** viewport top coordinate */
  71109. y: number,
  71110. /**viewport width */
  71111. width: number,
  71112. /** viewport height */
  71113. height: number);
  71114. /**
  71115. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  71116. * @param renderWidth defines the rendering width
  71117. * @param renderHeight defines the rendering height
  71118. * @returns a new Viewport
  71119. */
  71120. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  71121. /**
  71122. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  71123. * @param renderWidth defines the rendering width
  71124. * @param renderHeight defines the rendering height
  71125. * @param ref defines the target viewport
  71126. * @returns the current viewport
  71127. */
  71128. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  71129. /**
  71130. * Returns a new Viewport copied from the current one
  71131. * @returns a new Viewport
  71132. */
  71133. clone(): Viewport;
  71134. }
  71135. }
  71136. declare module BABYLON {
  71137. /**
  71138. * Class containing a set of static utilities functions for arrays.
  71139. */
  71140. export class ArrayTools {
  71141. /**
  71142. * Returns an array of the given size filled with element built from the given constructor and the paramters
  71143. * @param size the number of element to construct and put in the array
  71144. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  71145. * @returns a new array filled with new objects
  71146. */
  71147. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  71148. }
  71149. }
  71150. declare module BABYLON {
  71151. /**
  71152. * Class representing a vector containing 2 coordinates
  71153. */
  71154. export class Vector2 {
  71155. /** defines the first coordinate */
  71156. x: number;
  71157. /** defines the second coordinate */
  71158. y: number;
  71159. /**
  71160. * Creates a new Vector2 from the given x and y coordinates
  71161. * @param x defines the first coordinate
  71162. * @param y defines the second coordinate
  71163. */
  71164. constructor(
  71165. /** defines the first coordinate */
  71166. x?: number,
  71167. /** defines the second coordinate */
  71168. y?: number);
  71169. /**
  71170. * Gets a string with the Vector2 coordinates
  71171. * @returns a string with the Vector2 coordinates
  71172. */
  71173. toString(): string;
  71174. /**
  71175. * Gets class name
  71176. * @returns the string "Vector2"
  71177. */
  71178. getClassName(): string;
  71179. /**
  71180. * Gets current vector hash code
  71181. * @returns the Vector2 hash code as a number
  71182. */
  71183. getHashCode(): number;
  71184. /**
  71185. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  71186. * @param array defines the source array
  71187. * @param index defines the offset in source array
  71188. * @returns the current Vector2
  71189. */
  71190. toArray(array: FloatArray, index?: number): Vector2;
  71191. /**
  71192. * Copy the current vector to an array
  71193. * @returns a new array with 2 elements: the Vector2 coordinates.
  71194. */
  71195. asArray(): number[];
  71196. /**
  71197. * Sets the Vector2 coordinates with the given Vector2 coordinates
  71198. * @param source defines the source Vector2
  71199. * @returns the current updated Vector2
  71200. */
  71201. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  71202. /**
  71203. * Sets the Vector2 coordinates with the given floats
  71204. * @param x defines the first coordinate
  71205. * @param y defines the second coordinate
  71206. * @returns the current updated Vector2
  71207. */
  71208. copyFromFloats(x: number, y: number): Vector2;
  71209. /**
  71210. * Sets the Vector2 coordinates with the given floats
  71211. * @param x defines the first coordinate
  71212. * @param y defines the second coordinate
  71213. * @returns the current updated Vector2
  71214. */
  71215. set(x: number, y: number): Vector2;
  71216. /**
  71217. * Add another vector with the current one
  71218. * @param otherVector defines the other vector
  71219. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  71220. */
  71221. add(otherVector: DeepImmutable<Vector2>): Vector2;
  71222. /**
  71223. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  71224. * @param otherVector defines the other vector
  71225. * @param result defines the target vector
  71226. * @returns the unmodified current Vector2
  71227. */
  71228. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  71229. /**
  71230. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  71231. * @param otherVector defines the other vector
  71232. * @returns the current updated Vector2
  71233. */
  71234. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  71235. /**
  71236. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  71237. * @param otherVector defines the other vector
  71238. * @returns a new Vector2
  71239. */
  71240. addVector3(otherVector: Vector3): Vector2;
  71241. /**
  71242. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  71243. * @param otherVector defines the other vector
  71244. * @returns a new Vector2
  71245. */
  71246. subtract(otherVector: Vector2): Vector2;
  71247. /**
  71248. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  71249. * @param otherVector defines the other vector
  71250. * @param result defines the target vector
  71251. * @returns the unmodified current Vector2
  71252. */
  71253. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  71254. /**
  71255. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  71256. * @param otherVector defines the other vector
  71257. * @returns the current updated Vector2
  71258. */
  71259. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  71260. /**
  71261. * Multiplies in place the current Vector2 coordinates by the given ones
  71262. * @param otherVector defines the other vector
  71263. * @returns the current updated Vector2
  71264. */
  71265. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  71266. /**
  71267. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  71268. * @param otherVector defines the other vector
  71269. * @returns a new Vector2
  71270. */
  71271. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  71272. /**
  71273. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  71274. * @param otherVector defines the other vector
  71275. * @param result defines the target vector
  71276. * @returns the unmodified current Vector2
  71277. */
  71278. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  71279. /**
  71280. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  71281. * @param x defines the first coordinate
  71282. * @param y defines the second coordinate
  71283. * @returns a new Vector2
  71284. */
  71285. multiplyByFloats(x: number, y: number): Vector2;
  71286. /**
  71287. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  71288. * @param otherVector defines the other vector
  71289. * @returns a new Vector2
  71290. */
  71291. divide(otherVector: Vector2): Vector2;
  71292. /**
  71293. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  71294. * @param otherVector defines the other vector
  71295. * @param result defines the target vector
  71296. * @returns the unmodified current Vector2
  71297. */
  71298. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  71299. /**
  71300. * Divides the current Vector2 coordinates by the given ones
  71301. * @param otherVector defines the other vector
  71302. * @returns the current updated Vector2
  71303. */
  71304. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  71305. /**
  71306. * Gets a new Vector2 with current Vector2 negated coordinates
  71307. * @returns a new Vector2
  71308. */
  71309. negate(): Vector2;
  71310. /**
  71311. * Multiply the Vector2 coordinates by scale
  71312. * @param scale defines the scaling factor
  71313. * @returns the current updated Vector2
  71314. */
  71315. scaleInPlace(scale: number): Vector2;
  71316. /**
  71317. * Returns a new Vector2 scaled by "scale" from the current Vector2
  71318. * @param scale defines the scaling factor
  71319. * @returns a new Vector2
  71320. */
  71321. scale(scale: number): Vector2;
  71322. /**
  71323. * Scale the current Vector2 values by a factor to a given Vector2
  71324. * @param scale defines the scale factor
  71325. * @param result defines the Vector2 object where to store the result
  71326. * @returns the unmodified current Vector2
  71327. */
  71328. scaleToRef(scale: number, result: Vector2): Vector2;
  71329. /**
  71330. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  71331. * @param scale defines the scale factor
  71332. * @param result defines the Vector2 object where to store the result
  71333. * @returns the unmodified current Vector2
  71334. */
  71335. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  71336. /**
  71337. * Gets a boolean if two vectors are equals
  71338. * @param otherVector defines the other vector
  71339. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  71340. */
  71341. equals(otherVector: DeepImmutable<Vector2>): boolean;
  71342. /**
  71343. * Gets a boolean if two vectors are equals (using an epsilon value)
  71344. * @param otherVector defines the other vector
  71345. * @param epsilon defines the minimal distance to consider equality
  71346. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  71347. */
  71348. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  71349. /**
  71350. * Gets a new Vector2 from current Vector2 floored values
  71351. * @returns a new Vector2
  71352. */
  71353. floor(): Vector2;
  71354. /**
  71355. * Gets a new Vector2 from current Vector2 floored values
  71356. * @returns a new Vector2
  71357. */
  71358. fract(): Vector2;
  71359. /**
  71360. * Gets the length of the vector
  71361. * @returns the vector length (float)
  71362. */
  71363. length(): number;
  71364. /**
  71365. * Gets the vector squared length
  71366. * @returns the vector squared length (float)
  71367. */
  71368. lengthSquared(): number;
  71369. /**
  71370. * Normalize the vector
  71371. * @returns the current updated Vector2
  71372. */
  71373. normalize(): Vector2;
  71374. /**
  71375. * Gets a new Vector2 copied from the Vector2
  71376. * @returns a new Vector2
  71377. */
  71378. clone(): Vector2;
  71379. /**
  71380. * Gets a new Vector2(0, 0)
  71381. * @returns a new Vector2
  71382. */
  71383. static Zero(): Vector2;
  71384. /**
  71385. * Gets a new Vector2(1, 1)
  71386. * @returns a new Vector2
  71387. */
  71388. static One(): Vector2;
  71389. /**
  71390. * Gets a new Vector2 set from the given index element of the given array
  71391. * @param array defines the data source
  71392. * @param offset defines the offset in the data source
  71393. * @returns a new Vector2
  71394. */
  71395. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  71396. /**
  71397. * Sets "result" from the given index element of the given array
  71398. * @param array defines the data source
  71399. * @param offset defines the offset in the data source
  71400. * @param result defines the target vector
  71401. */
  71402. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  71403. /**
  71404. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  71405. * @param value1 defines 1st point of control
  71406. * @param value2 defines 2nd point of control
  71407. * @param value3 defines 3rd point of control
  71408. * @param value4 defines 4th point of control
  71409. * @param amount defines the interpolation factor
  71410. * @returns a new Vector2
  71411. */
  71412. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  71413. /**
  71414. * 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".
  71415. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  71416. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  71417. * @param value defines the value to clamp
  71418. * @param min defines the lower limit
  71419. * @param max defines the upper limit
  71420. * @returns a new Vector2
  71421. */
  71422. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  71423. /**
  71424. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  71425. * @param value1 defines the 1st control point
  71426. * @param tangent1 defines the outgoing tangent
  71427. * @param value2 defines the 2nd control point
  71428. * @param tangent2 defines the incoming tangent
  71429. * @param amount defines the interpolation factor
  71430. * @returns a new Vector2
  71431. */
  71432. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  71433. /**
  71434. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  71435. * @param start defines the start vector
  71436. * @param end defines the end vector
  71437. * @param amount defines the interpolation factor
  71438. * @returns a new Vector2
  71439. */
  71440. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  71441. /**
  71442. * Gets the dot product of the vector "left" and the vector "right"
  71443. * @param left defines first vector
  71444. * @param right defines second vector
  71445. * @returns the dot product (float)
  71446. */
  71447. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  71448. /**
  71449. * Returns a new Vector2 equal to the normalized given vector
  71450. * @param vector defines the vector to normalize
  71451. * @returns a new Vector2
  71452. */
  71453. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  71454. /**
  71455. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  71456. * @param left defines 1st vector
  71457. * @param right defines 2nd vector
  71458. * @returns a new Vector2
  71459. */
  71460. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  71461. /**
  71462. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  71463. * @param left defines 1st vector
  71464. * @param right defines 2nd vector
  71465. * @returns a new Vector2
  71466. */
  71467. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  71468. /**
  71469. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  71470. * @param vector defines the vector to transform
  71471. * @param transformation defines the matrix to apply
  71472. * @returns a new Vector2
  71473. */
  71474. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  71475. /**
  71476. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  71477. * @param vector defines the vector to transform
  71478. * @param transformation defines the matrix to apply
  71479. * @param result defines the target vector
  71480. */
  71481. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  71482. /**
  71483. * Determines if a given vector is included in a triangle
  71484. * @param p defines the vector to test
  71485. * @param p0 defines 1st triangle point
  71486. * @param p1 defines 2nd triangle point
  71487. * @param p2 defines 3rd triangle point
  71488. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  71489. */
  71490. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  71491. /**
  71492. * Gets the distance between the vectors "value1" and "value2"
  71493. * @param value1 defines first vector
  71494. * @param value2 defines second vector
  71495. * @returns the distance between vectors
  71496. */
  71497. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  71498. /**
  71499. * Returns the squared distance between the vectors "value1" and "value2"
  71500. * @param value1 defines first vector
  71501. * @param value2 defines second vector
  71502. * @returns the squared distance between vectors
  71503. */
  71504. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  71505. /**
  71506. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  71507. * @param value1 defines first vector
  71508. * @param value2 defines second vector
  71509. * @returns a new Vector2
  71510. */
  71511. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  71512. /**
  71513. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  71514. * @param p defines the middle point
  71515. * @param segA defines one point of the segment
  71516. * @param segB defines the other point of the segment
  71517. * @returns the shortest distance
  71518. */
  71519. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  71520. }
  71521. /**
  71522. * Class used to store (x,y,z) vector representation
  71523. * A Vector3 is the main object used in 3D geometry
  71524. * It can represent etiher the coordinates of a point the space, either a direction
  71525. * Reminder: js uses a left handed forward facing system
  71526. */
  71527. export class Vector3 {
  71528. /**
  71529. * Defines the first coordinates (on X axis)
  71530. */
  71531. x: number;
  71532. /**
  71533. * Defines the second coordinates (on Y axis)
  71534. */
  71535. y: number;
  71536. /**
  71537. * Defines the third coordinates (on Z axis)
  71538. */
  71539. z: number;
  71540. private static _UpReadOnly;
  71541. private static _ZeroReadOnly;
  71542. /**
  71543. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  71544. * @param x defines the first coordinates (on X axis)
  71545. * @param y defines the second coordinates (on Y axis)
  71546. * @param z defines the third coordinates (on Z axis)
  71547. */
  71548. constructor(
  71549. /**
  71550. * Defines the first coordinates (on X axis)
  71551. */
  71552. x?: number,
  71553. /**
  71554. * Defines the second coordinates (on Y axis)
  71555. */
  71556. y?: number,
  71557. /**
  71558. * Defines the third coordinates (on Z axis)
  71559. */
  71560. z?: number);
  71561. /**
  71562. * Creates a string representation of the Vector3
  71563. * @returns a string with the Vector3 coordinates.
  71564. */
  71565. toString(): string;
  71566. /**
  71567. * Gets the class name
  71568. * @returns the string "Vector3"
  71569. */
  71570. getClassName(): string;
  71571. /**
  71572. * Creates the Vector3 hash code
  71573. * @returns a number which tends to be unique between Vector3 instances
  71574. */
  71575. getHashCode(): number;
  71576. /**
  71577. * Creates an array containing three elements : the coordinates of the Vector3
  71578. * @returns a new array of numbers
  71579. */
  71580. asArray(): number[];
  71581. /**
  71582. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  71583. * @param array defines the destination array
  71584. * @param index defines the offset in the destination array
  71585. * @returns the current Vector3
  71586. */
  71587. toArray(array: FloatArray, index?: number): Vector3;
  71588. /**
  71589. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  71590. * @returns a new Quaternion object, computed from the Vector3 coordinates
  71591. */
  71592. toQuaternion(): Quaternion;
  71593. /**
  71594. * Adds the given vector to the current Vector3
  71595. * @param otherVector defines the second operand
  71596. * @returns the current updated Vector3
  71597. */
  71598. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  71599. /**
  71600. * Adds the given coordinates to the current Vector3
  71601. * @param x defines the x coordinate of the operand
  71602. * @param y defines the y coordinate of the operand
  71603. * @param z defines the z coordinate of the operand
  71604. * @returns the current updated Vector3
  71605. */
  71606. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  71607. /**
  71608. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  71609. * @param otherVector defines the second operand
  71610. * @returns the resulting Vector3
  71611. */
  71612. add(otherVector: DeepImmutable<Vector3>): Vector3;
  71613. /**
  71614. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  71615. * @param otherVector defines the second operand
  71616. * @param result defines the Vector3 object where to store the result
  71617. * @returns the current Vector3
  71618. */
  71619. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  71620. /**
  71621. * Subtract the given vector from the current Vector3
  71622. * @param otherVector defines the second operand
  71623. * @returns the current updated Vector3
  71624. */
  71625. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  71626. /**
  71627. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  71628. * @param otherVector defines the second operand
  71629. * @returns the resulting Vector3
  71630. */
  71631. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  71632. /**
  71633. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  71634. * @param otherVector defines the second operand
  71635. * @param result defines the Vector3 object where to store the result
  71636. * @returns the current Vector3
  71637. */
  71638. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  71639. /**
  71640. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  71641. * @param x defines the x coordinate of the operand
  71642. * @param y defines the y coordinate of the operand
  71643. * @param z defines the z coordinate of the operand
  71644. * @returns the resulting Vector3
  71645. */
  71646. subtractFromFloats(x: number, y: number, z: number): Vector3;
  71647. /**
  71648. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  71649. * @param x defines the x coordinate of the operand
  71650. * @param y defines the y coordinate of the operand
  71651. * @param z defines the z coordinate of the operand
  71652. * @param result defines the Vector3 object where to store the result
  71653. * @returns the current Vector3
  71654. */
  71655. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  71656. /**
  71657. * Gets a new Vector3 set with the current Vector3 negated coordinates
  71658. * @returns a new Vector3
  71659. */
  71660. negate(): Vector3;
  71661. /**
  71662. * Multiplies the Vector3 coordinates by the float "scale"
  71663. * @param scale defines the multiplier factor
  71664. * @returns the current updated Vector3
  71665. */
  71666. scaleInPlace(scale: number): Vector3;
  71667. /**
  71668. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  71669. * @param scale defines the multiplier factor
  71670. * @returns a new Vector3
  71671. */
  71672. scale(scale: number): Vector3;
  71673. /**
  71674. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  71675. * @param scale defines the multiplier factor
  71676. * @param result defines the Vector3 object where to store the result
  71677. * @returns the current Vector3
  71678. */
  71679. scaleToRef(scale: number, result: Vector3): Vector3;
  71680. /**
  71681. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  71682. * @param scale defines the scale factor
  71683. * @param result defines the Vector3 object where to store the result
  71684. * @returns the unmodified current Vector3
  71685. */
  71686. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  71687. /**
  71688. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  71689. * @param otherVector defines the second operand
  71690. * @returns true if both vectors are equals
  71691. */
  71692. equals(otherVector: DeepImmutable<Vector3>): boolean;
  71693. /**
  71694. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  71695. * @param otherVector defines the second operand
  71696. * @param epsilon defines the minimal distance to define values as equals
  71697. * @returns true if both vectors are distant less than epsilon
  71698. */
  71699. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  71700. /**
  71701. * Returns true if the current Vector3 coordinates equals the given floats
  71702. * @param x defines the x coordinate of the operand
  71703. * @param y defines the y coordinate of the operand
  71704. * @param z defines the z coordinate of the operand
  71705. * @returns true if both vectors are equals
  71706. */
  71707. equalsToFloats(x: number, y: number, z: number): boolean;
  71708. /**
  71709. * Multiplies the current Vector3 coordinates by the given ones
  71710. * @param otherVector defines the second operand
  71711. * @returns the current updated Vector3
  71712. */
  71713. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  71714. /**
  71715. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  71716. * @param otherVector defines the second operand
  71717. * @returns the new Vector3
  71718. */
  71719. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  71720. /**
  71721. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  71722. * @param otherVector defines the second operand
  71723. * @param result defines the Vector3 object where to store the result
  71724. * @returns the current Vector3
  71725. */
  71726. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  71727. /**
  71728. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  71729. * @param x defines the x coordinate of the operand
  71730. * @param y defines the y coordinate of the operand
  71731. * @param z defines the z coordinate of the operand
  71732. * @returns the new Vector3
  71733. */
  71734. multiplyByFloats(x: number, y: number, z: number): Vector3;
  71735. /**
  71736. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  71737. * @param otherVector defines the second operand
  71738. * @returns the new Vector3
  71739. */
  71740. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  71741. /**
  71742. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  71743. * @param otherVector defines the second operand
  71744. * @param result defines the Vector3 object where to store the result
  71745. * @returns the current Vector3
  71746. */
  71747. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  71748. /**
  71749. * Divides the current Vector3 coordinates by the given ones.
  71750. * @param otherVector defines the second operand
  71751. * @returns the current updated Vector3
  71752. */
  71753. divideInPlace(otherVector: Vector3): Vector3;
  71754. /**
  71755. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  71756. * @param other defines the second operand
  71757. * @returns the current updated Vector3
  71758. */
  71759. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  71760. /**
  71761. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  71762. * @param other defines the second operand
  71763. * @returns the current updated Vector3
  71764. */
  71765. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  71766. /**
  71767. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  71768. * @param x defines the x coordinate of the operand
  71769. * @param y defines the y coordinate of the operand
  71770. * @param z defines the z coordinate of the operand
  71771. * @returns the current updated Vector3
  71772. */
  71773. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  71774. /**
  71775. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  71776. * @param x defines the x coordinate of the operand
  71777. * @param y defines the y coordinate of the operand
  71778. * @param z defines the z coordinate of the operand
  71779. * @returns the current updated Vector3
  71780. */
  71781. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  71782. /**
  71783. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  71784. * Check if is non uniform within a certain amount of decimal places to account for this
  71785. * @param epsilon the amount the values can differ
  71786. * @returns if the the vector is non uniform to a certain number of decimal places
  71787. */
  71788. isNonUniformWithinEpsilon(epsilon: number): boolean;
  71789. /**
  71790. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  71791. */
  71792. readonly isNonUniform: boolean;
  71793. /**
  71794. * Gets a new Vector3 from current Vector3 floored values
  71795. * @returns a new Vector3
  71796. */
  71797. floor(): Vector3;
  71798. /**
  71799. * Gets a new Vector3 from current Vector3 floored values
  71800. * @returns a new Vector3
  71801. */
  71802. fract(): Vector3;
  71803. /**
  71804. * Gets the length of the Vector3
  71805. * @returns the length of the Vector3
  71806. */
  71807. length(): number;
  71808. /**
  71809. * Gets the squared length of the Vector3
  71810. * @returns squared length of the Vector3
  71811. */
  71812. lengthSquared(): number;
  71813. /**
  71814. * Normalize the current Vector3.
  71815. * Please note that this is an in place operation.
  71816. * @returns the current updated Vector3
  71817. */
  71818. normalize(): Vector3;
  71819. /**
  71820. * Reorders the x y z properties of the vector in place
  71821. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  71822. * @returns the current updated vector
  71823. */
  71824. reorderInPlace(order: string): this;
  71825. /**
  71826. * Rotates the vector around 0,0,0 by a quaternion
  71827. * @param quaternion the rotation quaternion
  71828. * @param result vector to store the result
  71829. * @returns the resulting vector
  71830. */
  71831. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  71832. /**
  71833. * Rotates a vector around a given point
  71834. * @param quaternion the rotation quaternion
  71835. * @param point the point to rotate around
  71836. * @param result vector to store the result
  71837. * @returns the resulting vector
  71838. */
  71839. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  71840. /**
  71841. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  71842. * The cross product is then orthogonal to both current and "other"
  71843. * @param other defines the right operand
  71844. * @returns the cross product
  71845. */
  71846. cross(other: Vector3): Vector3;
  71847. /**
  71848. * Normalize the current Vector3 with the given input length.
  71849. * Please note that this is an in place operation.
  71850. * @param len the length of the vector
  71851. * @returns the current updated Vector3
  71852. */
  71853. normalizeFromLength(len: number): Vector3;
  71854. /**
  71855. * Normalize the current Vector3 to a new vector
  71856. * @returns the new Vector3
  71857. */
  71858. normalizeToNew(): Vector3;
  71859. /**
  71860. * Normalize the current Vector3 to the reference
  71861. * @param reference define the Vector3 to update
  71862. * @returns the updated Vector3
  71863. */
  71864. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  71865. /**
  71866. * Creates a new Vector3 copied from the current Vector3
  71867. * @returns the new Vector3
  71868. */
  71869. clone(): Vector3;
  71870. /**
  71871. * Copies the given vector coordinates to the current Vector3 ones
  71872. * @param source defines the source Vector3
  71873. * @returns the current updated Vector3
  71874. */
  71875. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  71876. /**
  71877. * Copies the given floats to the current Vector3 coordinates
  71878. * @param x defines the x coordinate of the operand
  71879. * @param y defines the y coordinate of the operand
  71880. * @param z defines the z coordinate of the operand
  71881. * @returns the current updated Vector3
  71882. */
  71883. copyFromFloats(x: number, y: number, z: number): Vector3;
  71884. /**
  71885. * Copies the given floats to the current Vector3 coordinates
  71886. * @param x defines the x coordinate of the operand
  71887. * @param y defines the y coordinate of the operand
  71888. * @param z defines the z coordinate of the operand
  71889. * @returns the current updated Vector3
  71890. */
  71891. set(x: number, y: number, z: number): Vector3;
  71892. /**
  71893. * Copies the given float to the current Vector3 coordinates
  71894. * @param v defines the x, y and z coordinates of the operand
  71895. * @returns the current updated Vector3
  71896. */
  71897. setAll(v: number): Vector3;
  71898. /**
  71899. * Get the clip factor between two vectors
  71900. * @param vector0 defines the first operand
  71901. * @param vector1 defines the second operand
  71902. * @param axis defines the axis to use
  71903. * @param size defines the size along the axis
  71904. * @returns the clip factor
  71905. */
  71906. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  71907. /**
  71908. * Get angle between two vectors
  71909. * @param vector0 angle between vector0 and vector1
  71910. * @param vector1 angle between vector0 and vector1
  71911. * @param normal direction of the normal
  71912. * @return the angle between vector0 and vector1
  71913. */
  71914. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  71915. /**
  71916. * Returns a new Vector3 set from the index "offset" of the given array
  71917. * @param array defines the source array
  71918. * @param offset defines the offset in the source array
  71919. * @returns the new Vector3
  71920. */
  71921. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  71922. /**
  71923. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  71924. * @param array defines the source array
  71925. * @param offset defines the offset in the source array
  71926. * @returns the new Vector3
  71927. * @deprecated Please use FromArray instead.
  71928. */
  71929. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  71930. /**
  71931. * Sets the given vector "result" with the element values from the index "offset" of the given array
  71932. * @param array defines the source array
  71933. * @param offset defines the offset in the source array
  71934. * @param result defines the Vector3 where to store the result
  71935. */
  71936. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  71937. /**
  71938. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  71939. * @param array defines the source array
  71940. * @param offset defines the offset in the source array
  71941. * @param result defines the Vector3 where to store the result
  71942. * @deprecated Please use FromArrayToRef instead.
  71943. */
  71944. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  71945. /**
  71946. * Sets the given vector "result" with the given floats.
  71947. * @param x defines the x coordinate of the source
  71948. * @param y defines the y coordinate of the source
  71949. * @param z defines the z coordinate of the source
  71950. * @param result defines the Vector3 where to store the result
  71951. */
  71952. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  71953. /**
  71954. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  71955. * @returns a new empty Vector3
  71956. */
  71957. static Zero(): Vector3;
  71958. /**
  71959. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  71960. * @returns a new unit Vector3
  71961. */
  71962. static One(): Vector3;
  71963. /**
  71964. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  71965. * @returns a new up Vector3
  71966. */
  71967. static Up(): Vector3;
  71968. /**
  71969. * Gets a up Vector3 that must not be updated
  71970. */
  71971. static readonly UpReadOnly: DeepImmutable<Vector3>;
  71972. /**
  71973. * Gets a zero Vector3 that must not be updated
  71974. */
  71975. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  71976. /**
  71977. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  71978. * @returns a new down Vector3
  71979. */
  71980. static Down(): Vector3;
  71981. /**
  71982. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  71983. * @returns a new forward Vector3
  71984. */
  71985. static Forward(): Vector3;
  71986. /**
  71987. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  71988. * @returns a new forward Vector3
  71989. */
  71990. static Backward(): Vector3;
  71991. /**
  71992. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  71993. * @returns a new right Vector3
  71994. */
  71995. static Right(): Vector3;
  71996. /**
  71997. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  71998. * @returns a new left Vector3
  71999. */
  72000. static Left(): Vector3;
  72001. /**
  72002. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  72003. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  72004. * @param vector defines the Vector3 to transform
  72005. * @param transformation defines the transformation matrix
  72006. * @returns the transformed Vector3
  72007. */
  72008. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  72009. /**
  72010. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  72011. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  72012. * @param vector defines the Vector3 to transform
  72013. * @param transformation defines the transformation matrix
  72014. * @param result defines the Vector3 where to store the result
  72015. */
  72016. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  72017. /**
  72018. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  72019. * This method computes tranformed coordinates only, not transformed direction vectors
  72020. * @param x define the x coordinate of the source vector
  72021. * @param y define the y coordinate of the source vector
  72022. * @param z define the z coordinate of the source vector
  72023. * @param transformation defines the transformation matrix
  72024. * @param result defines the Vector3 where to store the result
  72025. */
  72026. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  72027. /**
  72028. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  72029. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  72030. * @param vector defines the Vector3 to transform
  72031. * @param transformation defines the transformation matrix
  72032. * @returns the new Vector3
  72033. */
  72034. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  72035. /**
  72036. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  72037. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  72038. * @param vector defines the Vector3 to transform
  72039. * @param transformation defines the transformation matrix
  72040. * @param result defines the Vector3 where to store the result
  72041. */
  72042. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  72043. /**
  72044. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  72045. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  72046. * @param x define the x coordinate of the source vector
  72047. * @param y define the y coordinate of the source vector
  72048. * @param z define the z coordinate of the source vector
  72049. * @param transformation defines the transformation matrix
  72050. * @param result defines the Vector3 where to store the result
  72051. */
  72052. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  72053. /**
  72054. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  72055. * @param value1 defines the first control point
  72056. * @param value2 defines the second control point
  72057. * @param value3 defines the third control point
  72058. * @param value4 defines the fourth control point
  72059. * @param amount defines the amount on the spline to use
  72060. * @returns the new Vector3
  72061. */
  72062. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  72063. /**
  72064. * 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"
  72065. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  72066. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  72067. * @param value defines the current value
  72068. * @param min defines the lower range value
  72069. * @param max defines the upper range value
  72070. * @returns the new Vector3
  72071. */
  72072. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  72073. /**
  72074. * 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"
  72075. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  72076. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  72077. * @param value defines the current value
  72078. * @param min defines the lower range value
  72079. * @param max defines the upper range value
  72080. * @param result defines the Vector3 where to store the result
  72081. */
  72082. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  72083. /**
  72084. * Checks if a given vector is inside a specific range
  72085. * @param v defines the vector to test
  72086. * @param min defines the minimum range
  72087. * @param max defines the maximum range
  72088. */
  72089. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  72090. /**
  72091. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  72092. * @param value1 defines the first control point
  72093. * @param tangent1 defines the first tangent vector
  72094. * @param value2 defines the second control point
  72095. * @param tangent2 defines the second tangent vector
  72096. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  72097. * @returns the new Vector3
  72098. */
  72099. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  72100. /**
  72101. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  72102. * @param start defines the start value
  72103. * @param end defines the end value
  72104. * @param amount max defines amount between both (between 0 and 1)
  72105. * @returns the new Vector3
  72106. */
  72107. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  72108. /**
  72109. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  72110. * @param start defines the start value
  72111. * @param end defines the end value
  72112. * @param amount max defines amount between both (between 0 and 1)
  72113. * @param result defines the Vector3 where to store the result
  72114. */
  72115. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  72116. /**
  72117. * Returns the dot product (float) between the vectors "left" and "right"
  72118. * @param left defines the left operand
  72119. * @param right defines the right operand
  72120. * @returns the dot product
  72121. */
  72122. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  72123. /**
  72124. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  72125. * The cross product is then orthogonal to both "left" and "right"
  72126. * @param left defines the left operand
  72127. * @param right defines the right operand
  72128. * @returns the cross product
  72129. */
  72130. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  72131. /**
  72132. * Sets the given vector "result" with the cross product of "left" and "right"
  72133. * The cross product is then orthogonal to both "left" and "right"
  72134. * @param left defines the left operand
  72135. * @param right defines the right operand
  72136. * @param result defines the Vector3 where to store the result
  72137. */
  72138. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  72139. /**
  72140. * Returns a new Vector3 as the normalization of the given vector
  72141. * @param vector defines the Vector3 to normalize
  72142. * @returns the new Vector3
  72143. */
  72144. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  72145. /**
  72146. * Sets the given vector "result" with the normalization of the given first vector
  72147. * @param vector defines the Vector3 to normalize
  72148. * @param result defines the Vector3 where to store the result
  72149. */
  72150. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  72151. /**
  72152. * Project a Vector3 onto screen space
  72153. * @param vector defines the Vector3 to project
  72154. * @param world defines the world matrix to use
  72155. * @param transform defines the transform (view x projection) matrix to use
  72156. * @param viewport defines the screen viewport to use
  72157. * @returns the new Vector3
  72158. */
  72159. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  72160. /** @hidden */
  72161. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  72162. /**
  72163. * Unproject from screen space to object space
  72164. * @param source defines the screen space Vector3 to use
  72165. * @param viewportWidth defines the current width of the viewport
  72166. * @param viewportHeight defines the current height of the viewport
  72167. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  72168. * @param transform defines the transform (view x projection) matrix to use
  72169. * @returns the new Vector3
  72170. */
  72171. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  72172. /**
  72173. * Unproject from screen space to object space
  72174. * @param source defines the screen space Vector3 to use
  72175. * @param viewportWidth defines the current width of the viewport
  72176. * @param viewportHeight defines the current height of the viewport
  72177. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  72178. * @param view defines the view matrix to use
  72179. * @param projection defines the projection matrix to use
  72180. * @returns the new Vector3
  72181. */
  72182. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  72183. /**
  72184. * Unproject from screen space to object space
  72185. * @param source defines the screen space Vector3 to use
  72186. * @param viewportWidth defines the current width of the viewport
  72187. * @param viewportHeight defines the current height of the viewport
  72188. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  72189. * @param view defines the view matrix to use
  72190. * @param projection defines the projection matrix to use
  72191. * @param result defines the Vector3 where to store the result
  72192. */
  72193. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  72194. /**
  72195. * Unproject from screen space to object space
  72196. * @param sourceX defines the screen space x coordinate to use
  72197. * @param sourceY defines the screen space y coordinate to use
  72198. * @param sourceZ defines the screen space z coordinate to use
  72199. * @param viewportWidth defines the current width of the viewport
  72200. * @param viewportHeight defines the current height of the viewport
  72201. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  72202. * @param view defines the view matrix to use
  72203. * @param projection defines the projection matrix to use
  72204. * @param result defines the Vector3 where to store the result
  72205. */
  72206. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  72207. /**
  72208. * Gets the minimal coordinate values between two Vector3
  72209. * @param left defines the first operand
  72210. * @param right defines the second operand
  72211. * @returns the new Vector3
  72212. */
  72213. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  72214. /**
  72215. * Gets the maximal coordinate values between two Vector3
  72216. * @param left defines the first operand
  72217. * @param right defines the second operand
  72218. * @returns the new Vector3
  72219. */
  72220. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  72221. /**
  72222. * Returns the distance between the vectors "value1" and "value2"
  72223. * @param value1 defines the first operand
  72224. * @param value2 defines the second operand
  72225. * @returns the distance
  72226. */
  72227. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  72228. /**
  72229. * Returns the squared distance between the vectors "value1" and "value2"
  72230. * @param value1 defines the first operand
  72231. * @param value2 defines the second operand
  72232. * @returns the squared distance
  72233. */
  72234. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  72235. /**
  72236. * Returns a new Vector3 located at the center between "value1" and "value2"
  72237. * @param value1 defines the first operand
  72238. * @param value2 defines the second operand
  72239. * @returns the new Vector3
  72240. */
  72241. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  72242. /**
  72243. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  72244. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  72245. * to something in order to rotate it from its local system to the given target system
  72246. * Note: axis1, axis2 and axis3 are normalized during this operation
  72247. * @param axis1 defines the first axis
  72248. * @param axis2 defines the second axis
  72249. * @param axis3 defines the third axis
  72250. * @returns a new Vector3
  72251. */
  72252. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  72253. /**
  72254. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  72255. * @param axis1 defines the first axis
  72256. * @param axis2 defines the second axis
  72257. * @param axis3 defines the third axis
  72258. * @param ref defines the Vector3 where to store the result
  72259. */
  72260. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  72261. }
  72262. /**
  72263. * Vector4 class created for EulerAngle class conversion to Quaternion
  72264. */
  72265. export class Vector4 {
  72266. /** x value of the vector */
  72267. x: number;
  72268. /** y value of the vector */
  72269. y: number;
  72270. /** z value of the vector */
  72271. z: number;
  72272. /** w value of the vector */
  72273. w: number;
  72274. /**
  72275. * Creates a Vector4 object from the given floats.
  72276. * @param x x value of the vector
  72277. * @param y y value of the vector
  72278. * @param z z value of the vector
  72279. * @param w w value of the vector
  72280. */
  72281. constructor(
  72282. /** x value of the vector */
  72283. x: number,
  72284. /** y value of the vector */
  72285. y: number,
  72286. /** z value of the vector */
  72287. z: number,
  72288. /** w value of the vector */
  72289. w: number);
  72290. /**
  72291. * Returns the string with the Vector4 coordinates.
  72292. * @returns a string containing all the vector values
  72293. */
  72294. toString(): string;
  72295. /**
  72296. * Returns the string "Vector4".
  72297. * @returns "Vector4"
  72298. */
  72299. getClassName(): string;
  72300. /**
  72301. * Returns the Vector4 hash code.
  72302. * @returns a unique hash code
  72303. */
  72304. getHashCode(): number;
  72305. /**
  72306. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  72307. * @returns the resulting array
  72308. */
  72309. asArray(): number[];
  72310. /**
  72311. * Populates the given array from the given index with the Vector4 coordinates.
  72312. * @param array array to populate
  72313. * @param index index of the array to start at (default: 0)
  72314. * @returns the Vector4.
  72315. */
  72316. toArray(array: FloatArray, index?: number): Vector4;
  72317. /**
  72318. * Adds the given vector to the current Vector4.
  72319. * @param otherVector the vector to add
  72320. * @returns the updated Vector4.
  72321. */
  72322. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  72323. /**
  72324. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  72325. * @param otherVector the vector to add
  72326. * @returns the resulting vector
  72327. */
  72328. add(otherVector: DeepImmutable<Vector4>): Vector4;
  72329. /**
  72330. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  72331. * @param otherVector the vector to add
  72332. * @param result the vector to store the result
  72333. * @returns the current Vector4.
  72334. */
  72335. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  72336. /**
  72337. * Subtract in place the given vector from the current Vector4.
  72338. * @param otherVector the vector to subtract
  72339. * @returns the updated Vector4.
  72340. */
  72341. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  72342. /**
  72343. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  72344. * @param otherVector the vector to add
  72345. * @returns the new vector with the result
  72346. */
  72347. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  72348. /**
  72349. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  72350. * @param otherVector the vector to subtract
  72351. * @param result the vector to store the result
  72352. * @returns the current Vector4.
  72353. */
  72354. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  72355. /**
  72356. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  72357. */
  72358. /**
  72359. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  72360. * @param x value to subtract
  72361. * @param y value to subtract
  72362. * @param z value to subtract
  72363. * @param w value to subtract
  72364. * @returns new vector containing the result
  72365. */
  72366. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  72367. /**
  72368. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  72369. * @param x value to subtract
  72370. * @param y value to subtract
  72371. * @param z value to subtract
  72372. * @param w value to subtract
  72373. * @param result the vector to store the result in
  72374. * @returns the current Vector4.
  72375. */
  72376. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  72377. /**
  72378. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  72379. * @returns a new vector with the negated values
  72380. */
  72381. negate(): Vector4;
  72382. /**
  72383. * Multiplies the current Vector4 coordinates by scale (float).
  72384. * @param scale the number to scale with
  72385. * @returns the updated Vector4.
  72386. */
  72387. scaleInPlace(scale: number): Vector4;
  72388. /**
  72389. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  72390. * @param scale the number to scale with
  72391. * @returns a new vector with the result
  72392. */
  72393. scale(scale: number): Vector4;
  72394. /**
  72395. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  72396. * @param scale the number to scale with
  72397. * @param result a vector to store the result in
  72398. * @returns the current Vector4.
  72399. */
  72400. scaleToRef(scale: number, result: Vector4): Vector4;
  72401. /**
  72402. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  72403. * @param scale defines the scale factor
  72404. * @param result defines the Vector4 object where to store the result
  72405. * @returns the unmodified current Vector4
  72406. */
  72407. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  72408. /**
  72409. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  72410. * @param otherVector the vector to compare against
  72411. * @returns true if they are equal
  72412. */
  72413. equals(otherVector: DeepImmutable<Vector4>): boolean;
  72414. /**
  72415. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  72416. * @param otherVector vector to compare against
  72417. * @param epsilon (Default: very small number)
  72418. * @returns true if they are equal
  72419. */
  72420. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  72421. /**
  72422. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  72423. * @param x x value to compare against
  72424. * @param y y value to compare against
  72425. * @param z z value to compare against
  72426. * @param w w value to compare against
  72427. * @returns true if equal
  72428. */
  72429. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  72430. /**
  72431. * Multiplies in place the current Vector4 by the given one.
  72432. * @param otherVector vector to multiple with
  72433. * @returns the updated Vector4.
  72434. */
  72435. multiplyInPlace(otherVector: Vector4): Vector4;
  72436. /**
  72437. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  72438. * @param otherVector vector to multiple with
  72439. * @returns resulting new vector
  72440. */
  72441. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  72442. /**
  72443. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  72444. * @param otherVector vector to multiple with
  72445. * @param result vector to store the result
  72446. * @returns the current Vector4.
  72447. */
  72448. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  72449. /**
  72450. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  72451. * @param x x value multiply with
  72452. * @param y y value multiply with
  72453. * @param z z value multiply with
  72454. * @param w w value multiply with
  72455. * @returns resulting new vector
  72456. */
  72457. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  72458. /**
  72459. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  72460. * @param otherVector vector to devide with
  72461. * @returns resulting new vector
  72462. */
  72463. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  72464. /**
  72465. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  72466. * @param otherVector vector to devide with
  72467. * @param result vector to store the result
  72468. * @returns the current Vector4.
  72469. */
  72470. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  72471. /**
  72472. * Divides the current Vector3 coordinates by the given ones.
  72473. * @param otherVector vector to devide with
  72474. * @returns the updated Vector3.
  72475. */
  72476. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  72477. /**
  72478. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  72479. * @param other defines the second operand
  72480. * @returns the current updated Vector4
  72481. */
  72482. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  72483. /**
  72484. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  72485. * @param other defines the second operand
  72486. * @returns the current updated Vector4
  72487. */
  72488. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  72489. /**
  72490. * Gets a new Vector4 from current Vector4 floored values
  72491. * @returns a new Vector4
  72492. */
  72493. floor(): Vector4;
  72494. /**
  72495. * Gets a new Vector4 from current Vector3 floored values
  72496. * @returns a new Vector4
  72497. */
  72498. fract(): Vector4;
  72499. /**
  72500. * Returns the Vector4 length (float).
  72501. * @returns the length
  72502. */
  72503. length(): number;
  72504. /**
  72505. * Returns the Vector4 squared length (float).
  72506. * @returns the length squared
  72507. */
  72508. lengthSquared(): number;
  72509. /**
  72510. * Normalizes in place the Vector4.
  72511. * @returns the updated Vector4.
  72512. */
  72513. normalize(): Vector4;
  72514. /**
  72515. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  72516. * @returns this converted to a new vector3
  72517. */
  72518. toVector3(): Vector3;
  72519. /**
  72520. * Returns a new Vector4 copied from the current one.
  72521. * @returns the new cloned vector
  72522. */
  72523. clone(): Vector4;
  72524. /**
  72525. * Updates the current Vector4 with the given one coordinates.
  72526. * @param source the source vector to copy from
  72527. * @returns the updated Vector4.
  72528. */
  72529. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  72530. /**
  72531. * Updates the current Vector4 coordinates with the given floats.
  72532. * @param x float to copy from
  72533. * @param y float to copy from
  72534. * @param z float to copy from
  72535. * @param w float to copy from
  72536. * @returns the updated Vector4.
  72537. */
  72538. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  72539. /**
  72540. * Updates the current Vector4 coordinates with the given floats.
  72541. * @param x float to set from
  72542. * @param y float to set from
  72543. * @param z float to set from
  72544. * @param w float to set from
  72545. * @returns the updated Vector4.
  72546. */
  72547. set(x: number, y: number, z: number, w: number): Vector4;
  72548. /**
  72549. * Copies the given float to the current Vector3 coordinates
  72550. * @param v defines the x, y, z and w coordinates of the operand
  72551. * @returns the current updated Vector3
  72552. */
  72553. setAll(v: number): Vector4;
  72554. /**
  72555. * Returns a new Vector4 set from the starting index of the given array.
  72556. * @param array the array to pull values from
  72557. * @param offset the offset into the array to start at
  72558. * @returns the new vector
  72559. */
  72560. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  72561. /**
  72562. * Updates the given vector "result" from the starting index of the given array.
  72563. * @param array the array to pull values from
  72564. * @param offset the offset into the array to start at
  72565. * @param result the vector to store the result in
  72566. */
  72567. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  72568. /**
  72569. * Updates the given vector "result" from the starting index of the given Float32Array.
  72570. * @param array the array to pull values from
  72571. * @param offset the offset into the array to start at
  72572. * @param result the vector to store the result in
  72573. */
  72574. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  72575. /**
  72576. * Updates the given vector "result" coordinates from the given floats.
  72577. * @param x float to set from
  72578. * @param y float to set from
  72579. * @param z float to set from
  72580. * @param w float to set from
  72581. * @param result the vector to the floats in
  72582. */
  72583. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  72584. /**
  72585. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  72586. * @returns the new vector
  72587. */
  72588. static Zero(): Vector4;
  72589. /**
  72590. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  72591. * @returns the new vector
  72592. */
  72593. static One(): Vector4;
  72594. /**
  72595. * Returns a new normalized Vector4 from the given one.
  72596. * @param vector the vector to normalize
  72597. * @returns the vector
  72598. */
  72599. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  72600. /**
  72601. * Updates the given vector "result" from the normalization of the given one.
  72602. * @param vector the vector to normalize
  72603. * @param result the vector to store the result in
  72604. */
  72605. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  72606. /**
  72607. * Returns a vector with the minimum values from the left and right vectors
  72608. * @param left left vector to minimize
  72609. * @param right right vector to minimize
  72610. * @returns a new vector with the minimum of the left and right vector values
  72611. */
  72612. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  72613. /**
  72614. * Returns a vector with the maximum values from the left and right vectors
  72615. * @param left left vector to maximize
  72616. * @param right right vector to maximize
  72617. * @returns a new vector with the maximum of the left and right vector values
  72618. */
  72619. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  72620. /**
  72621. * Returns the distance (float) between the vectors "value1" and "value2".
  72622. * @param value1 value to calulate the distance between
  72623. * @param value2 value to calulate the distance between
  72624. * @return the distance between the two vectors
  72625. */
  72626. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  72627. /**
  72628. * Returns the squared distance (float) between the vectors "value1" and "value2".
  72629. * @param value1 value to calulate the distance between
  72630. * @param value2 value to calulate the distance between
  72631. * @return the distance between the two vectors squared
  72632. */
  72633. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  72634. /**
  72635. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  72636. * @param value1 value to calulate the center between
  72637. * @param value2 value to calulate the center between
  72638. * @return the center between the two vectors
  72639. */
  72640. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  72641. /**
  72642. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  72643. * This methods computes transformed normalized direction vectors only.
  72644. * @param vector the vector to transform
  72645. * @param transformation the transformation matrix to apply
  72646. * @returns the new vector
  72647. */
  72648. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  72649. /**
  72650. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  72651. * This methods computes transformed normalized direction vectors only.
  72652. * @param vector the vector to transform
  72653. * @param transformation the transformation matrix to apply
  72654. * @param result the vector to store the result in
  72655. */
  72656. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  72657. /**
  72658. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  72659. * This methods computes transformed normalized direction vectors only.
  72660. * @param x value to transform
  72661. * @param y value to transform
  72662. * @param z value to transform
  72663. * @param w value to transform
  72664. * @param transformation the transformation matrix to apply
  72665. * @param result the vector to store the results in
  72666. */
  72667. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  72668. /**
  72669. * Creates a new Vector4 from a Vector3
  72670. * @param source defines the source data
  72671. * @param w defines the 4th component (default is 0)
  72672. * @returns a new Vector4
  72673. */
  72674. static FromVector3(source: Vector3, w?: number): Vector4;
  72675. }
  72676. /**
  72677. * Class used to store quaternion data
  72678. * @see https://en.wikipedia.org/wiki/Quaternion
  72679. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  72680. */
  72681. export class Quaternion {
  72682. /** defines the first component (0 by default) */
  72683. x: number;
  72684. /** defines the second component (0 by default) */
  72685. y: number;
  72686. /** defines the third component (0 by default) */
  72687. z: number;
  72688. /** defines the fourth component (1.0 by default) */
  72689. w: number;
  72690. /**
  72691. * Creates a new Quaternion from the given floats
  72692. * @param x defines the first component (0 by default)
  72693. * @param y defines the second component (0 by default)
  72694. * @param z defines the third component (0 by default)
  72695. * @param w defines the fourth component (1.0 by default)
  72696. */
  72697. constructor(
  72698. /** defines the first component (0 by default) */
  72699. x?: number,
  72700. /** defines the second component (0 by default) */
  72701. y?: number,
  72702. /** defines the third component (0 by default) */
  72703. z?: number,
  72704. /** defines the fourth component (1.0 by default) */
  72705. w?: number);
  72706. /**
  72707. * Gets a string representation for the current quaternion
  72708. * @returns a string with the Quaternion coordinates
  72709. */
  72710. toString(): string;
  72711. /**
  72712. * Gets the class name of the quaternion
  72713. * @returns the string "Quaternion"
  72714. */
  72715. getClassName(): string;
  72716. /**
  72717. * Gets a hash code for this quaternion
  72718. * @returns the quaternion hash code
  72719. */
  72720. getHashCode(): number;
  72721. /**
  72722. * Copy the quaternion to an array
  72723. * @returns a new array populated with 4 elements from the quaternion coordinates
  72724. */
  72725. asArray(): number[];
  72726. /**
  72727. * Check if two quaternions are equals
  72728. * @param otherQuaternion defines the second operand
  72729. * @return true if the current quaternion and the given one coordinates are strictly equals
  72730. */
  72731. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  72732. /**
  72733. * Clone the current quaternion
  72734. * @returns a new quaternion copied from the current one
  72735. */
  72736. clone(): Quaternion;
  72737. /**
  72738. * Copy a quaternion to the current one
  72739. * @param other defines the other quaternion
  72740. * @returns the updated current quaternion
  72741. */
  72742. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  72743. /**
  72744. * Updates the current quaternion with the given float coordinates
  72745. * @param x defines the x coordinate
  72746. * @param y defines the y coordinate
  72747. * @param z defines the z coordinate
  72748. * @param w defines the w coordinate
  72749. * @returns the updated current quaternion
  72750. */
  72751. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  72752. /**
  72753. * Updates the current quaternion from the given float coordinates
  72754. * @param x defines the x coordinate
  72755. * @param y defines the y coordinate
  72756. * @param z defines the z coordinate
  72757. * @param w defines the w coordinate
  72758. * @returns the updated current quaternion
  72759. */
  72760. set(x: number, y: number, z: number, w: number): Quaternion;
  72761. /**
  72762. * Adds two quaternions
  72763. * @param other defines the second operand
  72764. * @returns a new quaternion as the addition result of the given one and the current quaternion
  72765. */
  72766. add(other: DeepImmutable<Quaternion>): Quaternion;
  72767. /**
  72768. * Add a quaternion to the current one
  72769. * @param other defines the quaternion to add
  72770. * @returns the current quaternion
  72771. */
  72772. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  72773. /**
  72774. * Subtract two quaternions
  72775. * @param other defines the second operand
  72776. * @returns a new quaternion as the subtraction result of the given one from the current one
  72777. */
  72778. subtract(other: Quaternion): Quaternion;
  72779. /**
  72780. * Multiplies the current quaternion by a scale factor
  72781. * @param value defines the scale factor
  72782. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  72783. */
  72784. scale(value: number): Quaternion;
  72785. /**
  72786. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  72787. * @param scale defines the scale factor
  72788. * @param result defines the Quaternion object where to store the result
  72789. * @returns the unmodified current quaternion
  72790. */
  72791. scaleToRef(scale: number, result: Quaternion): Quaternion;
  72792. /**
  72793. * Multiplies in place the current quaternion by a scale factor
  72794. * @param value defines the scale factor
  72795. * @returns the current modified quaternion
  72796. */
  72797. scaleInPlace(value: number): Quaternion;
  72798. /**
  72799. * Scale the current quaternion values by a factor and add the result to a given quaternion
  72800. * @param scale defines the scale factor
  72801. * @param result defines the Quaternion object where to store the result
  72802. * @returns the unmodified current quaternion
  72803. */
  72804. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  72805. /**
  72806. * Multiplies two quaternions
  72807. * @param q1 defines the second operand
  72808. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  72809. */
  72810. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  72811. /**
  72812. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  72813. * @param q1 defines the second operand
  72814. * @param result defines the target quaternion
  72815. * @returns the current quaternion
  72816. */
  72817. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  72818. /**
  72819. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  72820. * @param q1 defines the second operand
  72821. * @returns the currentupdated quaternion
  72822. */
  72823. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  72824. /**
  72825. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  72826. * @param ref defines the target quaternion
  72827. * @returns the current quaternion
  72828. */
  72829. conjugateToRef(ref: Quaternion): Quaternion;
  72830. /**
  72831. * Conjugates in place (1-q) the current quaternion
  72832. * @returns the current updated quaternion
  72833. */
  72834. conjugateInPlace(): Quaternion;
  72835. /**
  72836. * Conjugates in place (1-q) the current quaternion
  72837. * @returns a new quaternion
  72838. */
  72839. conjugate(): Quaternion;
  72840. /**
  72841. * Gets length of current quaternion
  72842. * @returns the quaternion length (float)
  72843. */
  72844. length(): number;
  72845. /**
  72846. * Normalize in place the current quaternion
  72847. * @returns the current updated quaternion
  72848. */
  72849. normalize(): Quaternion;
  72850. /**
  72851. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  72852. * @param order is a reserved parameter and is ignore for now
  72853. * @returns a new Vector3 containing the Euler angles
  72854. */
  72855. toEulerAngles(order?: string): Vector3;
  72856. /**
  72857. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  72858. * @param result defines the vector which will be filled with the Euler angles
  72859. * @param order is a reserved parameter and is ignore for now
  72860. * @returns the current unchanged quaternion
  72861. */
  72862. toEulerAnglesToRef(result: Vector3): Quaternion;
  72863. /**
  72864. * Updates the given rotation matrix with the current quaternion values
  72865. * @param result defines the target matrix
  72866. * @returns the current unchanged quaternion
  72867. */
  72868. toRotationMatrix(result: Matrix): Quaternion;
  72869. /**
  72870. * Updates the current quaternion from the given rotation matrix values
  72871. * @param matrix defines the source matrix
  72872. * @returns the current updated quaternion
  72873. */
  72874. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  72875. /**
  72876. * Creates a new quaternion from a rotation matrix
  72877. * @param matrix defines the source matrix
  72878. * @returns a new quaternion created from the given rotation matrix values
  72879. */
  72880. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  72881. /**
  72882. * Updates the given quaternion with the given rotation matrix values
  72883. * @param matrix defines the source matrix
  72884. * @param result defines the target quaternion
  72885. */
  72886. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  72887. /**
  72888. * Returns the dot product (float) between the quaternions "left" and "right"
  72889. * @param left defines the left operand
  72890. * @param right defines the right operand
  72891. * @returns the dot product
  72892. */
  72893. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  72894. /**
  72895. * Checks if the two quaternions are close to each other
  72896. * @param quat0 defines the first quaternion to check
  72897. * @param quat1 defines the second quaternion to check
  72898. * @returns true if the two quaternions are close to each other
  72899. */
  72900. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  72901. /**
  72902. * Creates an empty quaternion
  72903. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  72904. */
  72905. static Zero(): Quaternion;
  72906. /**
  72907. * Inverse a given quaternion
  72908. * @param q defines the source quaternion
  72909. * @returns a new quaternion as the inverted current quaternion
  72910. */
  72911. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  72912. /**
  72913. * Inverse a given quaternion
  72914. * @param q defines the source quaternion
  72915. * @param result the quaternion the result will be stored in
  72916. * @returns the result quaternion
  72917. */
  72918. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  72919. /**
  72920. * Creates an identity quaternion
  72921. * @returns the identity quaternion
  72922. */
  72923. static Identity(): Quaternion;
  72924. /**
  72925. * Gets a boolean indicating if the given quaternion is identity
  72926. * @param quaternion defines the quaternion to check
  72927. * @returns true if the quaternion is identity
  72928. */
  72929. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  72930. /**
  72931. * Creates a quaternion from a rotation around an axis
  72932. * @param axis defines the axis to use
  72933. * @param angle defines the angle to use
  72934. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  72935. */
  72936. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  72937. /**
  72938. * Creates a rotation around an axis and stores it into the given quaternion
  72939. * @param axis defines the axis to use
  72940. * @param angle defines the angle to use
  72941. * @param result defines the target quaternion
  72942. * @returns the target quaternion
  72943. */
  72944. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  72945. /**
  72946. * Creates a new quaternion from data stored into an array
  72947. * @param array defines the data source
  72948. * @param offset defines the offset in the source array where the data starts
  72949. * @returns a new quaternion
  72950. */
  72951. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  72952. /**
  72953. * Create a quaternion from Euler rotation angles
  72954. * @param x Pitch
  72955. * @param y Yaw
  72956. * @param z Roll
  72957. * @returns the new Quaternion
  72958. */
  72959. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  72960. /**
  72961. * Updates a quaternion from Euler rotation angles
  72962. * @param x Pitch
  72963. * @param y Yaw
  72964. * @param z Roll
  72965. * @param result the quaternion to store the result
  72966. * @returns the updated quaternion
  72967. */
  72968. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  72969. /**
  72970. * Create a quaternion from Euler rotation vector
  72971. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  72972. * @returns the new Quaternion
  72973. */
  72974. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  72975. /**
  72976. * Updates a quaternion from Euler rotation vector
  72977. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  72978. * @param result the quaternion to store the result
  72979. * @returns the updated quaternion
  72980. */
  72981. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  72982. /**
  72983. * Creates a new quaternion from the given Euler float angles (y, x, z)
  72984. * @param yaw defines the rotation around Y axis
  72985. * @param pitch defines the rotation around X axis
  72986. * @param roll defines the rotation around Z axis
  72987. * @returns the new quaternion
  72988. */
  72989. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  72990. /**
  72991. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  72992. * @param yaw defines the rotation around Y axis
  72993. * @param pitch defines the rotation around X axis
  72994. * @param roll defines the rotation around Z axis
  72995. * @param result defines the target quaternion
  72996. */
  72997. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  72998. /**
  72999. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  73000. * @param alpha defines the rotation around first axis
  73001. * @param beta defines the rotation around second axis
  73002. * @param gamma defines the rotation around third axis
  73003. * @returns the new quaternion
  73004. */
  73005. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  73006. /**
  73007. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  73008. * @param alpha defines the rotation around first axis
  73009. * @param beta defines the rotation around second axis
  73010. * @param gamma defines the rotation around third axis
  73011. * @param result defines the target quaternion
  73012. */
  73013. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  73014. /**
  73015. * 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)
  73016. * @param axis1 defines the first axis
  73017. * @param axis2 defines the second axis
  73018. * @param axis3 defines the third axis
  73019. * @returns the new quaternion
  73020. */
  73021. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  73022. /**
  73023. * 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
  73024. * @param axis1 defines the first axis
  73025. * @param axis2 defines the second axis
  73026. * @param axis3 defines the third axis
  73027. * @param ref defines the target quaternion
  73028. */
  73029. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  73030. /**
  73031. * Interpolates between two quaternions
  73032. * @param left defines first quaternion
  73033. * @param right defines second quaternion
  73034. * @param amount defines the gradient to use
  73035. * @returns the new interpolated quaternion
  73036. */
  73037. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  73038. /**
  73039. * Interpolates between two quaternions and stores it into a target quaternion
  73040. * @param left defines first quaternion
  73041. * @param right defines second quaternion
  73042. * @param amount defines the gradient to use
  73043. * @param result defines the target quaternion
  73044. */
  73045. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  73046. /**
  73047. * Interpolate between two quaternions using Hermite interpolation
  73048. * @param value1 defines first quaternion
  73049. * @param tangent1 defines the incoming tangent
  73050. * @param value2 defines second quaternion
  73051. * @param tangent2 defines the outgoing tangent
  73052. * @param amount defines the target quaternion
  73053. * @returns the new interpolated quaternion
  73054. */
  73055. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  73056. }
  73057. /**
  73058. * Class used to store matrix data (4x4)
  73059. */
  73060. export class Matrix {
  73061. private static _updateFlagSeed;
  73062. private static _identityReadOnly;
  73063. private _isIdentity;
  73064. private _isIdentityDirty;
  73065. private _isIdentity3x2;
  73066. private _isIdentity3x2Dirty;
  73067. /**
  73068. * Gets the update flag of the matrix which is an unique number for the matrix.
  73069. * It will be incremented every time the matrix data change.
  73070. * You can use it to speed the comparison between two versions of the same matrix.
  73071. */
  73072. updateFlag: number;
  73073. private readonly _m;
  73074. /**
  73075. * Gets the internal data of the matrix
  73076. */
  73077. readonly m: DeepImmutable<Float32Array>;
  73078. /** @hidden */
  73079. _markAsUpdated(): void;
  73080. /** @hidden */
  73081. private _updateIdentityStatus;
  73082. /**
  73083. * Creates an empty matrix (filled with zeros)
  73084. */
  73085. constructor();
  73086. /**
  73087. * Check if the current matrix is identity
  73088. * @returns true is the matrix is the identity matrix
  73089. */
  73090. isIdentity(): boolean;
  73091. /**
  73092. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  73093. * @returns true is the matrix is the identity matrix
  73094. */
  73095. isIdentityAs3x2(): boolean;
  73096. /**
  73097. * Gets the determinant of the matrix
  73098. * @returns the matrix determinant
  73099. */
  73100. determinant(): number;
  73101. /**
  73102. * Returns the matrix as a Float32Array
  73103. * @returns the matrix underlying array
  73104. */
  73105. toArray(): DeepImmutable<Float32Array>;
  73106. /**
  73107. * Returns the matrix as a Float32Array
  73108. * @returns the matrix underlying array.
  73109. */
  73110. asArray(): DeepImmutable<Float32Array>;
  73111. /**
  73112. * Inverts the current matrix in place
  73113. * @returns the current inverted matrix
  73114. */
  73115. invert(): Matrix;
  73116. /**
  73117. * Sets all the matrix elements to zero
  73118. * @returns the current matrix
  73119. */
  73120. reset(): Matrix;
  73121. /**
  73122. * Adds the current matrix with a second one
  73123. * @param other defines the matrix to add
  73124. * @returns a new matrix as the addition of the current matrix and the given one
  73125. */
  73126. add(other: DeepImmutable<Matrix>): Matrix;
  73127. /**
  73128. * Sets the given matrix "result" to the addition of the current matrix and the given one
  73129. * @param other defines the matrix to add
  73130. * @param result defines the target matrix
  73131. * @returns the current matrix
  73132. */
  73133. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  73134. /**
  73135. * Adds in place the given matrix to the current matrix
  73136. * @param other defines the second operand
  73137. * @returns the current updated matrix
  73138. */
  73139. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  73140. /**
  73141. * Sets the given matrix to the current inverted Matrix
  73142. * @param other defines the target matrix
  73143. * @returns the unmodified current matrix
  73144. */
  73145. invertToRef(other: Matrix): Matrix;
  73146. /**
  73147. * add a value at the specified position in the current Matrix
  73148. * @param index the index of the value within the matrix. between 0 and 15.
  73149. * @param value the value to be added
  73150. * @returns the current updated matrix
  73151. */
  73152. addAtIndex(index: number, value: number): Matrix;
  73153. /**
  73154. * mutiply the specified position in the current Matrix by a value
  73155. * @param index the index of the value within the matrix. between 0 and 15.
  73156. * @param value the value to be added
  73157. * @returns the current updated matrix
  73158. */
  73159. multiplyAtIndex(index: number, value: number): Matrix;
  73160. /**
  73161. * Inserts the translation vector (using 3 floats) in the current matrix
  73162. * @param x defines the 1st component of the translation
  73163. * @param y defines the 2nd component of the translation
  73164. * @param z defines the 3rd component of the translation
  73165. * @returns the current updated matrix
  73166. */
  73167. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  73168. /**
  73169. * Adds the translation vector (using 3 floats) in the current matrix
  73170. * @param x defines the 1st component of the translation
  73171. * @param y defines the 2nd component of the translation
  73172. * @param z defines the 3rd component of the translation
  73173. * @returns the current updated matrix
  73174. */
  73175. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  73176. /**
  73177. * Inserts the translation vector in the current matrix
  73178. * @param vector3 defines the translation to insert
  73179. * @returns the current updated matrix
  73180. */
  73181. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  73182. /**
  73183. * Gets the translation value of the current matrix
  73184. * @returns a new Vector3 as the extracted translation from the matrix
  73185. */
  73186. getTranslation(): Vector3;
  73187. /**
  73188. * Fill a Vector3 with the extracted translation from the matrix
  73189. * @param result defines the Vector3 where to store the translation
  73190. * @returns the current matrix
  73191. */
  73192. getTranslationToRef(result: Vector3): Matrix;
  73193. /**
  73194. * Remove rotation and scaling part from the matrix
  73195. * @returns the updated matrix
  73196. */
  73197. removeRotationAndScaling(): Matrix;
  73198. /**
  73199. * Multiply two matrices
  73200. * @param other defines the second operand
  73201. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  73202. */
  73203. multiply(other: DeepImmutable<Matrix>): Matrix;
  73204. /**
  73205. * Copy the current matrix from the given one
  73206. * @param other defines the source matrix
  73207. * @returns the current updated matrix
  73208. */
  73209. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  73210. /**
  73211. * Populates the given array from the starting index with the current matrix values
  73212. * @param array defines the target array
  73213. * @param offset defines the offset in the target array where to start storing values
  73214. * @returns the current matrix
  73215. */
  73216. copyToArray(array: Float32Array, offset?: number): Matrix;
  73217. /**
  73218. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  73219. * @param other defines the second operand
  73220. * @param result defines the matrix where to store the multiplication
  73221. * @returns the current matrix
  73222. */
  73223. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  73224. /**
  73225. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  73226. * @param other defines the second operand
  73227. * @param result defines the array where to store the multiplication
  73228. * @param offset defines the offset in the target array where to start storing values
  73229. * @returns the current matrix
  73230. */
  73231. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  73232. /**
  73233. * Check equality between this matrix and a second one
  73234. * @param value defines the second matrix to compare
  73235. * @returns true is the current matrix and the given one values are strictly equal
  73236. */
  73237. equals(value: DeepImmutable<Matrix>): boolean;
  73238. /**
  73239. * Clone the current matrix
  73240. * @returns a new matrix from the current matrix
  73241. */
  73242. clone(): Matrix;
  73243. /**
  73244. * Returns the name of the current matrix class
  73245. * @returns the string "Matrix"
  73246. */
  73247. getClassName(): string;
  73248. /**
  73249. * Gets the hash code of the current matrix
  73250. * @returns the hash code
  73251. */
  73252. getHashCode(): number;
  73253. /**
  73254. * Decomposes the current Matrix into a translation, rotation and scaling components
  73255. * @param scale defines the scale vector3 given as a reference to update
  73256. * @param rotation defines the rotation quaternion given as a reference to update
  73257. * @param translation defines the translation vector3 given as a reference to update
  73258. * @returns true if operation was successful
  73259. */
  73260. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  73261. /**
  73262. * Gets specific row of the matrix
  73263. * @param index defines the number of the row to get
  73264. * @returns the index-th row of the current matrix as a new Vector4
  73265. */
  73266. getRow(index: number): Nullable<Vector4>;
  73267. /**
  73268. * Sets the index-th row of the current matrix to the vector4 values
  73269. * @param index defines the number of the row to set
  73270. * @param row defines the target vector4
  73271. * @returns the updated current matrix
  73272. */
  73273. setRow(index: number, row: Vector4): Matrix;
  73274. /**
  73275. * Compute the transpose of the matrix
  73276. * @returns the new transposed matrix
  73277. */
  73278. transpose(): Matrix;
  73279. /**
  73280. * Compute the transpose of the matrix and store it in a given matrix
  73281. * @param result defines the target matrix
  73282. * @returns the current matrix
  73283. */
  73284. transposeToRef(result: Matrix): Matrix;
  73285. /**
  73286. * Sets the index-th row of the current matrix with the given 4 x float values
  73287. * @param index defines the row index
  73288. * @param x defines the x component to set
  73289. * @param y defines the y component to set
  73290. * @param z defines the z component to set
  73291. * @param w defines the w component to set
  73292. * @returns the updated current matrix
  73293. */
  73294. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  73295. /**
  73296. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  73297. * @param scale defines the scale factor
  73298. * @returns a new matrix
  73299. */
  73300. scale(scale: number): Matrix;
  73301. /**
  73302. * Scale the current matrix values by a factor to a given result matrix
  73303. * @param scale defines the scale factor
  73304. * @param result defines the matrix to store the result
  73305. * @returns the current matrix
  73306. */
  73307. scaleToRef(scale: number, result: Matrix): Matrix;
  73308. /**
  73309. * Scale the current matrix values by a factor and add the result to a given matrix
  73310. * @param scale defines the scale factor
  73311. * @param result defines the Matrix to store the result
  73312. * @returns the current matrix
  73313. */
  73314. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  73315. /**
  73316. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  73317. * @param ref matrix to store the result
  73318. */
  73319. toNormalMatrix(ref: Matrix): void;
  73320. /**
  73321. * Gets only rotation part of the current matrix
  73322. * @returns a new matrix sets to the extracted rotation matrix from the current one
  73323. */
  73324. getRotationMatrix(): Matrix;
  73325. /**
  73326. * Extracts the rotation matrix from the current one and sets it as the given "result"
  73327. * @param result defines the target matrix to store data to
  73328. * @returns the current matrix
  73329. */
  73330. getRotationMatrixToRef(result: Matrix): Matrix;
  73331. /**
  73332. * Toggles model matrix from being right handed to left handed in place and vice versa
  73333. */
  73334. toggleModelMatrixHandInPlace(): void;
  73335. /**
  73336. * Toggles projection matrix from being right handed to left handed in place and vice versa
  73337. */
  73338. toggleProjectionMatrixHandInPlace(): void;
  73339. /**
  73340. * Creates a matrix from an array
  73341. * @param array defines the source array
  73342. * @param offset defines an offset in the source array
  73343. * @returns a new Matrix set from the starting index of the given array
  73344. */
  73345. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  73346. /**
  73347. * Copy the content of an array into a given matrix
  73348. * @param array defines the source array
  73349. * @param offset defines an offset in the source array
  73350. * @param result defines the target matrix
  73351. */
  73352. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  73353. /**
  73354. * Stores an array into a matrix after having multiplied each component by a given factor
  73355. * @param array defines the source array
  73356. * @param offset defines the offset in the source array
  73357. * @param scale defines the scaling factor
  73358. * @param result defines the target matrix
  73359. */
  73360. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  73361. /**
  73362. * Gets an identity matrix that must not be updated
  73363. */
  73364. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  73365. /**
  73366. * Stores a list of values (16) inside a given matrix
  73367. * @param initialM11 defines 1st value of 1st row
  73368. * @param initialM12 defines 2nd value of 1st row
  73369. * @param initialM13 defines 3rd value of 1st row
  73370. * @param initialM14 defines 4th value of 1st row
  73371. * @param initialM21 defines 1st value of 2nd row
  73372. * @param initialM22 defines 2nd value of 2nd row
  73373. * @param initialM23 defines 3rd value of 2nd row
  73374. * @param initialM24 defines 4th value of 2nd row
  73375. * @param initialM31 defines 1st value of 3rd row
  73376. * @param initialM32 defines 2nd value of 3rd row
  73377. * @param initialM33 defines 3rd value of 3rd row
  73378. * @param initialM34 defines 4th value of 3rd row
  73379. * @param initialM41 defines 1st value of 4th row
  73380. * @param initialM42 defines 2nd value of 4th row
  73381. * @param initialM43 defines 3rd value of 4th row
  73382. * @param initialM44 defines 4th value of 4th row
  73383. * @param result defines the target matrix
  73384. */
  73385. 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;
  73386. /**
  73387. * Creates new matrix from a list of values (16)
  73388. * @param initialM11 defines 1st value of 1st row
  73389. * @param initialM12 defines 2nd value of 1st row
  73390. * @param initialM13 defines 3rd value of 1st row
  73391. * @param initialM14 defines 4th value of 1st row
  73392. * @param initialM21 defines 1st value of 2nd row
  73393. * @param initialM22 defines 2nd value of 2nd row
  73394. * @param initialM23 defines 3rd value of 2nd row
  73395. * @param initialM24 defines 4th value of 2nd row
  73396. * @param initialM31 defines 1st value of 3rd row
  73397. * @param initialM32 defines 2nd value of 3rd row
  73398. * @param initialM33 defines 3rd value of 3rd row
  73399. * @param initialM34 defines 4th value of 3rd row
  73400. * @param initialM41 defines 1st value of 4th row
  73401. * @param initialM42 defines 2nd value of 4th row
  73402. * @param initialM43 defines 3rd value of 4th row
  73403. * @param initialM44 defines 4th value of 4th row
  73404. * @returns the new matrix
  73405. */
  73406. 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;
  73407. /**
  73408. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  73409. * @param scale defines the scale vector3
  73410. * @param rotation defines the rotation quaternion
  73411. * @param translation defines the translation vector3
  73412. * @returns a new matrix
  73413. */
  73414. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  73415. /**
  73416. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  73417. * @param scale defines the scale vector3
  73418. * @param rotation defines the rotation quaternion
  73419. * @param translation defines the translation vector3
  73420. * @param result defines the target matrix
  73421. */
  73422. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  73423. /**
  73424. * Creates a new identity matrix
  73425. * @returns a new identity matrix
  73426. */
  73427. static Identity(): Matrix;
  73428. /**
  73429. * Creates a new identity matrix and stores the result in a given matrix
  73430. * @param result defines the target matrix
  73431. */
  73432. static IdentityToRef(result: Matrix): void;
  73433. /**
  73434. * Creates a new zero matrix
  73435. * @returns a new zero matrix
  73436. */
  73437. static Zero(): Matrix;
  73438. /**
  73439. * Creates a new rotation matrix for "angle" radians around the X axis
  73440. * @param angle defines the angle (in radians) to use
  73441. * @return the new matrix
  73442. */
  73443. static RotationX(angle: number): Matrix;
  73444. /**
  73445. * Creates a new matrix as the invert of a given matrix
  73446. * @param source defines the source matrix
  73447. * @returns the new matrix
  73448. */
  73449. static Invert(source: DeepImmutable<Matrix>): Matrix;
  73450. /**
  73451. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  73452. * @param angle defines the angle (in radians) to use
  73453. * @param result defines the target matrix
  73454. */
  73455. static RotationXToRef(angle: number, result: Matrix): void;
  73456. /**
  73457. * Creates a new rotation matrix for "angle" radians around the Y axis
  73458. * @param angle defines the angle (in radians) to use
  73459. * @return the new matrix
  73460. */
  73461. static RotationY(angle: number): Matrix;
  73462. /**
  73463. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  73464. * @param angle defines the angle (in radians) to use
  73465. * @param result defines the target matrix
  73466. */
  73467. static RotationYToRef(angle: number, result: Matrix): void;
  73468. /**
  73469. * Creates a new rotation matrix for "angle" radians around the Z axis
  73470. * @param angle defines the angle (in radians) to use
  73471. * @return the new matrix
  73472. */
  73473. static RotationZ(angle: number): Matrix;
  73474. /**
  73475. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  73476. * @param angle defines the angle (in radians) to use
  73477. * @param result defines the target matrix
  73478. */
  73479. static RotationZToRef(angle: number, result: Matrix): void;
  73480. /**
  73481. * Creates a new rotation matrix for "angle" radians around the given axis
  73482. * @param axis defines the axis to use
  73483. * @param angle defines the angle (in radians) to use
  73484. * @return the new matrix
  73485. */
  73486. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  73487. /**
  73488. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  73489. * @param axis defines the axis to use
  73490. * @param angle defines the angle (in radians) to use
  73491. * @param result defines the target matrix
  73492. */
  73493. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  73494. /**
  73495. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  73496. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  73497. * @param from defines the vector to align
  73498. * @param to defines the vector to align to
  73499. * @param result defines the target matrix
  73500. */
  73501. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  73502. /**
  73503. * Creates a rotation matrix
  73504. * @param yaw defines the yaw angle in radians (Y axis)
  73505. * @param pitch defines the pitch angle in radians (X axis)
  73506. * @param roll defines the roll angle in radians (X axis)
  73507. * @returns the new rotation matrix
  73508. */
  73509. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  73510. /**
  73511. * Creates a rotation matrix and stores it in a given matrix
  73512. * @param yaw defines the yaw angle in radians (Y axis)
  73513. * @param pitch defines the pitch angle in radians (X axis)
  73514. * @param roll defines the roll angle in radians (X axis)
  73515. * @param result defines the target matrix
  73516. */
  73517. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  73518. /**
  73519. * Creates a scaling matrix
  73520. * @param x defines the scale factor on X axis
  73521. * @param y defines the scale factor on Y axis
  73522. * @param z defines the scale factor on Z axis
  73523. * @returns the new matrix
  73524. */
  73525. static Scaling(x: number, y: number, z: number): Matrix;
  73526. /**
  73527. * Creates a scaling matrix and stores it in a given matrix
  73528. * @param x defines the scale factor on X axis
  73529. * @param y defines the scale factor on Y axis
  73530. * @param z defines the scale factor on Z axis
  73531. * @param result defines the target matrix
  73532. */
  73533. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  73534. /**
  73535. * Creates a translation matrix
  73536. * @param x defines the translation on X axis
  73537. * @param y defines the translation on Y axis
  73538. * @param z defines the translationon Z axis
  73539. * @returns the new matrix
  73540. */
  73541. static Translation(x: number, y: number, z: number): Matrix;
  73542. /**
  73543. * Creates a translation matrix and stores it in a given matrix
  73544. * @param x defines the translation on X axis
  73545. * @param y defines the translation on Y axis
  73546. * @param z defines the translationon Z axis
  73547. * @param result defines the target matrix
  73548. */
  73549. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  73550. /**
  73551. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  73552. * @param startValue defines the start value
  73553. * @param endValue defines the end value
  73554. * @param gradient defines the gradient factor
  73555. * @returns the new matrix
  73556. */
  73557. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  73558. /**
  73559. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  73560. * @param startValue defines the start value
  73561. * @param endValue defines the end value
  73562. * @param gradient defines the gradient factor
  73563. * @param result defines the Matrix object where to store data
  73564. */
  73565. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  73566. /**
  73567. * Builds a new matrix whose values are computed by:
  73568. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  73569. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  73570. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  73571. * @param startValue defines the first matrix
  73572. * @param endValue defines the second matrix
  73573. * @param gradient defines the gradient between the two matrices
  73574. * @returns the new matrix
  73575. */
  73576. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  73577. /**
  73578. * Update a matrix to values which are computed by:
  73579. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  73580. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  73581. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  73582. * @param startValue defines the first matrix
  73583. * @param endValue defines the second matrix
  73584. * @param gradient defines the gradient between the two matrices
  73585. * @param result defines the target matrix
  73586. */
  73587. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  73588. /**
  73589. * 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"
  73590. * This function works in left handed mode
  73591. * @param eye defines the final position of the entity
  73592. * @param target defines where the entity should look at
  73593. * @param up defines the up vector for the entity
  73594. * @returns the new matrix
  73595. */
  73596. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  73597. /**
  73598. * 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".
  73599. * This function works in left handed mode
  73600. * @param eye defines the final position of the entity
  73601. * @param target defines where the entity should look at
  73602. * @param up defines the up vector for the entity
  73603. * @param result defines the target matrix
  73604. */
  73605. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  73606. /**
  73607. * 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"
  73608. * This function works in right handed mode
  73609. * @param eye defines the final position of the entity
  73610. * @param target defines where the entity should look at
  73611. * @param up defines the up vector for the entity
  73612. * @returns the new matrix
  73613. */
  73614. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  73615. /**
  73616. * 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".
  73617. * This function works in right handed mode
  73618. * @param eye defines the final position of the entity
  73619. * @param target defines where the entity should look at
  73620. * @param up defines the up vector for the entity
  73621. * @param result defines the target matrix
  73622. */
  73623. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  73624. /**
  73625. * Create a left-handed orthographic projection matrix
  73626. * @param width defines the viewport width
  73627. * @param height defines the viewport height
  73628. * @param znear defines the near clip plane
  73629. * @param zfar defines the far clip plane
  73630. * @returns a new matrix as a left-handed orthographic projection matrix
  73631. */
  73632. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  73633. /**
  73634. * Store a left-handed orthographic projection to a given matrix
  73635. * @param width defines the viewport width
  73636. * @param height defines the viewport height
  73637. * @param znear defines the near clip plane
  73638. * @param zfar defines the far clip plane
  73639. * @param result defines the target matrix
  73640. */
  73641. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  73642. /**
  73643. * Create a left-handed orthographic projection matrix
  73644. * @param left defines the viewport left coordinate
  73645. * @param right defines the viewport right coordinate
  73646. * @param bottom defines the viewport bottom coordinate
  73647. * @param top defines the viewport top coordinate
  73648. * @param znear defines the near clip plane
  73649. * @param zfar defines the far clip plane
  73650. * @returns a new matrix as a left-handed orthographic projection matrix
  73651. */
  73652. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  73653. /**
  73654. * Stores a left-handed orthographic projection into a given matrix
  73655. * @param left defines the viewport left coordinate
  73656. * @param right defines the viewport right coordinate
  73657. * @param bottom defines the viewport bottom coordinate
  73658. * @param top defines the viewport top coordinate
  73659. * @param znear defines the near clip plane
  73660. * @param zfar defines the far clip plane
  73661. * @param result defines the target matrix
  73662. */
  73663. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  73664. /**
  73665. * Creates a right-handed orthographic projection matrix
  73666. * @param left defines the viewport left coordinate
  73667. * @param right defines the viewport right coordinate
  73668. * @param bottom defines the viewport bottom coordinate
  73669. * @param top defines the viewport top coordinate
  73670. * @param znear defines the near clip plane
  73671. * @param zfar defines the far clip plane
  73672. * @returns a new matrix as a right-handed orthographic projection matrix
  73673. */
  73674. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  73675. /**
  73676. * Stores a right-handed orthographic projection into a given matrix
  73677. * @param left defines the viewport left coordinate
  73678. * @param right defines the viewport right coordinate
  73679. * @param bottom defines the viewport bottom coordinate
  73680. * @param top defines the viewport top coordinate
  73681. * @param znear defines the near clip plane
  73682. * @param zfar defines the far clip plane
  73683. * @param result defines the target matrix
  73684. */
  73685. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  73686. /**
  73687. * Creates a left-handed perspective projection matrix
  73688. * @param width defines the viewport width
  73689. * @param height defines the viewport height
  73690. * @param znear defines the near clip plane
  73691. * @param zfar defines the far clip plane
  73692. * @returns a new matrix as a left-handed perspective projection matrix
  73693. */
  73694. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  73695. /**
  73696. * Creates a left-handed perspective projection matrix
  73697. * @param fov defines the horizontal field of view
  73698. * @param aspect defines the aspect ratio
  73699. * @param znear defines the near clip plane
  73700. * @param zfar defines the far clip plane
  73701. * @returns a new matrix as a left-handed perspective projection matrix
  73702. */
  73703. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  73704. /**
  73705. * Stores a left-handed perspective projection into a given matrix
  73706. * @param fov defines the horizontal field of view
  73707. * @param aspect defines the aspect ratio
  73708. * @param znear defines the near clip plane
  73709. * @param zfar defines the far clip plane
  73710. * @param result defines the target matrix
  73711. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  73712. */
  73713. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  73714. /**
  73715. * Stores a left-handed perspective projection into a given matrix with depth reversed
  73716. * @param fov defines the horizontal field of view
  73717. * @param aspect defines the aspect ratio
  73718. * @param znear defines the near clip plane
  73719. * @param zfar not used as infinity is used as far clip
  73720. * @param result defines the target matrix
  73721. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  73722. */
  73723. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  73724. /**
  73725. * Creates a right-handed perspective projection matrix
  73726. * @param fov defines the horizontal field of view
  73727. * @param aspect defines the aspect ratio
  73728. * @param znear defines the near clip plane
  73729. * @param zfar defines the far clip plane
  73730. * @returns a new matrix as a right-handed perspective projection matrix
  73731. */
  73732. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  73733. /**
  73734. * Stores a right-handed perspective projection into a given matrix
  73735. * @param fov defines the horizontal field of view
  73736. * @param aspect defines the aspect ratio
  73737. * @param znear defines the near clip plane
  73738. * @param zfar defines the far clip plane
  73739. * @param result defines the target matrix
  73740. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  73741. */
  73742. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  73743. /**
  73744. * Stores a right-handed perspective projection into a given matrix
  73745. * @param fov defines the horizontal field of view
  73746. * @param aspect defines the aspect ratio
  73747. * @param znear defines the near clip plane
  73748. * @param zfar not used as infinity is used as far clip
  73749. * @param result defines the target matrix
  73750. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  73751. */
  73752. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  73753. /**
  73754. * Stores a perspective projection for WebVR info a given matrix
  73755. * @param fov defines the field of view
  73756. * @param znear defines the near clip plane
  73757. * @param zfar defines the far clip plane
  73758. * @param result defines the target matrix
  73759. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  73760. */
  73761. static PerspectiveFovWebVRToRef(fov: {
  73762. upDegrees: number;
  73763. downDegrees: number;
  73764. leftDegrees: number;
  73765. rightDegrees: number;
  73766. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  73767. /**
  73768. * Computes a complete transformation matrix
  73769. * @param viewport defines the viewport to use
  73770. * @param world defines the world matrix
  73771. * @param view defines the view matrix
  73772. * @param projection defines the projection matrix
  73773. * @param zmin defines the near clip plane
  73774. * @param zmax defines the far clip plane
  73775. * @returns the transformation matrix
  73776. */
  73777. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  73778. /**
  73779. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  73780. * @param matrix defines the matrix to use
  73781. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  73782. */
  73783. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  73784. /**
  73785. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  73786. * @param matrix defines the matrix to use
  73787. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  73788. */
  73789. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  73790. /**
  73791. * Compute the transpose of a given matrix
  73792. * @param matrix defines the matrix to transpose
  73793. * @returns the new matrix
  73794. */
  73795. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  73796. /**
  73797. * Compute the transpose of a matrix and store it in a target matrix
  73798. * @param matrix defines the matrix to transpose
  73799. * @param result defines the target matrix
  73800. */
  73801. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  73802. /**
  73803. * Computes a reflection matrix from a plane
  73804. * @param plane defines the reflection plane
  73805. * @returns a new matrix
  73806. */
  73807. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  73808. /**
  73809. * Computes a reflection matrix from a plane
  73810. * @param plane defines the reflection plane
  73811. * @param result defines the target matrix
  73812. */
  73813. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  73814. /**
  73815. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  73816. * @param xaxis defines the value of the 1st axis
  73817. * @param yaxis defines the value of the 2nd axis
  73818. * @param zaxis defines the value of the 3rd axis
  73819. * @param result defines the target matrix
  73820. */
  73821. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  73822. /**
  73823. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  73824. * @param quat defines the quaternion to use
  73825. * @param result defines the target matrix
  73826. */
  73827. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  73828. }
  73829. /**
  73830. * @hidden
  73831. */
  73832. export class TmpVectors {
  73833. static Vector2: Vector2[];
  73834. static Vector3: Vector3[];
  73835. static Vector4: Vector4[];
  73836. static Quaternion: Quaternion[];
  73837. static Matrix: Matrix[];
  73838. }
  73839. }
  73840. declare module BABYLON {
  73841. /**
  73842. * Defines potential orientation for back face culling
  73843. */
  73844. export enum Orientation {
  73845. /**
  73846. * Clockwise
  73847. */
  73848. CW = 0,
  73849. /** Counter clockwise */
  73850. CCW = 1
  73851. }
  73852. /** Class used to represent a Bezier curve */
  73853. export class BezierCurve {
  73854. /**
  73855. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  73856. * @param t defines the time
  73857. * @param x1 defines the left coordinate on X axis
  73858. * @param y1 defines the left coordinate on Y axis
  73859. * @param x2 defines the right coordinate on X axis
  73860. * @param y2 defines the right coordinate on Y axis
  73861. * @returns the interpolated value
  73862. */
  73863. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  73864. }
  73865. /**
  73866. * Defines angle representation
  73867. */
  73868. export class Angle {
  73869. private _radians;
  73870. /**
  73871. * Creates an Angle object of "radians" radians (float).
  73872. * @param radians the angle in radians
  73873. */
  73874. constructor(radians: number);
  73875. /**
  73876. * Get value in degrees
  73877. * @returns the Angle value in degrees (float)
  73878. */
  73879. degrees(): number;
  73880. /**
  73881. * Get value in radians
  73882. * @returns the Angle value in radians (float)
  73883. */
  73884. radians(): number;
  73885. /**
  73886. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  73887. * @param a defines first vector
  73888. * @param b defines second vector
  73889. * @returns a new Angle
  73890. */
  73891. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  73892. /**
  73893. * Gets a new Angle object from the given float in radians
  73894. * @param radians defines the angle value in radians
  73895. * @returns a new Angle
  73896. */
  73897. static FromRadians(radians: number): Angle;
  73898. /**
  73899. * Gets a new Angle object from the given float in degrees
  73900. * @param degrees defines the angle value in degrees
  73901. * @returns a new Angle
  73902. */
  73903. static FromDegrees(degrees: number): Angle;
  73904. }
  73905. /**
  73906. * This represents an arc in a 2d space.
  73907. */
  73908. export class Arc2 {
  73909. /** Defines the start point of the arc */
  73910. startPoint: Vector2;
  73911. /** Defines the mid point of the arc */
  73912. midPoint: Vector2;
  73913. /** Defines the end point of the arc */
  73914. endPoint: Vector2;
  73915. /**
  73916. * Defines the center point of the arc.
  73917. */
  73918. centerPoint: Vector2;
  73919. /**
  73920. * Defines the radius of the arc.
  73921. */
  73922. radius: number;
  73923. /**
  73924. * Defines the angle of the arc (from mid point to end point).
  73925. */
  73926. angle: Angle;
  73927. /**
  73928. * Defines the start angle of the arc (from start point to middle point).
  73929. */
  73930. startAngle: Angle;
  73931. /**
  73932. * Defines the orientation of the arc (clock wise/counter clock wise).
  73933. */
  73934. orientation: Orientation;
  73935. /**
  73936. * Creates an Arc object from the three given points : start, middle and end.
  73937. * @param startPoint Defines the start point of the arc
  73938. * @param midPoint Defines the midlle point of the arc
  73939. * @param endPoint Defines the end point of the arc
  73940. */
  73941. constructor(
  73942. /** Defines the start point of the arc */
  73943. startPoint: Vector2,
  73944. /** Defines the mid point of the arc */
  73945. midPoint: Vector2,
  73946. /** Defines the end point of the arc */
  73947. endPoint: Vector2);
  73948. }
  73949. /**
  73950. * Represents a 2D path made up of multiple 2D points
  73951. */
  73952. export class Path2 {
  73953. private _points;
  73954. private _length;
  73955. /**
  73956. * If the path start and end point are the same
  73957. */
  73958. closed: boolean;
  73959. /**
  73960. * Creates a Path2 object from the starting 2D coordinates x and y.
  73961. * @param x the starting points x value
  73962. * @param y the starting points y value
  73963. */
  73964. constructor(x: number, y: number);
  73965. /**
  73966. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  73967. * @param x the added points x value
  73968. * @param y the added points y value
  73969. * @returns the updated Path2.
  73970. */
  73971. addLineTo(x: number, y: number): Path2;
  73972. /**
  73973. * 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.
  73974. * @param midX middle point x value
  73975. * @param midY middle point y value
  73976. * @param endX end point x value
  73977. * @param endY end point y value
  73978. * @param numberOfSegments (default: 36)
  73979. * @returns the updated Path2.
  73980. */
  73981. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  73982. /**
  73983. * Closes the Path2.
  73984. * @returns the Path2.
  73985. */
  73986. close(): Path2;
  73987. /**
  73988. * Gets the sum of the distance between each sequential point in the path
  73989. * @returns the Path2 total length (float).
  73990. */
  73991. length(): number;
  73992. /**
  73993. * Gets the points which construct the path
  73994. * @returns the Path2 internal array of points.
  73995. */
  73996. getPoints(): Vector2[];
  73997. /**
  73998. * Retreives the point at the distance aways from the starting point
  73999. * @param normalizedLengthPosition the length along the path to retreive the point from
  74000. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  74001. */
  74002. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  74003. /**
  74004. * Creates a new path starting from an x and y position
  74005. * @param x starting x value
  74006. * @param y starting y value
  74007. * @returns a new Path2 starting at the coordinates (x, y).
  74008. */
  74009. static StartingAt(x: number, y: number): Path2;
  74010. }
  74011. /**
  74012. * Represents a 3D path made up of multiple 3D points
  74013. */
  74014. export class Path3D {
  74015. /**
  74016. * an array of Vector3, the curve axis of the Path3D
  74017. */
  74018. path: Vector3[];
  74019. private _curve;
  74020. private _distances;
  74021. private _tangents;
  74022. private _normals;
  74023. private _binormals;
  74024. private _raw;
  74025. private _alignTangentsWithPath;
  74026. private readonly _pointAtData;
  74027. /**
  74028. * new Path3D(path, normal, raw)
  74029. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  74030. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  74031. * @param path an array of Vector3, the curve axis of the Path3D
  74032. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  74033. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  74034. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  74035. */
  74036. constructor(
  74037. /**
  74038. * an array of Vector3, the curve axis of the Path3D
  74039. */
  74040. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  74041. /**
  74042. * Returns the Path3D array of successive Vector3 designing its curve.
  74043. * @returns the Path3D array of successive Vector3 designing its curve.
  74044. */
  74045. getCurve(): Vector3[];
  74046. /**
  74047. * Returns the Path3D array of successive Vector3 designing its curve.
  74048. * @returns the Path3D array of successive Vector3 designing its curve.
  74049. */
  74050. getPoints(): Vector3[];
  74051. /**
  74052. * @returns the computed length (float) of the path.
  74053. */
  74054. length(): number;
  74055. /**
  74056. * Returns an array populated with tangent vectors on each Path3D curve point.
  74057. * @returns an array populated with tangent vectors on each Path3D curve point.
  74058. */
  74059. getTangents(): Vector3[];
  74060. /**
  74061. * Returns an array populated with normal vectors on each Path3D curve point.
  74062. * @returns an array populated with normal vectors on each Path3D curve point.
  74063. */
  74064. getNormals(): Vector3[];
  74065. /**
  74066. * Returns an array populated with binormal vectors on each Path3D curve point.
  74067. * @returns an array populated with binormal vectors on each Path3D curve point.
  74068. */
  74069. getBinormals(): Vector3[];
  74070. /**
  74071. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  74072. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  74073. */
  74074. getDistances(): number[];
  74075. /**
  74076. * Returns an interpolated point along this path
  74077. * @param position the position of the point along this path, from 0.0 to 1.0
  74078. * @returns a new Vector3 as the point
  74079. */
  74080. getPointAt(position: number): Vector3;
  74081. /**
  74082. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  74083. * @param position the position of the point along this path, from 0.0 to 1.0
  74084. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  74085. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  74086. */
  74087. getTangentAt(position: number, interpolated?: boolean): Vector3;
  74088. /**
  74089. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  74090. * @param position the position of the point along this path, from 0.0 to 1.0
  74091. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  74092. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  74093. */
  74094. getNormalAt(position: number, interpolated?: boolean): Vector3;
  74095. /**
  74096. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  74097. * @param position the position of the point along this path, from 0.0 to 1.0
  74098. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  74099. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  74100. */
  74101. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  74102. /**
  74103. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  74104. * @param position the position of the point along this path, from 0.0 to 1.0
  74105. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  74106. */
  74107. getDistanceAt(position: number): number;
  74108. /**
  74109. * Returns the array index of the previous point of an interpolated point along this path
  74110. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  74111. * @returns the array index
  74112. */
  74113. getPreviousPointIndexAt(position: number): number;
  74114. /**
  74115. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  74116. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  74117. * @returns the sub position
  74118. */
  74119. getSubPositionAt(position: number): number;
  74120. /**
  74121. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  74122. * @param target the vector of which to get the closest position to
  74123. * @returns the position of the closest virtual point on this path to the target vector
  74124. */
  74125. getClosestPositionTo(target: Vector3): number;
  74126. /**
  74127. * Returns a sub path (slice) of this path
  74128. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  74129. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  74130. * @returns a sub path (slice) of this path
  74131. */
  74132. slice(start?: number, end?: number): Path3D;
  74133. /**
  74134. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  74135. * @param path path which all values are copied into the curves points
  74136. * @param firstNormal which should be projected onto the curve
  74137. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  74138. * @returns the same object updated.
  74139. */
  74140. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  74141. private _compute;
  74142. private _getFirstNonNullVector;
  74143. private _getLastNonNullVector;
  74144. private _normalVector;
  74145. /**
  74146. * Updates the point at data for an interpolated point along this curve
  74147. * @param position the position of the point along this curve, from 0.0 to 1.0
  74148. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  74149. * @returns the (updated) point at data
  74150. */
  74151. private _updatePointAtData;
  74152. /**
  74153. * Updates the point at data from the specified parameters
  74154. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  74155. * @param point the interpolated point
  74156. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  74157. */
  74158. private _setPointAtData;
  74159. /**
  74160. * Updates the point at interpolation matrix for the tangents, normals and binormals
  74161. */
  74162. private _updateInterpolationMatrix;
  74163. }
  74164. /**
  74165. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  74166. * A Curve3 is designed from a series of successive Vector3.
  74167. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  74168. */
  74169. export class Curve3 {
  74170. private _points;
  74171. private _length;
  74172. /**
  74173. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  74174. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  74175. * @param v1 (Vector3) the control point
  74176. * @param v2 (Vector3) the end point of the Quadratic Bezier
  74177. * @param nbPoints (integer) the wanted number of points in the curve
  74178. * @returns the created Curve3
  74179. */
  74180. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  74181. /**
  74182. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  74183. * @param v0 (Vector3) the origin point of the Cubic Bezier
  74184. * @param v1 (Vector3) the first control point
  74185. * @param v2 (Vector3) the second control point
  74186. * @param v3 (Vector3) the end point of the Cubic Bezier
  74187. * @param nbPoints (integer) the wanted number of points in the curve
  74188. * @returns the created Curve3
  74189. */
  74190. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  74191. /**
  74192. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  74193. * @param p1 (Vector3) the origin point of the Hermite Spline
  74194. * @param t1 (Vector3) the tangent vector at the origin point
  74195. * @param p2 (Vector3) the end point of the Hermite Spline
  74196. * @param t2 (Vector3) the tangent vector at the end point
  74197. * @param nbPoints (integer) the wanted number of points in the curve
  74198. * @returns the created Curve3
  74199. */
  74200. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  74201. /**
  74202. * Returns a Curve3 object along a CatmullRom Spline curve :
  74203. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  74204. * @param nbPoints (integer) the wanted number of points between each curve control points
  74205. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  74206. * @returns the created Curve3
  74207. */
  74208. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  74209. /**
  74210. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  74211. * A Curve3 is designed from a series of successive Vector3.
  74212. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  74213. * @param points points which make up the curve
  74214. */
  74215. constructor(points: Vector3[]);
  74216. /**
  74217. * @returns the Curve3 stored array of successive Vector3
  74218. */
  74219. getPoints(): Vector3[];
  74220. /**
  74221. * @returns the computed length (float) of the curve.
  74222. */
  74223. length(): number;
  74224. /**
  74225. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  74226. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  74227. * curveA and curveB keep unchanged.
  74228. * @param curve the curve to continue from this curve
  74229. * @returns the newly constructed curve
  74230. */
  74231. continue(curve: DeepImmutable<Curve3>): Curve3;
  74232. private _computeLength;
  74233. }
  74234. }
  74235. declare module BABYLON {
  74236. /**
  74237. * This represents the main contract an easing function should follow.
  74238. * Easing functions are used throughout the animation system.
  74239. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74240. */
  74241. export interface IEasingFunction {
  74242. /**
  74243. * Given an input gradient between 0 and 1, this returns the corrseponding value
  74244. * of the easing function.
  74245. * The link below provides some of the most common examples of easing functions.
  74246. * @see https://easings.net/
  74247. * @param gradient Defines the value between 0 and 1 we want the easing value for
  74248. * @returns the corresponding value on the curve defined by the easing function
  74249. */
  74250. ease(gradient: number): number;
  74251. }
  74252. /**
  74253. * Base class used for every default easing function.
  74254. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74255. */
  74256. export class EasingFunction implements IEasingFunction {
  74257. /**
  74258. * Interpolation follows the mathematical formula associated with the easing function.
  74259. */
  74260. static readonly EASINGMODE_EASEIN: number;
  74261. /**
  74262. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  74263. */
  74264. static readonly EASINGMODE_EASEOUT: number;
  74265. /**
  74266. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  74267. */
  74268. static readonly EASINGMODE_EASEINOUT: number;
  74269. private _easingMode;
  74270. /**
  74271. * Sets the easing mode of the current function.
  74272. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  74273. */
  74274. setEasingMode(easingMode: number): void;
  74275. /**
  74276. * Gets the current easing mode.
  74277. * @returns the easing mode
  74278. */
  74279. getEasingMode(): number;
  74280. /**
  74281. * @hidden
  74282. */
  74283. easeInCore(gradient: number): number;
  74284. /**
  74285. * Given an input gradient between 0 and 1, this returns the corresponding value
  74286. * of the easing function.
  74287. * @param gradient Defines the value between 0 and 1 we want the easing value for
  74288. * @returns the corresponding value on the curve defined by the easing function
  74289. */
  74290. ease(gradient: number): number;
  74291. }
  74292. /**
  74293. * Easing function with a circle shape (see link below).
  74294. * @see https://easings.net/#easeInCirc
  74295. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74296. */
  74297. export class CircleEase extends EasingFunction implements IEasingFunction {
  74298. /** @hidden */
  74299. easeInCore(gradient: number): number;
  74300. }
  74301. /**
  74302. * Easing function with a ease back shape (see link below).
  74303. * @see https://easings.net/#easeInBack
  74304. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74305. */
  74306. export class BackEase extends EasingFunction implements IEasingFunction {
  74307. /** Defines the amplitude of the function */
  74308. amplitude: number;
  74309. /**
  74310. * Instantiates a back ease easing
  74311. * @see https://easings.net/#easeInBack
  74312. * @param amplitude Defines the amplitude of the function
  74313. */
  74314. constructor(
  74315. /** Defines the amplitude of the function */
  74316. amplitude?: number);
  74317. /** @hidden */
  74318. easeInCore(gradient: number): number;
  74319. }
  74320. /**
  74321. * Easing function with a bouncing shape (see link below).
  74322. * @see https://easings.net/#easeInBounce
  74323. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74324. */
  74325. export class BounceEase extends EasingFunction implements IEasingFunction {
  74326. /** Defines the number of bounces */
  74327. bounces: number;
  74328. /** Defines the amplitude of the bounce */
  74329. bounciness: number;
  74330. /**
  74331. * Instantiates a bounce easing
  74332. * @see https://easings.net/#easeInBounce
  74333. * @param bounces Defines the number of bounces
  74334. * @param bounciness Defines the amplitude of the bounce
  74335. */
  74336. constructor(
  74337. /** Defines the number of bounces */
  74338. bounces?: number,
  74339. /** Defines the amplitude of the bounce */
  74340. bounciness?: number);
  74341. /** @hidden */
  74342. easeInCore(gradient: number): number;
  74343. }
  74344. /**
  74345. * Easing function with a power of 3 shape (see link below).
  74346. * @see https://easings.net/#easeInCubic
  74347. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74348. */
  74349. export class CubicEase extends EasingFunction implements IEasingFunction {
  74350. /** @hidden */
  74351. easeInCore(gradient: number): number;
  74352. }
  74353. /**
  74354. * Easing function with an elastic shape (see link below).
  74355. * @see https://easings.net/#easeInElastic
  74356. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74357. */
  74358. export class ElasticEase extends EasingFunction implements IEasingFunction {
  74359. /** Defines the number of oscillations*/
  74360. oscillations: number;
  74361. /** Defines the amplitude of the oscillations*/
  74362. springiness: number;
  74363. /**
  74364. * Instantiates an elastic easing function
  74365. * @see https://easings.net/#easeInElastic
  74366. * @param oscillations Defines the number of oscillations
  74367. * @param springiness Defines the amplitude of the oscillations
  74368. */
  74369. constructor(
  74370. /** Defines the number of oscillations*/
  74371. oscillations?: number,
  74372. /** Defines the amplitude of the oscillations*/
  74373. springiness?: number);
  74374. /** @hidden */
  74375. easeInCore(gradient: number): number;
  74376. }
  74377. /**
  74378. * Easing function with an exponential shape (see link below).
  74379. * @see https://easings.net/#easeInExpo
  74380. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74381. */
  74382. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  74383. /** Defines the exponent of the function */
  74384. exponent: number;
  74385. /**
  74386. * Instantiates an exponential easing function
  74387. * @see https://easings.net/#easeInExpo
  74388. * @param exponent Defines the exponent of the function
  74389. */
  74390. constructor(
  74391. /** Defines the exponent of the function */
  74392. exponent?: number);
  74393. /** @hidden */
  74394. easeInCore(gradient: number): number;
  74395. }
  74396. /**
  74397. * Easing function with a power shape (see link below).
  74398. * @see https://easings.net/#easeInQuad
  74399. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74400. */
  74401. export class PowerEase extends EasingFunction implements IEasingFunction {
  74402. /** Defines the power of the function */
  74403. power: number;
  74404. /**
  74405. * Instantiates an power base easing function
  74406. * @see https://easings.net/#easeInQuad
  74407. * @param power Defines the power of the function
  74408. */
  74409. constructor(
  74410. /** Defines the power of the function */
  74411. power?: number);
  74412. /** @hidden */
  74413. easeInCore(gradient: number): number;
  74414. }
  74415. /**
  74416. * Easing function with a power of 2 shape (see link below).
  74417. * @see https://easings.net/#easeInQuad
  74418. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74419. */
  74420. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  74421. /** @hidden */
  74422. easeInCore(gradient: number): number;
  74423. }
  74424. /**
  74425. * Easing function with a power of 4 shape (see link below).
  74426. * @see https://easings.net/#easeInQuart
  74427. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74428. */
  74429. export class QuarticEase extends EasingFunction implements IEasingFunction {
  74430. /** @hidden */
  74431. easeInCore(gradient: number): number;
  74432. }
  74433. /**
  74434. * Easing function with a power of 5 shape (see link below).
  74435. * @see https://easings.net/#easeInQuint
  74436. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74437. */
  74438. export class QuinticEase extends EasingFunction implements IEasingFunction {
  74439. /** @hidden */
  74440. easeInCore(gradient: number): number;
  74441. }
  74442. /**
  74443. * Easing function with a sin shape (see link below).
  74444. * @see https://easings.net/#easeInSine
  74445. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74446. */
  74447. export class SineEase extends EasingFunction implements IEasingFunction {
  74448. /** @hidden */
  74449. easeInCore(gradient: number): number;
  74450. }
  74451. /**
  74452. * Easing function with a bezier shape (see link below).
  74453. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  74454. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74455. */
  74456. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  74457. /** Defines the x component of the start tangent in the bezier curve */
  74458. x1: number;
  74459. /** Defines the y component of the start tangent in the bezier curve */
  74460. y1: number;
  74461. /** Defines the x component of the end tangent in the bezier curve */
  74462. x2: number;
  74463. /** Defines the y component of the end tangent in the bezier curve */
  74464. y2: number;
  74465. /**
  74466. * Instantiates a bezier function
  74467. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  74468. * @param x1 Defines the x component of the start tangent in the bezier curve
  74469. * @param y1 Defines the y component of the start tangent in the bezier curve
  74470. * @param x2 Defines the x component of the end tangent in the bezier curve
  74471. * @param y2 Defines the y component of the end tangent in the bezier curve
  74472. */
  74473. constructor(
  74474. /** Defines the x component of the start tangent in the bezier curve */
  74475. x1?: number,
  74476. /** Defines the y component of the start tangent in the bezier curve */
  74477. y1?: number,
  74478. /** Defines the x component of the end tangent in the bezier curve */
  74479. x2?: number,
  74480. /** Defines the y component of the end tangent in the bezier curve */
  74481. y2?: number);
  74482. /** @hidden */
  74483. easeInCore(gradient: number): number;
  74484. }
  74485. }
  74486. declare module BABYLON {
  74487. /**
  74488. * Class used to hold a RBG color
  74489. */
  74490. export class Color3 {
  74491. /**
  74492. * Defines the red component (between 0 and 1, default is 0)
  74493. */
  74494. r: number;
  74495. /**
  74496. * Defines the green component (between 0 and 1, default is 0)
  74497. */
  74498. g: number;
  74499. /**
  74500. * Defines the blue component (between 0 and 1, default is 0)
  74501. */
  74502. b: number;
  74503. /**
  74504. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  74505. * @param r defines the red component (between 0 and 1, default is 0)
  74506. * @param g defines the green component (between 0 and 1, default is 0)
  74507. * @param b defines the blue component (between 0 and 1, default is 0)
  74508. */
  74509. constructor(
  74510. /**
  74511. * Defines the red component (between 0 and 1, default is 0)
  74512. */
  74513. r?: number,
  74514. /**
  74515. * Defines the green component (between 0 and 1, default is 0)
  74516. */
  74517. g?: number,
  74518. /**
  74519. * Defines the blue component (between 0 and 1, default is 0)
  74520. */
  74521. b?: number);
  74522. /**
  74523. * Creates a string with the Color3 current values
  74524. * @returns the string representation of the Color3 object
  74525. */
  74526. toString(): string;
  74527. /**
  74528. * Returns the string "Color3"
  74529. * @returns "Color3"
  74530. */
  74531. getClassName(): string;
  74532. /**
  74533. * Compute the Color3 hash code
  74534. * @returns an unique number that can be used to hash Color3 objects
  74535. */
  74536. getHashCode(): number;
  74537. /**
  74538. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  74539. * @param array defines the array where to store the r,g,b components
  74540. * @param index defines an optional index in the target array to define where to start storing values
  74541. * @returns the current Color3 object
  74542. */
  74543. toArray(array: FloatArray, index?: number): Color3;
  74544. /**
  74545. * Returns a new Color4 object from the current Color3 and the given alpha
  74546. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  74547. * @returns a new Color4 object
  74548. */
  74549. toColor4(alpha?: number): Color4;
  74550. /**
  74551. * Returns a new array populated with 3 numeric elements : red, green and blue values
  74552. * @returns the new array
  74553. */
  74554. asArray(): number[];
  74555. /**
  74556. * Returns the luminance value
  74557. * @returns a float value
  74558. */
  74559. toLuminance(): number;
  74560. /**
  74561. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  74562. * @param otherColor defines the second operand
  74563. * @returns the new Color3 object
  74564. */
  74565. multiply(otherColor: DeepImmutable<Color3>): Color3;
  74566. /**
  74567. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  74568. * @param otherColor defines the second operand
  74569. * @param result defines the Color3 object where to store the result
  74570. * @returns the current Color3
  74571. */
  74572. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  74573. /**
  74574. * Determines equality between Color3 objects
  74575. * @param otherColor defines the second operand
  74576. * @returns true if the rgb values are equal to the given ones
  74577. */
  74578. equals(otherColor: DeepImmutable<Color3>): boolean;
  74579. /**
  74580. * Determines equality between the current Color3 object and a set of r,b,g values
  74581. * @param r defines the red component to check
  74582. * @param g defines the green component to check
  74583. * @param b defines the blue component to check
  74584. * @returns true if the rgb values are equal to the given ones
  74585. */
  74586. equalsFloats(r: number, g: number, b: number): boolean;
  74587. /**
  74588. * Multiplies in place each rgb value by scale
  74589. * @param scale defines the scaling factor
  74590. * @returns the updated Color3
  74591. */
  74592. scale(scale: number): Color3;
  74593. /**
  74594. * Multiplies the rgb values by scale and stores the result into "result"
  74595. * @param scale defines the scaling factor
  74596. * @param result defines the Color3 object where to store the result
  74597. * @returns the unmodified current Color3
  74598. */
  74599. scaleToRef(scale: number, result: Color3): Color3;
  74600. /**
  74601. * Scale the current Color3 values by a factor and add the result to a given Color3
  74602. * @param scale defines the scale factor
  74603. * @param result defines color to store the result into
  74604. * @returns the unmodified current Color3
  74605. */
  74606. scaleAndAddToRef(scale: number, result: Color3): Color3;
  74607. /**
  74608. * Clamps the rgb values by the min and max values and stores the result into "result"
  74609. * @param min defines minimum clamping value (default is 0)
  74610. * @param max defines maximum clamping value (default is 1)
  74611. * @param result defines color to store the result into
  74612. * @returns the original Color3
  74613. */
  74614. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  74615. /**
  74616. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  74617. * @param otherColor defines the second operand
  74618. * @returns the new Color3
  74619. */
  74620. add(otherColor: DeepImmutable<Color3>): Color3;
  74621. /**
  74622. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  74623. * @param otherColor defines the second operand
  74624. * @param result defines Color3 object to store the result into
  74625. * @returns the unmodified current Color3
  74626. */
  74627. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  74628. /**
  74629. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  74630. * @param otherColor defines the second operand
  74631. * @returns the new Color3
  74632. */
  74633. subtract(otherColor: DeepImmutable<Color3>): Color3;
  74634. /**
  74635. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  74636. * @param otherColor defines the second operand
  74637. * @param result defines Color3 object to store the result into
  74638. * @returns the unmodified current Color3
  74639. */
  74640. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  74641. /**
  74642. * Copy the current object
  74643. * @returns a new Color3 copied the current one
  74644. */
  74645. clone(): Color3;
  74646. /**
  74647. * Copies the rgb values from the source in the current Color3
  74648. * @param source defines the source Color3 object
  74649. * @returns the updated Color3 object
  74650. */
  74651. copyFrom(source: DeepImmutable<Color3>): Color3;
  74652. /**
  74653. * Updates the Color3 rgb values from the given floats
  74654. * @param r defines the red component to read from
  74655. * @param g defines the green component to read from
  74656. * @param b defines the blue component to read from
  74657. * @returns the current Color3 object
  74658. */
  74659. copyFromFloats(r: number, g: number, b: number): Color3;
  74660. /**
  74661. * Updates the Color3 rgb values from the given floats
  74662. * @param r defines the red component to read from
  74663. * @param g defines the green component to read from
  74664. * @param b defines the blue component to read from
  74665. * @returns the current Color3 object
  74666. */
  74667. set(r: number, g: number, b: number): Color3;
  74668. /**
  74669. * Compute the Color3 hexadecimal code as a string
  74670. * @returns a string containing the hexadecimal representation of the Color3 object
  74671. */
  74672. toHexString(): string;
  74673. /**
  74674. * Computes a new Color3 converted from the current one to linear space
  74675. * @returns a new Color3 object
  74676. */
  74677. toLinearSpace(): Color3;
  74678. /**
  74679. * Converts current color in rgb space to HSV values
  74680. * @returns a new color3 representing the HSV values
  74681. */
  74682. toHSV(): Color3;
  74683. /**
  74684. * Converts current color in rgb space to HSV values
  74685. * @param result defines the Color3 where to store the HSV values
  74686. */
  74687. toHSVToRef(result: Color3): void;
  74688. /**
  74689. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  74690. * @param convertedColor defines the Color3 object where to store the linear space version
  74691. * @returns the unmodified Color3
  74692. */
  74693. toLinearSpaceToRef(convertedColor: Color3): Color3;
  74694. /**
  74695. * Computes a new Color3 converted from the current one to gamma space
  74696. * @returns a new Color3 object
  74697. */
  74698. toGammaSpace(): Color3;
  74699. /**
  74700. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  74701. * @param convertedColor defines the Color3 object where to store the gamma space version
  74702. * @returns the unmodified Color3
  74703. */
  74704. toGammaSpaceToRef(convertedColor: Color3): Color3;
  74705. private static _BlackReadOnly;
  74706. /**
  74707. * Convert Hue, saturation and value to a Color3 (RGB)
  74708. * @param hue defines the hue
  74709. * @param saturation defines the saturation
  74710. * @param value defines the value
  74711. * @param result defines the Color3 where to store the RGB values
  74712. */
  74713. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  74714. /**
  74715. * Creates a new Color3 from the string containing valid hexadecimal values
  74716. * @param hex defines a string containing valid hexadecimal values
  74717. * @returns a new Color3 object
  74718. */
  74719. static FromHexString(hex: string): Color3;
  74720. /**
  74721. * Creates a new Color3 from the starting index of the given array
  74722. * @param array defines the source array
  74723. * @param offset defines an offset in the source array
  74724. * @returns a new Color3 object
  74725. */
  74726. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  74727. /**
  74728. * Creates a new Color3 from integer values (< 256)
  74729. * @param r defines the red component to read from (value between 0 and 255)
  74730. * @param g defines the green component to read from (value between 0 and 255)
  74731. * @param b defines the blue component to read from (value between 0 and 255)
  74732. * @returns a new Color3 object
  74733. */
  74734. static FromInts(r: number, g: number, b: number): Color3;
  74735. /**
  74736. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  74737. * @param start defines the start Color3 value
  74738. * @param end defines the end Color3 value
  74739. * @param amount defines the gradient value between start and end
  74740. * @returns a new Color3 object
  74741. */
  74742. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  74743. /**
  74744. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  74745. * @param left defines the start value
  74746. * @param right defines the end value
  74747. * @param amount defines the gradient factor
  74748. * @param result defines the Color3 object where to store the result
  74749. */
  74750. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  74751. /**
  74752. * Returns a Color3 value containing a red color
  74753. * @returns a new Color3 object
  74754. */
  74755. static Red(): Color3;
  74756. /**
  74757. * Returns a Color3 value containing a green color
  74758. * @returns a new Color3 object
  74759. */
  74760. static Green(): Color3;
  74761. /**
  74762. * Returns a Color3 value containing a blue color
  74763. * @returns a new Color3 object
  74764. */
  74765. static Blue(): Color3;
  74766. /**
  74767. * Returns a Color3 value containing a black color
  74768. * @returns a new Color3 object
  74769. */
  74770. static Black(): Color3;
  74771. /**
  74772. * Gets a Color3 value containing a black color that must not be updated
  74773. */
  74774. static readonly BlackReadOnly: DeepImmutable<Color3>;
  74775. /**
  74776. * Returns a Color3 value containing a white color
  74777. * @returns a new Color3 object
  74778. */
  74779. static White(): Color3;
  74780. /**
  74781. * Returns a Color3 value containing a purple color
  74782. * @returns a new Color3 object
  74783. */
  74784. static Purple(): Color3;
  74785. /**
  74786. * Returns a Color3 value containing a magenta color
  74787. * @returns a new Color3 object
  74788. */
  74789. static Magenta(): Color3;
  74790. /**
  74791. * Returns a Color3 value containing a yellow color
  74792. * @returns a new Color3 object
  74793. */
  74794. static Yellow(): Color3;
  74795. /**
  74796. * Returns a Color3 value containing a gray color
  74797. * @returns a new Color3 object
  74798. */
  74799. static Gray(): Color3;
  74800. /**
  74801. * Returns a Color3 value containing a teal color
  74802. * @returns a new Color3 object
  74803. */
  74804. static Teal(): Color3;
  74805. /**
  74806. * Returns a Color3 value containing a random color
  74807. * @returns a new Color3 object
  74808. */
  74809. static Random(): Color3;
  74810. }
  74811. /**
  74812. * Class used to hold a RBGA color
  74813. */
  74814. export class Color4 {
  74815. /**
  74816. * Defines the red component (between 0 and 1, default is 0)
  74817. */
  74818. r: number;
  74819. /**
  74820. * Defines the green component (between 0 and 1, default is 0)
  74821. */
  74822. g: number;
  74823. /**
  74824. * Defines the blue component (between 0 and 1, default is 0)
  74825. */
  74826. b: number;
  74827. /**
  74828. * Defines the alpha component (between 0 and 1, default is 1)
  74829. */
  74830. a: number;
  74831. /**
  74832. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  74833. * @param r defines the red component (between 0 and 1, default is 0)
  74834. * @param g defines the green component (between 0 and 1, default is 0)
  74835. * @param b defines the blue component (between 0 and 1, default is 0)
  74836. * @param a defines the alpha component (between 0 and 1, default is 1)
  74837. */
  74838. constructor(
  74839. /**
  74840. * Defines the red component (between 0 and 1, default is 0)
  74841. */
  74842. r?: number,
  74843. /**
  74844. * Defines the green component (between 0 and 1, default is 0)
  74845. */
  74846. g?: number,
  74847. /**
  74848. * Defines the blue component (between 0 and 1, default is 0)
  74849. */
  74850. b?: number,
  74851. /**
  74852. * Defines the alpha component (between 0 and 1, default is 1)
  74853. */
  74854. a?: number);
  74855. /**
  74856. * Adds in place the given Color4 values to the current Color4 object
  74857. * @param right defines the second operand
  74858. * @returns the current updated Color4 object
  74859. */
  74860. addInPlace(right: DeepImmutable<Color4>): Color4;
  74861. /**
  74862. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  74863. * @returns the new array
  74864. */
  74865. asArray(): number[];
  74866. /**
  74867. * Stores from the starting index in the given array the Color4 successive values
  74868. * @param array defines the array where to store the r,g,b components
  74869. * @param index defines an optional index in the target array to define where to start storing values
  74870. * @returns the current Color4 object
  74871. */
  74872. toArray(array: number[], index?: number): Color4;
  74873. /**
  74874. * Determines equality between Color4 objects
  74875. * @param otherColor defines the second operand
  74876. * @returns true if the rgba values are equal to the given ones
  74877. */
  74878. equals(otherColor: DeepImmutable<Color4>): boolean;
  74879. /**
  74880. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  74881. * @param right defines the second operand
  74882. * @returns a new Color4 object
  74883. */
  74884. add(right: DeepImmutable<Color4>): Color4;
  74885. /**
  74886. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  74887. * @param right defines the second operand
  74888. * @returns a new Color4 object
  74889. */
  74890. subtract(right: DeepImmutable<Color4>): Color4;
  74891. /**
  74892. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  74893. * @param right defines the second operand
  74894. * @param result defines the Color4 object where to store the result
  74895. * @returns the current Color4 object
  74896. */
  74897. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  74898. /**
  74899. * Creates a new Color4 with the current Color4 values multiplied by scale
  74900. * @param scale defines the scaling factor to apply
  74901. * @returns a new Color4 object
  74902. */
  74903. scale(scale: number): Color4;
  74904. /**
  74905. * Multiplies the current Color4 values by scale and stores the result in "result"
  74906. * @param scale defines the scaling factor to apply
  74907. * @param result defines the Color4 object where to store the result
  74908. * @returns the current unmodified Color4
  74909. */
  74910. scaleToRef(scale: number, result: Color4): Color4;
  74911. /**
  74912. * Scale the current Color4 values by a factor and add the result to a given Color4
  74913. * @param scale defines the scale factor
  74914. * @param result defines the Color4 object where to store the result
  74915. * @returns the unmodified current Color4
  74916. */
  74917. scaleAndAddToRef(scale: number, result: Color4): Color4;
  74918. /**
  74919. * Clamps the rgb values by the min and max values and stores the result into "result"
  74920. * @param min defines minimum clamping value (default is 0)
  74921. * @param max defines maximum clamping value (default is 1)
  74922. * @param result defines color to store the result into.
  74923. * @returns the cuurent Color4
  74924. */
  74925. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  74926. /**
  74927. * Multipy an Color4 value by another and return a new Color4 object
  74928. * @param color defines the Color4 value to multiply by
  74929. * @returns a new Color4 object
  74930. */
  74931. multiply(color: Color4): Color4;
  74932. /**
  74933. * Multipy a Color4 value by another and push the result in a reference value
  74934. * @param color defines the Color4 value to multiply by
  74935. * @param result defines the Color4 to fill the result in
  74936. * @returns the result Color4
  74937. */
  74938. multiplyToRef(color: Color4, result: Color4): Color4;
  74939. /**
  74940. * Creates a string with the Color4 current values
  74941. * @returns the string representation of the Color4 object
  74942. */
  74943. toString(): string;
  74944. /**
  74945. * Returns the string "Color4"
  74946. * @returns "Color4"
  74947. */
  74948. getClassName(): string;
  74949. /**
  74950. * Compute the Color4 hash code
  74951. * @returns an unique number that can be used to hash Color4 objects
  74952. */
  74953. getHashCode(): number;
  74954. /**
  74955. * Creates a new Color4 copied from the current one
  74956. * @returns a new Color4 object
  74957. */
  74958. clone(): Color4;
  74959. /**
  74960. * Copies the given Color4 values into the current one
  74961. * @param source defines the source Color4 object
  74962. * @returns the current updated Color4 object
  74963. */
  74964. copyFrom(source: Color4): Color4;
  74965. /**
  74966. * Copies the given float values into the current one
  74967. * @param r defines the red component to read from
  74968. * @param g defines the green component to read from
  74969. * @param b defines the blue component to read from
  74970. * @param a defines the alpha component to read from
  74971. * @returns the current updated Color4 object
  74972. */
  74973. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  74974. /**
  74975. * Copies the given float values into the current one
  74976. * @param r defines the red component to read from
  74977. * @param g defines the green component to read from
  74978. * @param b defines the blue component to read from
  74979. * @param a defines the alpha component to read from
  74980. * @returns the current updated Color4 object
  74981. */
  74982. set(r: number, g: number, b: number, a: number): Color4;
  74983. /**
  74984. * Compute the Color4 hexadecimal code as a string
  74985. * @returns a string containing the hexadecimal representation of the Color4 object
  74986. */
  74987. toHexString(): string;
  74988. /**
  74989. * Computes a new Color4 converted from the current one to linear space
  74990. * @returns a new Color4 object
  74991. */
  74992. toLinearSpace(): Color4;
  74993. /**
  74994. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  74995. * @param convertedColor defines the Color4 object where to store the linear space version
  74996. * @returns the unmodified Color4
  74997. */
  74998. toLinearSpaceToRef(convertedColor: Color4): Color4;
  74999. /**
  75000. * Computes a new Color4 converted from the current one to gamma space
  75001. * @returns a new Color4 object
  75002. */
  75003. toGammaSpace(): Color4;
  75004. /**
  75005. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  75006. * @param convertedColor defines the Color4 object where to store the gamma space version
  75007. * @returns the unmodified Color4
  75008. */
  75009. toGammaSpaceToRef(convertedColor: Color4): Color4;
  75010. /**
  75011. * Creates a new Color4 from the string containing valid hexadecimal values
  75012. * @param hex defines a string containing valid hexadecimal values
  75013. * @returns a new Color4 object
  75014. */
  75015. static FromHexString(hex: string): Color4;
  75016. /**
  75017. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  75018. * @param left defines the start value
  75019. * @param right defines the end value
  75020. * @param amount defines the gradient factor
  75021. * @returns a new Color4 object
  75022. */
  75023. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  75024. /**
  75025. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  75026. * @param left defines the start value
  75027. * @param right defines the end value
  75028. * @param amount defines the gradient factor
  75029. * @param result defines the Color4 object where to store data
  75030. */
  75031. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  75032. /**
  75033. * Creates a new Color4 from a Color3 and an alpha value
  75034. * @param color3 defines the source Color3 to read from
  75035. * @param alpha defines the alpha component (1.0 by default)
  75036. * @returns a new Color4 object
  75037. */
  75038. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  75039. /**
  75040. * Creates a new Color4 from the starting index element of the given array
  75041. * @param array defines the source array to read from
  75042. * @param offset defines the offset in the source array
  75043. * @returns a new Color4 object
  75044. */
  75045. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  75046. /**
  75047. * Creates a new Color3 from integer values (< 256)
  75048. * @param r defines the red component to read from (value between 0 and 255)
  75049. * @param g defines the green component to read from (value between 0 and 255)
  75050. * @param b defines the blue component to read from (value between 0 and 255)
  75051. * @param a defines the alpha component to read from (value between 0 and 255)
  75052. * @returns a new Color3 object
  75053. */
  75054. static FromInts(r: number, g: number, b: number, a: number): Color4;
  75055. /**
  75056. * Check the content of a given array and convert it to an array containing RGBA data
  75057. * If the original array was already containing count * 4 values then it is returned directly
  75058. * @param colors defines the array to check
  75059. * @param count defines the number of RGBA data to expect
  75060. * @returns an array containing count * 4 values (RGBA)
  75061. */
  75062. static CheckColors4(colors: number[], count: number): number[];
  75063. }
  75064. /**
  75065. * @hidden
  75066. */
  75067. export class TmpColors {
  75068. static Color3: Color3[];
  75069. static Color4: Color4[];
  75070. }
  75071. }
  75072. declare module BABYLON {
  75073. /**
  75074. * Defines an interface which represents an animation key frame
  75075. */
  75076. export interface IAnimationKey {
  75077. /**
  75078. * Frame of the key frame
  75079. */
  75080. frame: number;
  75081. /**
  75082. * Value at the specifies key frame
  75083. */
  75084. value: any;
  75085. /**
  75086. * The input tangent for the cubic hermite spline
  75087. */
  75088. inTangent?: any;
  75089. /**
  75090. * The output tangent for the cubic hermite spline
  75091. */
  75092. outTangent?: any;
  75093. /**
  75094. * The animation interpolation type
  75095. */
  75096. interpolation?: AnimationKeyInterpolation;
  75097. }
  75098. /**
  75099. * Enum for the animation key frame interpolation type
  75100. */
  75101. export enum AnimationKeyInterpolation {
  75102. /**
  75103. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  75104. */
  75105. STEP = 1
  75106. }
  75107. }
  75108. declare module BABYLON {
  75109. /**
  75110. * Represents the range of an animation
  75111. */
  75112. export class AnimationRange {
  75113. /**The name of the animation range**/
  75114. name: string;
  75115. /**The starting frame of the animation */
  75116. from: number;
  75117. /**The ending frame of the animation*/
  75118. to: number;
  75119. /**
  75120. * Initializes the range of an animation
  75121. * @param name The name of the animation range
  75122. * @param from The starting frame of the animation
  75123. * @param to The ending frame of the animation
  75124. */
  75125. constructor(
  75126. /**The name of the animation range**/
  75127. name: string,
  75128. /**The starting frame of the animation */
  75129. from: number,
  75130. /**The ending frame of the animation*/
  75131. to: number);
  75132. /**
  75133. * Makes a copy of the animation range
  75134. * @returns A copy of the animation range
  75135. */
  75136. clone(): AnimationRange;
  75137. }
  75138. }
  75139. declare module BABYLON {
  75140. /**
  75141. * Composed of a frame, and an action function
  75142. */
  75143. export class AnimationEvent {
  75144. /** The frame for which the event is triggered **/
  75145. frame: number;
  75146. /** The event to perform when triggered **/
  75147. action: (currentFrame: number) => void;
  75148. /** Specifies if the event should be triggered only once**/
  75149. onlyOnce?: boolean | undefined;
  75150. /**
  75151. * Specifies if the animation event is done
  75152. */
  75153. isDone: boolean;
  75154. /**
  75155. * Initializes the animation event
  75156. * @param frame The frame for which the event is triggered
  75157. * @param action The event to perform when triggered
  75158. * @param onlyOnce Specifies if the event should be triggered only once
  75159. */
  75160. constructor(
  75161. /** The frame for which the event is triggered **/
  75162. frame: number,
  75163. /** The event to perform when triggered **/
  75164. action: (currentFrame: number) => void,
  75165. /** Specifies if the event should be triggered only once**/
  75166. onlyOnce?: boolean | undefined);
  75167. /** @hidden */
  75168. _clone(): AnimationEvent;
  75169. }
  75170. }
  75171. declare module BABYLON {
  75172. /**
  75173. * Interface used to define a behavior
  75174. */
  75175. export interface Behavior<T> {
  75176. /** gets or sets behavior's name */
  75177. name: string;
  75178. /**
  75179. * Function called when the behavior needs to be initialized (after attaching it to a target)
  75180. */
  75181. init(): void;
  75182. /**
  75183. * Called when the behavior is attached to a target
  75184. * @param target defines the target where the behavior is attached to
  75185. */
  75186. attach(target: T): void;
  75187. /**
  75188. * Called when the behavior is detached from its target
  75189. */
  75190. detach(): void;
  75191. }
  75192. /**
  75193. * Interface implemented by classes supporting behaviors
  75194. */
  75195. export interface IBehaviorAware<T> {
  75196. /**
  75197. * Attach a behavior
  75198. * @param behavior defines the behavior to attach
  75199. * @returns the current host
  75200. */
  75201. addBehavior(behavior: Behavior<T>): T;
  75202. /**
  75203. * Remove a behavior from the current object
  75204. * @param behavior defines the behavior to detach
  75205. * @returns the current host
  75206. */
  75207. removeBehavior(behavior: Behavior<T>): T;
  75208. /**
  75209. * Gets a behavior using its name to search
  75210. * @param name defines the name to search
  75211. * @returns the behavior or null if not found
  75212. */
  75213. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  75214. }
  75215. }
  75216. declare module BABYLON {
  75217. /**
  75218. * Defines an array and its length.
  75219. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  75220. */
  75221. export interface ISmartArrayLike<T> {
  75222. /**
  75223. * The data of the array.
  75224. */
  75225. data: Array<T>;
  75226. /**
  75227. * The active length of the array.
  75228. */
  75229. length: number;
  75230. }
  75231. /**
  75232. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  75233. */
  75234. export class SmartArray<T> implements ISmartArrayLike<T> {
  75235. /**
  75236. * The full set of data from the array.
  75237. */
  75238. data: Array<T>;
  75239. /**
  75240. * The active length of the array.
  75241. */
  75242. length: number;
  75243. protected _id: number;
  75244. /**
  75245. * Instantiates a Smart Array.
  75246. * @param capacity defines the default capacity of the array.
  75247. */
  75248. constructor(capacity: number);
  75249. /**
  75250. * Pushes a value at the end of the active data.
  75251. * @param value defines the object to push in the array.
  75252. */
  75253. push(value: T): void;
  75254. /**
  75255. * Iterates over the active data and apply the lambda to them.
  75256. * @param func defines the action to apply on each value.
  75257. */
  75258. forEach(func: (content: T) => void): void;
  75259. /**
  75260. * Sorts the full sets of data.
  75261. * @param compareFn defines the comparison function to apply.
  75262. */
  75263. sort(compareFn: (a: T, b: T) => number): void;
  75264. /**
  75265. * Resets the active data to an empty array.
  75266. */
  75267. reset(): void;
  75268. /**
  75269. * Releases all the data from the array as well as the array.
  75270. */
  75271. dispose(): void;
  75272. /**
  75273. * Concats the active data with a given array.
  75274. * @param array defines the data to concatenate with.
  75275. */
  75276. concat(array: any): void;
  75277. /**
  75278. * Returns the position of a value in the active data.
  75279. * @param value defines the value to find the index for
  75280. * @returns the index if found in the active data otherwise -1
  75281. */
  75282. indexOf(value: T): number;
  75283. /**
  75284. * Returns whether an element is part of the active data.
  75285. * @param value defines the value to look for
  75286. * @returns true if found in the active data otherwise false
  75287. */
  75288. contains(value: T): boolean;
  75289. private static _GlobalId;
  75290. }
  75291. /**
  75292. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  75293. * The data in this array can only be present once
  75294. */
  75295. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  75296. private _duplicateId;
  75297. /**
  75298. * Pushes a value at the end of the active data.
  75299. * THIS DOES NOT PREVENT DUPPLICATE DATA
  75300. * @param value defines the object to push in the array.
  75301. */
  75302. push(value: T): void;
  75303. /**
  75304. * Pushes a value at the end of the active data.
  75305. * If the data is already present, it won t be added again
  75306. * @param value defines the object to push in the array.
  75307. * @returns true if added false if it was already present
  75308. */
  75309. pushNoDuplicate(value: T): boolean;
  75310. /**
  75311. * Resets the active data to an empty array.
  75312. */
  75313. reset(): void;
  75314. /**
  75315. * Concats the active data with a given array.
  75316. * This ensures no dupplicate will be present in the result.
  75317. * @param array defines the data to concatenate with.
  75318. */
  75319. concatWithNoDuplicate(array: any): void;
  75320. }
  75321. }
  75322. declare module BABYLON {
  75323. /**
  75324. * @ignore
  75325. * This is a list of all the different input types that are available in the application.
  75326. * Fo instance: ArcRotateCameraGamepadInput...
  75327. */
  75328. export var CameraInputTypes: {};
  75329. /**
  75330. * This is the contract to implement in order to create a new input class.
  75331. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  75332. */
  75333. export interface ICameraInput<TCamera extends Camera> {
  75334. /**
  75335. * Defines the camera the input is attached to.
  75336. */
  75337. camera: Nullable<TCamera>;
  75338. /**
  75339. * Gets the class name of the current intput.
  75340. * @returns the class name
  75341. */
  75342. getClassName(): string;
  75343. /**
  75344. * Get the friendly name associated with the input class.
  75345. * @returns the input friendly name
  75346. */
  75347. getSimpleName(): string;
  75348. /**
  75349. * Attach the input controls to a specific dom element to get the input from.
  75350. * @param element Defines the element the controls should be listened from
  75351. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  75352. */
  75353. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  75354. /**
  75355. * Detach the current controls from the specified dom element.
  75356. * @param element Defines the element to stop listening the inputs from
  75357. */
  75358. detachControl(element: Nullable<HTMLElement>): void;
  75359. /**
  75360. * Update the current camera state depending on the inputs that have been used this frame.
  75361. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  75362. */
  75363. checkInputs?: () => void;
  75364. }
  75365. /**
  75366. * Represents a map of input types to input instance or input index to input instance.
  75367. */
  75368. export interface CameraInputsMap<TCamera extends Camera> {
  75369. /**
  75370. * Accessor to the input by input type.
  75371. */
  75372. [name: string]: ICameraInput<TCamera>;
  75373. /**
  75374. * Accessor to the input by input index.
  75375. */
  75376. [idx: number]: ICameraInput<TCamera>;
  75377. }
  75378. /**
  75379. * This represents the input manager used within a camera.
  75380. * It helps dealing with all the different kind of input attached to a camera.
  75381. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  75382. */
  75383. export class CameraInputsManager<TCamera extends Camera> {
  75384. /**
  75385. * Defines the list of inputs attahed to the camera.
  75386. */
  75387. attached: CameraInputsMap<TCamera>;
  75388. /**
  75389. * Defines the dom element the camera is collecting inputs from.
  75390. * This is null if the controls have not been attached.
  75391. */
  75392. attachedElement: Nullable<HTMLElement>;
  75393. /**
  75394. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  75395. */
  75396. noPreventDefault: boolean;
  75397. /**
  75398. * Defined the camera the input manager belongs to.
  75399. */
  75400. camera: TCamera;
  75401. /**
  75402. * Update the current camera state depending on the inputs that have been used this frame.
  75403. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  75404. */
  75405. checkInputs: () => void;
  75406. /**
  75407. * Instantiate a new Camera Input Manager.
  75408. * @param camera Defines the camera the input manager blongs to
  75409. */
  75410. constructor(camera: TCamera);
  75411. /**
  75412. * Add an input method to a camera
  75413. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  75414. * @param input camera input method
  75415. */
  75416. add(input: ICameraInput<TCamera>): void;
  75417. /**
  75418. * Remove a specific input method from a camera
  75419. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  75420. * @param inputToRemove camera input method
  75421. */
  75422. remove(inputToRemove: ICameraInput<TCamera>): void;
  75423. /**
  75424. * Remove a specific input type from a camera
  75425. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  75426. * @param inputType the type of the input to remove
  75427. */
  75428. removeByType(inputType: string): void;
  75429. private _addCheckInputs;
  75430. /**
  75431. * Attach the input controls to the currently attached dom element to listen the events from.
  75432. * @param input Defines the input to attach
  75433. */
  75434. attachInput(input: ICameraInput<TCamera>): void;
  75435. /**
  75436. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  75437. * @param element Defines the dom element to collect the events from
  75438. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  75439. */
  75440. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  75441. /**
  75442. * Detach the current manager inputs controls from a specific dom element.
  75443. * @param element Defines the dom element to collect the events from
  75444. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  75445. */
  75446. detachElement(element: HTMLElement, disconnect?: boolean): void;
  75447. /**
  75448. * Rebuild the dynamic inputCheck function from the current list of
  75449. * defined inputs in the manager.
  75450. */
  75451. rebuildInputCheck(): void;
  75452. /**
  75453. * Remove all attached input methods from a camera
  75454. */
  75455. clear(): void;
  75456. /**
  75457. * Serialize the current input manager attached to a camera.
  75458. * This ensures than once parsed,
  75459. * the input associated to the camera will be identical to the current ones
  75460. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  75461. */
  75462. serialize(serializedCamera: any): void;
  75463. /**
  75464. * Parses an input manager serialized JSON to restore the previous list of inputs
  75465. * and states associated to a camera.
  75466. * @param parsedCamera Defines the JSON to parse
  75467. */
  75468. parse(parsedCamera: any): void;
  75469. }
  75470. }
  75471. declare module BABYLON {
  75472. /**
  75473. * Class used to store data that will be store in GPU memory
  75474. */
  75475. export class Buffer {
  75476. private _engine;
  75477. private _buffer;
  75478. /** @hidden */
  75479. _data: Nullable<DataArray>;
  75480. private _updatable;
  75481. private _instanced;
  75482. private _divisor;
  75483. /**
  75484. * Gets the byte stride.
  75485. */
  75486. readonly byteStride: number;
  75487. /**
  75488. * Constructor
  75489. * @param engine the engine
  75490. * @param data the data to use for this buffer
  75491. * @param updatable whether the data is updatable
  75492. * @param stride the stride (optional)
  75493. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  75494. * @param instanced whether the buffer is instanced (optional)
  75495. * @param useBytes set to true if the stride in in bytes (optional)
  75496. * @param divisor sets an optional divisor for instances (1 by default)
  75497. */
  75498. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  75499. /**
  75500. * Create a new VertexBuffer based on the current buffer
  75501. * @param kind defines the vertex buffer kind (position, normal, etc.)
  75502. * @param offset defines offset in the buffer (0 by default)
  75503. * @param size defines the size in floats of attributes (position is 3 for instance)
  75504. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  75505. * @param instanced defines if the vertex buffer contains indexed data
  75506. * @param useBytes defines if the offset and stride are in bytes *
  75507. * @param divisor sets an optional divisor for instances (1 by default)
  75508. * @returns the new vertex buffer
  75509. */
  75510. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  75511. /**
  75512. * Gets a boolean indicating if the Buffer is updatable?
  75513. * @returns true if the buffer is updatable
  75514. */
  75515. isUpdatable(): boolean;
  75516. /**
  75517. * Gets current buffer's data
  75518. * @returns a DataArray or null
  75519. */
  75520. getData(): Nullable<DataArray>;
  75521. /**
  75522. * Gets underlying native buffer
  75523. * @returns underlying native buffer
  75524. */
  75525. getBuffer(): Nullable<DataBuffer>;
  75526. /**
  75527. * Gets the stride in float32 units (i.e. byte stride / 4).
  75528. * May not be an integer if the byte stride is not divisible by 4.
  75529. * @returns the stride in float32 units
  75530. * @deprecated Please use byteStride instead.
  75531. */
  75532. getStrideSize(): number;
  75533. /**
  75534. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  75535. * @param data defines the data to store
  75536. */
  75537. create(data?: Nullable<DataArray>): void;
  75538. /** @hidden */
  75539. _rebuild(): void;
  75540. /**
  75541. * Update current buffer data
  75542. * @param data defines the data to store
  75543. */
  75544. update(data: DataArray): void;
  75545. /**
  75546. * Updates the data directly.
  75547. * @param data the new data
  75548. * @param offset the new offset
  75549. * @param vertexCount the vertex count (optional)
  75550. * @param useBytes set to true if the offset is in bytes
  75551. */
  75552. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  75553. /**
  75554. * Release all resources
  75555. */
  75556. dispose(): void;
  75557. }
  75558. /**
  75559. * Specialized buffer used to store vertex data
  75560. */
  75561. export class VertexBuffer {
  75562. /** @hidden */
  75563. _buffer: Buffer;
  75564. private _kind;
  75565. private _size;
  75566. private _ownsBuffer;
  75567. private _instanced;
  75568. private _instanceDivisor;
  75569. /**
  75570. * The byte type.
  75571. */
  75572. static readonly BYTE: number;
  75573. /**
  75574. * The unsigned byte type.
  75575. */
  75576. static readonly UNSIGNED_BYTE: number;
  75577. /**
  75578. * The short type.
  75579. */
  75580. static readonly SHORT: number;
  75581. /**
  75582. * The unsigned short type.
  75583. */
  75584. static readonly UNSIGNED_SHORT: number;
  75585. /**
  75586. * The integer type.
  75587. */
  75588. static readonly INT: number;
  75589. /**
  75590. * The unsigned integer type.
  75591. */
  75592. static readonly UNSIGNED_INT: number;
  75593. /**
  75594. * The float type.
  75595. */
  75596. static readonly FLOAT: number;
  75597. /**
  75598. * Gets or sets the instance divisor when in instanced mode
  75599. */
  75600. instanceDivisor: number;
  75601. /**
  75602. * Gets the byte stride.
  75603. */
  75604. readonly byteStride: number;
  75605. /**
  75606. * Gets the byte offset.
  75607. */
  75608. readonly byteOffset: number;
  75609. /**
  75610. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  75611. */
  75612. readonly normalized: boolean;
  75613. /**
  75614. * Gets the data type of each component in the array.
  75615. */
  75616. readonly type: number;
  75617. /**
  75618. * Constructor
  75619. * @param engine the engine
  75620. * @param data the data to use for this vertex buffer
  75621. * @param kind the vertex buffer kind
  75622. * @param updatable whether the data is updatable
  75623. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  75624. * @param stride the stride (optional)
  75625. * @param instanced whether the buffer is instanced (optional)
  75626. * @param offset the offset of the data (optional)
  75627. * @param size the number of components (optional)
  75628. * @param type the type of the component (optional)
  75629. * @param normalized whether the data contains normalized data (optional)
  75630. * @param useBytes set to true if stride and offset are in bytes (optional)
  75631. * @param divisor defines the instance divisor to use (1 by default)
  75632. */
  75633. 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, divisor?: number);
  75634. /** @hidden */
  75635. _rebuild(): void;
  75636. /**
  75637. * Returns the kind of the VertexBuffer (string)
  75638. * @returns a string
  75639. */
  75640. getKind(): string;
  75641. /**
  75642. * Gets a boolean indicating if the VertexBuffer is updatable?
  75643. * @returns true if the buffer is updatable
  75644. */
  75645. isUpdatable(): boolean;
  75646. /**
  75647. * Gets current buffer's data
  75648. * @returns a DataArray or null
  75649. */
  75650. getData(): Nullable<DataArray>;
  75651. /**
  75652. * Gets underlying native buffer
  75653. * @returns underlying native buffer
  75654. */
  75655. getBuffer(): Nullable<DataBuffer>;
  75656. /**
  75657. * Gets the stride in float32 units (i.e. byte stride / 4).
  75658. * May not be an integer if the byte stride is not divisible by 4.
  75659. * @returns the stride in float32 units
  75660. * @deprecated Please use byteStride instead.
  75661. */
  75662. getStrideSize(): number;
  75663. /**
  75664. * Returns the offset as a multiple of the type byte length.
  75665. * @returns the offset in bytes
  75666. * @deprecated Please use byteOffset instead.
  75667. */
  75668. getOffset(): number;
  75669. /**
  75670. * Returns the number of components per vertex attribute (integer)
  75671. * @returns the size in float
  75672. */
  75673. getSize(): number;
  75674. /**
  75675. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  75676. * @returns true if this buffer is instanced
  75677. */
  75678. getIsInstanced(): boolean;
  75679. /**
  75680. * Returns the instancing divisor, zero for non-instanced (integer).
  75681. * @returns a number
  75682. */
  75683. getInstanceDivisor(): number;
  75684. /**
  75685. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  75686. * @param data defines the data to store
  75687. */
  75688. create(data?: DataArray): void;
  75689. /**
  75690. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  75691. * This function will create a new buffer if the current one is not updatable
  75692. * @param data defines the data to store
  75693. */
  75694. update(data: DataArray): void;
  75695. /**
  75696. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  75697. * Returns the directly updated WebGLBuffer.
  75698. * @param data the new data
  75699. * @param offset the new offset
  75700. * @param useBytes set to true if the offset is in bytes
  75701. */
  75702. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  75703. /**
  75704. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  75705. */
  75706. dispose(): void;
  75707. /**
  75708. * Enumerates each value of this vertex buffer as numbers.
  75709. * @param count the number of values to enumerate
  75710. * @param callback the callback function called for each value
  75711. */
  75712. forEach(count: number, callback: (value: number, index: number) => void): void;
  75713. /**
  75714. * Positions
  75715. */
  75716. static readonly PositionKind: string;
  75717. /**
  75718. * Normals
  75719. */
  75720. static readonly NormalKind: string;
  75721. /**
  75722. * Tangents
  75723. */
  75724. static readonly TangentKind: string;
  75725. /**
  75726. * Texture coordinates
  75727. */
  75728. static readonly UVKind: string;
  75729. /**
  75730. * Texture coordinates 2
  75731. */
  75732. static readonly UV2Kind: string;
  75733. /**
  75734. * Texture coordinates 3
  75735. */
  75736. static readonly UV3Kind: string;
  75737. /**
  75738. * Texture coordinates 4
  75739. */
  75740. static readonly UV4Kind: string;
  75741. /**
  75742. * Texture coordinates 5
  75743. */
  75744. static readonly UV5Kind: string;
  75745. /**
  75746. * Texture coordinates 6
  75747. */
  75748. static readonly UV6Kind: string;
  75749. /**
  75750. * Colors
  75751. */
  75752. static readonly ColorKind: string;
  75753. /**
  75754. * Matrix indices (for bones)
  75755. */
  75756. static readonly MatricesIndicesKind: string;
  75757. /**
  75758. * Matrix weights (for bones)
  75759. */
  75760. static readonly MatricesWeightsKind: string;
  75761. /**
  75762. * Additional matrix indices (for bones)
  75763. */
  75764. static readonly MatricesIndicesExtraKind: string;
  75765. /**
  75766. * Additional matrix weights (for bones)
  75767. */
  75768. static readonly MatricesWeightsExtraKind: string;
  75769. /**
  75770. * Deduces the stride given a kind.
  75771. * @param kind The kind string to deduce
  75772. * @returns The deduced stride
  75773. */
  75774. static DeduceStride(kind: string): number;
  75775. /**
  75776. * Gets the byte length of the given type.
  75777. * @param type the type
  75778. * @returns the number of bytes
  75779. */
  75780. static GetTypeByteLength(type: number): number;
  75781. /**
  75782. * Enumerates each value of the given parameters as numbers.
  75783. * @param data the data to enumerate
  75784. * @param byteOffset the byte offset of the data
  75785. * @param byteStride the byte stride of the data
  75786. * @param componentCount the number of components per element
  75787. * @param componentType the type of the component
  75788. * @param count the number of values to enumerate
  75789. * @param normalized whether the data is normalized
  75790. * @param callback the callback function called for each value
  75791. */
  75792. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  75793. private static _GetFloatValue;
  75794. }
  75795. }
  75796. declare module BABYLON {
  75797. /**
  75798. * @hidden
  75799. */
  75800. export class IntersectionInfo {
  75801. bu: Nullable<number>;
  75802. bv: Nullable<number>;
  75803. distance: number;
  75804. faceId: number;
  75805. subMeshId: number;
  75806. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  75807. }
  75808. }
  75809. declare module BABYLON {
  75810. /**
  75811. * Represens a plane by the equation ax + by + cz + d = 0
  75812. */
  75813. export class Plane {
  75814. private static _TmpMatrix;
  75815. /**
  75816. * Normal of the plane (a,b,c)
  75817. */
  75818. normal: Vector3;
  75819. /**
  75820. * d component of the plane
  75821. */
  75822. d: number;
  75823. /**
  75824. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  75825. * @param a a component of the plane
  75826. * @param b b component of the plane
  75827. * @param c c component of the plane
  75828. * @param d d component of the plane
  75829. */
  75830. constructor(a: number, b: number, c: number, d: number);
  75831. /**
  75832. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  75833. */
  75834. asArray(): number[];
  75835. /**
  75836. * @returns a new plane copied from the current Plane.
  75837. */
  75838. clone(): Plane;
  75839. /**
  75840. * @returns the string "Plane".
  75841. */
  75842. getClassName(): string;
  75843. /**
  75844. * @returns the Plane hash code.
  75845. */
  75846. getHashCode(): number;
  75847. /**
  75848. * Normalize the current Plane in place.
  75849. * @returns the updated Plane.
  75850. */
  75851. normalize(): Plane;
  75852. /**
  75853. * Applies a transformation the plane and returns the result
  75854. * @param transformation the transformation matrix to be applied to the plane
  75855. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  75856. */
  75857. transform(transformation: DeepImmutable<Matrix>): Plane;
  75858. /**
  75859. * Calcualtte the dot product between the point and the plane normal
  75860. * @param point point to calculate the dot product with
  75861. * @returns the dot product (float) of the point coordinates and the plane normal.
  75862. */
  75863. dotCoordinate(point: DeepImmutable<Vector3>): number;
  75864. /**
  75865. * Updates the current Plane from the plane defined by the three given points.
  75866. * @param point1 one of the points used to contruct the plane
  75867. * @param point2 one of the points used to contruct the plane
  75868. * @param point3 one of the points used to contruct the plane
  75869. * @returns the updated Plane.
  75870. */
  75871. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  75872. /**
  75873. * Checks if the plane is facing a given direction
  75874. * @param direction the direction to check if the plane is facing
  75875. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  75876. * @returns True is the vector "direction" is the same side than the plane normal.
  75877. */
  75878. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  75879. /**
  75880. * Calculates the distance to a point
  75881. * @param point point to calculate distance to
  75882. * @returns the signed distance (float) from the given point to the Plane.
  75883. */
  75884. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  75885. /**
  75886. * Creates a plane from an array
  75887. * @param array the array to create a plane from
  75888. * @returns a new Plane from the given array.
  75889. */
  75890. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  75891. /**
  75892. * Creates a plane from three points
  75893. * @param point1 point used to create the plane
  75894. * @param point2 point used to create the plane
  75895. * @param point3 point used to create the plane
  75896. * @returns a new Plane defined by the three given points.
  75897. */
  75898. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  75899. /**
  75900. * Creates a plane from an origin point and a normal
  75901. * @param origin origin of the plane to be constructed
  75902. * @param normal normal of the plane to be constructed
  75903. * @returns a new Plane the normal vector to this plane at the given origin point.
  75904. * Note : the vector "normal" is updated because normalized.
  75905. */
  75906. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  75907. /**
  75908. * Calculates the distance from a plane and a point
  75909. * @param origin origin of the plane to be constructed
  75910. * @param normal normal of the plane to be constructed
  75911. * @param point point to calculate distance to
  75912. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  75913. */
  75914. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  75915. }
  75916. }
  75917. declare module BABYLON {
  75918. /**
  75919. * Class used to store bounding sphere information
  75920. */
  75921. export class BoundingSphere {
  75922. /**
  75923. * Gets the center of the bounding sphere in local space
  75924. */
  75925. readonly center: Vector3;
  75926. /**
  75927. * Radius of the bounding sphere in local space
  75928. */
  75929. radius: number;
  75930. /**
  75931. * Gets the center of the bounding sphere in world space
  75932. */
  75933. readonly centerWorld: Vector3;
  75934. /**
  75935. * Radius of the bounding sphere in world space
  75936. */
  75937. radiusWorld: number;
  75938. /**
  75939. * Gets the minimum vector in local space
  75940. */
  75941. readonly minimum: Vector3;
  75942. /**
  75943. * Gets the maximum vector in local space
  75944. */
  75945. readonly maximum: Vector3;
  75946. private _worldMatrix;
  75947. private static readonly TmpVector3;
  75948. /**
  75949. * Creates a new bounding sphere
  75950. * @param min defines the minimum vector (in local space)
  75951. * @param max defines the maximum vector (in local space)
  75952. * @param worldMatrix defines the new world matrix
  75953. */
  75954. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  75955. /**
  75956. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  75957. * @param min defines the new minimum vector (in local space)
  75958. * @param max defines the new maximum vector (in local space)
  75959. * @param worldMatrix defines the new world matrix
  75960. */
  75961. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  75962. /**
  75963. * Scale the current bounding sphere by applying a scale factor
  75964. * @param factor defines the scale factor to apply
  75965. * @returns the current bounding box
  75966. */
  75967. scale(factor: number): BoundingSphere;
  75968. /**
  75969. * Gets the world matrix of the bounding box
  75970. * @returns a matrix
  75971. */
  75972. getWorldMatrix(): DeepImmutable<Matrix>;
  75973. /** @hidden */
  75974. _update(worldMatrix: DeepImmutable<Matrix>): void;
  75975. /**
  75976. * Tests if the bounding sphere is intersecting the frustum planes
  75977. * @param frustumPlanes defines the frustum planes to test
  75978. * @returns true if there is an intersection
  75979. */
  75980. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75981. /**
  75982. * Tests if the bounding sphere center is in between the frustum planes.
  75983. * Used for optimistic fast inclusion.
  75984. * @param frustumPlanes defines the frustum planes to test
  75985. * @returns true if the sphere center is in between the frustum planes
  75986. */
  75987. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75988. /**
  75989. * Tests if a point is inside the bounding sphere
  75990. * @param point defines the point to test
  75991. * @returns true if the point is inside the bounding sphere
  75992. */
  75993. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  75994. /**
  75995. * Checks if two sphere intersct
  75996. * @param sphere0 sphere 0
  75997. * @param sphere1 sphere 1
  75998. * @returns true if the speres intersect
  75999. */
  76000. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  76001. }
  76002. }
  76003. declare module BABYLON {
  76004. /**
  76005. * Class used to store bounding box information
  76006. */
  76007. export class BoundingBox implements ICullable {
  76008. /**
  76009. * Gets the 8 vectors representing the bounding box in local space
  76010. */
  76011. readonly vectors: Vector3[];
  76012. /**
  76013. * Gets the center of the bounding box in local space
  76014. */
  76015. readonly center: Vector3;
  76016. /**
  76017. * Gets the center of the bounding box in world space
  76018. */
  76019. readonly centerWorld: Vector3;
  76020. /**
  76021. * Gets the extend size in local space
  76022. */
  76023. readonly extendSize: Vector3;
  76024. /**
  76025. * Gets the extend size in world space
  76026. */
  76027. readonly extendSizeWorld: Vector3;
  76028. /**
  76029. * Gets the OBB (object bounding box) directions
  76030. */
  76031. readonly directions: Vector3[];
  76032. /**
  76033. * Gets the 8 vectors representing the bounding box in world space
  76034. */
  76035. readonly vectorsWorld: Vector3[];
  76036. /**
  76037. * Gets the minimum vector in world space
  76038. */
  76039. readonly minimumWorld: Vector3;
  76040. /**
  76041. * Gets the maximum vector in world space
  76042. */
  76043. readonly maximumWorld: Vector3;
  76044. /**
  76045. * Gets the minimum vector in local space
  76046. */
  76047. readonly minimum: Vector3;
  76048. /**
  76049. * Gets the maximum vector in local space
  76050. */
  76051. readonly maximum: Vector3;
  76052. private _worldMatrix;
  76053. private static readonly TmpVector3;
  76054. /**
  76055. * @hidden
  76056. */
  76057. _tag: number;
  76058. /**
  76059. * Creates a new bounding box
  76060. * @param min defines the minimum vector (in local space)
  76061. * @param max defines the maximum vector (in local space)
  76062. * @param worldMatrix defines the new world matrix
  76063. */
  76064. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  76065. /**
  76066. * Recreates the entire bounding box from scratch as if we call the constructor in place
  76067. * @param min defines the new minimum vector (in local space)
  76068. * @param max defines the new maximum vector (in local space)
  76069. * @param worldMatrix defines the new world matrix
  76070. */
  76071. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  76072. /**
  76073. * Scale the current bounding box by applying a scale factor
  76074. * @param factor defines the scale factor to apply
  76075. * @returns the current bounding box
  76076. */
  76077. scale(factor: number): BoundingBox;
  76078. /**
  76079. * Gets the world matrix of the bounding box
  76080. * @returns a matrix
  76081. */
  76082. getWorldMatrix(): DeepImmutable<Matrix>;
  76083. /** @hidden */
  76084. _update(world: DeepImmutable<Matrix>): void;
  76085. /**
  76086. * Tests if the bounding box is intersecting the frustum planes
  76087. * @param frustumPlanes defines the frustum planes to test
  76088. * @returns true if there is an intersection
  76089. */
  76090. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  76091. /**
  76092. * Tests if the bounding box is entirely inside the frustum planes
  76093. * @param frustumPlanes defines the frustum planes to test
  76094. * @returns true if there is an inclusion
  76095. */
  76096. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  76097. /**
  76098. * Tests if a point is inside the bounding box
  76099. * @param point defines the point to test
  76100. * @returns true if the point is inside the bounding box
  76101. */
  76102. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  76103. /**
  76104. * Tests if the bounding box intersects with a bounding sphere
  76105. * @param sphere defines the sphere to test
  76106. * @returns true if there is an intersection
  76107. */
  76108. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  76109. /**
  76110. * Tests if the bounding box intersects with a box defined by a min and max vectors
  76111. * @param min defines the min vector to use
  76112. * @param max defines the max vector to use
  76113. * @returns true if there is an intersection
  76114. */
  76115. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  76116. /**
  76117. * Tests if two bounding boxes are intersections
  76118. * @param box0 defines the first box to test
  76119. * @param box1 defines the second box to test
  76120. * @returns true if there is an intersection
  76121. */
  76122. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  76123. /**
  76124. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  76125. * @param minPoint defines the minimum vector of the bounding box
  76126. * @param maxPoint defines the maximum vector of the bounding box
  76127. * @param sphereCenter defines the sphere center
  76128. * @param sphereRadius defines the sphere radius
  76129. * @returns true if there is an intersection
  76130. */
  76131. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  76132. /**
  76133. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  76134. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  76135. * @param frustumPlanes defines the frustum planes to test
  76136. * @return true if there is an inclusion
  76137. */
  76138. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  76139. /**
  76140. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  76141. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  76142. * @param frustumPlanes defines the frustum planes to test
  76143. * @return true if there is an intersection
  76144. */
  76145. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  76146. }
  76147. }
  76148. declare module BABYLON {
  76149. /** @hidden */
  76150. export class Collider {
  76151. /** Define if a collision was found */
  76152. collisionFound: boolean;
  76153. /**
  76154. * Define last intersection point in local space
  76155. */
  76156. intersectionPoint: Vector3;
  76157. /**
  76158. * Define last collided mesh
  76159. */
  76160. collidedMesh: Nullable<AbstractMesh>;
  76161. private _collisionPoint;
  76162. private _planeIntersectionPoint;
  76163. private _tempVector;
  76164. private _tempVector2;
  76165. private _tempVector3;
  76166. private _tempVector4;
  76167. private _edge;
  76168. private _baseToVertex;
  76169. private _destinationPoint;
  76170. private _slidePlaneNormal;
  76171. private _displacementVector;
  76172. /** @hidden */
  76173. _radius: Vector3;
  76174. /** @hidden */
  76175. _retry: number;
  76176. private _velocity;
  76177. private _basePoint;
  76178. private _epsilon;
  76179. /** @hidden */
  76180. _velocityWorldLength: number;
  76181. /** @hidden */
  76182. _basePointWorld: Vector3;
  76183. private _velocityWorld;
  76184. private _normalizedVelocity;
  76185. /** @hidden */
  76186. _initialVelocity: Vector3;
  76187. /** @hidden */
  76188. _initialPosition: Vector3;
  76189. private _nearestDistance;
  76190. private _collisionMask;
  76191. collisionMask: number;
  76192. /**
  76193. * Gets the plane normal used to compute the sliding response (in local space)
  76194. */
  76195. readonly slidePlaneNormal: Vector3;
  76196. /** @hidden */
  76197. _initialize(source: Vector3, dir: Vector3, e: number): void;
  76198. /** @hidden */
  76199. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  76200. /** @hidden */
  76201. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  76202. /** @hidden */
  76203. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  76204. /** @hidden */
  76205. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  76206. /** @hidden */
  76207. _getResponse(pos: Vector3, vel: Vector3): void;
  76208. }
  76209. }
  76210. declare module BABYLON {
  76211. /**
  76212. * Interface for cullable objects
  76213. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  76214. */
  76215. export interface ICullable {
  76216. /**
  76217. * Checks if the object or part of the object is in the frustum
  76218. * @param frustumPlanes Camera near/planes
  76219. * @returns true if the object is in frustum otherwise false
  76220. */
  76221. isInFrustum(frustumPlanes: Plane[]): boolean;
  76222. /**
  76223. * Checks if a cullable object (mesh...) is in the camera frustum
  76224. * Unlike isInFrustum this cheks the full bounding box
  76225. * @param frustumPlanes Camera near/planes
  76226. * @returns true if the object is in frustum otherwise false
  76227. */
  76228. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  76229. }
  76230. /**
  76231. * Info for a bounding data of a mesh
  76232. */
  76233. export class BoundingInfo implements ICullable {
  76234. /**
  76235. * Bounding box for the mesh
  76236. */
  76237. readonly boundingBox: BoundingBox;
  76238. /**
  76239. * Bounding sphere for the mesh
  76240. */
  76241. readonly boundingSphere: BoundingSphere;
  76242. private _isLocked;
  76243. private static readonly TmpVector3;
  76244. /**
  76245. * Constructs bounding info
  76246. * @param minimum min vector of the bounding box/sphere
  76247. * @param maximum max vector of the bounding box/sphere
  76248. * @param worldMatrix defines the new world matrix
  76249. */
  76250. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  76251. /**
  76252. * Recreates the entire bounding info from scratch as if we call the constructor in place
  76253. * @param min defines the new minimum vector (in local space)
  76254. * @param max defines the new maximum vector (in local space)
  76255. * @param worldMatrix defines the new world matrix
  76256. */
  76257. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  76258. /**
  76259. * min vector of the bounding box/sphere
  76260. */
  76261. readonly minimum: Vector3;
  76262. /**
  76263. * max vector of the bounding box/sphere
  76264. */
  76265. readonly maximum: Vector3;
  76266. /**
  76267. * If the info is locked and won't be updated to avoid perf overhead
  76268. */
  76269. isLocked: boolean;
  76270. /**
  76271. * Updates the bounding sphere and box
  76272. * @param world world matrix to be used to update
  76273. */
  76274. update(world: DeepImmutable<Matrix>): void;
  76275. /**
  76276. * Recreate the bounding info to be centered around a specific point given a specific extend.
  76277. * @param center New center of the bounding info
  76278. * @param extend New extend of the bounding info
  76279. * @returns the current bounding info
  76280. */
  76281. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  76282. /**
  76283. * Scale the current bounding info by applying a scale factor
  76284. * @param factor defines the scale factor to apply
  76285. * @returns the current bounding info
  76286. */
  76287. scale(factor: number): BoundingInfo;
  76288. /**
  76289. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  76290. * @param frustumPlanes defines the frustum to test
  76291. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  76292. * @returns true if the bounding info is in the frustum planes
  76293. */
  76294. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  76295. /**
  76296. * Gets the world distance between the min and max points of the bounding box
  76297. */
  76298. readonly diagonalLength: number;
  76299. /**
  76300. * Checks if a cullable object (mesh...) is in the camera frustum
  76301. * Unlike isInFrustum this cheks the full bounding box
  76302. * @param frustumPlanes Camera near/planes
  76303. * @returns true if the object is in frustum otherwise false
  76304. */
  76305. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  76306. /** @hidden */
  76307. _checkCollision(collider: Collider): boolean;
  76308. /**
  76309. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  76310. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  76311. * @param point the point to check intersection with
  76312. * @returns if the point intersects
  76313. */
  76314. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  76315. /**
  76316. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  76317. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  76318. * @param boundingInfo the bounding info to check intersection with
  76319. * @param precise if the intersection should be done using OBB
  76320. * @returns if the bounding info intersects
  76321. */
  76322. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  76323. }
  76324. }
  76325. declare module BABYLON {
  76326. /**
  76327. * Extracts minimum and maximum values from a list of indexed positions
  76328. * @param positions defines the positions to use
  76329. * @param indices defines the indices to the positions
  76330. * @param indexStart defines the start index
  76331. * @param indexCount defines the end index
  76332. * @param bias defines bias value to add to the result
  76333. * @return minimum and maximum values
  76334. */
  76335. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  76336. minimum: Vector3;
  76337. maximum: Vector3;
  76338. };
  76339. /**
  76340. * Extracts minimum and maximum values from a list of positions
  76341. * @param positions defines the positions to use
  76342. * @param start defines the start index in the positions array
  76343. * @param count defines the number of positions to handle
  76344. * @param bias defines bias value to add to the result
  76345. * @param stride defines the stride size to use (distance between two positions in the positions array)
  76346. * @return minimum and maximum values
  76347. */
  76348. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  76349. minimum: Vector3;
  76350. maximum: Vector3;
  76351. };
  76352. }
  76353. declare module BABYLON {
  76354. /** @hidden */
  76355. export class WebGLDataBuffer extends DataBuffer {
  76356. private _buffer;
  76357. constructor(resource: WebGLBuffer);
  76358. readonly underlyingResource: any;
  76359. }
  76360. }
  76361. declare module BABYLON {
  76362. /** @hidden */
  76363. export class WebGLPipelineContext implements IPipelineContext {
  76364. engine: ThinEngine;
  76365. program: Nullable<WebGLProgram>;
  76366. context?: WebGLRenderingContext;
  76367. vertexShader?: WebGLShader;
  76368. fragmentShader?: WebGLShader;
  76369. isParallelCompiled: boolean;
  76370. onCompiled?: () => void;
  76371. transformFeedback?: WebGLTransformFeedback | null;
  76372. readonly isAsync: boolean;
  76373. readonly isReady: boolean;
  76374. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  76375. }
  76376. }
  76377. declare module BABYLON {
  76378. interface ThinEngine {
  76379. /**
  76380. * Create an uniform buffer
  76381. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  76382. * @param elements defines the content of the uniform buffer
  76383. * @returns the webGL uniform buffer
  76384. */
  76385. createUniformBuffer(elements: FloatArray): DataBuffer;
  76386. /**
  76387. * Create a dynamic uniform buffer
  76388. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  76389. * @param elements defines the content of the uniform buffer
  76390. * @returns the webGL uniform buffer
  76391. */
  76392. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  76393. /**
  76394. * Update an existing uniform buffer
  76395. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  76396. * @param uniformBuffer defines the target uniform buffer
  76397. * @param elements defines the content to update
  76398. * @param offset defines the offset in the uniform buffer where update should start
  76399. * @param count defines the size of the data to update
  76400. */
  76401. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  76402. /**
  76403. * Bind an uniform buffer to the current webGL context
  76404. * @param buffer defines the buffer to bind
  76405. */
  76406. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  76407. /**
  76408. * Bind a buffer to the current webGL context at a given location
  76409. * @param buffer defines the buffer to bind
  76410. * @param location defines the index where to bind the buffer
  76411. */
  76412. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  76413. /**
  76414. * Bind a specific block at a given index in a specific shader program
  76415. * @param pipelineContext defines the pipeline context to use
  76416. * @param blockName defines the block name
  76417. * @param index defines the index where to bind the block
  76418. */
  76419. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  76420. }
  76421. }
  76422. declare module BABYLON {
  76423. /**
  76424. * Uniform buffer objects.
  76425. *
  76426. * Handles blocks of uniform on the GPU.
  76427. *
  76428. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  76429. *
  76430. * For more information, please refer to :
  76431. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  76432. */
  76433. export class UniformBuffer {
  76434. private _engine;
  76435. private _buffer;
  76436. private _data;
  76437. private _bufferData;
  76438. private _dynamic?;
  76439. private _uniformLocations;
  76440. private _uniformSizes;
  76441. private _uniformLocationPointer;
  76442. private _needSync;
  76443. private _noUBO;
  76444. private _currentEffect;
  76445. /** @hidden */
  76446. _alreadyBound: boolean;
  76447. private static _MAX_UNIFORM_SIZE;
  76448. private static _tempBuffer;
  76449. /**
  76450. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  76451. * This is dynamic to allow compat with webgl 1 and 2.
  76452. * You will need to pass the name of the uniform as well as the value.
  76453. */
  76454. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  76455. /**
  76456. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  76457. * This is dynamic to allow compat with webgl 1 and 2.
  76458. * You will need to pass the name of the uniform as well as the value.
  76459. */
  76460. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  76461. /**
  76462. * Lambda to Update a single float in a uniform buffer.
  76463. * This is dynamic to allow compat with webgl 1 and 2.
  76464. * You will need to pass the name of the uniform as well as the value.
  76465. */
  76466. updateFloat: (name: string, x: number) => void;
  76467. /**
  76468. * Lambda to Update a vec2 of float in a uniform buffer.
  76469. * This is dynamic to allow compat with webgl 1 and 2.
  76470. * You will need to pass the name of the uniform as well as the value.
  76471. */
  76472. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  76473. /**
  76474. * Lambda to Update a vec3 of float in a uniform buffer.
  76475. * This is dynamic to allow compat with webgl 1 and 2.
  76476. * You will need to pass the name of the uniform as well as the value.
  76477. */
  76478. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  76479. /**
  76480. * Lambda to Update a vec4 of float in a uniform buffer.
  76481. * This is dynamic to allow compat with webgl 1 and 2.
  76482. * You will need to pass the name of the uniform as well as the value.
  76483. */
  76484. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  76485. /**
  76486. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  76487. * This is dynamic to allow compat with webgl 1 and 2.
  76488. * You will need to pass the name of the uniform as well as the value.
  76489. */
  76490. updateMatrix: (name: string, mat: Matrix) => void;
  76491. /**
  76492. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  76493. * This is dynamic to allow compat with webgl 1 and 2.
  76494. * You will need to pass the name of the uniform as well as the value.
  76495. */
  76496. updateVector3: (name: string, vector: Vector3) => void;
  76497. /**
  76498. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  76499. * This is dynamic to allow compat with webgl 1 and 2.
  76500. * You will need to pass the name of the uniform as well as the value.
  76501. */
  76502. updateVector4: (name: string, vector: Vector4) => void;
  76503. /**
  76504. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  76505. * This is dynamic to allow compat with webgl 1 and 2.
  76506. * You will need to pass the name of the uniform as well as the value.
  76507. */
  76508. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  76509. /**
  76510. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  76511. * This is dynamic to allow compat with webgl 1 and 2.
  76512. * You will need to pass the name of the uniform as well as the value.
  76513. */
  76514. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  76515. /**
  76516. * Instantiates a new Uniform buffer objects.
  76517. *
  76518. * Handles blocks of uniform on the GPU.
  76519. *
  76520. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  76521. *
  76522. * For more information, please refer to :
  76523. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  76524. * @param engine Define the engine the buffer is associated with
  76525. * @param data Define the data contained in the buffer
  76526. * @param dynamic Define if the buffer is updatable
  76527. */
  76528. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  76529. /**
  76530. * Indicates if the buffer is using the WebGL2 UBO implementation,
  76531. * or just falling back on setUniformXXX calls.
  76532. */
  76533. readonly useUbo: boolean;
  76534. /**
  76535. * Indicates if the WebGL underlying uniform buffer is in sync
  76536. * with the javascript cache data.
  76537. */
  76538. readonly isSync: boolean;
  76539. /**
  76540. * Indicates if the WebGL underlying uniform buffer is dynamic.
  76541. * Also, a dynamic UniformBuffer will disable cache verification and always
  76542. * update the underlying WebGL uniform buffer to the GPU.
  76543. * @returns if Dynamic, otherwise false
  76544. */
  76545. isDynamic(): boolean;
  76546. /**
  76547. * The data cache on JS side.
  76548. * @returns the underlying data as a float array
  76549. */
  76550. getData(): Float32Array;
  76551. /**
  76552. * The underlying WebGL Uniform buffer.
  76553. * @returns the webgl buffer
  76554. */
  76555. getBuffer(): Nullable<DataBuffer>;
  76556. /**
  76557. * std140 layout specifies how to align data within an UBO structure.
  76558. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  76559. * for specs.
  76560. */
  76561. private _fillAlignment;
  76562. /**
  76563. * Adds an uniform in the buffer.
  76564. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  76565. * for the layout to be correct !
  76566. * @param name Name of the uniform, as used in the uniform block in the shader.
  76567. * @param size Data size, or data directly.
  76568. */
  76569. addUniform(name: string, size: number | number[]): void;
  76570. /**
  76571. * Adds a Matrix 4x4 to the uniform buffer.
  76572. * @param name Name of the uniform, as used in the uniform block in the shader.
  76573. * @param mat A 4x4 matrix.
  76574. */
  76575. addMatrix(name: string, mat: Matrix): void;
  76576. /**
  76577. * Adds a vec2 to the uniform buffer.
  76578. * @param name Name of the uniform, as used in the uniform block in the shader.
  76579. * @param x Define the x component value of the vec2
  76580. * @param y Define the y component value of the vec2
  76581. */
  76582. addFloat2(name: string, x: number, y: number): void;
  76583. /**
  76584. * Adds a vec3 to the uniform buffer.
  76585. * @param name Name of the uniform, as used in the uniform block in the shader.
  76586. * @param x Define the x component value of the vec3
  76587. * @param y Define the y component value of the vec3
  76588. * @param z Define the z component value of the vec3
  76589. */
  76590. addFloat3(name: string, x: number, y: number, z: number): void;
  76591. /**
  76592. * Adds a vec3 to the uniform buffer.
  76593. * @param name Name of the uniform, as used in the uniform block in the shader.
  76594. * @param color Define the vec3 from a Color
  76595. */
  76596. addColor3(name: string, color: Color3): void;
  76597. /**
  76598. * Adds a vec4 to the uniform buffer.
  76599. * @param name Name of the uniform, as used in the uniform block in the shader.
  76600. * @param color Define the rgb components from a Color
  76601. * @param alpha Define the a component of the vec4
  76602. */
  76603. addColor4(name: string, color: Color3, alpha: number): void;
  76604. /**
  76605. * Adds a vec3 to the uniform buffer.
  76606. * @param name Name of the uniform, as used in the uniform block in the shader.
  76607. * @param vector Define the vec3 components from a Vector
  76608. */
  76609. addVector3(name: string, vector: Vector3): void;
  76610. /**
  76611. * Adds a Matrix 3x3 to the uniform buffer.
  76612. * @param name Name of the uniform, as used in the uniform block in the shader.
  76613. */
  76614. addMatrix3x3(name: string): void;
  76615. /**
  76616. * Adds a Matrix 2x2 to the uniform buffer.
  76617. * @param name Name of the uniform, as used in the uniform block in the shader.
  76618. */
  76619. addMatrix2x2(name: string): void;
  76620. /**
  76621. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  76622. */
  76623. create(): void;
  76624. /** @hidden */
  76625. _rebuild(): void;
  76626. /**
  76627. * Updates the WebGL Uniform Buffer on the GPU.
  76628. * If the `dynamic` flag is set to true, no cache comparison is done.
  76629. * Otherwise, the buffer will be updated only if the cache differs.
  76630. */
  76631. update(): void;
  76632. /**
  76633. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  76634. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  76635. * @param data Define the flattened data
  76636. * @param size Define the size of the data.
  76637. */
  76638. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  76639. private _valueCache;
  76640. private _cacheMatrix;
  76641. private _updateMatrix3x3ForUniform;
  76642. private _updateMatrix3x3ForEffect;
  76643. private _updateMatrix2x2ForEffect;
  76644. private _updateMatrix2x2ForUniform;
  76645. private _updateFloatForEffect;
  76646. private _updateFloatForUniform;
  76647. private _updateFloat2ForEffect;
  76648. private _updateFloat2ForUniform;
  76649. private _updateFloat3ForEffect;
  76650. private _updateFloat3ForUniform;
  76651. private _updateFloat4ForEffect;
  76652. private _updateFloat4ForUniform;
  76653. private _updateMatrixForEffect;
  76654. private _updateMatrixForUniform;
  76655. private _updateVector3ForEffect;
  76656. private _updateVector3ForUniform;
  76657. private _updateVector4ForEffect;
  76658. private _updateVector4ForUniform;
  76659. private _updateColor3ForEffect;
  76660. private _updateColor3ForUniform;
  76661. private _updateColor4ForEffect;
  76662. private _updateColor4ForUniform;
  76663. /**
  76664. * Sets a sampler uniform on the effect.
  76665. * @param name Define the name of the sampler.
  76666. * @param texture Define the texture to set in the sampler
  76667. */
  76668. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  76669. /**
  76670. * Directly updates the value of the uniform in the cache AND on the GPU.
  76671. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  76672. * @param data Define the flattened data
  76673. */
  76674. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  76675. /**
  76676. * Binds this uniform buffer to an effect.
  76677. * @param effect Define the effect to bind the buffer to
  76678. * @param name Name of the uniform block in the shader.
  76679. */
  76680. bindToEffect(effect: Effect, name: string): void;
  76681. /**
  76682. * Disposes the uniform buffer.
  76683. */
  76684. dispose(): void;
  76685. }
  76686. }
  76687. declare module BABYLON {
  76688. /**
  76689. * Enum that determines the text-wrapping mode to use.
  76690. */
  76691. export enum InspectableType {
  76692. /**
  76693. * Checkbox for booleans
  76694. */
  76695. Checkbox = 0,
  76696. /**
  76697. * Sliders for numbers
  76698. */
  76699. Slider = 1,
  76700. /**
  76701. * Vector3
  76702. */
  76703. Vector3 = 2,
  76704. /**
  76705. * Quaternions
  76706. */
  76707. Quaternion = 3,
  76708. /**
  76709. * Color3
  76710. */
  76711. Color3 = 4,
  76712. /**
  76713. * String
  76714. */
  76715. String = 5
  76716. }
  76717. /**
  76718. * Interface used to define custom inspectable properties.
  76719. * This interface is used by the inspector to display custom property grids
  76720. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  76721. */
  76722. export interface IInspectable {
  76723. /**
  76724. * Gets the label to display
  76725. */
  76726. label: string;
  76727. /**
  76728. * Gets the name of the property to edit
  76729. */
  76730. propertyName: string;
  76731. /**
  76732. * Gets the type of the editor to use
  76733. */
  76734. type: InspectableType;
  76735. /**
  76736. * Gets the minimum value of the property when using in "slider" mode
  76737. */
  76738. min?: number;
  76739. /**
  76740. * Gets the maximum value of the property when using in "slider" mode
  76741. */
  76742. max?: number;
  76743. /**
  76744. * Gets the setp to use when using in "slider" mode
  76745. */
  76746. step?: number;
  76747. }
  76748. }
  76749. declare module BABYLON {
  76750. /**
  76751. * Class used to provide helper for timing
  76752. */
  76753. export class TimingTools {
  76754. /**
  76755. * Polyfill for setImmediate
  76756. * @param action defines the action to execute after the current execution block
  76757. */
  76758. static SetImmediate(action: () => void): void;
  76759. }
  76760. }
  76761. declare module BABYLON {
  76762. /**
  76763. * Class used to enable instatition of objects by class name
  76764. */
  76765. export class InstantiationTools {
  76766. /**
  76767. * Use this object to register external classes like custom textures or material
  76768. * to allow the laoders to instantiate them
  76769. */
  76770. static RegisteredExternalClasses: {
  76771. [key: string]: Object;
  76772. };
  76773. /**
  76774. * Tries to instantiate a new object from a given class name
  76775. * @param className defines the class name to instantiate
  76776. * @returns the new object or null if the system was not able to do the instantiation
  76777. */
  76778. static Instantiate(className: string): any;
  76779. }
  76780. }
  76781. declare module BABYLON {
  76782. /**
  76783. * Define options used to create a depth texture
  76784. */
  76785. export class DepthTextureCreationOptions {
  76786. /** Specifies whether or not a stencil should be allocated in the texture */
  76787. generateStencil?: boolean;
  76788. /** Specifies whether or not bilinear filtering is enable on the texture */
  76789. bilinearFiltering?: boolean;
  76790. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  76791. comparisonFunction?: number;
  76792. /** Specifies if the created texture is a cube texture */
  76793. isCube?: boolean;
  76794. }
  76795. }
  76796. declare module BABYLON {
  76797. interface ThinEngine {
  76798. /**
  76799. * Creates a depth stencil cube texture.
  76800. * This is only available in WebGL 2.
  76801. * @param size The size of face edge in the cube texture.
  76802. * @param options The options defining the cube texture.
  76803. * @returns The cube texture
  76804. */
  76805. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  76806. /**
  76807. * Creates a cube texture
  76808. * @param rootUrl defines the url where the files to load is located
  76809. * @param scene defines the current scene
  76810. * @param files defines the list of files to load (1 per face)
  76811. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  76812. * @param onLoad defines an optional callback raised when the texture is loaded
  76813. * @param onError defines an optional callback raised if there is an issue to load the texture
  76814. * @param format defines the format of the data
  76815. * @param forcedExtension defines the extension to use to pick the right loader
  76816. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  76817. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  76818. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  76819. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  76820. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  76821. * @returns the cube texture as an InternalTexture
  76822. */
  76823. 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;
  76824. /**
  76825. * Creates a cube texture
  76826. * @param rootUrl defines the url where the files to load is located
  76827. * @param scene defines the current scene
  76828. * @param files defines the list of files to load (1 per face)
  76829. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  76830. * @param onLoad defines an optional callback raised when the texture is loaded
  76831. * @param onError defines an optional callback raised if there is an issue to load the texture
  76832. * @param format defines the format of the data
  76833. * @param forcedExtension defines the extension to use to pick the right loader
  76834. * @returns the cube texture as an InternalTexture
  76835. */
  76836. 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;
  76837. /**
  76838. * Creates a cube texture
  76839. * @param rootUrl defines the url where the files to load is located
  76840. * @param scene defines the current scene
  76841. * @param files defines the list of files to load (1 per face)
  76842. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  76843. * @param onLoad defines an optional callback raised when the texture is loaded
  76844. * @param onError defines an optional callback raised if there is an issue to load the texture
  76845. * @param format defines the format of the data
  76846. * @param forcedExtension defines the extension to use to pick the right loader
  76847. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  76848. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  76849. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  76850. * @returns the cube texture as an InternalTexture
  76851. */
  76852. 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;
  76853. /** @hidden */
  76854. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  76855. /** @hidden */
  76856. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  76857. /** @hidden */
  76858. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  76859. /** @hidden */
  76860. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  76861. /**
  76862. * @hidden
  76863. */
  76864. _setCubeMapTextureParams(loadMipmap: boolean): void;
  76865. }
  76866. }
  76867. declare module BABYLON {
  76868. /**
  76869. * Class for creating a cube texture
  76870. */
  76871. export class CubeTexture extends BaseTexture {
  76872. private _delayedOnLoad;
  76873. /**
  76874. * The url of the texture
  76875. */
  76876. url: string;
  76877. /**
  76878. * Gets or sets the center of the bounding box associated with the cube texture.
  76879. * It must define where the camera used to render the texture was set
  76880. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  76881. */
  76882. boundingBoxPosition: Vector3;
  76883. private _boundingBoxSize;
  76884. /**
  76885. * Gets or sets the size of the bounding box associated with the cube texture
  76886. * When defined, the cubemap will switch to local mode
  76887. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  76888. * @example https://www.babylonjs-playground.com/#RNASML
  76889. */
  76890. /**
  76891. * Returns the bounding box size
  76892. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  76893. */
  76894. boundingBoxSize: Vector3;
  76895. protected _rotationY: number;
  76896. /**
  76897. * Sets texture matrix rotation angle around Y axis in radians.
  76898. */
  76899. /**
  76900. * Gets texture matrix rotation angle around Y axis radians.
  76901. */
  76902. rotationY: number;
  76903. /**
  76904. * Are mip maps generated for this texture or not.
  76905. */
  76906. readonly noMipmap: boolean;
  76907. private _noMipmap;
  76908. private _files;
  76909. protected _forcedExtension: Nullable<string>;
  76910. private _extensions;
  76911. private _textureMatrix;
  76912. private _format;
  76913. private _createPolynomials;
  76914. /** @hidden */
  76915. _prefiltered: boolean;
  76916. /**
  76917. * Creates a cube texture from an array of image urls
  76918. * @param files defines an array of image urls
  76919. * @param scene defines the hosting scene
  76920. * @param noMipmap specifies if mip maps are not used
  76921. * @returns a cube texture
  76922. */
  76923. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  76924. /**
  76925. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  76926. * @param url defines the url of the prefiltered texture
  76927. * @param scene defines the scene the texture is attached to
  76928. * @param forcedExtension defines the extension of the file if different from the url
  76929. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  76930. * @return the prefiltered texture
  76931. */
  76932. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  76933. /**
  76934. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  76935. * as prefiltered data.
  76936. * @param rootUrl defines the url of the texture or the root name of the six images
  76937. * @param scene defines the scene the texture is attached to
  76938. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  76939. * @param noMipmap defines if mipmaps should be created or not
  76940. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  76941. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  76942. * @param onError defines a callback triggered in case of error during load
  76943. * @param format defines the internal format to use for the texture once loaded
  76944. * @param prefiltered defines whether or not the texture is created from prefiltered data
  76945. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  76946. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  76947. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  76948. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  76949. * @return the cube texture
  76950. */
  76951. 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);
  76952. /**
  76953. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  76954. */
  76955. readonly isPrefiltered: boolean;
  76956. /**
  76957. * Get the current class name of the texture useful for serialization or dynamic coding.
  76958. * @returns "CubeTexture"
  76959. */
  76960. getClassName(): string;
  76961. /**
  76962. * Update the url (and optional buffer) of this texture if url was null during construction.
  76963. * @param url the url of the texture
  76964. * @param forcedExtension defines the extension to use
  76965. * @param onLoad callback called when the texture is loaded (defaults to null)
  76966. */
  76967. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  76968. /**
  76969. * Delays loading of the cube texture
  76970. * @param forcedExtension defines the extension to use
  76971. */
  76972. delayLoad(forcedExtension?: string): void;
  76973. /**
  76974. * Returns the reflection texture matrix
  76975. * @returns the reflection texture matrix
  76976. */
  76977. getReflectionTextureMatrix(): Matrix;
  76978. /**
  76979. * Sets the reflection texture matrix
  76980. * @param value Reflection texture matrix
  76981. */
  76982. setReflectionTextureMatrix(value: Matrix): void;
  76983. /**
  76984. * Parses text to create a cube texture
  76985. * @param parsedTexture define the serialized text to read from
  76986. * @param scene defines the hosting scene
  76987. * @param rootUrl defines the root url of the cube texture
  76988. * @returns a cube texture
  76989. */
  76990. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  76991. /**
  76992. * Makes a clone, or deep copy, of the cube texture
  76993. * @returns a new cube texture
  76994. */
  76995. clone(): CubeTexture;
  76996. }
  76997. }
  76998. declare module BABYLON {
  76999. /**
  77000. * Manages the defines for the Material
  77001. */
  77002. export class MaterialDefines {
  77003. /** @hidden */
  77004. protected _keys: string[];
  77005. private _isDirty;
  77006. /** @hidden */
  77007. _renderId: number;
  77008. /** @hidden */
  77009. _areLightsDirty: boolean;
  77010. /** @hidden */
  77011. _areLightsDisposed: boolean;
  77012. /** @hidden */
  77013. _areAttributesDirty: boolean;
  77014. /** @hidden */
  77015. _areTexturesDirty: boolean;
  77016. /** @hidden */
  77017. _areFresnelDirty: boolean;
  77018. /** @hidden */
  77019. _areMiscDirty: boolean;
  77020. /** @hidden */
  77021. _areImageProcessingDirty: boolean;
  77022. /** @hidden */
  77023. _normals: boolean;
  77024. /** @hidden */
  77025. _uvs: boolean;
  77026. /** @hidden */
  77027. _needNormals: boolean;
  77028. /** @hidden */
  77029. _needUVs: boolean;
  77030. [id: string]: any;
  77031. /**
  77032. * Specifies if the material needs to be re-calculated
  77033. */
  77034. readonly isDirty: boolean;
  77035. /**
  77036. * Marks the material to indicate that it has been re-calculated
  77037. */
  77038. markAsProcessed(): void;
  77039. /**
  77040. * Marks the material to indicate that it needs to be re-calculated
  77041. */
  77042. markAsUnprocessed(): void;
  77043. /**
  77044. * Marks the material to indicate all of its defines need to be re-calculated
  77045. */
  77046. markAllAsDirty(): void;
  77047. /**
  77048. * Marks the material to indicate that image processing needs to be re-calculated
  77049. */
  77050. markAsImageProcessingDirty(): void;
  77051. /**
  77052. * Marks the material to indicate the lights need to be re-calculated
  77053. * @param disposed Defines whether the light is dirty due to dispose or not
  77054. */
  77055. markAsLightDirty(disposed?: boolean): void;
  77056. /**
  77057. * Marks the attribute state as changed
  77058. */
  77059. markAsAttributesDirty(): void;
  77060. /**
  77061. * Marks the texture state as changed
  77062. */
  77063. markAsTexturesDirty(): void;
  77064. /**
  77065. * Marks the fresnel state as changed
  77066. */
  77067. markAsFresnelDirty(): void;
  77068. /**
  77069. * Marks the misc state as changed
  77070. */
  77071. markAsMiscDirty(): void;
  77072. /**
  77073. * Rebuilds the material defines
  77074. */
  77075. rebuild(): void;
  77076. /**
  77077. * Specifies if two material defines are equal
  77078. * @param other - A material define instance to compare to
  77079. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  77080. */
  77081. isEqual(other: MaterialDefines): boolean;
  77082. /**
  77083. * Clones this instance's defines to another instance
  77084. * @param other - material defines to clone values to
  77085. */
  77086. cloneTo(other: MaterialDefines): void;
  77087. /**
  77088. * Resets the material define values
  77089. */
  77090. reset(): void;
  77091. /**
  77092. * Converts the material define values to a string
  77093. * @returns - String of material define information
  77094. */
  77095. toString(): string;
  77096. }
  77097. }
  77098. declare module BABYLON {
  77099. /**
  77100. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  77101. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  77102. * 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;
  77103. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  77104. */
  77105. export class ColorCurves {
  77106. private _dirty;
  77107. private _tempColor;
  77108. private _globalCurve;
  77109. private _highlightsCurve;
  77110. private _midtonesCurve;
  77111. private _shadowsCurve;
  77112. private _positiveCurve;
  77113. private _negativeCurve;
  77114. private _globalHue;
  77115. private _globalDensity;
  77116. private _globalSaturation;
  77117. private _globalExposure;
  77118. /**
  77119. * Gets the global Hue value.
  77120. * 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).
  77121. */
  77122. /**
  77123. * Sets the global Hue value.
  77124. * 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).
  77125. */
  77126. globalHue: number;
  77127. /**
  77128. * Gets the global Density value.
  77129. * 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.
  77130. * Values less than zero provide a filter of opposite hue.
  77131. */
  77132. /**
  77133. * Sets the global Density value.
  77134. * 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.
  77135. * Values less than zero provide a filter of opposite hue.
  77136. */
  77137. globalDensity: number;
  77138. /**
  77139. * Gets the global Saturation value.
  77140. * 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.
  77141. */
  77142. /**
  77143. * Sets the global Saturation value.
  77144. * 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.
  77145. */
  77146. globalSaturation: number;
  77147. /**
  77148. * Gets the global Exposure value.
  77149. * 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.
  77150. */
  77151. /**
  77152. * Sets the global Exposure value.
  77153. * 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.
  77154. */
  77155. globalExposure: number;
  77156. private _highlightsHue;
  77157. private _highlightsDensity;
  77158. private _highlightsSaturation;
  77159. private _highlightsExposure;
  77160. /**
  77161. * Gets the highlights Hue value.
  77162. * 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).
  77163. */
  77164. /**
  77165. * Sets the highlights Hue value.
  77166. * 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).
  77167. */
  77168. highlightsHue: number;
  77169. /**
  77170. * Gets the highlights Density value.
  77171. * 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.
  77172. * Values less than zero provide a filter of opposite hue.
  77173. */
  77174. /**
  77175. * Sets the highlights Density value.
  77176. * 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.
  77177. * Values less than zero provide a filter of opposite hue.
  77178. */
  77179. highlightsDensity: number;
  77180. /**
  77181. * Gets the highlights Saturation value.
  77182. * 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.
  77183. */
  77184. /**
  77185. * Sets the highlights Saturation value.
  77186. * 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.
  77187. */
  77188. highlightsSaturation: number;
  77189. /**
  77190. * Gets the highlights Exposure value.
  77191. * 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.
  77192. */
  77193. /**
  77194. * Sets the highlights Exposure value.
  77195. * 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.
  77196. */
  77197. highlightsExposure: number;
  77198. private _midtonesHue;
  77199. private _midtonesDensity;
  77200. private _midtonesSaturation;
  77201. private _midtonesExposure;
  77202. /**
  77203. * Gets the midtones Hue value.
  77204. * 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).
  77205. */
  77206. /**
  77207. * Sets the midtones Hue value.
  77208. * 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).
  77209. */
  77210. midtonesHue: number;
  77211. /**
  77212. * Gets the midtones Density value.
  77213. * 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.
  77214. * Values less than zero provide a filter of opposite hue.
  77215. */
  77216. /**
  77217. * Sets the midtones Density value.
  77218. * 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.
  77219. * Values less than zero provide a filter of opposite hue.
  77220. */
  77221. midtonesDensity: number;
  77222. /**
  77223. * Gets the midtones Saturation value.
  77224. * 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.
  77225. */
  77226. /**
  77227. * Sets the midtones Saturation value.
  77228. * 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.
  77229. */
  77230. midtonesSaturation: number;
  77231. /**
  77232. * Gets the midtones Exposure value.
  77233. * 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.
  77234. */
  77235. /**
  77236. * Sets the midtones Exposure value.
  77237. * 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.
  77238. */
  77239. midtonesExposure: number;
  77240. private _shadowsHue;
  77241. private _shadowsDensity;
  77242. private _shadowsSaturation;
  77243. private _shadowsExposure;
  77244. /**
  77245. * Gets the shadows Hue value.
  77246. * 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).
  77247. */
  77248. /**
  77249. * Sets the shadows Hue value.
  77250. * 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).
  77251. */
  77252. shadowsHue: number;
  77253. /**
  77254. * Gets the shadows Density value.
  77255. * 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.
  77256. * Values less than zero provide a filter of opposite hue.
  77257. */
  77258. /**
  77259. * Sets the shadows Density value.
  77260. * 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.
  77261. * Values less than zero provide a filter of opposite hue.
  77262. */
  77263. shadowsDensity: number;
  77264. /**
  77265. * Gets the shadows Saturation value.
  77266. * 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.
  77267. */
  77268. /**
  77269. * Sets the shadows Saturation value.
  77270. * 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.
  77271. */
  77272. shadowsSaturation: number;
  77273. /**
  77274. * Gets the shadows Exposure value.
  77275. * 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.
  77276. */
  77277. /**
  77278. * Sets the shadows Exposure value.
  77279. * 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.
  77280. */
  77281. shadowsExposure: number;
  77282. /**
  77283. * Returns the class name
  77284. * @returns The class name
  77285. */
  77286. getClassName(): string;
  77287. /**
  77288. * Binds the color curves to the shader.
  77289. * @param colorCurves The color curve to bind
  77290. * @param effect The effect to bind to
  77291. * @param positiveUniform The positive uniform shader parameter
  77292. * @param neutralUniform The neutral uniform shader parameter
  77293. * @param negativeUniform The negative uniform shader parameter
  77294. */
  77295. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  77296. /**
  77297. * Prepare the list of uniforms associated with the ColorCurves effects.
  77298. * @param uniformsList The list of uniforms used in the effect
  77299. */
  77300. static PrepareUniforms(uniformsList: string[]): void;
  77301. /**
  77302. * Returns color grading data based on a hue, density, saturation and exposure value.
  77303. * @param filterHue The hue of the color filter.
  77304. * @param filterDensity The density of the color filter.
  77305. * @param saturation The saturation.
  77306. * @param exposure The exposure.
  77307. * @param result The result data container.
  77308. */
  77309. private getColorGradingDataToRef;
  77310. /**
  77311. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  77312. * @param value The input slider value in range [-100,100].
  77313. * @returns Adjusted value.
  77314. */
  77315. private static applyColorGradingSliderNonlinear;
  77316. /**
  77317. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  77318. * @param hue The hue (H) input.
  77319. * @param saturation The saturation (S) input.
  77320. * @param brightness The brightness (B) input.
  77321. * @result An RGBA color represented as Vector4.
  77322. */
  77323. private static fromHSBToRef;
  77324. /**
  77325. * Returns a value clamped between min and max
  77326. * @param value The value to clamp
  77327. * @param min The minimum of value
  77328. * @param max The maximum of value
  77329. * @returns The clamped value.
  77330. */
  77331. private static clamp;
  77332. /**
  77333. * Clones the current color curve instance.
  77334. * @return The cloned curves
  77335. */
  77336. clone(): ColorCurves;
  77337. /**
  77338. * Serializes the current color curve instance to a json representation.
  77339. * @return a JSON representation
  77340. */
  77341. serialize(): any;
  77342. /**
  77343. * Parses the color curve from a json representation.
  77344. * @param source the JSON source to parse
  77345. * @return The parsed curves
  77346. */
  77347. static Parse(source: any): ColorCurves;
  77348. }
  77349. }
  77350. declare module BABYLON {
  77351. /**
  77352. * Interface to follow in your material defines to integrate easily the
  77353. * Image proccessing functions.
  77354. * @hidden
  77355. */
  77356. export interface IImageProcessingConfigurationDefines {
  77357. IMAGEPROCESSING: boolean;
  77358. VIGNETTE: boolean;
  77359. VIGNETTEBLENDMODEMULTIPLY: boolean;
  77360. VIGNETTEBLENDMODEOPAQUE: boolean;
  77361. TONEMAPPING: boolean;
  77362. TONEMAPPING_ACES: boolean;
  77363. CONTRAST: boolean;
  77364. EXPOSURE: boolean;
  77365. COLORCURVES: boolean;
  77366. COLORGRADING: boolean;
  77367. COLORGRADING3D: boolean;
  77368. SAMPLER3DGREENDEPTH: boolean;
  77369. SAMPLER3DBGRMAP: boolean;
  77370. IMAGEPROCESSINGPOSTPROCESS: boolean;
  77371. }
  77372. /**
  77373. * @hidden
  77374. */
  77375. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  77376. IMAGEPROCESSING: boolean;
  77377. VIGNETTE: boolean;
  77378. VIGNETTEBLENDMODEMULTIPLY: boolean;
  77379. VIGNETTEBLENDMODEOPAQUE: boolean;
  77380. TONEMAPPING: boolean;
  77381. TONEMAPPING_ACES: boolean;
  77382. CONTRAST: boolean;
  77383. COLORCURVES: boolean;
  77384. COLORGRADING: boolean;
  77385. COLORGRADING3D: boolean;
  77386. SAMPLER3DGREENDEPTH: boolean;
  77387. SAMPLER3DBGRMAP: boolean;
  77388. IMAGEPROCESSINGPOSTPROCESS: boolean;
  77389. EXPOSURE: boolean;
  77390. constructor();
  77391. }
  77392. /**
  77393. * This groups together the common properties used for image processing either in direct forward pass
  77394. * or through post processing effect depending on the use of the image processing pipeline in your scene
  77395. * or not.
  77396. */
  77397. export class ImageProcessingConfiguration {
  77398. /**
  77399. * Default tone mapping applied in BabylonJS.
  77400. */
  77401. static readonly TONEMAPPING_STANDARD: number;
  77402. /**
  77403. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  77404. * to other engines rendering to increase portability.
  77405. */
  77406. static readonly TONEMAPPING_ACES: number;
  77407. /**
  77408. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  77409. */
  77410. colorCurves: Nullable<ColorCurves>;
  77411. private _colorCurvesEnabled;
  77412. /**
  77413. * Gets wether the color curves effect is enabled.
  77414. */
  77415. /**
  77416. * Sets wether the color curves effect is enabled.
  77417. */
  77418. colorCurvesEnabled: boolean;
  77419. private _colorGradingTexture;
  77420. /**
  77421. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  77422. */
  77423. /**
  77424. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  77425. */
  77426. colorGradingTexture: Nullable<BaseTexture>;
  77427. private _colorGradingEnabled;
  77428. /**
  77429. * Gets wether the color grading effect is enabled.
  77430. */
  77431. /**
  77432. * Sets wether the color grading effect is enabled.
  77433. */
  77434. colorGradingEnabled: boolean;
  77435. private _colorGradingWithGreenDepth;
  77436. /**
  77437. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  77438. */
  77439. /**
  77440. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  77441. */
  77442. colorGradingWithGreenDepth: boolean;
  77443. private _colorGradingBGR;
  77444. /**
  77445. * Gets wether the color grading texture contains BGR values.
  77446. */
  77447. /**
  77448. * Sets wether the color grading texture contains BGR values.
  77449. */
  77450. colorGradingBGR: boolean;
  77451. /** @hidden */
  77452. _exposure: number;
  77453. /**
  77454. * Gets the Exposure used in the effect.
  77455. */
  77456. /**
  77457. * Sets the Exposure used in the effect.
  77458. */
  77459. exposure: number;
  77460. private _toneMappingEnabled;
  77461. /**
  77462. * Gets wether the tone mapping effect is enabled.
  77463. */
  77464. /**
  77465. * Sets wether the tone mapping effect is enabled.
  77466. */
  77467. toneMappingEnabled: boolean;
  77468. private _toneMappingType;
  77469. /**
  77470. * Gets the type of tone mapping effect.
  77471. */
  77472. /**
  77473. * Sets the type of tone mapping effect used in BabylonJS.
  77474. */
  77475. toneMappingType: number;
  77476. protected _contrast: number;
  77477. /**
  77478. * Gets the contrast used in the effect.
  77479. */
  77480. /**
  77481. * Sets the contrast used in the effect.
  77482. */
  77483. contrast: number;
  77484. /**
  77485. * Vignette stretch size.
  77486. */
  77487. vignetteStretch: number;
  77488. /**
  77489. * Vignette centre X Offset.
  77490. */
  77491. vignetteCentreX: number;
  77492. /**
  77493. * Vignette centre Y Offset.
  77494. */
  77495. vignetteCentreY: number;
  77496. /**
  77497. * Vignette weight or intensity of the vignette effect.
  77498. */
  77499. vignetteWeight: number;
  77500. /**
  77501. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  77502. * if vignetteEnabled is set to true.
  77503. */
  77504. vignetteColor: Color4;
  77505. /**
  77506. * Camera field of view used by the Vignette effect.
  77507. */
  77508. vignetteCameraFov: number;
  77509. private _vignetteBlendMode;
  77510. /**
  77511. * Gets the vignette blend mode allowing different kind of effect.
  77512. */
  77513. /**
  77514. * Sets the vignette blend mode allowing different kind of effect.
  77515. */
  77516. vignetteBlendMode: number;
  77517. private _vignetteEnabled;
  77518. /**
  77519. * Gets wether the vignette effect is enabled.
  77520. */
  77521. /**
  77522. * Sets wether the vignette effect is enabled.
  77523. */
  77524. vignetteEnabled: boolean;
  77525. private _applyByPostProcess;
  77526. /**
  77527. * Gets wether the image processing is applied through a post process or not.
  77528. */
  77529. /**
  77530. * Sets wether the image processing is applied through a post process or not.
  77531. */
  77532. applyByPostProcess: boolean;
  77533. private _isEnabled;
  77534. /**
  77535. * Gets wether the image processing is enabled or not.
  77536. */
  77537. /**
  77538. * Sets wether the image processing is enabled or not.
  77539. */
  77540. isEnabled: boolean;
  77541. /**
  77542. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  77543. */
  77544. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  77545. /**
  77546. * Method called each time the image processing information changes requires to recompile the effect.
  77547. */
  77548. protected _updateParameters(): void;
  77549. /**
  77550. * Gets the current class name.
  77551. * @return "ImageProcessingConfiguration"
  77552. */
  77553. getClassName(): string;
  77554. /**
  77555. * Prepare the list of uniforms associated with the Image Processing effects.
  77556. * @param uniforms The list of uniforms used in the effect
  77557. * @param defines the list of defines currently in use
  77558. */
  77559. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  77560. /**
  77561. * Prepare the list of samplers associated with the Image Processing effects.
  77562. * @param samplersList The list of uniforms used in the effect
  77563. * @param defines the list of defines currently in use
  77564. */
  77565. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  77566. /**
  77567. * Prepare the list of defines associated to the shader.
  77568. * @param defines the list of defines to complete
  77569. * @param forPostProcess Define if we are currently in post process mode or not
  77570. */
  77571. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  77572. /**
  77573. * Returns true if all the image processing information are ready.
  77574. * @returns True if ready, otherwise, false
  77575. */
  77576. isReady(): boolean;
  77577. /**
  77578. * Binds the image processing to the shader.
  77579. * @param effect The effect to bind to
  77580. * @param overrideAspectRatio Override the aspect ratio of the effect
  77581. */
  77582. bind(effect: Effect, overrideAspectRatio?: number): void;
  77583. /**
  77584. * Clones the current image processing instance.
  77585. * @return The cloned image processing
  77586. */
  77587. clone(): ImageProcessingConfiguration;
  77588. /**
  77589. * Serializes the current image processing instance to a json representation.
  77590. * @return a JSON representation
  77591. */
  77592. serialize(): any;
  77593. /**
  77594. * Parses the image processing from a json representation.
  77595. * @param source the JSON source to parse
  77596. * @return The parsed image processing
  77597. */
  77598. static Parse(source: any): ImageProcessingConfiguration;
  77599. private static _VIGNETTEMODE_MULTIPLY;
  77600. private static _VIGNETTEMODE_OPAQUE;
  77601. /**
  77602. * Used to apply the vignette as a mix with the pixel color.
  77603. */
  77604. static readonly VIGNETTEMODE_MULTIPLY: number;
  77605. /**
  77606. * Used to apply the vignette as a replacement of the pixel color.
  77607. */
  77608. static readonly VIGNETTEMODE_OPAQUE: number;
  77609. }
  77610. }
  77611. declare module BABYLON {
  77612. /** @hidden */
  77613. export var postprocessVertexShader: {
  77614. name: string;
  77615. shader: string;
  77616. };
  77617. }
  77618. declare module BABYLON {
  77619. interface ThinEngine {
  77620. /**
  77621. * Creates a new render target texture
  77622. * @param size defines the size of the texture
  77623. * @param options defines the options used to create the texture
  77624. * @returns a new render target texture stored in an InternalTexture
  77625. */
  77626. createRenderTargetTexture(size: number | {
  77627. width: number;
  77628. height: number;
  77629. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  77630. /**
  77631. * Creates a depth stencil texture.
  77632. * This is only available in WebGL 2 or with the depth texture extension available.
  77633. * @param size The size of face edge in the texture.
  77634. * @param options The options defining the texture.
  77635. * @returns The texture
  77636. */
  77637. createDepthStencilTexture(size: number | {
  77638. width: number;
  77639. height: number;
  77640. }, options: DepthTextureCreationOptions): InternalTexture;
  77641. /** @hidden */
  77642. _createDepthStencilTexture(size: number | {
  77643. width: number;
  77644. height: number;
  77645. }, options: DepthTextureCreationOptions): InternalTexture;
  77646. }
  77647. }
  77648. declare module BABYLON {
  77649. /** Defines supported spaces */
  77650. export enum Space {
  77651. /** Local (object) space */
  77652. LOCAL = 0,
  77653. /** World space */
  77654. WORLD = 1,
  77655. /** Bone space */
  77656. BONE = 2
  77657. }
  77658. /** Defines the 3 main axes */
  77659. export class Axis {
  77660. /** X axis */
  77661. static X: Vector3;
  77662. /** Y axis */
  77663. static Y: Vector3;
  77664. /** Z axis */
  77665. static Z: Vector3;
  77666. }
  77667. }
  77668. declare module BABYLON {
  77669. /**
  77670. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  77671. * This is the base of the follow, arc rotate cameras and Free camera
  77672. * @see http://doc.babylonjs.com/features/cameras
  77673. */
  77674. export class TargetCamera extends Camera {
  77675. private static _RigCamTransformMatrix;
  77676. private static _TargetTransformMatrix;
  77677. private static _TargetFocalPoint;
  77678. /**
  77679. * Define the current direction the camera is moving to
  77680. */
  77681. cameraDirection: Vector3;
  77682. /**
  77683. * Define the current rotation the camera is rotating to
  77684. */
  77685. cameraRotation: Vector2;
  77686. /**
  77687. * When set, the up vector of the camera will be updated by the rotation of the camera
  77688. */
  77689. updateUpVectorFromRotation: boolean;
  77690. private _tmpQuaternion;
  77691. /**
  77692. * Define the current rotation of the camera
  77693. */
  77694. rotation: Vector3;
  77695. /**
  77696. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  77697. */
  77698. rotationQuaternion: Quaternion;
  77699. /**
  77700. * Define the current speed of the camera
  77701. */
  77702. speed: number;
  77703. /**
  77704. * Add constraint to the camera to prevent it to move freely in all directions and
  77705. * around all axis.
  77706. */
  77707. noRotationConstraint: boolean;
  77708. /**
  77709. * Define the current target of the camera as an object or a position.
  77710. */
  77711. lockedTarget: any;
  77712. /** @hidden */
  77713. _currentTarget: Vector3;
  77714. /** @hidden */
  77715. _initialFocalDistance: number;
  77716. /** @hidden */
  77717. _viewMatrix: Matrix;
  77718. /** @hidden */
  77719. _camMatrix: Matrix;
  77720. /** @hidden */
  77721. _cameraTransformMatrix: Matrix;
  77722. /** @hidden */
  77723. _cameraRotationMatrix: Matrix;
  77724. /** @hidden */
  77725. _referencePoint: Vector3;
  77726. /** @hidden */
  77727. _transformedReferencePoint: Vector3;
  77728. protected _globalCurrentTarget: Vector3;
  77729. protected _globalCurrentUpVector: Vector3;
  77730. /** @hidden */
  77731. _reset: () => void;
  77732. private _defaultUp;
  77733. /**
  77734. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  77735. * This is the base of the follow, arc rotate cameras and Free camera
  77736. * @see http://doc.babylonjs.com/features/cameras
  77737. * @param name Defines the name of the camera in the scene
  77738. * @param position Defines the start position of the camera in the scene
  77739. * @param scene Defines the scene the camera belongs to
  77740. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  77741. */
  77742. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  77743. /**
  77744. * Gets the position in front of the camera at a given distance.
  77745. * @param distance The distance from the camera we want the position to be
  77746. * @returns the position
  77747. */
  77748. getFrontPosition(distance: number): Vector3;
  77749. /** @hidden */
  77750. _getLockedTargetPosition(): Nullable<Vector3>;
  77751. private _storedPosition;
  77752. private _storedRotation;
  77753. private _storedRotationQuaternion;
  77754. /**
  77755. * Store current camera state of the camera (fov, position, rotation, etc..)
  77756. * @returns the camera
  77757. */
  77758. storeState(): Camera;
  77759. /**
  77760. * Restored camera state. You must call storeState() first
  77761. * @returns whether it was successful or not
  77762. * @hidden
  77763. */
  77764. _restoreStateValues(): boolean;
  77765. /** @hidden */
  77766. _initCache(): void;
  77767. /** @hidden */
  77768. _updateCache(ignoreParentClass?: boolean): void;
  77769. /** @hidden */
  77770. _isSynchronizedViewMatrix(): boolean;
  77771. /** @hidden */
  77772. _computeLocalCameraSpeed(): number;
  77773. /**
  77774. * Defines the target the camera should look at.
  77775. * @param target Defines the new target as a Vector or a mesh
  77776. */
  77777. setTarget(target: Vector3): void;
  77778. /**
  77779. * Return the current target position of the camera. This value is expressed in local space.
  77780. * @returns the target position
  77781. */
  77782. getTarget(): Vector3;
  77783. /** @hidden */
  77784. _decideIfNeedsToMove(): boolean;
  77785. /** @hidden */
  77786. _updatePosition(): void;
  77787. /** @hidden */
  77788. _checkInputs(): void;
  77789. protected _updateCameraRotationMatrix(): void;
  77790. /**
  77791. * 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)
  77792. * @returns the current camera
  77793. */
  77794. private _rotateUpVectorWithCameraRotationMatrix;
  77795. private _cachedRotationZ;
  77796. private _cachedQuaternionRotationZ;
  77797. /** @hidden */
  77798. _getViewMatrix(): Matrix;
  77799. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  77800. /**
  77801. * @hidden
  77802. */
  77803. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  77804. /**
  77805. * @hidden
  77806. */
  77807. _updateRigCameras(): void;
  77808. private _getRigCamPositionAndTarget;
  77809. /**
  77810. * Gets the current object class name.
  77811. * @return the class name
  77812. */
  77813. getClassName(): string;
  77814. }
  77815. }
  77816. declare module BABYLON {
  77817. /**
  77818. * Gather the list of keyboard event types as constants.
  77819. */
  77820. export class KeyboardEventTypes {
  77821. /**
  77822. * The keydown event is fired when a key becomes active (pressed).
  77823. */
  77824. static readonly KEYDOWN: number;
  77825. /**
  77826. * The keyup event is fired when a key has been released.
  77827. */
  77828. static readonly KEYUP: number;
  77829. }
  77830. /**
  77831. * This class is used to store keyboard related info for the onKeyboardObservable event.
  77832. */
  77833. export class KeyboardInfo {
  77834. /**
  77835. * Defines the type of event (KeyboardEventTypes)
  77836. */
  77837. type: number;
  77838. /**
  77839. * Defines the related dom event
  77840. */
  77841. event: KeyboardEvent;
  77842. /**
  77843. * Instantiates a new keyboard info.
  77844. * This class is used to store keyboard related info for the onKeyboardObservable event.
  77845. * @param type Defines the type of event (KeyboardEventTypes)
  77846. * @param event Defines the related dom event
  77847. */
  77848. constructor(
  77849. /**
  77850. * Defines the type of event (KeyboardEventTypes)
  77851. */
  77852. type: number,
  77853. /**
  77854. * Defines the related dom event
  77855. */
  77856. event: KeyboardEvent);
  77857. }
  77858. /**
  77859. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  77860. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  77861. */
  77862. export class KeyboardInfoPre extends KeyboardInfo {
  77863. /**
  77864. * Defines the type of event (KeyboardEventTypes)
  77865. */
  77866. type: number;
  77867. /**
  77868. * Defines the related dom event
  77869. */
  77870. event: KeyboardEvent;
  77871. /**
  77872. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  77873. */
  77874. skipOnPointerObservable: boolean;
  77875. /**
  77876. * Instantiates a new keyboard pre info.
  77877. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  77878. * @param type Defines the type of event (KeyboardEventTypes)
  77879. * @param event Defines the related dom event
  77880. */
  77881. constructor(
  77882. /**
  77883. * Defines the type of event (KeyboardEventTypes)
  77884. */
  77885. type: number,
  77886. /**
  77887. * Defines the related dom event
  77888. */
  77889. event: KeyboardEvent);
  77890. }
  77891. }
  77892. declare module BABYLON {
  77893. /**
  77894. * Manage the keyboard inputs to control the movement of a free camera.
  77895. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  77896. */
  77897. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  77898. /**
  77899. * Defines the camera the input is attached to.
  77900. */
  77901. camera: FreeCamera;
  77902. /**
  77903. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  77904. */
  77905. keysUp: number[];
  77906. /**
  77907. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  77908. */
  77909. keysDown: number[];
  77910. /**
  77911. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  77912. */
  77913. keysLeft: number[];
  77914. /**
  77915. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  77916. */
  77917. keysRight: number[];
  77918. private _keys;
  77919. private _onCanvasBlurObserver;
  77920. private _onKeyboardObserver;
  77921. private _engine;
  77922. private _scene;
  77923. /**
  77924. * Attach the input controls to a specific dom element to get the input from.
  77925. * @param element Defines the element the controls should be listened from
  77926. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  77927. */
  77928. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  77929. /**
  77930. * Detach the current controls from the specified dom element.
  77931. * @param element Defines the element to stop listening the inputs from
  77932. */
  77933. detachControl(element: Nullable<HTMLElement>): void;
  77934. /**
  77935. * Update the current camera state depending on the inputs that have been used this frame.
  77936. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  77937. */
  77938. checkInputs(): void;
  77939. /**
  77940. * Gets the class name of the current intput.
  77941. * @returns the class name
  77942. */
  77943. getClassName(): string;
  77944. /** @hidden */
  77945. _onLostFocus(): void;
  77946. /**
  77947. * Get the friendly name associated with the input class.
  77948. * @returns the input friendly name
  77949. */
  77950. getSimpleName(): string;
  77951. }
  77952. }
  77953. declare module BABYLON {
  77954. /**
  77955. * Interface describing all the common properties and methods a shadow light needs to implement.
  77956. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  77957. * as well as binding the different shadow properties to the effects.
  77958. */
  77959. export interface IShadowLight extends Light {
  77960. /**
  77961. * The light id in the scene (used in scene.findLighById for instance)
  77962. */
  77963. id: string;
  77964. /**
  77965. * The position the shdow will be casted from.
  77966. */
  77967. position: Vector3;
  77968. /**
  77969. * In 2d mode (needCube being false), the direction used to cast the shadow.
  77970. */
  77971. direction: Vector3;
  77972. /**
  77973. * The transformed position. Position of the light in world space taking parenting in account.
  77974. */
  77975. transformedPosition: Vector3;
  77976. /**
  77977. * The transformed direction. Direction of the light in world space taking parenting in account.
  77978. */
  77979. transformedDirection: Vector3;
  77980. /**
  77981. * The friendly name of the light in the scene.
  77982. */
  77983. name: string;
  77984. /**
  77985. * Defines the shadow projection clipping minimum z value.
  77986. */
  77987. shadowMinZ: number;
  77988. /**
  77989. * Defines the shadow projection clipping maximum z value.
  77990. */
  77991. shadowMaxZ: number;
  77992. /**
  77993. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  77994. * @returns true if the information has been computed, false if it does not need to (no parenting)
  77995. */
  77996. computeTransformedInformation(): boolean;
  77997. /**
  77998. * Gets the scene the light belongs to.
  77999. * @returns The scene
  78000. */
  78001. getScene(): Scene;
  78002. /**
  78003. * Callback defining a custom Projection Matrix Builder.
  78004. * This can be used to override the default projection matrix computation.
  78005. */
  78006. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  78007. /**
  78008. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  78009. * @param matrix The materix to updated with the projection information
  78010. * @param viewMatrix The transform matrix of the light
  78011. * @param renderList The list of mesh to render in the map
  78012. * @returns The current light
  78013. */
  78014. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  78015. /**
  78016. * Gets the current depth scale used in ESM.
  78017. * @returns The scale
  78018. */
  78019. getDepthScale(): number;
  78020. /**
  78021. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  78022. * @returns true if a cube texture needs to be use
  78023. */
  78024. needCube(): boolean;
  78025. /**
  78026. * Detects if the projection matrix requires to be recomputed this frame.
  78027. * @returns true if it requires to be recomputed otherwise, false.
  78028. */
  78029. needProjectionMatrixCompute(): boolean;
  78030. /**
  78031. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  78032. */
  78033. forceProjectionMatrixCompute(): void;
  78034. /**
  78035. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  78036. * @param faceIndex The index of the face we are computed the direction to generate shadow
  78037. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  78038. */
  78039. getShadowDirection(faceIndex?: number): Vector3;
  78040. /**
  78041. * Gets the minZ used for shadow according to both the scene and the light.
  78042. * @param activeCamera The camera we are returning the min for
  78043. * @returns the depth min z
  78044. */
  78045. getDepthMinZ(activeCamera: Camera): number;
  78046. /**
  78047. * Gets the maxZ used for shadow according to both the scene and the light.
  78048. * @param activeCamera The camera we are returning the max for
  78049. * @returns the depth max z
  78050. */
  78051. getDepthMaxZ(activeCamera: Camera): number;
  78052. }
  78053. /**
  78054. * Base implementation IShadowLight
  78055. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  78056. */
  78057. export abstract class ShadowLight extends Light implements IShadowLight {
  78058. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  78059. protected _position: Vector3;
  78060. protected _setPosition(value: Vector3): void;
  78061. /**
  78062. * Sets the position the shadow will be casted from. Also use as the light position for both
  78063. * point and spot lights.
  78064. */
  78065. /**
  78066. * Sets the position the shadow will be casted from. Also use as the light position for both
  78067. * point and spot lights.
  78068. */
  78069. position: Vector3;
  78070. protected _direction: Vector3;
  78071. protected _setDirection(value: Vector3): void;
  78072. /**
  78073. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  78074. * Also use as the light direction on spot and directional lights.
  78075. */
  78076. /**
  78077. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  78078. * Also use as the light direction on spot and directional lights.
  78079. */
  78080. direction: Vector3;
  78081. private _shadowMinZ;
  78082. /**
  78083. * Gets the shadow projection clipping minimum z value.
  78084. */
  78085. /**
  78086. * Sets the shadow projection clipping minimum z value.
  78087. */
  78088. shadowMinZ: number;
  78089. private _shadowMaxZ;
  78090. /**
  78091. * Sets the shadow projection clipping maximum z value.
  78092. */
  78093. /**
  78094. * Gets the shadow projection clipping maximum z value.
  78095. */
  78096. shadowMaxZ: number;
  78097. /**
  78098. * Callback defining a custom Projection Matrix Builder.
  78099. * This can be used to override the default projection matrix computation.
  78100. */
  78101. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  78102. /**
  78103. * The transformed position. Position of the light in world space taking parenting in account.
  78104. */
  78105. transformedPosition: Vector3;
  78106. /**
  78107. * The transformed direction. Direction of the light in world space taking parenting in account.
  78108. */
  78109. transformedDirection: Vector3;
  78110. private _needProjectionMatrixCompute;
  78111. /**
  78112. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  78113. * @returns true if the information has been computed, false if it does not need to (no parenting)
  78114. */
  78115. computeTransformedInformation(): boolean;
  78116. /**
  78117. * Return the depth scale used for the shadow map.
  78118. * @returns the depth scale.
  78119. */
  78120. getDepthScale(): number;
  78121. /**
  78122. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  78123. * @param faceIndex The index of the face we are computed the direction to generate shadow
  78124. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  78125. */
  78126. getShadowDirection(faceIndex?: number): Vector3;
  78127. /**
  78128. * Returns the ShadowLight absolute position in the World.
  78129. * @returns the position vector in world space
  78130. */
  78131. getAbsolutePosition(): Vector3;
  78132. /**
  78133. * Sets the ShadowLight direction toward the passed target.
  78134. * @param target The point to target in local space
  78135. * @returns the updated ShadowLight direction
  78136. */
  78137. setDirectionToTarget(target: Vector3): Vector3;
  78138. /**
  78139. * Returns the light rotation in euler definition.
  78140. * @returns the x y z rotation in local space.
  78141. */
  78142. getRotation(): Vector3;
  78143. /**
  78144. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  78145. * @returns true if a cube texture needs to be use
  78146. */
  78147. needCube(): boolean;
  78148. /**
  78149. * Detects if the projection matrix requires to be recomputed this frame.
  78150. * @returns true if it requires to be recomputed otherwise, false.
  78151. */
  78152. needProjectionMatrixCompute(): boolean;
  78153. /**
  78154. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  78155. */
  78156. forceProjectionMatrixCompute(): void;
  78157. /** @hidden */
  78158. _initCache(): void;
  78159. /** @hidden */
  78160. _isSynchronized(): boolean;
  78161. /**
  78162. * Computes the world matrix of the node
  78163. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  78164. * @returns the world matrix
  78165. */
  78166. computeWorldMatrix(force?: boolean): Matrix;
  78167. /**
  78168. * Gets the minZ used for shadow according to both the scene and the light.
  78169. * @param activeCamera The camera we are returning the min for
  78170. * @returns the depth min z
  78171. */
  78172. getDepthMinZ(activeCamera: Camera): number;
  78173. /**
  78174. * Gets the maxZ used for shadow according to both the scene and the light.
  78175. * @param activeCamera The camera we are returning the max for
  78176. * @returns the depth max z
  78177. */
  78178. getDepthMaxZ(activeCamera: Camera): number;
  78179. /**
  78180. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  78181. * @param matrix The materix to updated with the projection information
  78182. * @param viewMatrix The transform matrix of the light
  78183. * @param renderList The list of mesh to render in the map
  78184. * @returns The current light
  78185. */
  78186. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  78187. }
  78188. }
  78189. declare module BABYLON {
  78190. /**
  78191. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  78192. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  78193. */
  78194. export class EffectFallbacks implements IEffectFallbacks {
  78195. private _defines;
  78196. private _currentRank;
  78197. private _maxRank;
  78198. private _mesh;
  78199. /**
  78200. * Removes the fallback from the bound mesh.
  78201. */
  78202. unBindMesh(): void;
  78203. /**
  78204. * Adds a fallback on the specified property.
  78205. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  78206. * @param define The name of the define in the shader
  78207. */
  78208. addFallback(rank: number, define: string): void;
  78209. /**
  78210. * Sets the mesh to use CPU skinning when needing to fallback.
  78211. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  78212. * @param mesh The mesh to use the fallbacks.
  78213. */
  78214. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  78215. /**
  78216. * Checks to see if more fallbacks are still availible.
  78217. */
  78218. readonly hasMoreFallbacks: boolean;
  78219. /**
  78220. * Removes the defines that should be removed when falling back.
  78221. * @param currentDefines defines the current define statements for the shader.
  78222. * @param effect defines the current effect we try to compile
  78223. * @returns The resulting defines with defines of the current rank removed.
  78224. */
  78225. reduce(currentDefines: string, effect: Effect): string;
  78226. }
  78227. }
  78228. declare module BABYLON {
  78229. /**
  78230. * "Static Class" containing the most commonly used helper while dealing with material for
  78231. * rendering purpose.
  78232. *
  78233. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  78234. *
  78235. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  78236. */
  78237. export class MaterialHelper {
  78238. /**
  78239. * Bind the current view position to an effect.
  78240. * @param effect The effect to be bound
  78241. * @param scene The scene the eyes position is used from
  78242. */
  78243. static BindEyePosition(effect: Effect, scene: Scene): void;
  78244. /**
  78245. * Helps preparing the defines values about the UVs in used in the effect.
  78246. * UVs are shared as much as we can accross channels in the shaders.
  78247. * @param texture The texture we are preparing the UVs for
  78248. * @param defines The defines to update
  78249. * @param key The channel key "diffuse", "specular"... used in the shader
  78250. */
  78251. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  78252. /**
  78253. * Binds a texture matrix value to its corrsponding uniform
  78254. * @param texture The texture to bind the matrix for
  78255. * @param uniformBuffer The uniform buffer receivin the data
  78256. * @param key The channel key "diffuse", "specular"... used in the shader
  78257. */
  78258. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  78259. /**
  78260. * Gets the current status of the fog (should it be enabled?)
  78261. * @param mesh defines the mesh to evaluate for fog support
  78262. * @param scene defines the hosting scene
  78263. * @returns true if fog must be enabled
  78264. */
  78265. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  78266. /**
  78267. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  78268. * @param mesh defines the current mesh
  78269. * @param scene defines the current scene
  78270. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  78271. * @param pointsCloud defines if point cloud rendering has to be turned on
  78272. * @param fogEnabled defines if fog has to be turned on
  78273. * @param alphaTest defines if alpha testing has to be turned on
  78274. * @param defines defines the current list of defines
  78275. */
  78276. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  78277. /**
  78278. * Helper used to prepare the list of defines associated with frame values for shader compilation
  78279. * @param scene defines the current scene
  78280. * @param engine defines the current engine
  78281. * @param defines specifies the list of active defines
  78282. * @param useInstances defines if instances have to be turned on
  78283. * @param useClipPlane defines if clip plane have to be turned on
  78284. */
  78285. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  78286. /**
  78287. * Prepares the defines for bones
  78288. * @param mesh The mesh containing the geometry data we will draw
  78289. * @param defines The defines to update
  78290. */
  78291. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  78292. /**
  78293. * Prepares the defines for morph targets
  78294. * @param mesh The mesh containing the geometry data we will draw
  78295. * @param defines The defines to update
  78296. */
  78297. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  78298. /**
  78299. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  78300. * @param mesh The mesh containing the geometry data we will draw
  78301. * @param defines The defines to update
  78302. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  78303. * @param useBones Precise whether bones should be used or not (override mesh info)
  78304. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  78305. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  78306. * @returns false if defines are considered not dirty and have not been checked
  78307. */
  78308. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  78309. /**
  78310. * Prepares the defines related to multiview
  78311. * @param scene The scene we are intending to draw
  78312. * @param defines The defines to update
  78313. */
  78314. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  78315. /**
  78316. * Prepares the defines related to the light information passed in parameter
  78317. * @param scene The scene we are intending to draw
  78318. * @param mesh The mesh the effect is compiling for
  78319. * @param light The light the effect is compiling for
  78320. * @param lightIndex The index of the light
  78321. * @param defines The defines to update
  78322. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  78323. * @param state Defines the current state regarding what is needed (normals, etc...)
  78324. */
  78325. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  78326. needNormals: boolean;
  78327. needRebuild: boolean;
  78328. shadowEnabled: boolean;
  78329. specularEnabled: boolean;
  78330. lightmapMode: boolean;
  78331. }): void;
  78332. /**
  78333. * Prepares the defines related to the light information passed in parameter
  78334. * @param scene The scene we are intending to draw
  78335. * @param mesh The mesh the effect is compiling for
  78336. * @param defines The defines to update
  78337. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  78338. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  78339. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  78340. * @returns true if normals will be required for the rest of the effect
  78341. */
  78342. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  78343. /**
  78344. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  78345. * @param lightIndex defines the light index
  78346. * @param uniformsList The uniform list
  78347. * @param samplersList The sampler list
  78348. * @param projectedLightTexture defines if projected texture must be used
  78349. * @param uniformBuffersList defines an optional list of uniform buffers
  78350. */
  78351. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  78352. /**
  78353. * Prepares the uniforms and samplers list to be used in the effect
  78354. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  78355. * @param samplersList The sampler list
  78356. * @param defines The defines helping in the list generation
  78357. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  78358. */
  78359. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  78360. /**
  78361. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  78362. * @param defines The defines to update while falling back
  78363. * @param fallbacks The authorized effect fallbacks
  78364. * @param maxSimultaneousLights The maximum number of lights allowed
  78365. * @param rank the current rank of the Effect
  78366. * @returns The newly affected rank
  78367. */
  78368. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  78369. private static _TmpMorphInfluencers;
  78370. /**
  78371. * Prepares the list of attributes required for morph targets according to the effect defines.
  78372. * @param attribs The current list of supported attribs
  78373. * @param mesh The mesh to prepare the morph targets attributes for
  78374. * @param influencers The number of influencers
  78375. */
  78376. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  78377. /**
  78378. * Prepares the list of attributes required for morph targets according to the effect defines.
  78379. * @param attribs The current list of supported attribs
  78380. * @param mesh The mesh to prepare the morph targets attributes for
  78381. * @param defines The current Defines of the effect
  78382. */
  78383. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  78384. /**
  78385. * Prepares the list of attributes required for bones according to the effect defines.
  78386. * @param attribs The current list of supported attribs
  78387. * @param mesh The mesh to prepare the bones attributes for
  78388. * @param defines The current Defines of the effect
  78389. * @param fallbacks The current efffect fallback strategy
  78390. */
  78391. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  78392. /**
  78393. * Check and prepare the list of attributes required for instances according to the effect defines.
  78394. * @param attribs The current list of supported attribs
  78395. * @param defines The current MaterialDefines of the effect
  78396. */
  78397. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  78398. /**
  78399. * Add the list of attributes required for instances to the attribs array.
  78400. * @param attribs The current list of supported attribs
  78401. */
  78402. static PushAttributesForInstances(attribs: string[]): void;
  78403. /**
  78404. * Binds the light information to the effect.
  78405. * @param light The light containing the generator
  78406. * @param effect The effect we are binding the data to
  78407. * @param lightIndex The light index in the effect used to render
  78408. */
  78409. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  78410. /**
  78411. * Binds the lights information from the scene to the effect for the given mesh.
  78412. * @param light Light to bind
  78413. * @param lightIndex Light index
  78414. * @param scene The scene where the light belongs to
  78415. * @param effect The effect we are binding the data to
  78416. * @param useSpecular Defines if specular is supported
  78417. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  78418. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  78419. */
  78420. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  78421. /**
  78422. * Binds the lights information from the scene to the effect for the given mesh.
  78423. * @param scene The scene the lights belongs to
  78424. * @param mesh The mesh we are binding the information to render
  78425. * @param effect The effect we are binding the data to
  78426. * @param defines The generated defines for the effect
  78427. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  78428. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  78429. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  78430. */
  78431. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  78432. private static _tempFogColor;
  78433. /**
  78434. * Binds the fog information from the scene to the effect for the given mesh.
  78435. * @param scene The scene the lights belongs to
  78436. * @param mesh The mesh we are binding the information to render
  78437. * @param effect The effect we are binding the data to
  78438. * @param linearSpace Defines if the fog effect is applied in linear space
  78439. */
  78440. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  78441. /**
  78442. * Binds the bones information from the mesh to the effect.
  78443. * @param mesh The mesh we are binding the information to render
  78444. * @param effect The effect we are binding the data to
  78445. */
  78446. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  78447. /**
  78448. * Binds the morph targets information from the mesh to the effect.
  78449. * @param abstractMesh The mesh we are binding the information to render
  78450. * @param effect The effect we are binding the data to
  78451. */
  78452. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  78453. /**
  78454. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  78455. * @param defines The generated defines used in the effect
  78456. * @param effect The effect we are binding the data to
  78457. * @param scene The scene we are willing to render with logarithmic scale for
  78458. */
  78459. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  78460. /**
  78461. * Binds the clip plane information from the scene to the effect.
  78462. * @param scene The scene the clip plane information are extracted from
  78463. * @param effect The effect we are binding the data to
  78464. */
  78465. static BindClipPlane(effect: Effect, scene: Scene): void;
  78466. }
  78467. }
  78468. declare module BABYLON {
  78469. /** @hidden */
  78470. export var packingFunctions: {
  78471. name: string;
  78472. shader: string;
  78473. };
  78474. }
  78475. declare module BABYLON {
  78476. /** @hidden */
  78477. export var shadowMapPixelShader: {
  78478. name: string;
  78479. shader: string;
  78480. };
  78481. }
  78482. declare module BABYLON {
  78483. /** @hidden */
  78484. export var bonesDeclaration: {
  78485. name: string;
  78486. shader: string;
  78487. };
  78488. }
  78489. declare module BABYLON {
  78490. /** @hidden */
  78491. export var morphTargetsVertexGlobalDeclaration: {
  78492. name: string;
  78493. shader: string;
  78494. };
  78495. }
  78496. declare module BABYLON {
  78497. /** @hidden */
  78498. export var morphTargetsVertexDeclaration: {
  78499. name: string;
  78500. shader: string;
  78501. };
  78502. }
  78503. declare module BABYLON {
  78504. /** @hidden */
  78505. export var instancesDeclaration: {
  78506. name: string;
  78507. shader: string;
  78508. };
  78509. }
  78510. declare module BABYLON {
  78511. /** @hidden */
  78512. export var helperFunctions: {
  78513. name: string;
  78514. shader: string;
  78515. };
  78516. }
  78517. declare module BABYLON {
  78518. /** @hidden */
  78519. export var morphTargetsVertex: {
  78520. name: string;
  78521. shader: string;
  78522. };
  78523. }
  78524. declare module BABYLON {
  78525. /** @hidden */
  78526. export var instancesVertex: {
  78527. name: string;
  78528. shader: string;
  78529. };
  78530. }
  78531. declare module BABYLON {
  78532. /** @hidden */
  78533. export var bonesVertex: {
  78534. name: string;
  78535. shader: string;
  78536. };
  78537. }
  78538. declare module BABYLON {
  78539. /** @hidden */
  78540. export var shadowMapVertexShader: {
  78541. name: string;
  78542. shader: string;
  78543. };
  78544. }
  78545. declare module BABYLON {
  78546. /** @hidden */
  78547. export var depthBoxBlurPixelShader: {
  78548. name: string;
  78549. shader: string;
  78550. };
  78551. }
  78552. declare module BABYLON {
  78553. /**
  78554. * Defines the options associated with the creation of a custom shader for a shadow generator.
  78555. */
  78556. export interface ICustomShaderOptions {
  78557. /**
  78558. * Gets or sets the custom shader name to use
  78559. */
  78560. shaderName: string;
  78561. /**
  78562. * The list of attribute names used in the shader
  78563. */
  78564. attributes?: string[];
  78565. /**
  78566. * The list of unifrom names used in the shader
  78567. */
  78568. uniforms?: string[];
  78569. /**
  78570. * The list of sampler names used in the shader
  78571. */
  78572. samplers?: string[];
  78573. /**
  78574. * The list of defines used in the shader
  78575. */
  78576. defines?: string[];
  78577. }
  78578. /**
  78579. * Interface to implement to create a shadow generator compatible with BJS.
  78580. */
  78581. export interface IShadowGenerator {
  78582. /**
  78583. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  78584. * @returns The render target texture if present otherwise, null
  78585. */
  78586. getShadowMap(): Nullable<RenderTargetTexture>;
  78587. /**
  78588. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  78589. * @returns The render target texture if the shadow map is present otherwise, null
  78590. */
  78591. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  78592. /**
  78593. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  78594. * @param subMesh The submesh we want to render in the shadow map
  78595. * @param useInstances Defines wether will draw in the map using instances
  78596. * @returns true if ready otherwise, false
  78597. */
  78598. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  78599. /**
  78600. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  78601. * @param defines Defines of the material we want to update
  78602. * @param lightIndex Index of the light in the enabled light list of the material
  78603. */
  78604. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  78605. /**
  78606. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  78607. * defined in the generator but impacting the effect).
  78608. * It implies the unifroms available on the materials are the standard BJS ones.
  78609. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  78610. * @param effect The effect we are binfing the information for
  78611. */
  78612. bindShadowLight(lightIndex: string, effect: Effect): void;
  78613. /**
  78614. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  78615. * (eq to shadow prjection matrix * light transform matrix)
  78616. * @returns The transform matrix used to create the shadow map
  78617. */
  78618. getTransformMatrix(): Matrix;
  78619. /**
  78620. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  78621. * Cube and 2D textures for instance.
  78622. */
  78623. recreateShadowMap(): void;
  78624. /**
  78625. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  78626. * @param onCompiled Callback triggered at the and of the effects compilation
  78627. * @param options Sets of optional options forcing the compilation with different modes
  78628. */
  78629. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  78630. useInstances: boolean;
  78631. }>): void;
  78632. /**
  78633. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  78634. * @param options Sets of optional options forcing the compilation with different modes
  78635. * @returns A promise that resolves when the compilation completes
  78636. */
  78637. forceCompilationAsync(options?: Partial<{
  78638. useInstances: boolean;
  78639. }>): Promise<void>;
  78640. /**
  78641. * Serializes the shadow generator setup to a json object.
  78642. * @returns The serialized JSON object
  78643. */
  78644. serialize(): any;
  78645. /**
  78646. * Disposes the Shadow map and related Textures and effects.
  78647. */
  78648. dispose(): void;
  78649. }
  78650. /**
  78651. * Default implementation IShadowGenerator.
  78652. * This is the main object responsible of generating shadows in the framework.
  78653. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  78654. */
  78655. export class ShadowGenerator implements IShadowGenerator {
  78656. /**
  78657. * Shadow generator mode None: no filtering applied.
  78658. */
  78659. static readonly FILTER_NONE: number;
  78660. /**
  78661. * Shadow generator mode ESM: Exponential Shadow Mapping.
  78662. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  78663. */
  78664. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  78665. /**
  78666. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  78667. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  78668. */
  78669. static readonly FILTER_POISSONSAMPLING: number;
  78670. /**
  78671. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  78672. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  78673. */
  78674. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  78675. /**
  78676. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  78677. * edge artifacts on steep falloff.
  78678. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  78679. */
  78680. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  78681. /**
  78682. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  78683. * edge artifacts on steep falloff.
  78684. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  78685. */
  78686. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  78687. /**
  78688. * Shadow generator mode PCF: Percentage Closer Filtering
  78689. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  78690. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  78691. */
  78692. static readonly FILTER_PCF: number;
  78693. /**
  78694. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  78695. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  78696. * Contact Hardening
  78697. */
  78698. static readonly FILTER_PCSS: number;
  78699. /**
  78700. * Reserved for PCF and PCSS
  78701. * Highest Quality.
  78702. *
  78703. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  78704. *
  78705. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  78706. */
  78707. static readonly QUALITY_HIGH: number;
  78708. /**
  78709. * Reserved for PCF and PCSS
  78710. * Good tradeoff for quality/perf cross devices
  78711. *
  78712. * Execute PCF on a 3*3 kernel.
  78713. *
  78714. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  78715. */
  78716. static readonly QUALITY_MEDIUM: number;
  78717. /**
  78718. * Reserved for PCF and PCSS
  78719. * The lowest quality but the fastest.
  78720. *
  78721. * Execute PCF on a 1*1 kernel.
  78722. *
  78723. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  78724. */
  78725. static readonly QUALITY_LOW: number;
  78726. /** Gets or sets the custom shader name to use */
  78727. customShaderOptions: ICustomShaderOptions;
  78728. /**
  78729. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  78730. */
  78731. onBeforeShadowMapRenderObservable: Observable<Effect>;
  78732. /**
  78733. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  78734. */
  78735. onAfterShadowMapRenderObservable: Observable<Effect>;
  78736. /**
  78737. * Observable triggered before a mesh is rendered in the shadow map.
  78738. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  78739. */
  78740. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  78741. /**
  78742. * Observable triggered after a mesh is rendered in the shadow map.
  78743. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  78744. */
  78745. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  78746. private _bias;
  78747. /**
  78748. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  78749. */
  78750. /**
  78751. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  78752. */
  78753. bias: number;
  78754. private _normalBias;
  78755. /**
  78756. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  78757. */
  78758. /**
  78759. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  78760. */
  78761. normalBias: number;
  78762. private _blurBoxOffset;
  78763. /**
  78764. * Gets the blur box offset: offset applied during the blur pass.
  78765. * Only useful if useKernelBlur = false
  78766. */
  78767. /**
  78768. * Sets the blur box offset: offset applied during the blur pass.
  78769. * Only useful if useKernelBlur = false
  78770. */
  78771. blurBoxOffset: number;
  78772. private _blurScale;
  78773. /**
  78774. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  78775. * 2 means half of the size.
  78776. */
  78777. /**
  78778. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  78779. * 2 means half of the size.
  78780. */
  78781. blurScale: number;
  78782. private _blurKernel;
  78783. /**
  78784. * Gets the blur kernel: kernel size of the blur pass.
  78785. * Only useful if useKernelBlur = true
  78786. */
  78787. /**
  78788. * Sets the blur kernel: kernel size of the blur pass.
  78789. * Only useful if useKernelBlur = true
  78790. */
  78791. blurKernel: number;
  78792. private _useKernelBlur;
  78793. /**
  78794. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  78795. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  78796. */
  78797. /**
  78798. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  78799. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  78800. */
  78801. useKernelBlur: boolean;
  78802. private _depthScale;
  78803. /**
  78804. * Gets the depth scale used in ESM mode.
  78805. */
  78806. /**
  78807. * Sets the depth scale used in ESM mode.
  78808. * This can override the scale stored on the light.
  78809. */
  78810. depthScale: number;
  78811. private _filter;
  78812. /**
  78813. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  78814. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  78815. */
  78816. /**
  78817. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  78818. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  78819. */
  78820. filter: number;
  78821. /**
  78822. * Gets if the current filter is set to Poisson Sampling.
  78823. */
  78824. /**
  78825. * Sets the current filter to Poisson Sampling.
  78826. */
  78827. usePoissonSampling: boolean;
  78828. /**
  78829. * Gets if the current filter is set to ESM.
  78830. */
  78831. /**
  78832. * Sets the current filter is to ESM.
  78833. */
  78834. useExponentialShadowMap: boolean;
  78835. /**
  78836. * Gets if the current filter is set to filtered ESM.
  78837. */
  78838. /**
  78839. * Gets if the current filter is set to filtered ESM.
  78840. */
  78841. useBlurExponentialShadowMap: boolean;
  78842. /**
  78843. * Gets if the current filter is set to "close ESM" (using the inverse of the
  78844. * exponential to prevent steep falloff artifacts).
  78845. */
  78846. /**
  78847. * Sets the current filter to "close ESM" (using the inverse of the
  78848. * exponential to prevent steep falloff artifacts).
  78849. */
  78850. useCloseExponentialShadowMap: boolean;
  78851. /**
  78852. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  78853. * exponential to prevent steep falloff artifacts).
  78854. */
  78855. /**
  78856. * Sets the current filter to filtered "close ESM" (using the inverse of the
  78857. * exponential to prevent steep falloff artifacts).
  78858. */
  78859. useBlurCloseExponentialShadowMap: boolean;
  78860. /**
  78861. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  78862. */
  78863. /**
  78864. * Sets the current filter to "PCF" (percentage closer filtering).
  78865. */
  78866. usePercentageCloserFiltering: boolean;
  78867. private _filteringQuality;
  78868. /**
  78869. * Gets the PCF or PCSS Quality.
  78870. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  78871. */
  78872. /**
  78873. * Sets the PCF or PCSS Quality.
  78874. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  78875. */
  78876. filteringQuality: number;
  78877. /**
  78878. * Gets if the current filter is set to "PCSS" (contact hardening).
  78879. */
  78880. /**
  78881. * Sets the current filter to "PCSS" (contact hardening).
  78882. */
  78883. useContactHardeningShadow: boolean;
  78884. private _contactHardeningLightSizeUVRatio;
  78885. /**
  78886. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  78887. * Using a ratio helps keeping shape stability independently of the map size.
  78888. *
  78889. * It does not account for the light projection as it was having too much
  78890. * instability during the light setup or during light position changes.
  78891. *
  78892. * Only valid if useContactHardeningShadow is true.
  78893. */
  78894. /**
  78895. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  78896. * Using a ratio helps keeping shape stability independently of the map size.
  78897. *
  78898. * It does not account for the light projection as it was having too much
  78899. * instability during the light setup or during light position changes.
  78900. *
  78901. * Only valid if useContactHardeningShadow is true.
  78902. */
  78903. contactHardeningLightSizeUVRatio: number;
  78904. private _darkness;
  78905. /** Gets or sets the actual darkness of a shadow */
  78906. darkness: number;
  78907. /**
  78908. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  78909. * 0 means strongest and 1 would means no shadow.
  78910. * @returns the darkness.
  78911. */
  78912. getDarkness(): number;
  78913. /**
  78914. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  78915. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  78916. * @returns the shadow generator allowing fluent coding.
  78917. */
  78918. setDarkness(darkness: number): ShadowGenerator;
  78919. private _transparencyShadow;
  78920. /** Gets or sets the ability to have transparent shadow */
  78921. transparencyShadow: boolean;
  78922. /**
  78923. * Sets the ability to have transparent shadow (boolean).
  78924. * @param transparent True if transparent else False
  78925. * @returns the shadow generator allowing fluent coding
  78926. */
  78927. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  78928. private _shadowMap;
  78929. private _shadowMap2;
  78930. /**
  78931. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  78932. * @returns The render target texture if present otherwise, null
  78933. */
  78934. getShadowMap(): Nullable<RenderTargetTexture>;
  78935. /**
  78936. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  78937. * @returns The render target texture if the shadow map is present otherwise, null
  78938. */
  78939. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  78940. /**
  78941. * Gets the class name of that object
  78942. * @returns "ShadowGenerator"
  78943. */
  78944. getClassName(): string;
  78945. /**
  78946. * Helper function to add a mesh and its descendants to the list of shadow casters.
  78947. * @param mesh Mesh to add
  78948. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  78949. * @returns the Shadow Generator itself
  78950. */
  78951. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  78952. /**
  78953. * Helper function to remove a mesh and its descendants from the list of shadow casters
  78954. * @param mesh Mesh to remove
  78955. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  78956. * @returns the Shadow Generator itself
  78957. */
  78958. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  78959. /**
  78960. * Controls the extent to which the shadows fade out at the edge of the frustum
  78961. * Used only by directionals and spots
  78962. */
  78963. frustumEdgeFalloff: number;
  78964. private _light;
  78965. /**
  78966. * Returns the associated light object.
  78967. * @returns the light generating the shadow
  78968. */
  78969. getLight(): IShadowLight;
  78970. /**
  78971. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  78972. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  78973. * It might on the other hand introduce peter panning.
  78974. */
  78975. forceBackFacesOnly: boolean;
  78976. private _scene;
  78977. private _lightDirection;
  78978. private _effect;
  78979. private _viewMatrix;
  78980. private _projectionMatrix;
  78981. private _transformMatrix;
  78982. private _cachedPosition;
  78983. private _cachedDirection;
  78984. private _cachedDefines;
  78985. private _currentRenderID;
  78986. private _boxBlurPostprocess;
  78987. private _kernelBlurXPostprocess;
  78988. private _kernelBlurYPostprocess;
  78989. private _blurPostProcesses;
  78990. private _mapSize;
  78991. private _currentFaceIndex;
  78992. private _currentFaceIndexCache;
  78993. private _textureType;
  78994. private _defaultTextureMatrix;
  78995. private _storedUniqueId;
  78996. /** @hidden */
  78997. static _SceneComponentInitialization: (scene: Scene) => void;
  78998. /**
  78999. * Creates a ShadowGenerator object.
  79000. * A ShadowGenerator is the required tool to use the shadows.
  79001. * Each light casting shadows needs to use its own ShadowGenerator.
  79002. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  79003. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  79004. * @param light The light object generating the shadows.
  79005. * @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.
  79006. */
  79007. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  79008. private _initializeGenerator;
  79009. private _initializeShadowMap;
  79010. private _initializeBlurRTTAndPostProcesses;
  79011. private _renderForShadowMap;
  79012. private _renderSubMeshForShadowMap;
  79013. private _applyFilterValues;
  79014. /**
  79015. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  79016. * @param onCompiled Callback triggered at the and of the effects compilation
  79017. * @param options Sets of optional options forcing the compilation with different modes
  79018. */
  79019. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  79020. useInstances: boolean;
  79021. }>): void;
  79022. /**
  79023. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  79024. * @param options Sets of optional options forcing the compilation with different modes
  79025. * @returns A promise that resolves when the compilation completes
  79026. */
  79027. forceCompilationAsync(options?: Partial<{
  79028. useInstances: boolean;
  79029. }>): Promise<void>;
  79030. /**
  79031. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  79032. * @param subMesh The submesh we want to render in the shadow map
  79033. * @param useInstances Defines wether will draw in the map using instances
  79034. * @returns true if ready otherwise, false
  79035. */
  79036. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  79037. /**
  79038. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  79039. * @param defines Defines of the material we want to update
  79040. * @param lightIndex Index of the light in the enabled light list of the material
  79041. */
  79042. prepareDefines(defines: any, lightIndex: number): void;
  79043. /**
  79044. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  79045. * defined in the generator but impacting the effect).
  79046. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  79047. * @param effect The effect we are binfing the information for
  79048. */
  79049. bindShadowLight(lightIndex: string, effect: Effect): void;
  79050. /**
  79051. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  79052. * (eq to shadow prjection matrix * light transform matrix)
  79053. * @returns The transform matrix used to create the shadow map
  79054. */
  79055. getTransformMatrix(): Matrix;
  79056. /**
  79057. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  79058. * Cube and 2D textures for instance.
  79059. */
  79060. recreateShadowMap(): void;
  79061. private _disposeBlurPostProcesses;
  79062. private _disposeRTTandPostProcesses;
  79063. /**
  79064. * Disposes the ShadowGenerator.
  79065. * Returns nothing.
  79066. */
  79067. dispose(): void;
  79068. /**
  79069. * Serializes the shadow generator setup to a json object.
  79070. * @returns The serialized JSON object
  79071. */
  79072. serialize(): any;
  79073. /**
  79074. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  79075. * @param parsedShadowGenerator The JSON object to parse
  79076. * @param scene The scene to create the shadow map for
  79077. * @returns The parsed shadow generator
  79078. */
  79079. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  79080. }
  79081. }
  79082. declare module BABYLON {
  79083. /**
  79084. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  79085. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  79086. * 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.
  79087. */
  79088. export abstract class Light extends Node {
  79089. /**
  79090. * Falloff Default: light is falling off following the material specification:
  79091. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  79092. */
  79093. static readonly FALLOFF_DEFAULT: number;
  79094. /**
  79095. * Falloff Physical: light is falling off following the inverse squared distance law.
  79096. */
  79097. static readonly FALLOFF_PHYSICAL: number;
  79098. /**
  79099. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  79100. * to enhance interoperability with other engines.
  79101. */
  79102. static readonly FALLOFF_GLTF: number;
  79103. /**
  79104. * Falloff Standard: light is falling off like in the standard material
  79105. * to enhance interoperability with other materials.
  79106. */
  79107. static readonly FALLOFF_STANDARD: number;
  79108. /**
  79109. * If every light affecting the material is in this lightmapMode,
  79110. * material.lightmapTexture adds or multiplies
  79111. * (depends on material.useLightmapAsShadowmap)
  79112. * after every other light calculations.
  79113. */
  79114. static readonly LIGHTMAP_DEFAULT: number;
  79115. /**
  79116. * material.lightmapTexture as only diffuse lighting from this light
  79117. * adds only specular lighting from this light
  79118. * adds dynamic shadows
  79119. */
  79120. static readonly LIGHTMAP_SPECULAR: number;
  79121. /**
  79122. * material.lightmapTexture as only lighting
  79123. * no light calculation from this light
  79124. * only adds dynamic shadows from this light
  79125. */
  79126. static readonly LIGHTMAP_SHADOWSONLY: number;
  79127. /**
  79128. * Each light type uses the default quantity according to its type:
  79129. * point/spot lights use luminous intensity
  79130. * directional lights use illuminance
  79131. */
  79132. static readonly INTENSITYMODE_AUTOMATIC: number;
  79133. /**
  79134. * lumen (lm)
  79135. */
  79136. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  79137. /**
  79138. * candela (lm/sr)
  79139. */
  79140. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  79141. /**
  79142. * lux (lm/m^2)
  79143. */
  79144. static readonly INTENSITYMODE_ILLUMINANCE: number;
  79145. /**
  79146. * nit (cd/m^2)
  79147. */
  79148. static readonly INTENSITYMODE_LUMINANCE: number;
  79149. /**
  79150. * Light type const id of the point light.
  79151. */
  79152. static readonly LIGHTTYPEID_POINTLIGHT: number;
  79153. /**
  79154. * Light type const id of the directional light.
  79155. */
  79156. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  79157. /**
  79158. * Light type const id of the spot light.
  79159. */
  79160. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  79161. /**
  79162. * Light type const id of the hemispheric light.
  79163. */
  79164. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  79165. /**
  79166. * Diffuse gives the basic color to an object.
  79167. */
  79168. diffuse: Color3;
  79169. /**
  79170. * Specular produces a highlight color on an object.
  79171. * Note: This is note affecting PBR materials.
  79172. */
  79173. specular: Color3;
  79174. /**
  79175. * Defines the falloff type for this light. This lets overrriding how punctual light are
  79176. * falling off base on range or angle.
  79177. * This can be set to any values in Light.FALLOFF_x.
  79178. *
  79179. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  79180. * other types of materials.
  79181. */
  79182. falloffType: number;
  79183. /**
  79184. * Strength of the light.
  79185. * Note: By default it is define in the framework own unit.
  79186. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  79187. */
  79188. intensity: number;
  79189. private _range;
  79190. protected _inverseSquaredRange: number;
  79191. /**
  79192. * Defines how far from the source the light is impacting in scene units.
  79193. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  79194. */
  79195. /**
  79196. * Defines how far from the source the light is impacting in scene units.
  79197. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  79198. */
  79199. range: number;
  79200. /**
  79201. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  79202. * of light.
  79203. */
  79204. private _photometricScale;
  79205. private _intensityMode;
  79206. /**
  79207. * Gets the photometric scale used to interpret the intensity.
  79208. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  79209. */
  79210. /**
  79211. * Sets the photometric scale used to interpret the intensity.
  79212. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  79213. */
  79214. intensityMode: number;
  79215. private _radius;
  79216. /**
  79217. * Gets the light radius used by PBR Materials to simulate soft area lights.
  79218. */
  79219. /**
  79220. * sets the light radius used by PBR Materials to simulate soft area lights.
  79221. */
  79222. radius: number;
  79223. private _renderPriority;
  79224. /**
  79225. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  79226. * exceeding the number allowed of the materials.
  79227. */
  79228. renderPriority: number;
  79229. private _shadowEnabled;
  79230. /**
  79231. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  79232. * the current shadow generator.
  79233. */
  79234. /**
  79235. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  79236. * the current shadow generator.
  79237. */
  79238. shadowEnabled: boolean;
  79239. private _includedOnlyMeshes;
  79240. /**
  79241. * Gets the only meshes impacted by this light.
  79242. */
  79243. /**
  79244. * Sets the only meshes impacted by this light.
  79245. */
  79246. includedOnlyMeshes: AbstractMesh[];
  79247. private _excludedMeshes;
  79248. /**
  79249. * Gets the meshes not impacted by this light.
  79250. */
  79251. /**
  79252. * Sets the meshes not impacted by this light.
  79253. */
  79254. excludedMeshes: AbstractMesh[];
  79255. private _excludeWithLayerMask;
  79256. /**
  79257. * Gets the layer id use to find what meshes are not impacted by the light.
  79258. * Inactive if 0
  79259. */
  79260. /**
  79261. * Sets the layer id use to find what meshes are not impacted by the light.
  79262. * Inactive if 0
  79263. */
  79264. excludeWithLayerMask: number;
  79265. private _includeOnlyWithLayerMask;
  79266. /**
  79267. * Gets the layer id use to find what meshes are impacted by the light.
  79268. * Inactive if 0
  79269. */
  79270. /**
  79271. * Sets the layer id use to find what meshes are impacted by the light.
  79272. * Inactive if 0
  79273. */
  79274. includeOnlyWithLayerMask: number;
  79275. private _lightmapMode;
  79276. /**
  79277. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  79278. */
  79279. /**
  79280. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  79281. */
  79282. lightmapMode: number;
  79283. /**
  79284. * Shadow generator associted to the light.
  79285. * @hidden Internal use only.
  79286. */
  79287. _shadowGenerator: Nullable<IShadowGenerator>;
  79288. /**
  79289. * @hidden Internal use only.
  79290. */
  79291. _excludedMeshesIds: string[];
  79292. /**
  79293. * @hidden Internal use only.
  79294. */
  79295. _includedOnlyMeshesIds: string[];
  79296. /**
  79297. * The current light unifom buffer.
  79298. * @hidden Internal use only.
  79299. */
  79300. _uniformBuffer: UniformBuffer;
  79301. /** @hidden */
  79302. _renderId: number;
  79303. /**
  79304. * Creates a Light object in the scene.
  79305. * Documentation : https://doc.babylonjs.com/babylon101/lights
  79306. * @param name The firendly name of the light
  79307. * @param scene The scene the light belongs too
  79308. */
  79309. constructor(name: string, scene: Scene);
  79310. protected abstract _buildUniformLayout(): void;
  79311. /**
  79312. * Sets the passed Effect "effect" with the Light information.
  79313. * @param effect The effect to update
  79314. * @param lightIndex The index of the light in the effect to update
  79315. * @returns The light
  79316. */
  79317. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  79318. /**
  79319. * Sets the passed Effect "effect" with the Light textures.
  79320. * @param effect The effect to update
  79321. * @param lightIndex The index of the light in the effect to update
  79322. * @returns The light
  79323. */
  79324. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  79325. /**
  79326. * Binds the lights information from the scene to the effect for the given mesh.
  79327. * @param lightIndex Light index
  79328. * @param scene The scene where the light belongs to
  79329. * @param effect The effect we are binding the data to
  79330. * @param useSpecular Defines if specular is supported
  79331. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  79332. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  79333. */
  79334. bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  79335. /**
  79336. * Sets the passed Effect "effect" with the Light information.
  79337. * @param effect The effect to update
  79338. * @param lightDataUniformName The uniform used to store light data (position or direction)
  79339. * @returns The light
  79340. */
  79341. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  79342. /**
  79343. * Returns the string "Light".
  79344. * @returns the class name
  79345. */
  79346. getClassName(): string;
  79347. /** @hidden */
  79348. readonly _isLight: boolean;
  79349. /**
  79350. * Converts the light information to a readable string for debug purpose.
  79351. * @param fullDetails Supports for multiple levels of logging within scene loading
  79352. * @returns the human readable light info
  79353. */
  79354. toString(fullDetails?: boolean): string;
  79355. /** @hidden */
  79356. protected _syncParentEnabledState(): void;
  79357. /**
  79358. * Set the enabled state of this node.
  79359. * @param value - the new enabled state
  79360. */
  79361. setEnabled(value: boolean): void;
  79362. /**
  79363. * Returns the Light associated shadow generator if any.
  79364. * @return the associated shadow generator.
  79365. */
  79366. getShadowGenerator(): Nullable<IShadowGenerator>;
  79367. /**
  79368. * Returns a Vector3, the absolute light position in the World.
  79369. * @returns the world space position of the light
  79370. */
  79371. getAbsolutePosition(): Vector3;
  79372. /**
  79373. * Specifies if the light will affect the passed mesh.
  79374. * @param mesh The mesh to test against the light
  79375. * @return true the mesh is affected otherwise, false.
  79376. */
  79377. canAffectMesh(mesh: AbstractMesh): boolean;
  79378. /**
  79379. * Sort function to order lights for rendering.
  79380. * @param a First Light object to compare to second.
  79381. * @param b Second Light object to compare first.
  79382. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  79383. */
  79384. static CompareLightsPriority(a: Light, b: Light): number;
  79385. /**
  79386. * Releases resources associated with this node.
  79387. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  79388. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  79389. */
  79390. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  79391. /**
  79392. * Returns the light type ID (integer).
  79393. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  79394. */
  79395. getTypeID(): number;
  79396. /**
  79397. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  79398. * @returns the scaled intensity in intensity mode unit
  79399. */
  79400. getScaledIntensity(): number;
  79401. /**
  79402. * Returns a new Light object, named "name", from the current one.
  79403. * @param name The name of the cloned light
  79404. * @returns the new created light
  79405. */
  79406. clone(name: string): Nullable<Light>;
  79407. /**
  79408. * Serializes the current light into a Serialization object.
  79409. * @returns the serialized object.
  79410. */
  79411. serialize(): any;
  79412. /**
  79413. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  79414. * This new light is named "name" and added to the passed scene.
  79415. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  79416. * @param name The friendly name of the light
  79417. * @param scene The scene the new light will belong to
  79418. * @returns the constructor function
  79419. */
  79420. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  79421. /**
  79422. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  79423. * @param parsedLight The JSON representation of the light
  79424. * @param scene The scene to create the parsed light in
  79425. * @returns the created light after parsing
  79426. */
  79427. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  79428. private _hookArrayForExcluded;
  79429. private _hookArrayForIncludedOnly;
  79430. private _resyncMeshes;
  79431. /**
  79432. * Forces the meshes to update their light related information in their rendering used effects
  79433. * @hidden Internal Use Only
  79434. */
  79435. _markMeshesAsLightDirty(): void;
  79436. /**
  79437. * Recomputes the cached photometric scale if needed.
  79438. */
  79439. private _computePhotometricScale;
  79440. /**
  79441. * Returns the Photometric Scale according to the light type and intensity mode.
  79442. */
  79443. private _getPhotometricScale;
  79444. /**
  79445. * Reorder the light in the scene according to their defined priority.
  79446. * @hidden Internal Use Only
  79447. */
  79448. _reorderLightsInScene(): void;
  79449. /**
  79450. * Prepares the list of defines specific to the light type.
  79451. * @param defines the list of defines
  79452. * @param lightIndex defines the index of the light for the effect
  79453. */
  79454. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  79455. }
  79456. }
  79457. declare module BABYLON {
  79458. /**
  79459. * Interface used to define Action
  79460. */
  79461. export interface IAction {
  79462. /**
  79463. * Trigger for the action
  79464. */
  79465. trigger: number;
  79466. /** Options of the trigger */
  79467. triggerOptions: any;
  79468. /**
  79469. * Gets the trigger parameters
  79470. * @returns the trigger parameters
  79471. */
  79472. getTriggerParameter(): any;
  79473. /**
  79474. * Internal only - executes current action event
  79475. * @hidden
  79476. */
  79477. _executeCurrent(evt?: ActionEvent): void;
  79478. /**
  79479. * Serialize placeholder for child classes
  79480. * @param parent of child
  79481. * @returns the serialized object
  79482. */
  79483. serialize(parent: any): any;
  79484. /**
  79485. * Internal only
  79486. * @hidden
  79487. */
  79488. _prepare(): void;
  79489. /**
  79490. * Internal only - manager for action
  79491. * @hidden
  79492. */
  79493. _actionManager: AbstractActionManager;
  79494. /**
  79495. * Adds action to chain of actions, may be a DoNothingAction
  79496. * @param action defines the next action to execute
  79497. * @returns The action passed in
  79498. * @see https://www.babylonjs-playground.com/#1T30HR#0
  79499. */
  79500. then(action: IAction): IAction;
  79501. }
  79502. /**
  79503. * The action to be carried out following a trigger
  79504. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  79505. */
  79506. export class Action implements IAction {
  79507. /** the trigger, with or without parameters, for the action */
  79508. triggerOptions: any;
  79509. /**
  79510. * Trigger for the action
  79511. */
  79512. trigger: number;
  79513. /**
  79514. * Internal only - manager for action
  79515. * @hidden
  79516. */
  79517. _actionManager: ActionManager;
  79518. private _nextActiveAction;
  79519. private _child;
  79520. private _condition?;
  79521. private _triggerParameter;
  79522. /**
  79523. * An event triggered prior to action being executed.
  79524. */
  79525. onBeforeExecuteObservable: Observable<Action>;
  79526. /**
  79527. * Creates a new Action
  79528. * @param triggerOptions the trigger, with or without parameters, for the action
  79529. * @param condition an optional determinant of action
  79530. */
  79531. constructor(
  79532. /** the trigger, with or without parameters, for the action */
  79533. triggerOptions: any, condition?: Condition);
  79534. /**
  79535. * Internal only
  79536. * @hidden
  79537. */
  79538. _prepare(): void;
  79539. /**
  79540. * Gets the trigger parameters
  79541. * @returns the trigger parameters
  79542. */
  79543. getTriggerParameter(): any;
  79544. /**
  79545. * Internal only - executes current action event
  79546. * @hidden
  79547. */
  79548. _executeCurrent(evt?: ActionEvent): void;
  79549. /**
  79550. * Execute placeholder for child classes
  79551. * @param evt optional action event
  79552. */
  79553. execute(evt?: ActionEvent): void;
  79554. /**
  79555. * Skips to next active action
  79556. */
  79557. skipToNextActiveAction(): void;
  79558. /**
  79559. * Adds action to chain of actions, may be a DoNothingAction
  79560. * @param action defines the next action to execute
  79561. * @returns The action passed in
  79562. * @see https://www.babylonjs-playground.com/#1T30HR#0
  79563. */
  79564. then(action: Action): Action;
  79565. /**
  79566. * Internal only
  79567. * @hidden
  79568. */
  79569. _getProperty(propertyPath: string): string;
  79570. /**
  79571. * Internal only
  79572. * @hidden
  79573. */
  79574. _getEffectiveTarget(target: any, propertyPath: string): any;
  79575. /**
  79576. * Serialize placeholder for child classes
  79577. * @param parent of child
  79578. * @returns the serialized object
  79579. */
  79580. serialize(parent: any): any;
  79581. /**
  79582. * Internal only called by serialize
  79583. * @hidden
  79584. */
  79585. protected _serialize(serializedAction: any, parent?: any): any;
  79586. /**
  79587. * Internal only
  79588. * @hidden
  79589. */
  79590. static _SerializeValueAsString: (value: any) => string;
  79591. /**
  79592. * Internal only
  79593. * @hidden
  79594. */
  79595. static _GetTargetProperty: (target: Node | Scene) => {
  79596. name: string;
  79597. targetType: string;
  79598. value: string;
  79599. };
  79600. }
  79601. }
  79602. declare module BABYLON {
  79603. /**
  79604. * A Condition applied to an Action
  79605. */
  79606. export class Condition {
  79607. /**
  79608. * Internal only - manager for action
  79609. * @hidden
  79610. */
  79611. _actionManager: ActionManager;
  79612. /**
  79613. * Internal only
  79614. * @hidden
  79615. */
  79616. _evaluationId: number;
  79617. /**
  79618. * Internal only
  79619. * @hidden
  79620. */
  79621. _currentResult: boolean;
  79622. /**
  79623. * Creates a new Condition
  79624. * @param actionManager the manager of the action the condition is applied to
  79625. */
  79626. constructor(actionManager: ActionManager);
  79627. /**
  79628. * Check if the current condition is valid
  79629. * @returns a boolean
  79630. */
  79631. isValid(): boolean;
  79632. /**
  79633. * Internal only
  79634. * @hidden
  79635. */
  79636. _getProperty(propertyPath: string): string;
  79637. /**
  79638. * Internal only
  79639. * @hidden
  79640. */
  79641. _getEffectiveTarget(target: any, propertyPath: string): any;
  79642. /**
  79643. * Serialize placeholder for child classes
  79644. * @returns the serialized object
  79645. */
  79646. serialize(): any;
  79647. /**
  79648. * Internal only
  79649. * @hidden
  79650. */
  79651. protected _serialize(serializedCondition: any): any;
  79652. }
  79653. /**
  79654. * Defines specific conditional operators as extensions of Condition
  79655. */
  79656. export class ValueCondition extends Condition {
  79657. /** path to specify the property of the target the conditional operator uses */
  79658. propertyPath: string;
  79659. /** the value compared by the conditional operator against the current value of the property */
  79660. value: any;
  79661. /** the conditional operator, default ValueCondition.IsEqual */
  79662. operator: number;
  79663. /**
  79664. * Internal only
  79665. * @hidden
  79666. */
  79667. private static _IsEqual;
  79668. /**
  79669. * Internal only
  79670. * @hidden
  79671. */
  79672. private static _IsDifferent;
  79673. /**
  79674. * Internal only
  79675. * @hidden
  79676. */
  79677. private static _IsGreater;
  79678. /**
  79679. * Internal only
  79680. * @hidden
  79681. */
  79682. private static _IsLesser;
  79683. /**
  79684. * returns the number for IsEqual
  79685. */
  79686. static readonly IsEqual: number;
  79687. /**
  79688. * Returns the number for IsDifferent
  79689. */
  79690. static readonly IsDifferent: number;
  79691. /**
  79692. * Returns the number for IsGreater
  79693. */
  79694. static readonly IsGreater: number;
  79695. /**
  79696. * Returns the number for IsLesser
  79697. */
  79698. static readonly IsLesser: number;
  79699. /**
  79700. * Internal only The action manager for the condition
  79701. * @hidden
  79702. */
  79703. _actionManager: ActionManager;
  79704. /**
  79705. * Internal only
  79706. * @hidden
  79707. */
  79708. private _target;
  79709. /**
  79710. * Internal only
  79711. * @hidden
  79712. */
  79713. private _effectiveTarget;
  79714. /**
  79715. * Internal only
  79716. * @hidden
  79717. */
  79718. private _property;
  79719. /**
  79720. * Creates a new ValueCondition
  79721. * @param actionManager manager for the action the condition applies to
  79722. * @param target for the action
  79723. * @param propertyPath path to specify the property of the target the conditional operator uses
  79724. * @param value the value compared by the conditional operator against the current value of the property
  79725. * @param operator the conditional operator, default ValueCondition.IsEqual
  79726. */
  79727. constructor(actionManager: ActionManager, target: any,
  79728. /** path to specify the property of the target the conditional operator uses */
  79729. propertyPath: string,
  79730. /** the value compared by the conditional operator against the current value of the property */
  79731. value: any,
  79732. /** the conditional operator, default ValueCondition.IsEqual */
  79733. operator?: number);
  79734. /**
  79735. * Compares the given value with the property value for the specified conditional operator
  79736. * @returns the result of the comparison
  79737. */
  79738. isValid(): boolean;
  79739. /**
  79740. * Serialize the ValueCondition into a JSON compatible object
  79741. * @returns serialization object
  79742. */
  79743. serialize(): any;
  79744. /**
  79745. * Gets the name of the conditional operator for the ValueCondition
  79746. * @param operator the conditional operator
  79747. * @returns the name
  79748. */
  79749. static GetOperatorName(operator: number): string;
  79750. }
  79751. /**
  79752. * Defines a predicate condition as an extension of Condition
  79753. */
  79754. export class PredicateCondition extends Condition {
  79755. /** defines the predicate function used to validate the condition */
  79756. predicate: () => boolean;
  79757. /**
  79758. * Internal only - manager for action
  79759. * @hidden
  79760. */
  79761. _actionManager: ActionManager;
  79762. /**
  79763. * Creates a new PredicateCondition
  79764. * @param actionManager manager for the action the condition applies to
  79765. * @param predicate defines the predicate function used to validate the condition
  79766. */
  79767. constructor(actionManager: ActionManager,
  79768. /** defines the predicate function used to validate the condition */
  79769. predicate: () => boolean);
  79770. /**
  79771. * @returns the validity of the predicate condition
  79772. */
  79773. isValid(): boolean;
  79774. }
  79775. /**
  79776. * Defines a state condition as an extension of Condition
  79777. */
  79778. export class StateCondition extends Condition {
  79779. /** Value to compare with target state */
  79780. value: string;
  79781. /**
  79782. * Internal only - manager for action
  79783. * @hidden
  79784. */
  79785. _actionManager: ActionManager;
  79786. /**
  79787. * Internal only
  79788. * @hidden
  79789. */
  79790. private _target;
  79791. /**
  79792. * Creates a new StateCondition
  79793. * @param actionManager manager for the action the condition applies to
  79794. * @param target of the condition
  79795. * @param value to compare with target state
  79796. */
  79797. constructor(actionManager: ActionManager, target: any,
  79798. /** Value to compare with target state */
  79799. value: string);
  79800. /**
  79801. * Gets a boolean indicating if the current condition is met
  79802. * @returns the validity of the state
  79803. */
  79804. isValid(): boolean;
  79805. /**
  79806. * Serialize the StateCondition into a JSON compatible object
  79807. * @returns serialization object
  79808. */
  79809. serialize(): any;
  79810. }
  79811. }
  79812. declare module BABYLON {
  79813. /**
  79814. * This defines an action responsible to toggle a boolean once triggered.
  79815. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79816. */
  79817. export class SwitchBooleanAction extends Action {
  79818. /**
  79819. * The path to the boolean property in the target object
  79820. */
  79821. propertyPath: string;
  79822. private _target;
  79823. private _effectiveTarget;
  79824. private _property;
  79825. /**
  79826. * Instantiate the action
  79827. * @param triggerOptions defines the trigger options
  79828. * @param target defines the object containing the boolean
  79829. * @param propertyPath defines the path to the boolean property in the target object
  79830. * @param condition defines the trigger related conditions
  79831. */
  79832. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  79833. /** @hidden */
  79834. _prepare(): void;
  79835. /**
  79836. * Execute the action toggle the boolean value.
  79837. */
  79838. execute(): void;
  79839. /**
  79840. * Serializes the actions and its related information.
  79841. * @param parent defines the object to serialize in
  79842. * @returns the serialized object
  79843. */
  79844. serialize(parent: any): any;
  79845. }
  79846. /**
  79847. * This defines an action responsible to set a the state field of the target
  79848. * to a desired value once triggered.
  79849. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79850. */
  79851. export class SetStateAction extends Action {
  79852. /**
  79853. * The value to store in the state field.
  79854. */
  79855. value: string;
  79856. private _target;
  79857. /**
  79858. * Instantiate the action
  79859. * @param triggerOptions defines the trigger options
  79860. * @param target defines the object containing the state property
  79861. * @param value defines the value to store in the state field
  79862. * @param condition defines the trigger related conditions
  79863. */
  79864. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  79865. /**
  79866. * Execute the action and store the value on the target state property.
  79867. */
  79868. execute(): void;
  79869. /**
  79870. * Serializes the actions and its related information.
  79871. * @param parent defines the object to serialize in
  79872. * @returns the serialized object
  79873. */
  79874. serialize(parent: any): any;
  79875. }
  79876. /**
  79877. * This defines an action responsible to set a property of the target
  79878. * to a desired value once triggered.
  79879. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79880. */
  79881. export class SetValueAction extends Action {
  79882. /**
  79883. * The path of the property to set in the target.
  79884. */
  79885. propertyPath: string;
  79886. /**
  79887. * The value to set in the property
  79888. */
  79889. value: any;
  79890. private _target;
  79891. private _effectiveTarget;
  79892. private _property;
  79893. /**
  79894. * Instantiate the action
  79895. * @param triggerOptions defines the trigger options
  79896. * @param target defines the object containing the property
  79897. * @param propertyPath defines the path of the property to set in the target
  79898. * @param value defines the value to set in the property
  79899. * @param condition defines the trigger related conditions
  79900. */
  79901. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  79902. /** @hidden */
  79903. _prepare(): void;
  79904. /**
  79905. * Execute the action and set the targetted property to the desired value.
  79906. */
  79907. execute(): void;
  79908. /**
  79909. * Serializes the actions and its related information.
  79910. * @param parent defines the object to serialize in
  79911. * @returns the serialized object
  79912. */
  79913. serialize(parent: any): any;
  79914. }
  79915. /**
  79916. * This defines an action responsible to increment the target value
  79917. * to a desired value once triggered.
  79918. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79919. */
  79920. export class IncrementValueAction extends Action {
  79921. /**
  79922. * The path of the property to increment in the target.
  79923. */
  79924. propertyPath: string;
  79925. /**
  79926. * The value we should increment the property by.
  79927. */
  79928. value: any;
  79929. private _target;
  79930. private _effectiveTarget;
  79931. private _property;
  79932. /**
  79933. * Instantiate the action
  79934. * @param triggerOptions defines the trigger options
  79935. * @param target defines the object containing the property
  79936. * @param propertyPath defines the path of the property to increment in the target
  79937. * @param value defines the value value we should increment the property by
  79938. * @param condition defines the trigger related conditions
  79939. */
  79940. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  79941. /** @hidden */
  79942. _prepare(): void;
  79943. /**
  79944. * Execute the action and increment the target of the value amount.
  79945. */
  79946. execute(): void;
  79947. /**
  79948. * Serializes the actions and its related information.
  79949. * @param parent defines the object to serialize in
  79950. * @returns the serialized object
  79951. */
  79952. serialize(parent: any): any;
  79953. }
  79954. /**
  79955. * This defines an action responsible to start an animation once triggered.
  79956. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79957. */
  79958. export class PlayAnimationAction extends Action {
  79959. /**
  79960. * Where the animation should start (animation frame)
  79961. */
  79962. from: number;
  79963. /**
  79964. * Where the animation should stop (animation frame)
  79965. */
  79966. to: number;
  79967. /**
  79968. * Define if the animation should loop or stop after the first play.
  79969. */
  79970. loop?: boolean;
  79971. private _target;
  79972. /**
  79973. * Instantiate the action
  79974. * @param triggerOptions defines the trigger options
  79975. * @param target defines the target animation or animation name
  79976. * @param from defines from where the animation should start (animation frame)
  79977. * @param end defines where the animation should stop (animation frame)
  79978. * @param loop defines if the animation should loop or stop after the first play
  79979. * @param condition defines the trigger related conditions
  79980. */
  79981. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  79982. /** @hidden */
  79983. _prepare(): void;
  79984. /**
  79985. * Execute the action and play the animation.
  79986. */
  79987. execute(): void;
  79988. /**
  79989. * Serializes the actions and its related information.
  79990. * @param parent defines the object to serialize in
  79991. * @returns the serialized object
  79992. */
  79993. serialize(parent: any): any;
  79994. }
  79995. /**
  79996. * This defines an action responsible to stop an animation once triggered.
  79997. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79998. */
  79999. export class StopAnimationAction extends Action {
  80000. private _target;
  80001. /**
  80002. * Instantiate the action
  80003. * @param triggerOptions defines the trigger options
  80004. * @param target defines the target animation or animation name
  80005. * @param condition defines the trigger related conditions
  80006. */
  80007. constructor(triggerOptions: any, target: any, condition?: Condition);
  80008. /** @hidden */
  80009. _prepare(): void;
  80010. /**
  80011. * Execute the action and stop the animation.
  80012. */
  80013. execute(): void;
  80014. /**
  80015. * Serializes the actions and its related information.
  80016. * @param parent defines the object to serialize in
  80017. * @returns the serialized object
  80018. */
  80019. serialize(parent: any): any;
  80020. }
  80021. /**
  80022. * This defines an action responsible that does nothing once triggered.
  80023. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  80024. */
  80025. export class DoNothingAction extends Action {
  80026. /**
  80027. * Instantiate the action
  80028. * @param triggerOptions defines the trigger options
  80029. * @param condition defines the trigger related conditions
  80030. */
  80031. constructor(triggerOptions?: any, condition?: Condition);
  80032. /**
  80033. * Execute the action and do nothing.
  80034. */
  80035. execute(): void;
  80036. /**
  80037. * Serializes the actions and its related information.
  80038. * @param parent defines the object to serialize in
  80039. * @returns the serialized object
  80040. */
  80041. serialize(parent: any): any;
  80042. }
  80043. /**
  80044. * This defines an action responsible to trigger several actions once triggered.
  80045. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  80046. */
  80047. export class CombineAction extends Action {
  80048. /**
  80049. * The list of aggregated animations to run.
  80050. */
  80051. children: Action[];
  80052. /**
  80053. * Instantiate the action
  80054. * @param triggerOptions defines the trigger options
  80055. * @param children defines the list of aggregated animations to run
  80056. * @param condition defines the trigger related conditions
  80057. */
  80058. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  80059. /** @hidden */
  80060. _prepare(): void;
  80061. /**
  80062. * Execute the action and executes all the aggregated actions.
  80063. */
  80064. execute(evt: ActionEvent): void;
  80065. /**
  80066. * Serializes the actions and its related information.
  80067. * @param parent defines the object to serialize in
  80068. * @returns the serialized object
  80069. */
  80070. serialize(parent: any): any;
  80071. }
  80072. /**
  80073. * This defines an action responsible to run code (external event) once triggered.
  80074. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  80075. */
  80076. export class ExecuteCodeAction extends Action {
  80077. /**
  80078. * The callback function to run.
  80079. */
  80080. func: (evt: ActionEvent) => void;
  80081. /**
  80082. * Instantiate the action
  80083. * @param triggerOptions defines the trigger options
  80084. * @param func defines the callback function to run
  80085. * @param condition defines the trigger related conditions
  80086. */
  80087. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  80088. /**
  80089. * Execute the action and run the attached code.
  80090. */
  80091. execute(evt: ActionEvent): void;
  80092. }
  80093. /**
  80094. * This defines an action responsible to set the parent property of the target once triggered.
  80095. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  80096. */
  80097. export class SetParentAction extends Action {
  80098. private _parent;
  80099. private _target;
  80100. /**
  80101. * Instantiate the action
  80102. * @param triggerOptions defines the trigger options
  80103. * @param target defines the target containing the parent property
  80104. * @param parent defines from where the animation should start (animation frame)
  80105. * @param condition defines the trigger related conditions
  80106. */
  80107. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  80108. /** @hidden */
  80109. _prepare(): void;
  80110. /**
  80111. * Execute the action and set the parent property.
  80112. */
  80113. execute(): void;
  80114. /**
  80115. * Serializes the actions and its related information.
  80116. * @param parent defines the object to serialize in
  80117. * @returns the serialized object
  80118. */
  80119. serialize(parent: any): any;
  80120. }
  80121. }
  80122. declare module BABYLON {
  80123. /**
  80124. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  80125. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  80126. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  80127. */
  80128. export class ActionManager extends AbstractActionManager {
  80129. /**
  80130. * Nothing
  80131. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80132. */
  80133. static readonly NothingTrigger: number;
  80134. /**
  80135. * On pick
  80136. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80137. */
  80138. static readonly OnPickTrigger: number;
  80139. /**
  80140. * On left pick
  80141. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80142. */
  80143. static readonly OnLeftPickTrigger: number;
  80144. /**
  80145. * On right pick
  80146. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80147. */
  80148. static readonly OnRightPickTrigger: number;
  80149. /**
  80150. * On center pick
  80151. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80152. */
  80153. static readonly OnCenterPickTrigger: number;
  80154. /**
  80155. * On pick down
  80156. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80157. */
  80158. static readonly OnPickDownTrigger: number;
  80159. /**
  80160. * On double pick
  80161. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80162. */
  80163. static readonly OnDoublePickTrigger: number;
  80164. /**
  80165. * On pick up
  80166. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80167. */
  80168. static readonly OnPickUpTrigger: number;
  80169. /**
  80170. * On pick out.
  80171. * This trigger will only be raised if you also declared a OnPickDown
  80172. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80173. */
  80174. static readonly OnPickOutTrigger: number;
  80175. /**
  80176. * On long press
  80177. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80178. */
  80179. static readonly OnLongPressTrigger: number;
  80180. /**
  80181. * On pointer over
  80182. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80183. */
  80184. static readonly OnPointerOverTrigger: number;
  80185. /**
  80186. * On pointer out
  80187. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80188. */
  80189. static readonly OnPointerOutTrigger: number;
  80190. /**
  80191. * On every frame
  80192. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80193. */
  80194. static readonly OnEveryFrameTrigger: number;
  80195. /**
  80196. * On intersection enter
  80197. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80198. */
  80199. static readonly OnIntersectionEnterTrigger: number;
  80200. /**
  80201. * On intersection exit
  80202. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80203. */
  80204. static readonly OnIntersectionExitTrigger: number;
  80205. /**
  80206. * On key down
  80207. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80208. */
  80209. static readonly OnKeyDownTrigger: number;
  80210. /**
  80211. * On key up
  80212. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80213. */
  80214. static readonly OnKeyUpTrigger: number;
  80215. private _scene;
  80216. /**
  80217. * Creates a new action manager
  80218. * @param scene defines the hosting scene
  80219. */
  80220. constructor(scene: Scene);
  80221. /**
  80222. * Releases all associated resources
  80223. */
  80224. dispose(): void;
  80225. /**
  80226. * Gets hosting scene
  80227. * @returns the hosting scene
  80228. */
  80229. getScene(): Scene;
  80230. /**
  80231. * Does this action manager handles actions of any of the given triggers
  80232. * @param triggers defines the triggers to be tested
  80233. * @return a boolean indicating whether one (or more) of the triggers is handled
  80234. */
  80235. hasSpecificTriggers(triggers: number[]): boolean;
  80236. /**
  80237. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  80238. * speed.
  80239. * @param triggerA defines the trigger to be tested
  80240. * @param triggerB defines the trigger to be tested
  80241. * @return a boolean indicating whether one (or more) of the triggers is handled
  80242. */
  80243. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  80244. /**
  80245. * Does this action manager handles actions of a given trigger
  80246. * @param trigger defines the trigger to be tested
  80247. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  80248. * @return whether the trigger is handled
  80249. */
  80250. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  80251. /**
  80252. * Does this action manager has pointer triggers
  80253. */
  80254. readonly hasPointerTriggers: boolean;
  80255. /**
  80256. * Does this action manager has pick triggers
  80257. */
  80258. readonly hasPickTriggers: boolean;
  80259. /**
  80260. * Registers an action to this action manager
  80261. * @param action defines the action to be registered
  80262. * @return the action amended (prepared) after registration
  80263. */
  80264. registerAction(action: IAction): Nullable<IAction>;
  80265. /**
  80266. * Unregisters an action to this action manager
  80267. * @param action defines the action to be unregistered
  80268. * @return a boolean indicating whether the action has been unregistered
  80269. */
  80270. unregisterAction(action: IAction): Boolean;
  80271. /**
  80272. * Process a specific trigger
  80273. * @param trigger defines the trigger to process
  80274. * @param evt defines the event details to be processed
  80275. */
  80276. processTrigger(trigger: number, evt?: IActionEvent): void;
  80277. /** @hidden */
  80278. _getEffectiveTarget(target: any, propertyPath: string): any;
  80279. /** @hidden */
  80280. _getProperty(propertyPath: string): string;
  80281. /**
  80282. * Serialize this manager to a JSON object
  80283. * @param name defines the property name to store this manager
  80284. * @returns a JSON representation of this manager
  80285. */
  80286. serialize(name: string): any;
  80287. /**
  80288. * Creates a new ActionManager from a JSON data
  80289. * @param parsedActions defines the JSON data to read from
  80290. * @param object defines the hosting mesh
  80291. * @param scene defines the hosting scene
  80292. */
  80293. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  80294. /**
  80295. * Get a trigger name by index
  80296. * @param trigger defines the trigger index
  80297. * @returns a trigger name
  80298. */
  80299. static GetTriggerName(trigger: number): string;
  80300. }
  80301. }
  80302. declare module BABYLON {
  80303. /**
  80304. * Class representing a ray with position and direction
  80305. */
  80306. export class Ray {
  80307. /** origin point */
  80308. origin: Vector3;
  80309. /** direction */
  80310. direction: Vector3;
  80311. /** length of the ray */
  80312. length: number;
  80313. private static readonly TmpVector3;
  80314. private _tmpRay;
  80315. /**
  80316. * Creates a new ray
  80317. * @param origin origin point
  80318. * @param direction direction
  80319. * @param length length of the ray
  80320. */
  80321. constructor(
  80322. /** origin point */
  80323. origin: Vector3,
  80324. /** direction */
  80325. direction: Vector3,
  80326. /** length of the ray */
  80327. length?: number);
  80328. /**
  80329. * Checks if the ray intersects a box
  80330. * @param minimum bound of the box
  80331. * @param maximum bound of the box
  80332. * @param intersectionTreshold extra extend to be added to the box in all direction
  80333. * @returns if the box was hit
  80334. */
  80335. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  80336. /**
  80337. * Checks if the ray intersects a box
  80338. * @param box the bounding box to check
  80339. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  80340. * @returns if the box was hit
  80341. */
  80342. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  80343. /**
  80344. * If the ray hits a sphere
  80345. * @param sphere the bounding sphere to check
  80346. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  80347. * @returns true if it hits the sphere
  80348. */
  80349. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  80350. /**
  80351. * If the ray hits a triange
  80352. * @param vertex0 triangle vertex
  80353. * @param vertex1 triangle vertex
  80354. * @param vertex2 triangle vertex
  80355. * @returns intersection information if hit
  80356. */
  80357. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  80358. /**
  80359. * Checks if ray intersects a plane
  80360. * @param plane the plane to check
  80361. * @returns the distance away it was hit
  80362. */
  80363. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  80364. /**
  80365. * Calculate the intercept of a ray on a given axis
  80366. * @param axis to check 'x' | 'y' | 'z'
  80367. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  80368. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  80369. */
  80370. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  80371. /**
  80372. * Checks if ray intersects a mesh
  80373. * @param mesh the mesh to check
  80374. * @param fastCheck if only the bounding box should checked
  80375. * @returns picking info of the intersecton
  80376. */
  80377. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  80378. /**
  80379. * Checks if ray intersects a mesh
  80380. * @param meshes the meshes to check
  80381. * @param fastCheck if only the bounding box should checked
  80382. * @param results array to store result in
  80383. * @returns Array of picking infos
  80384. */
  80385. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  80386. private _comparePickingInfo;
  80387. private static smallnum;
  80388. private static rayl;
  80389. /**
  80390. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  80391. * @param sega the first point of the segment to test the intersection against
  80392. * @param segb the second point of the segment to test the intersection against
  80393. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  80394. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  80395. */
  80396. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  80397. /**
  80398. * Update the ray from viewport position
  80399. * @param x position
  80400. * @param y y position
  80401. * @param viewportWidth viewport width
  80402. * @param viewportHeight viewport height
  80403. * @param world world matrix
  80404. * @param view view matrix
  80405. * @param projection projection matrix
  80406. * @returns this ray updated
  80407. */
  80408. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  80409. /**
  80410. * Creates a ray with origin and direction of 0,0,0
  80411. * @returns the new ray
  80412. */
  80413. static Zero(): Ray;
  80414. /**
  80415. * Creates a new ray from screen space and viewport
  80416. * @param x position
  80417. * @param y y position
  80418. * @param viewportWidth viewport width
  80419. * @param viewportHeight viewport height
  80420. * @param world world matrix
  80421. * @param view view matrix
  80422. * @param projection projection matrix
  80423. * @returns new ray
  80424. */
  80425. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  80426. /**
  80427. * 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
  80428. * transformed to the given world matrix.
  80429. * @param origin The origin point
  80430. * @param end The end point
  80431. * @param world a matrix to transform the ray to. Default is the identity matrix.
  80432. * @returns the new ray
  80433. */
  80434. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  80435. /**
  80436. * Transforms a ray by a matrix
  80437. * @param ray ray to transform
  80438. * @param matrix matrix to apply
  80439. * @returns the resulting new ray
  80440. */
  80441. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  80442. /**
  80443. * Transforms a ray by a matrix
  80444. * @param ray ray to transform
  80445. * @param matrix matrix to apply
  80446. * @param result ray to store result in
  80447. */
  80448. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  80449. /**
  80450. * Unproject a ray from screen space to object space
  80451. * @param sourceX defines the screen space x coordinate to use
  80452. * @param sourceY defines the screen space y coordinate to use
  80453. * @param viewportWidth defines the current width of the viewport
  80454. * @param viewportHeight defines the current height of the viewport
  80455. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  80456. * @param view defines the view matrix to use
  80457. * @param projection defines the projection matrix to use
  80458. */
  80459. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  80460. }
  80461. /**
  80462. * Type used to define predicate used to select faces when a mesh intersection is detected
  80463. */
  80464. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  80465. interface Scene {
  80466. /** @hidden */
  80467. _tempPickingRay: Nullable<Ray>;
  80468. /** @hidden */
  80469. _cachedRayForTransform: Ray;
  80470. /** @hidden */
  80471. _pickWithRayInverseMatrix: Matrix;
  80472. /** @hidden */
  80473. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  80474. /** @hidden */
  80475. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  80476. }
  80477. }
  80478. declare module BABYLON {
  80479. /**
  80480. * Groups all the scene component constants in one place to ease maintenance.
  80481. * @hidden
  80482. */
  80483. export class SceneComponentConstants {
  80484. static readonly NAME_EFFECTLAYER: string;
  80485. static readonly NAME_LAYER: string;
  80486. static readonly NAME_LENSFLARESYSTEM: string;
  80487. static readonly NAME_BOUNDINGBOXRENDERER: string;
  80488. static readonly NAME_PARTICLESYSTEM: string;
  80489. static readonly NAME_GAMEPAD: string;
  80490. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  80491. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  80492. static readonly NAME_DEPTHRENDERER: string;
  80493. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  80494. static readonly NAME_SPRITE: string;
  80495. static readonly NAME_OUTLINERENDERER: string;
  80496. static readonly NAME_PROCEDURALTEXTURE: string;
  80497. static readonly NAME_SHADOWGENERATOR: string;
  80498. static readonly NAME_OCTREE: string;
  80499. static readonly NAME_PHYSICSENGINE: string;
  80500. static readonly NAME_AUDIO: string;
  80501. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  80502. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  80503. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  80504. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  80505. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  80506. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  80507. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  80508. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  80509. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  80510. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  80511. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  80512. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  80513. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  80514. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  80515. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  80516. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  80517. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  80518. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  80519. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  80520. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  80521. static readonly STEP_AFTERRENDER_AUDIO: number;
  80522. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  80523. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  80524. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  80525. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  80526. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  80527. static readonly STEP_POINTERMOVE_SPRITE: number;
  80528. static readonly STEP_POINTERDOWN_SPRITE: number;
  80529. static readonly STEP_POINTERUP_SPRITE: number;
  80530. }
  80531. /**
  80532. * This represents a scene component.
  80533. *
  80534. * This is used to decouple the dependency the scene is having on the different workloads like
  80535. * layers, post processes...
  80536. */
  80537. export interface ISceneComponent {
  80538. /**
  80539. * The name of the component. Each component must have a unique name.
  80540. */
  80541. name: string;
  80542. /**
  80543. * The scene the component belongs to.
  80544. */
  80545. scene: Scene;
  80546. /**
  80547. * Register the component to one instance of a scene.
  80548. */
  80549. register(): void;
  80550. /**
  80551. * Rebuilds the elements related to this component in case of
  80552. * context lost for instance.
  80553. */
  80554. rebuild(): void;
  80555. /**
  80556. * Disposes the component and the associated ressources.
  80557. */
  80558. dispose(): void;
  80559. }
  80560. /**
  80561. * This represents a SERIALIZABLE scene component.
  80562. *
  80563. * This extends Scene Component to add Serialization methods on top.
  80564. */
  80565. export interface ISceneSerializableComponent extends ISceneComponent {
  80566. /**
  80567. * Adds all the elements from the container to the scene
  80568. * @param container the container holding the elements
  80569. */
  80570. addFromContainer(container: AbstractScene): void;
  80571. /**
  80572. * Removes all the elements in the container from the scene
  80573. * @param container contains the elements to remove
  80574. * @param dispose if the removed element should be disposed (default: false)
  80575. */
  80576. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  80577. /**
  80578. * Serializes the component data to the specified json object
  80579. * @param serializationObject The object to serialize to
  80580. */
  80581. serialize(serializationObject: any): void;
  80582. }
  80583. /**
  80584. * Strong typing of a Mesh related stage step action
  80585. */
  80586. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  80587. /**
  80588. * Strong typing of a Evaluate Sub Mesh related stage step action
  80589. */
  80590. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  80591. /**
  80592. * Strong typing of a Active Mesh related stage step action
  80593. */
  80594. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  80595. /**
  80596. * Strong typing of a Camera related stage step action
  80597. */
  80598. export type CameraStageAction = (camera: Camera) => void;
  80599. /**
  80600. * Strong typing of a Camera Frame buffer related stage step action
  80601. */
  80602. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  80603. /**
  80604. * Strong typing of a Render Target related stage step action
  80605. */
  80606. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  80607. /**
  80608. * Strong typing of a RenderingGroup related stage step action
  80609. */
  80610. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  80611. /**
  80612. * Strong typing of a Mesh Render related stage step action
  80613. */
  80614. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  80615. /**
  80616. * Strong typing of a simple stage step action
  80617. */
  80618. export type SimpleStageAction = () => void;
  80619. /**
  80620. * Strong typing of a render target action.
  80621. */
  80622. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  80623. /**
  80624. * Strong typing of a pointer move action.
  80625. */
  80626. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  80627. /**
  80628. * Strong typing of a pointer up/down action.
  80629. */
  80630. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  80631. /**
  80632. * Representation of a stage in the scene (Basically a list of ordered steps)
  80633. * @hidden
  80634. */
  80635. export class Stage<T extends Function> extends Array<{
  80636. index: number;
  80637. component: ISceneComponent;
  80638. action: T;
  80639. }> {
  80640. /**
  80641. * Hide ctor from the rest of the world.
  80642. * @param items The items to add.
  80643. */
  80644. private constructor();
  80645. /**
  80646. * Creates a new Stage.
  80647. * @returns A new instance of a Stage
  80648. */
  80649. static Create<T extends Function>(): Stage<T>;
  80650. /**
  80651. * Registers a step in an ordered way in the targeted stage.
  80652. * @param index Defines the position to register the step in
  80653. * @param component Defines the component attached to the step
  80654. * @param action Defines the action to launch during the step
  80655. */
  80656. registerStep(index: number, component: ISceneComponent, action: T): void;
  80657. /**
  80658. * Clears all the steps from the stage.
  80659. */
  80660. clear(): void;
  80661. }
  80662. }
  80663. declare module BABYLON {
  80664. interface Scene {
  80665. /** @hidden */
  80666. _pointerOverSprite: Nullable<Sprite>;
  80667. /** @hidden */
  80668. _pickedDownSprite: Nullable<Sprite>;
  80669. /** @hidden */
  80670. _tempSpritePickingRay: Nullable<Ray>;
  80671. /**
  80672. * All of the sprite managers added to this scene
  80673. * @see http://doc.babylonjs.com/babylon101/sprites
  80674. */
  80675. spriteManagers: Array<ISpriteManager>;
  80676. /**
  80677. * An event triggered when sprites rendering is about to start
  80678. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  80679. */
  80680. onBeforeSpritesRenderingObservable: Observable<Scene>;
  80681. /**
  80682. * An event triggered when sprites rendering is done
  80683. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  80684. */
  80685. onAfterSpritesRenderingObservable: Observable<Scene>;
  80686. /** @hidden */
  80687. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  80688. /** Launch a ray to try to pick a sprite in the scene
  80689. * @param x position on screen
  80690. * @param y position on screen
  80691. * @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
  80692. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  80693. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  80694. * @returns a PickingInfo
  80695. */
  80696. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  80697. /** Use the given ray to pick a sprite in the scene
  80698. * @param ray The ray (in world space) to use to pick meshes
  80699. * @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
  80700. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  80701. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  80702. * @returns a PickingInfo
  80703. */
  80704. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  80705. /** @hidden */
  80706. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  80707. /** Launch a ray to try to pick sprites in the scene
  80708. * @param x position on screen
  80709. * @param y position on screen
  80710. * @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
  80711. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  80712. * @returns a PickingInfo array
  80713. */
  80714. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  80715. /** Use the given ray to pick sprites in the scene
  80716. * @param ray The ray (in world space) to use to pick meshes
  80717. * @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
  80718. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  80719. * @returns a PickingInfo array
  80720. */
  80721. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  80722. /**
  80723. * Force the sprite under the pointer
  80724. * @param sprite defines the sprite to use
  80725. */
  80726. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  80727. /**
  80728. * Gets the sprite under the pointer
  80729. * @returns a Sprite or null if no sprite is under the pointer
  80730. */
  80731. getPointerOverSprite(): Nullable<Sprite>;
  80732. }
  80733. /**
  80734. * Defines the sprite scene component responsible to manage sprites
  80735. * in a given scene.
  80736. */
  80737. export class SpriteSceneComponent implements ISceneComponent {
  80738. /**
  80739. * The component name helpfull to identify the component in the list of scene components.
  80740. */
  80741. readonly name: string;
  80742. /**
  80743. * The scene the component belongs to.
  80744. */
  80745. scene: Scene;
  80746. /** @hidden */
  80747. private _spritePredicate;
  80748. /**
  80749. * Creates a new instance of the component for the given scene
  80750. * @param scene Defines the scene to register the component in
  80751. */
  80752. constructor(scene: Scene);
  80753. /**
  80754. * Registers the component in a given scene
  80755. */
  80756. register(): void;
  80757. /**
  80758. * Rebuilds the elements related to this component in case of
  80759. * context lost for instance.
  80760. */
  80761. rebuild(): void;
  80762. /**
  80763. * Disposes the component and the associated ressources.
  80764. */
  80765. dispose(): void;
  80766. private _pickSpriteButKeepRay;
  80767. private _pointerMove;
  80768. private _pointerDown;
  80769. private _pointerUp;
  80770. }
  80771. }
  80772. declare module BABYLON {
  80773. /** @hidden */
  80774. export var fogFragmentDeclaration: {
  80775. name: string;
  80776. shader: string;
  80777. };
  80778. }
  80779. declare module BABYLON {
  80780. /** @hidden */
  80781. export var fogFragment: {
  80782. name: string;
  80783. shader: string;
  80784. };
  80785. }
  80786. declare module BABYLON {
  80787. /** @hidden */
  80788. export var spritesPixelShader: {
  80789. name: string;
  80790. shader: string;
  80791. };
  80792. }
  80793. declare module BABYLON {
  80794. /** @hidden */
  80795. export var fogVertexDeclaration: {
  80796. name: string;
  80797. shader: string;
  80798. };
  80799. }
  80800. declare module BABYLON {
  80801. /** @hidden */
  80802. export var spritesVertexShader: {
  80803. name: string;
  80804. shader: string;
  80805. };
  80806. }
  80807. declare module BABYLON {
  80808. /**
  80809. * Defines the minimum interface to fullfil in order to be a sprite manager.
  80810. */
  80811. export interface ISpriteManager extends IDisposable {
  80812. /**
  80813. * Restricts the camera to viewing objects with the same layerMask.
  80814. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  80815. */
  80816. layerMask: number;
  80817. /**
  80818. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  80819. */
  80820. isPickable: boolean;
  80821. /**
  80822. * Specifies the rendering group id for this mesh (0 by default)
  80823. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  80824. */
  80825. renderingGroupId: number;
  80826. /**
  80827. * Defines the list of sprites managed by the manager.
  80828. */
  80829. sprites: Array<Sprite>;
  80830. /**
  80831. * Tests the intersection of a sprite with a specific ray.
  80832. * @param ray The ray we are sending to test the collision
  80833. * @param camera The camera space we are sending rays in
  80834. * @param predicate A predicate allowing excluding sprites from the list of object to test
  80835. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  80836. * @returns picking info or null.
  80837. */
  80838. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  80839. /**
  80840. * Intersects the sprites with a ray
  80841. * @param ray defines the ray to intersect with
  80842. * @param camera defines the current active camera
  80843. * @param predicate defines a predicate used to select candidate sprites
  80844. * @returns null if no hit or a PickingInfo array
  80845. */
  80846. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  80847. /**
  80848. * Renders the list of sprites on screen.
  80849. */
  80850. render(): void;
  80851. }
  80852. /**
  80853. * Class used to manage multiple sprites on the same spritesheet
  80854. * @see http://doc.babylonjs.com/babylon101/sprites
  80855. */
  80856. export class SpriteManager implements ISpriteManager {
  80857. /** defines the manager's name */
  80858. name: string;
  80859. /** Gets the list of sprites */
  80860. sprites: Sprite[];
  80861. /** Gets or sets the rendering group id (0 by default) */
  80862. renderingGroupId: number;
  80863. /** Gets or sets camera layer mask */
  80864. layerMask: number;
  80865. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  80866. fogEnabled: boolean;
  80867. /** Gets or sets a boolean indicating if the sprites are pickable */
  80868. isPickable: boolean;
  80869. /** Defines the default width of a cell in the spritesheet */
  80870. cellWidth: number;
  80871. /** Defines the default height of a cell in the spritesheet */
  80872. cellHeight: number;
  80873. /** Associative array from JSON sprite data file */
  80874. private _cellData;
  80875. /** Array of sprite names from JSON sprite data file */
  80876. private _spriteMap;
  80877. /** True when packed cell data from JSON file is ready*/
  80878. private _packedAndReady;
  80879. /**
  80880. * An event triggered when the manager is disposed.
  80881. */
  80882. onDisposeObservable: Observable<SpriteManager>;
  80883. private _onDisposeObserver;
  80884. /**
  80885. * Callback called when the manager is disposed
  80886. */
  80887. onDispose: () => void;
  80888. private _capacity;
  80889. private _fromPacked;
  80890. private _spriteTexture;
  80891. private _epsilon;
  80892. private _scene;
  80893. private _vertexData;
  80894. private _buffer;
  80895. private _vertexBuffers;
  80896. private _indexBuffer;
  80897. private _effectBase;
  80898. private _effectFog;
  80899. /**
  80900. * Gets or sets the spritesheet texture
  80901. */
  80902. texture: Texture;
  80903. /**
  80904. * Creates a new sprite manager
  80905. * @param name defines the manager's name
  80906. * @param imgUrl defines the sprite sheet url
  80907. * @param capacity defines the maximum allowed number of sprites
  80908. * @param cellSize defines the size of a sprite cell
  80909. * @param scene defines the hosting scene
  80910. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  80911. * @param samplingMode defines the smapling mode to use with spritesheet
  80912. * @param fromPacked set to false; do not alter
  80913. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  80914. */
  80915. constructor(
  80916. /** defines the manager's name */
  80917. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  80918. private _makePacked;
  80919. private _appendSpriteVertex;
  80920. /**
  80921. * Intersects the sprites with a ray
  80922. * @param ray defines the ray to intersect with
  80923. * @param camera defines the current active camera
  80924. * @param predicate defines a predicate used to select candidate sprites
  80925. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  80926. * @returns null if no hit or a PickingInfo
  80927. */
  80928. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  80929. /**
  80930. * Intersects the sprites with a ray
  80931. * @param ray defines the ray to intersect with
  80932. * @param camera defines the current active camera
  80933. * @param predicate defines a predicate used to select candidate sprites
  80934. * @returns null if no hit or a PickingInfo array
  80935. */
  80936. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  80937. /**
  80938. * Render all child sprites
  80939. */
  80940. render(): void;
  80941. /**
  80942. * Release associated resources
  80943. */
  80944. dispose(): void;
  80945. }
  80946. }
  80947. declare module BABYLON {
  80948. /**
  80949. * Class used to represent a sprite
  80950. * @see http://doc.babylonjs.com/babylon101/sprites
  80951. */
  80952. export class Sprite {
  80953. /** defines the name */
  80954. name: string;
  80955. /** Gets or sets the current world position */
  80956. position: Vector3;
  80957. /** Gets or sets the main color */
  80958. color: Color4;
  80959. /** Gets or sets the width */
  80960. width: number;
  80961. /** Gets or sets the height */
  80962. height: number;
  80963. /** Gets or sets rotation angle */
  80964. angle: number;
  80965. /** Gets or sets the cell index in the sprite sheet */
  80966. cellIndex: number;
  80967. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  80968. cellRef: string;
  80969. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  80970. invertU: number;
  80971. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  80972. invertV: number;
  80973. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  80974. disposeWhenFinishedAnimating: boolean;
  80975. /** Gets the list of attached animations */
  80976. animations: Animation[];
  80977. /** Gets or sets a boolean indicating if the sprite can be picked */
  80978. isPickable: boolean;
  80979. /**
  80980. * Gets or sets the associated action manager
  80981. */
  80982. actionManager: Nullable<ActionManager>;
  80983. private _animationStarted;
  80984. private _loopAnimation;
  80985. private _fromIndex;
  80986. private _toIndex;
  80987. private _delay;
  80988. private _direction;
  80989. private _manager;
  80990. private _time;
  80991. private _onAnimationEnd;
  80992. /**
  80993. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  80994. */
  80995. isVisible: boolean;
  80996. /**
  80997. * Gets or sets the sprite size
  80998. */
  80999. size: number;
  81000. /**
  81001. * Creates a new Sprite
  81002. * @param name defines the name
  81003. * @param manager defines the manager
  81004. */
  81005. constructor(
  81006. /** defines the name */
  81007. name: string, manager: ISpriteManager);
  81008. /**
  81009. * Starts an animation
  81010. * @param from defines the initial key
  81011. * @param to defines the end key
  81012. * @param loop defines if the animation must loop
  81013. * @param delay defines the start delay (in ms)
  81014. * @param onAnimationEnd defines a callback to call when animation ends
  81015. */
  81016. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  81017. /** Stops current animation (if any) */
  81018. stopAnimation(): void;
  81019. /** @hidden */
  81020. _animate(deltaTime: number): void;
  81021. /** Release associated resources */
  81022. dispose(): void;
  81023. }
  81024. }
  81025. declare module BABYLON {
  81026. /**
  81027. * Information about the result of picking within a scene
  81028. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  81029. */
  81030. export class PickingInfo {
  81031. /** @hidden */
  81032. _pickingUnavailable: boolean;
  81033. /**
  81034. * If the pick collided with an object
  81035. */
  81036. hit: boolean;
  81037. /**
  81038. * Distance away where the pick collided
  81039. */
  81040. distance: number;
  81041. /**
  81042. * The location of pick collision
  81043. */
  81044. pickedPoint: Nullable<Vector3>;
  81045. /**
  81046. * The mesh corresponding the the pick collision
  81047. */
  81048. pickedMesh: Nullable<AbstractMesh>;
  81049. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  81050. bu: number;
  81051. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  81052. bv: number;
  81053. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  81054. faceId: number;
  81055. /** Id of the the submesh that was picked */
  81056. subMeshId: number;
  81057. /** If a sprite was picked, this will be the sprite the pick collided with */
  81058. pickedSprite: Nullable<Sprite>;
  81059. /**
  81060. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  81061. */
  81062. originMesh: Nullable<AbstractMesh>;
  81063. /**
  81064. * The ray that was used to perform the picking.
  81065. */
  81066. ray: Nullable<Ray>;
  81067. /**
  81068. * Gets the normal correspodning to the face the pick collided with
  81069. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  81070. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  81071. * @returns The normal correspodning to the face the pick collided with
  81072. */
  81073. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  81074. /**
  81075. * Gets the texture coordinates of where the pick occured
  81076. * @returns the vector containing the coordnates of the texture
  81077. */
  81078. getTextureCoordinates(): Nullable<Vector2>;
  81079. }
  81080. }
  81081. declare module BABYLON {
  81082. /**
  81083. * Gather the list of pointer event types as constants.
  81084. */
  81085. export class PointerEventTypes {
  81086. /**
  81087. * 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.
  81088. */
  81089. static readonly POINTERDOWN: number;
  81090. /**
  81091. * The pointerup event is fired when a pointer is no longer active.
  81092. */
  81093. static readonly POINTERUP: number;
  81094. /**
  81095. * The pointermove event is fired when a pointer changes coordinates.
  81096. */
  81097. static readonly POINTERMOVE: number;
  81098. /**
  81099. * The pointerwheel event is fired when a mouse wheel has been rotated.
  81100. */
  81101. static readonly POINTERWHEEL: number;
  81102. /**
  81103. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  81104. */
  81105. static readonly POINTERPICK: number;
  81106. /**
  81107. * The pointertap event is fired when a the object has been touched and released without drag.
  81108. */
  81109. static readonly POINTERTAP: number;
  81110. /**
  81111. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  81112. */
  81113. static readonly POINTERDOUBLETAP: number;
  81114. }
  81115. /**
  81116. * Base class of pointer info types.
  81117. */
  81118. export class PointerInfoBase {
  81119. /**
  81120. * Defines the type of event (PointerEventTypes)
  81121. */
  81122. type: number;
  81123. /**
  81124. * Defines the related dom event
  81125. */
  81126. event: PointerEvent | MouseWheelEvent;
  81127. /**
  81128. * Instantiates the base class of pointers info.
  81129. * @param type Defines the type of event (PointerEventTypes)
  81130. * @param event Defines the related dom event
  81131. */
  81132. constructor(
  81133. /**
  81134. * Defines the type of event (PointerEventTypes)
  81135. */
  81136. type: number,
  81137. /**
  81138. * Defines the related dom event
  81139. */
  81140. event: PointerEvent | MouseWheelEvent);
  81141. }
  81142. /**
  81143. * This class is used to store pointer related info for the onPrePointerObservable event.
  81144. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  81145. */
  81146. export class PointerInfoPre extends PointerInfoBase {
  81147. /**
  81148. * Ray from a pointer if availible (eg. 6dof controller)
  81149. */
  81150. ray: Nullable<Ray>;
  81151. /**
  81152. * Defines the local position of the pointer on the canvas.
  81153. */
  81154. localPosition: Vector2;
  81155. /**
  81156. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  81157. */
  81158. skipOnPointerObservable: boolean;
  81159. /**
  81160. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  81161. * @param type Defines the type of event (PointerEventTypes)
  81162. * @param event Defines the related dom event
  81163. * @param localX Defines the local x coordinates of the pointer when the event occured
  81164. * @param localY Defines the local y coordinates of the pointer when the event occured
  81165. */
  81166. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  81167. }
  81168. /**
  81169. * This type contains all the data related to a pointer event in Babylon.js.
  81170. * 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.
  81171. */
  81172. export class PointerInfo extends PointerInfoBase {
  81173. /**
  81174. * Defines the picking info associated to the info (if any)\
  81175. */
  81176. pickInfo: Nullable<PickingInfo>;
  81177. /**
  81178. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  81179. * @param type Defines the type of event (PointerEventTypes)
  81180. * @param event Defines the related dom event
  81181. * @param pickInfo Defines the picking info associated to the info (if any)\
  81182. */
  81183. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  81184. /**
  81185. * Defines the picking info associated to the info (if any)\
  81186. */
  81187. pickInfo: Nullable<PickingInfo>);
  81188. }
  81189. /**
  81190. * Data relating to a touch event on the screen.
  81191. */
  81192. export interface PointerTouch {
  81193. /**
  81194. * X coordinate of touch.
  81195. */
  81196. x: number;
  81197. /**
  81198. * Y coordinate of touch.
  81199. */
  81200. y: number;
  81201. /**
  81202. * Id of touch. Unique for each finger.
  81203. */
  81204. pointerId: number;
  81205. /**
  81206. * Event type passed from DOM.
  81207. */
  81208. type: any;
  81209. }
  81210. }
  81211. declare module BABYLON {
  81212. /**
  81213. * Manage the mouse inputs to control the movement of a free camera.
  81214. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  81215. */
  81216. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  81217. /**
  81218. * Define if touch is enabled in the mouse input
  81219. */
  81220. touchEnabled: boolean;
  81221. /**
  81222. * Defines the camera the input is attached to.
  81223. */
  81224. camera: FreeCamera;
  81225. /**
  81226. * Defines the buttons associated with the input to handle camera move.
  81227. */
  81228. buttons: number[];
  81229. /**
  81230. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  81231. */
  81232. angularSensibility: number;
  81233. private _pointerInput;
  81234. private _onMouseMove;
  81235. private _observer;
  81236. private previousPosition;
  81237. /**
  81238. * Observable for when a pointer move event occurs containing the move offset
  81239. */
  81240. onPointerMovedObservable: Observable<{
  81241. offsetX: number;
  81242. offsetY: number;
  81243. }>;
  81244. /**
  81245. * @hidden
  81246. * If the camera should be rotated automatically based on pointer movement
  81247. */
  81248. _allowCameraRotation: boolean;
  81249. /**
  81250. * Manage the mouse inputs to control the movement of a free camera.
  81251. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  81252. * @param touchEnabled Defines if touch is enabled or not
  81253. */
  81254. constructor(
  81255. /**
  81256. * Define if touch is enabled in the mouse input
  81257. */
  81258. touchEnabled?: boolean);
  81259. /**
  81260. * Attach the input controls to a specific dom element to get the input from.
  81261. * @param element Defines the element the controls should be listened from
  81262. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  81263. */
  81264. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  81265. /**
  81266. * Called on JS contextmenu event.
  81267. * Override this method to provide functionality.
  81268. */
  81269. protected onContextMenu(evt: PointerEvent): void;
  81270. /**
  81271. * Detach the current controls from the specified dom element.
  81272. * @param element Defines the element to stop listening the inputs from
  81273. */
  81274. detachControl(element: Nullable<HTMLElement>): void;
  81275. /**
  81276. * Gets the class name of the current intput.
  81277. * @returns the class name
  81278. */
  81279. getClassName(): string;
  81280. /**
  81281. * Get the friendly name associated with the input class.
  81282. * @returns the input friendly name
  81283. */
  81284. getSimpleName(): string;
  81285. }
  81286. }
  81287. declare module BABYLON {
  81288. /**
  81289. * Manage the touch inputs to control the movement of a free camera.
  81290. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  81291. */
  81292. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  81293. /**
  81294. * Defines the camera the input is attached to.
  81295. */
  81296. camera: FreeCamera;
  81297. /**
  81298. * Defines the touch sensibility for rotation.
  81299. * The higher the faster.
  81300. */
  81301. touchAngularSensibility: number;
  81302. /**
  81303. * Defines the touch sensibility for move.
  81304. * The higher the faster.
  81305. */
  81306. touchMoveSensibility: number;
  81307. private _offsetX;
  81308. private _offsetY;
  81309. private _pointerPressed;
  81310. private _pointerInput;
  81311. private _observer;
  81312. private _onLostFocus;
  81313. /**
  81314. * Attach the input controls to a specific dom element to get the input from.
  81315. * @param element Defines the element the controls should be listened from
  81316. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  81317. */
  81318. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  81319. /**
  81320. * Detach the current controls from the specified dom element.
  81321. * @param element Defines the element to stop listening the inputs from
  81322. */
  81323. detachControl(element: Nullable<HTMLElement>): void;
  81324. /**
  81325. * Update the current camera state depending on the inputs that have been used this frame.
  81326. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  81327. */
  81328. checkInputs(): void;
  81329. /**
  81330. * Gets the class name of the current intput.
  81331. * @returns the class name
  81332. */
  81333. getClassName(): string;
  81334. /**
  81335. * Get the friendly name associated with the input class.
  81336. * @returns the input friendly name
  81337. */
  81338. getSimpleName(): string;
  81339. }
  81340. }
  81341. declare module BABYLON {
  81342. /**
  81343. * Default Inputs manager for the FreeCamera.
  81344. * It groups all the default supported inputs for ease of use.
  81345. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  81346. */
  81347. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  81348. /**
  81349. * @hidden
  81350. */
  81351. _mouseInput: Nullable<FreeCameraMouseInput>;
  81352. /**
  81353. * Instantiates a new FreeCameraInputsManager.
  81354. * @param camera Defines the camera the inputs belong to
  81355. */
  81356. constructor(camera: FreeCamera);
  81357. /**
  81358. * Add keyboard input support to the input manager.
  81359. * @returns the current input manager
  81360. */
  81361. addKeyboard(): FreeCameraInputsManager;
  81362. /**
  81363. * Add mouse input support to the input manager.
  81364. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  81365. * @returns the current input manager
  81366. */
  81367. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  81368. /**
  81369. * Removes the mouse input support from the manager
  81370. * @returns the current input manager
  81371. */
  81372. removeMouse(): FreeCameraInputsManager;
  81373. /**
  81374. * Add touch input support to the input manager.
  81375. * @returns the current input manager
  81376. */
  81377. addTouch(): FreeCameraInputsManager;
  81378. /**
  81379. * Remove all attached input methods from a camera
  81380. */
  81381. clear(): void;
  81382. }
  81383. }
  81384. declare module BABYLON {
  81385. /**
  81386. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  81387. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  81388. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  81389. */
  81390. export class FreeCamera extends TargetCamera {
  81391. /**
  81392. * Define the collision ellipsoid of the camera.
  81393. * This is helpful to simulate a camera body like the player body around the camera
  81394. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  81395. */
  81396. ellipsoid: Vector3;
  81397. /**
  81398. * Define an offset for the position of the ellipsoid around the camera.
  81399. * This can be helpful to determine the center of the body near the gravity center of the body
  81400. * instead of its head.
  81401. */
  81402. ellipsoidOffset: Vector3;
  81403. /**
  81404. * Enable or disable collisions of the camera with the rest of the scene objects.
  81405. */
  81406. checkCollisions: boolean;
  81407. /**
  81408. * Enable or disable gravity on the camera.
  81409. */
  81410. applyGravity: boolean;
  81411. /**
  81412. * Define the input manager associated to the camera.
  81413. */
  81414. inputs: FreeCameraInputsManager;
  81415. /**
  81416. * Gets the input sensibility for a mouse input. (default is 2000.0)
  81417. * Higher values reduce sensitivity.
  81418. */
  81419. /**
  81420. * Sets the input sensibility for a mouse input. (default is 2000.0)
  81421. * Higher values reduce sensitivity.
  81422. */
  81423. angularSensibility: number;
  81424. /**
  81425. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  81426. */
  81427. keysUp: number[];
  81428. /**
  81429. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  81430. */
  81431. keysDown: number[];
  81432. /**
  81433. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  81434. */
  81435. keysLeft: number[];
  81436. /**
  81437. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  81438. */
  81439. keysRight: number[];
  81440. /**
  81441. * Event raised when the camera collide with a mesh in the scene.
  81442. */
  81443. onCollide: (collidedMesh: AbstractMesh) => void;
  81444. private _collider;
  81445. private _needMoveForGravity;
  81446. private _oldPosition;
  81447. private _diffPosition;
  81448. private _newPosition;
  81449. /** @hidden */
  81450. _localDirection: Vector3;
  81451. /** @hidden */
  81452. _transformedDirection: Vector3;
  81453. /**
  81454. * Instantiates a Free Camera.
  81455. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  81456. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  81457. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  81458. * @param name Define the name of the camera in the scene
  81459. * @param position Define the start position of the camera in the scene
  81460. * @param scene Define the scene the camera belongs to
  81461. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  81462. */
  81463. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  81464. /**
  81465. * Attached controls to the current camera.
  81466. * @param element Defines the element the controls should be listened from
  81467. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  81468. */
  81469. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  81470. /**
  81471. * Detach the current controls from the camera.
  81472. * The camera will stop reacting to inputs.
  81473. * @param element Defines the element to stop listening the inputs from
  81474. */
  81475. detachControl(element: HTMLElement): void;
  81476. private _collisionMask;
  81477. /**
  81478. * Define a collision mask to limit the list of object the camera can collide with
  81479. */
  81480. collisionMask: number;
  81481. /** @hidden */
  81482. _collideWithWorld(displacement: Vector3): void;
  81483. private _onCollisionPositionChange;
  81484. /** @hidden */
  81485. _checkInputs(): void;
  81486. /** @hidden */
  81487. _decideIfNeedsToMove(): boolean;
  81488. /** @hidden */
  81489. _updatePosition(): void;
  81490. /**
  81491. * Destroy the camera and release the current resources hold by it.
  81492. */
  81493. dispose(): void;
  81494. /**
  81495. * Gets the current object class name.
  81496. * @return the class name
  81497. */
  81498. getClassName(): string;
  81499. }
  81500. }
  81501. declare module BABYLON {
  81502. /**
  81503. * Represents a gamepad control stick position
  81504. */
  81505. export class StickValues {
  81506. /**
  81507. * The x component of the control stick
  81508. */
  81509. x: number;
  81510. /**
  81511. * The y component of the control stick
  81512. */
  81513. y: number;
  81514. /**
  81515. * Initializes the gamepad x and y control stick values
  81516. * @param x The x component of the gamepad control stick value
  81517. * @param y The y component of the gamepad control stick value
  81518. */
  81519. constructor(
  81520. /**
  81521. * The x component of the control stick
  81522. */
  81523. x: number,
  81524. /**
  81525. * The y component of the control stick
  81526. */
  81527. y: number);
  81528. }
  81529. /**
  81530. * An interface which manages callbacks for gamepad button changes
  81531. */
  81532. export interface GamepadButtonChanges {
  81533. /**
  81534. * Called when a gamepad has been changed
  81535. */
  81536. changed: boolean;
  81537. /**
  81538. * Called when a gamepad press event has been triggered
  81539. */
  81540. pressChanged: boolean;
  81541. /**
  81542. * Called when a touch event has been triggered
  81543. */
  81544. touchChanged: boolean;
  81545. /**
  81546. * Called when a value has changed
  81547. */
  81548. valueChanged: boolean;
  81549. }
  81550. /**
  81551. * Represents a gamepad
  81552. */
  81553. export class Gamepad {
  81554. /**
  81555. * The id of the gamepad
  81556. */
  81557. id: string;
  81558. /**
  81559. * The index of the gamepad
  81560. */
  81561. index: number;
  81562. /**
  81563. * The browser gamepad
  81564. */
  81565. browserGamepad: any;
  81566. /**
  81567. * Specifies what type of gamepad this represents
  81568. */
  81569. type: number;
  81570. private _leftStick;
  81571. private _rightStick;
  81572. /** @hidden */
  81573. _isConnected: boolean;
  81574. private _leftStickAxisX;
  81575. private _leftStickAxisY;
  81576. private _rightStickAxisX;
  81577. private _rightStickAxisY;
  81578. /**
  81579. * Triggered when the left control stick has been changed
  81580. */
  81581. private _onleftstickchanged;
  81582. /**
  81583. * Triggered when the right control stick has been changed
  81584. */
  81585. private _onrightstickchanged;
  81586. /**
  81587. * Represents a gamepad controller
  81588. */
  81589. static GAMEPAD: number;
  81590. /**
  81591. * Represents a generic controller
  81592. */
  81593. static GENERIC: number;
  81594. /**
  81595. * Represents an XBox controller
  81596. */
  81597. static XBOX: number;
  81598. /**
  81599. * Represents a pose-enabled controller
  81600. */
  81601. static POSE_ENABLED: number;
  81602. /**
  81603. * Represents an Dual Shock controller
  81604. */
  81605. static DUALSHOCK: number;
  81606. /**
  81607. * Specifies whether the left control stick should be Y-inverted
  81608. */
  81609. protected _invertLeftStickY: boolean;
  81610. /**
  81611. * Specifies if the gamepad has been connected
  81612. */
  81613. readonly isConnected: boolean;
  81614. /**
  81615. * Initializes the gamepad
  81616. * @param id The id of the gamepad
  81617. * @param index The index of the gamepad
  81618. * @param browserGamepad The browser gamepad
  81619. * @param leftStickX The x component of the left joystick
  81620. * @param leftStickY The y component of the left joystick
  81621. * @param rightStickX The x component of the right joystick
  81622. * @param rightStickY The y component of the right joystick
  81623. */
  81624. constructor(
  81625. /**
  81626. * The id of the gamepad
  81627. */
  81628. id: string,
  81629. /**
  81630. * The index of the gamepad
  81631. */
  81632. index: number,
  81633. /**
  81634. * The browser gamepad
  81635. */
  81636. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  81637. /**
  81638. * Callback triggered when the left joystick has changed
  81639. * @param callback
  81640. */
  81641. onleftstickchanged(callback: (values: StickValues) => void): void;
  81642. /**
  81643. * Callback triggered when the right joystick has changed
  81644. * @param callback
  81645. */
  81646. onrightstickchanged(callback: (values: StickValues) => void): void;
  81647. /**
  81648. * Gets the left joystick
  81649. */
  81650. /**
  81651. * Sets the left joystick values
  81652. */
  81653. leftStick: StickValues;
  81654. /**
  81655. * Gets the right joystick
  81656. */
  81657. /**
  81658. * Sets the right joystick value
  81659. */
  81660. rightStick: StickValues;
  81661. /**
  81662. * Updates the gamepad joystick positions
  81663. */
  81664. update(): void;
  81665. /**
  81666. * Disposes the gamepad
  81667. */
  81668. dispose(): void;
  81669. }
  81670. /**
  81671. * Represents a generic gamepad
  81672. */
  81673. export class GenericPad extends Gamepad {
  81674. private _buttons;
  81675. private _onbuttondown;
  81676. private _onbuttonup;
  81677. /**
  81678. * Observable triggered when a button has been pressed
  81679. */
  81680. onButtonDownObservable: Observable<number>;
  81681. /**
  81682. * Observable triggered when a button has been released
  81683. */
  81684. onButtonUpObservable: Observable<number>;
  81685. /**
  81686. * Callback triggered when a button has been pressed
  81687. * @param callback Called when a button has been pressed
  81688. */
  81689. onbuttondown(callback: (buttonPressed: number) => void): void;
  81690. /**
  81691. * Callback triggered when a button has been released
  81692. * @param callback Called when a button has been released
  81693. */
  81694. onbuttonup(callback: (buttonReleased: number) => void): void;
  81695. /**
  81696. * Initializes the generic gamepad
  81697. * @param id The id of the generic gamepad
  81698. * @param index The index of the generic gamepad
  81699. * @param browserGamepad The browser gamepad
  81700. */
  81701. constructor(id: string, index: number, browserGamepad: any);
  81702. private _setButtonValue;
  81703. /**
  81704. * Updates the generic gamepad
  81705. */
  81706. update(): void;
  81707. /**
  81708. * Disposes the generic gamepad
  81709. */
  81710. dispose(): void;
  81711. }
  81712. }
  81713. declare module BABYLON {
  81714. interface Engine {
  81715. /**
  81716. * Creates a raw texture
  81717. * @param data defines the data to store in the texture
  81718. * @param width defines the width of the texture
  81719. * @param height defines the height of the texture
  81720. * @param format defines the format of the data
  81721. * @param generateMipMaps defines if the engine should generate the mip levels
  81722. * @param invertY defines if data must be stored with Y axis inverted
  81723. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  81724. * @param compression defines the compression used (null by default)
  81725. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  81726. * @returns the raw texture inside an InternalTexture
  81727. */
  81728. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  81729. /**
  81730. * Update a raw texture
  81731. * @param texture defines the texture to update
  81732. * @param data defines the data to store in the texture
  81733. * @param format defines the format of the data
  81734. * @param invertY defines if data must be stored with Y axis inverted
  81735. */
  81736. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  81737. /**
  81738. * Update a raw texture
  81739. * @param texture defines the texture to update
  81740. * @param data defines the data to store in the texture
  81741. * @param format defines the format of the data
  81742. * @param invertY defines if data must be stored with Y axis inverted
  81743. * @param compression defines the compression used (null by default)
  81744. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  81745. */
  81746. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  81747. /**
  81748. * Creates a new raw cube texture
  81749. * @param data defines the array of data to use to create each face
  81750. * @param size defines the size of the textures
  81751. * @param format defines the format of the data
  81752. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  81753. * @param generateMipMaps defines if the engine should generate the mip levels
  81754. * @param invertY defines if data must be stored with Y axis inverted
  81755. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  81756. * @param compression defines the compression used (null by default)
  81757. * @returns the cube texture as an InternalTexture
  81758. */
  81759. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  81760. /**
  81761. * Update a raw cube texture
  81762. * @param texture defines the texture to udpdate
  81763. * @param data defines the data to store
  81764. * @param format defines the data format
  81765. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  81766. * @param invertY defines if data must be stored with Y axis inverted
  81767. */
  81768. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  81769. /**
  81770. * Update a raw cube texture
  81771. * @param texture defines the texture to udpdate
  81772. * @param data defines the data to store
  81773. * @param format defines the data format
  81774. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  81775. * @param invertY defines if data must be stored with Y axis inverted
  81776. * @param compression defines the compression used (null by default)
  81777. */
  81778. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  81779. /**
  81780. * Update a raw cube texture
  81781. * @param texture defines the texture to udpdate
  81782. * @param data defines the data to store
  81783. * @param format defines the data format
  81784. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  81785. * @param invertY defines if data must be stored with Y axis inverted
  81786. * @param compression defines the compression used (null by default)
  81787. * @param level defines which level of the texture to update
  81788. */
  81789. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  81790. /**
  81791. * Creates a new raw cube texture from a specified url
  81792. * @param url defines the url where the data is located
  81793. * @param scene defines the current scene
  81794. * @param size defines the size of the textures
  81795. * @param format defines the format of the data
  81796. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  81797. * @param noMipmap defines if the engine should avoid generating the mip levels
  81798. * @param callback defines a callback used to extract texture data from loaded data
  81799. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  81800. * @param onLoad defines a callback called when texture is loaded
  81801. * @param onError defines a callback called if there is an error
  81802. * @returns the cube texture as an InternalTexture
  81803. */
  81804. 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;
  81805. /**
  81806. * Creates a new raw cube texture from a specified url
  81807. * @param url defines the url where the data is located
  81808. * @param scene defines the current scene
  81809. * @param size defines the size of the textures
  81810. * @param format defines the format of the data
  81811. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  81812. * @param noMipmap defines if the engine should avoid generating the mip levels
  81813. * @param callback defines a callback used to extract texture data from loaded data
  81814. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  81815. * @param onLoad defines a callback called when texture is loaded
  81816. * @param onError defines a callback called if there is an error
  81817. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  81818. * @param invertY defines if data must be stored with Y axis inverted
  81819. * @returns the cube texture as an InternalTexture
  81820. */
  81821. 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;
  81822. /**
  81823. * Creates a new raw 3D texture
  81824. * @param data defines the data used to create the texture
  81825. * @param width defines the width of the texture
  81826. * @param height defines the height of the texture
  81827. * @param depth defines the depth of the texture
  81828. * @param format defines the format of the texture
  81829. * @param generateMipMaps defines if the engine must generate mip levels
  81830. * @param invertY defines if data must be stored with Y axis inverted
  81831. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  81832. * @param compression defines the compressed used (can be null)
  81833. * @param textureType defines the compressed used (can be null)
  81834. * @returns a new raw 3D texture (stored in an InternalTexture)
  81835. */
  81836. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  81837. /**
  81838. * Update a raw 3D texture
  81839. * @param texture defines the texture to update
  81840. * @param data defines the data to store
  81841. * @param format defines the data format
  81842. * @param invertY defines if data must be stored with Y axis inverted
  81843. */
  81844. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  81845. /**
  81846. * Update a raw 3D texture
  81847. * @param texture defines the texture to update
  81848. * @param data defines the data to store
  81849. * @param format defines the data format
  81850. * @param invertY defines if data must be stored with Y axis inverted
  81851. * @param compression defines the used compression (can be null)
  81852. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  81853. */
  81854. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  81855. /**
  81856. * Creates a new raw 2D array texture
  81857. * @param data defines the data used to create the texture
  81858. * @param width defines the width of the texture
  81859. * @param height defines the height of the texture
  81860. * @param depth defines the number of layers of the texture
  81861. * @param format defines the format of the texture
  81862. * @param generateMipMaps defines if the engine must generate mip levels
  81863. * @param invertY defines if data must be stored with Y axis inverted
  81864. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  81865. * @param compression defines the compressed used (can be null)
  81866. * @param textureType defines the compressed used (can be null)
  81867. * @returns a new raw 2D array texture (stored in an InternalTexture)
  81868. */
  81869. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  81870. /**
  81871. * Update a raw 2D array texture
  81872. * @param texture defines the texture to update
  81873. * @param data defines the data to store
  81874. * @param format defines the data format
  81875. * @param invertY defines if data must be stored with Y axis inverted
  81876. */
  81877. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  81878. /**
  81879. * Update a raw 2D array texture
  81880. * @param texture defines the texture to update
  81881. * @param data defines the data to store
  81882. * @param format defines the data format
  81883. * @param invertY defines if data must be stored with Y axis inverted
  81884. * @param compression defines the used compression (can be null)
  81885. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  81886. */
  81887. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  81888. }
  81889. }
  81890. declare module BABYLON {
  81891. /**
  81892. * Raw texture can help creating a texture directly from an array of data.
  81893. * This can be super useful if you either get the data from an uncompressed source or
  81894. * if you wish to create your texture pixel by pixel.
  81895. */
  81896. export class RawTexture extends Texture {
  81897. /**
  81898. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  81899. */
  81900. format: number;
  81901. private _engine;
  81902. /**
  81903. * Instantiates a new RawTexture.
  81904. * Raw texture can help creating a texture directly from an array of data.
  81905. * This can be super useful if you either get the data from an uncompressed source or
  81906. * if you wish to create your texture pixel by pixel.
  81907. * @param data define the array of data to use to create the texture
  81908. * @param width define the width of the texture
  81909. * @param height define the height of the texture
  81910. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  81911. * @param scene define the scene the texture belongs to
  81912. * @param generateMipMaps define whether mip maps should be generated or not
  81913. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81914. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81915. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  81916. */
  81917. constructor(data: ArrayBufferView, width: number, height: number,
  81918. /**
  81919. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  81920. */
  81921. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  81922. /**
  81923. * Updates the texture underlying data.
  81924. * @param data Define the new data of the texture
  81925. */
  81926. update(data: ArrayBufferView): void;
  81927. /**
  81928. * Creates a luminance texture from some data.
  81929. * @param data Define the texture data
  81930. * @param width Define the width of the texture
  81931. * @param height Define the height of the texture
  81932. * @param scene Define the scene the texture belongs to
  81933. * @param generateMipMaps Define whether or not to create mip maps for the texture
  81934. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81935. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81936. * @returns the luminance texture
  81937. */
  81938. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  81939. /**
  81940. * Creates a luminance alpha texture from some data.
  81941. * @param data Define the texture data
  81942. * @param width Define the width of the texture
  81943. * @param height Define the height of the texture
  81944. * @param scene Define the scene the texture belongs to
  81945. * @param generateMipMaps Define whether or not to create mip maps for the texture
  81946. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81947. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81948. * @returns the luminance alpha texture
  81949. */
  81950. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  81951. /**
  81952. * Creates an alpha texture from some data.
  81953. * @param data Define the texture data
  81954. * @param width Define the width of the texture
  81955. * @param height Define the height of the texture
  81956. * @param scene Define the scene the texture belongs to
  81957. * @param generateMipMaps Define whether or not to create mip maps for the texture
  81958. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81959. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81960. * @returns the alpha texture
  81961. */
  81962. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  81963. /**
  81964. * Creates a RGB texture from some data.
  81965. * @param data Define the texture data
  81966. * @param width Define the width of the texture
  81967. * @param height Define the height of the texture
  81968. * @param scene Define the scene the texture belongs to
  81969. * @param generateMipMaps Define whether or not to create mip maps for the texture
  81970. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81971. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81972. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  81973. * @returns the RGB alpha texture
  81974. */
  81975. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  81976. /**
  81977. * Creates a RGBA texture from some data.
  81978. * @param data Define the texture data
  81979. * @param width Define the width of the texture
  81980. * @param height Define the height of the texture
  81981. * @param scene Define the scene the texture belongs to
  81982. * @param generateMipMaps Define whether or not to create mip maps for the texture
  81983. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81984. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81985. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  81986. * @returns the RGBA texture
  81987. */
  81988. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  81989. /**
  81990. * Creates a R texture from some data.
  81991. * @param data Define the texture data
  81992. * @param width Define the width of the texture
  81993. * @param height Define the height of the texture
  81994. * @param scene Define the scene the texture belongs to
  81995. * @param generateMipMaps Define whether or not to create mip maps for the texture
  81996. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81997. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81998. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  81999. * @returns the R texture
  82000. */
  82001. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  82002. }
  82003. }
  82004. declare module BABYLON {
  82005. /**
  82006. * Interface for the size containing width and height
  82007. */
  82008. export interface ISize {
  82009. /**
  82010. * Width
  82011. */
  82012. width: number;
  82013. /**
  82014. * Heighht
  82015. */
  82016. height: number;
  82017. }
  82018. /**
  82019. * Size containing widht and height
  82020. */
  82021. export class Size implements ISize {
  82022. /**
  82023. * Width
  82024. */
  82025. width: number;
  82026. /**
  82027. * Height
  82028. */
  82029. height: number;
  82030. /**
  82031. * Creates a Size object from the given width and height (floats).
  82032. * @param width width of the new size
  82033. * @param height height of the new size
  82034. */
  82035. constructor(width: number, height: number);
  82036. /**
  82037. * Returns a string with the Size width and height
  82038. * @returns a string with the Size width and height
  82039. */
  82040. toString(): string;
  82041. /**
  82042. * "Size"
  82043. * @returns the string "Size"
  82044. */
  82045. getClassName(): string;
  82046. /**
  82047. * Returns the Size hash code.
  82048. * @returns a hash code for a unique width and height
  82049. */
  82050. getHashCode(): number;
  82051. /**
  82052. * Updates the current size from the given one.
  82053. * @param src the given size
  82054. */
  82055. copyFrom(src: Size): void;
  82056. /**
  82057. * Updates in place the current Size from the given floats.
  82058. * @param width width of the new size
  82059. * @param height height of the new size
  82060. * @returns the updated Size.
  82061. */
  82062. copyFromFloats(width: number, height: number): Size;
  82063. /**
  82064. * Updates in place the current Size from the given floats.
  82065. * @param width width to set
  82066. * @param height height to set
  82067. * @returns the updated Size.
  82068. */
  82069. set(width: number, height: number): Size;
  82070. /**
  82071. * Multiplies the width and height by numbers
  82072. * @param w factor to multiple the width by
  82073. * @param h factor to multiple the height by
  82074. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  82075. */
  82076. multiplyByFloats(w: number, h: number): Size;
  82077. /**
  82078. * Clones the size
  82079. * @returns a new Size copied from the given one.
  82080. */
  82081. clone(): Size;
  82082. /**
  82083. * True if the current Size and the given one width and height are strictly equal.
  82084. * @param other the other size to compare against
  82085. * @returns True if the current Size and the given one width and height are strictly equal.
  82086. */
  82087. equals(other: Size): boolean;
  82088. /**
  82089. * The surface of the Size : width * height (float).
  82090. */
  82091. readonly surface: number;
  82092. /**
  82093. * Create a new size of zero
  82094. * @returns a new Size set to (0.0, 0.0)
  82095. */
  82096. static Zero(): Size;
  82097. /**
  82098. * Sums the width and height of two sizes
  82099. * @param otherSize size to add to this size
  82100. * @returns a new Size set as the addition result of the current Size and the given one.
  82101. */
  82102. add(otherSize: Size): Size;
  82103. /**
  82104. * Subtracts the width and height of two
  82105. * @param otherSize size to subtract to this size
  82106. * @returns a new Size set as the subtraction result of the given one from the current Size.
  82107. */
  82108. subtract(otherSize: Size): Size;
  82109. /**
  82110. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  82111. * @param start starting size to lerp between
  82112. * @param end end size to lerp between
  82113. * @param amount amount to lerp between the start and end values
  82114. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  82115. */
  82116. static Lerp(start: Size, end: Size, amount: number): Size;
  82117. }
  82118. }
  82119. declare module BABYLON {
  82120. /**
  82121. * Defines a runtime animation
  82122. */
  82123. export class RuntimeAnimation {
  82124. private _events;
  82125. /**
  82126. * The current frame of the runtime animation
  82127. */
  82128. private _currentFrame;
  82129. /**
  82130. * The animation used by the runtime animation
  82131. */
  82132. private _animation;
  82133. /**
  82134. * The target of the runtime animation
  82135. */
  82136. private _target;
  82137. /**
  82138. * The initiating animatable
  82139. */
  82140. private _host;
  82141. /**
  82142. * The original value of the runtime animation
  82143. */
  82144. private _originalValue;
  82145. /**
  82146. * The original blend value of the runtime animation
  82147. */
  82148. private _originalBlendValue;
  82149. /**
  82150. * The offsets cache of the runtime animation
  82151. */
  82152. private _offsetsCache;
  82153. /**
  82154. * The high limits cache of the runtime animation
  82155. */
  82156. private _highLimitsCache;
  82157. /**
  82158. * Specifies if the runtime animation has been stopped
  82159. */
  82160. private _stopped;
  82161. /**
  82162. * The blending factor of the runtime animation
  82163. */
  82164. private _blendingFactor;
  82165. /**
  82166. * The BabylonJS scene
  82167. */
  82168. private _scene;
  82169. /**
  82170. * The current value of the runtime animation
  82171. */
  82172. private _currentValue;
  82173. /** @hidden */
  82174. _animationState: _IAnimationState;
  82175. /**
  82176. * The active target of the runtime animation
  82177. */
  82178. private _activeTargets;
  82179. private _currentActiveTarget;
  82180. private _directTarget;
  82181. /**
  82182. * The target path of the runtime animation
  82183. */
  82184. private _targetPath;
  82185. /**
  82186. * The weight of the runtime animation
  82187. */
  82188. private _weight;
  82189. /**
  82190. * The ratio offset of the runtime animation
  82191. */
  82192. private _ratioOffset;
  82193. /**
  82194. * The previous delay of the runtime animation
  82195. */
  82196. private _previousDelay;
  82197. /**
  82198. * The previous ratio of the runtime animation
  82199. */
  82200. private _previousRatio;
  82201. private _enableBlending;
  82202. private _keys;
  82203. private _minFrame;
  82204. private _maxFrame;
  82205. private _minValue;
  82206. private _maxValue;
  82207. private _targetIsArray;
  82208. /**
  82209. * Gets the current frame of the runtime animation
  82210. */
  82211. readonly currentFrame: number;
  82212. /**
  82213. * Gets the weight of the runtime animation
  82214. */
  82215. readonly weight: number;
  82216. /**
  82217. * Gets the current value of the runtime animation
  82218. */
  82219. readonly currentValue: any;
  82220. /**
  82221. * Gets the target path of the runtime animation
  82222. */
  82223. readonly targetPath: string;
  82224. /**
  82225. * Gets the actual target of the runtime animation
  82226. */
  82227. readonly target: any;
  82228. /** @hidden */
  82229. _onLoop: () => void;
  82230. /**
  82231. * Create a new RuntimeAnimation object
  82232. * @param target defines the target of the animation
  82233. * @param animation defines the source animation object
  82234. * @param scene defines the hosting scene
  82235. * @param host defines the initiating Animatable
  82236. */
  82237. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  82238. private _preparePath;
  82239. /**
  82240. * Gets the animation from the runtime animation
  82241. */
  82242. readonly animation: Animation;
  82243. /**
  82244. * Resets the runtime animation to the beginning
  82245. * @param restoreOriginal defines whether to restore the target property to the original value
  82246. */
  82247. reset(restoreOriginal?: boolean): void;
  82248. /**
  82249. * Specifies if the runtime animation is stopped
  82250. * @returns Boolean specifying if the runtime animation is stopped
  82251. */
  82252. isStopped(): boolean;
  82253. /**
  82254. * Disposes of the runtime animation
  82255. */
  82256. dispose(): void;
  82257. /**
  82258. * Apply the interpolated value to the target
  82259. * @param currentValue defines the value computed by the animation
  82260. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  82261. */
  82262. setValue(currentValue: any, weight: number): void;
  82263. private _getOriginalValues;
  82264. private _setValue;
  82265. /**
  82266. * Gets the loop pmode of the runtime animation
  82267. * @returns Loop Mode
  82268. */
  82269. private _getCorrectLoopMode;
  82270. /**
  82271. * Move the current animation to a given frame
  82272. * @param frame defines the frame to move to
  82273. */
  82274. goToFrame(frame: number): void;
  82275. /**
  82276. * @hidden Internal use only
  82277. */
  82278. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  82279. /**
  82280. * Execute the current animation
  82281. * @param delay defines the delay to add to the current frame
  82282. * @param from defines the lower bound of the animation range
  82283. * @param to defines the upper bound of the animation range
  82284. * @param loop defines if the current animation must loop
  82285. * @param speedRatio defines the current speed ratio
  82286. * @param weight defines the weight of the animation (default is -1 so no weight)
  82287. * @param onLoop optional callback called when animation loops
  82288. * @returns a boolean indicating if the animation is running
  82289. */
  82290. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  82291. }
  82292. }
  82293. declare module BABYLON {
  82294. /**
  82295. * Class used to store an actual running animation
  82296. */
  82297. export class Animatable {
  82298. /** defines the target object */
  82299. target: any;
  82300. /** defines the starting frame number (default is 0) */
  82301. fromFrame: number;
  82302. /** defines the ending frame number (default is 100) */
  82303. toFrame: number;
  82304. /** defines if the animation must loop (default is false) */
  82305. loopAnimation: boolean;
  82306. /** defines a callback to call when animation ends if it is not looping */
  82307. onAnimationEnd?: (() => void) | null | undefined;
  82308. /** defines a callback to call when animation loops */
  82309. onAnimationLoop?: (() => void) | null | undefined;
  82310. private _localDelayOffset;
  82311. private _pausedDelay;
  82312. private _runtimeAnimations;
  82313. private _paused;
  82314. private _scene;
  82315. private _speedRatio;
  82316. private _weight;
  82317. private _syncRoot;
  82318. /**
  82319. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  82320. * This will only apply for non looping animation (default is true)
  82321. */
  82322. disposeOnEnd: boolean;
  82323. /**
  82324. * Gets a boolean indicating if the animation has started
  82325. */
  82326. animationStarted: boolean;
  82327. /**
  82328. * Observer raised when the animation ends
  82329. */
  82330. onAnimationEndObservable: Observable<Animatable>;
  82331. /**
  82332. * Observer raised when the animation loops
  82333. */
  82334. onAnimationLoopObservable: Observable<Animatable>;
  82335. /**
  82336. * Gets the root Animatable used to synchronize and normalize animations
  82337. */
  82338. readonly syncRoot: Nullable<Animatable>;
  82339. /**
  82340. * Gets the current frame of the first RuntimeAnimation
  82341. * Used to synchronize Animatables
  82342. */
  82343. readonly masterFrame: number;
  82344. /**
  82345. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  82346. */
  82347. weight: number;
  82348. /**
  82349. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  82350. */
  82351. speedRatio: number;
  82352. /**
  82353. * Creates a new Animatable
  82354. * @param scene defines the hosting scene
  82355. * @param target defines the target object
  82356. * @param fromFrame defines the starting frame number (default is 0)
  82357. * @param toFrame defines the ending frame number (default is 100)
  82358. * @param loopAnimation defines if the animation must loop (default is false)
  82359. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  82360. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  82361. * @param animations defines a group of animation to add to the new Animatable
  82362. * @param onAnimationLoop defines a callback to call when animation loops
  82363. */
  82364. constructor(scene: Scene,
  82365. /** defines the target object */
  82366. target: any,
  82367. /** defines the starting frame number (default is 0) */
  82368. fromFrame?: number,
  82369. /** defines the ending frame number (default is 100) */
  82370. toFrame?: number,
  82371. /** defines if the animation must loop (default is false) */
  82372. loopAnimation?: boolean, speedRatio?: number,
  82373. /** defines a callback to call when animation ends if it is not looping */
  82374. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  82375. /** defines a callback to call when animation loops */
  82376. onAnimationLoop?: (() => void) | null | undefined);
  82377. /**
  82378. * Synchronize and normalize current Animatable with a source Animatable
  82379. * This is useful when using animation weights and when animations are not of the same length
  82380. * @param root defines the root Animatable to synchronize with
  82381. * @returns the current Animatable
  82382. */
  82383. syncWith(root: Animatable): Animatable;
  82384. /**
  82385. * Gets the list of runtime animations
  82386. * @returns an array of RuntimeAnimation
  82387. */
  82388. getAnimations(): RuntimeAnimation[];
  82389. /**
  82390. * Adds more animations to the current animatable
  82391. * @param target defines the target of the animations
  82392. * @param animations defines the new animations to add
  82393. */
  82394. appendAnimations(target: any, animations: Animation[]): void;
  82395. /**
  82396. * Gets the source animation for a specific property
  82397. * @param property defines the propertyu to look for
  82398. * @returns null or the source animation for the given property
  82399. */
  82400. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  82401. /**
  82402. * Gets the runtime animation for a specific property
  82403. * @param property defines the propertyu to look for
  82404. * @returns null or the runtime animation for the given property
  82405. */
  82406. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  82407. /**
  82408. * Resets the animatable to its original state
  82409. */
  82410. reset(): void;
  82411. /**
  82412. * Allows the animatable to blend with current running animations
  82413. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  82414. * @param blendingSpeed defines the blending speed to use
  82415. */
  82416. enableBlending(blendingSpeed: number): void;
  82417. /**
  82418. * Disable animation blending
  82419. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  82420. */
  82421. disableBlending(): void;
  82422. /**
  82423. * Jump directly to a given frame
  82424. * @param frame defines the frame to jump to
  82425. */
  82426. goToFrame(frame: number): void;
  82427. /**
  82428. * Pause the animation
  82429. */
  82430. pause(): void;
  82431. /**
  82432. * Restart the animation
  82433. */
  82434. restart(): void;
  82435. private _raiseOnAnimationEnd;
  82436. /**
  82437. * Stop and delete the current animation
  82438. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  82439. * @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)
  82440. */
  82441. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  82442. /**
  82443. * Wait asynchronously for the animation to end
  82444. * @returns a promise which will be fullfilled when the animation ends
  82445. */
  82446. waitAsync(): Promise<Animatable>;
  82447. /** @hidden */
  82448. _animate(delay: number): boolean;
  82449. }
  82450. interface Scene {
  82451. /** @hidden */
  82452. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  82453. /** @hidden */
  82454. _processLateAnimationBindingsForMatrices(holder: {
  82455. totalWeight: number;
  82456. animations: RuntimeAnimation[];
  82457. originalValue: Matrix;
  82458. }): any;
  82459. /** @hidden */
  82460. _processLateAnimationBindingsForQuaternions(holder: {
  82461. totalWeight: number;
  82462. animations: RuntimeAnimation[];
  82463. originalValue: Quaternion;
  82464. }, refQuaternion: Quaternion): Quaternion;
  82465. /** @hidden */
  82466. _processLateAnimationBindings(): void;
  82467. /**
  82468. * Will start the animation sequence of a given target
  82469. * @param target defines the target
  82470. * @param from defines from which frame should animation start
  82471. * @param to defines until which frame should animation run.
  82472. * @param weight defines the weight to apply to the animation (1.0 by default)
  82473. * @param loop defines if the animation loops
  82474. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  82475. * @param onAnimationEnd defines the function to be executed when the animation ends
  82476. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  82477. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  82478. * @param onAnimationLoop defines the callback to call when an animation loops
  82479. * @returns the animatable object created for this animation
  82480. */
  82481. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  82482. /**
  82483. * Will start the animation sequence of a given target
  82484. * @param target defines the target
  82485. * @param from defines from which frame should animation start
  82486. * @param to defines until which frame should animation run.
  82487. * @param loop defines if the animation loops
  82488. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  82489. * @param onAnimationEnd defines the function to be executed when the animation ends
  82490. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  82491. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  82492. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  82493. * @param onAnimationLoop defines the callback to call when an animation loops
  82494. * @returns the animatable object created for this animation
  82495. */
  82496. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  82497. /**
  82498. * Will start the animation sequence of a given target and its hierarchy
  82499. * @param target defines the target
  82500. * @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.
  82501. * @param from defines from which frame should animation start
  82502. * @param to defines until which frame should animation run.
  82503. * @param loop defines if the animation loops
  82504. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  82505. * @param onAnimationEnd defines the function to be executed when the animation ends
  82506. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  82507. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  82508. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  82509. * @param onAnimationLoop defines the callback to call when an animation loops
  82510. * @returns the list of created animatables
  82511. */
  82512. 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[];
  82513. /**
  82514. * Begin a new animation on a given node
  82515. * @param target defines the target where the animation will take place
  82516. * @param animations defines the list of animations to start
  82517. * @param from defines the initial value
  82518. * @param to defines the final value
  82519. * @param loop defines if you want animation to loop (off by default)
  82520. * @param speedRatio defines the speed ratio to apply to all animations
  82521. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  82522. * @param onAnimationLoop defines the callback to call when an animation loops
  82523. * @returns the list of created animatables
  82524. */
  82525. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  82526. /**
  82527. * Begin a new animation on a given node and its hierarchy
  82528. * @param target defines the root node where the animation will take place
  82529. * @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.
  82530. * @param animations defines the list of animations to start
  82531. * @param from defines the initial value
  82532. * @param to defines the final value
  82533. * @param loop defines if you want animation to loop (off by default)
  82534. * @param speedRatio defines the speed ratio to apply to all animations
  82535. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  82536. * @param onAnimationLoop defines the callback to call when an animation loops
  82537. * @returns the list of animatables created for all nodes
  82538. */
  82539. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  82540. /**
  82541. * Gets the animatable associated with a specific target
  82542. * @param target defines the target of the animatable
  82543. * @returns the required animatable if found
  82544. */
  82545. getAnimatableByTarget(target: any): Nullable<Animatable>;
  82546. /**
  82547. * Gets all animatables associated with a given target
  82548. * @param target defines the target to look animatables for
  82549. * @returns an array of Animatables
  82550. */
  82551. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  82552. /**
  82553. * Stops and removes all animations that have been applied to the scene
  82554. */
  82555. stopAllAnimations(): void;
  82556. /**
  82557. * Gets the current delta time used by animation engine
  82558. */
  82559. deltaTime: number;
  82560. }
  82561. interface Bone {
  82562. /**
  82563. * Copy an animation range from another bone
  82564. * @param source defines the source bone
  82565. * @param rangeName defines the range name to copy
  82566. * @param frameOffset defines the frame offset
  82567. * @param rescaleAsRequired defines if rescaling must be applied if required
  82568. * @param skelDimensionsRatio defines the scaling ratio
  82569. * @returns true if operation was successful
  82570. */
  82571. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  82572. }
  82573. }
  82574. declare module BABYLON {
  82575. /**
  82576. * Class used to override all child animations of a given target
  82577. */
  82578. export class AnimationPropertiesOverride {
  82579. /**
  82580. * Gets or sets a value indicating if animation blending must be used
  82581. */
  82582. enableBlending: boolean;
  82583. /**
  82584. * Gets or sets the blending speed to use when enableBlending is true
  82585. */
  82586. blendingSpeed: number;
  82587. /**
  82588. * Gets or sets the default loop mode to use
  82589. */
  82590. loopMode: number;
  82591. }
  82592. }
  82593. declare module BABYLON {
  82594. /**
  82595. * Class used to handle skinning animations
  82596. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  82597. */
  82598. export class Skeleton implements IAnimatable {
  82599. /** defines the skeleton name */
  82600. name: string;
  82601. /** defines the skeleton Id */
  82602. id: string;
  82603. /**
  82604. * Defines the list of child bones
  82605. */
  82606. bones: Bone[];
  82607. /**
  82608. * Defines an estimate of the dimension of the skeleton at rest
  82609. */
  82610. dimensionsAtRest: Vector3;
  82611. /**
  82612. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  82613. */
  82614. needInitialSkinMatrix: boolean;
  82615. /**
  82616. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  82617. */
  82618. overrideMesh: Nullable<AbstractMesh>;
  82619. /**
  82620. * Gets the list of animations attached to this skeleton
  82621. */
  82622. animations: Array<Animation>;
  82623. private _scene;
  82624. private _isDirty;
  82625. private _transformMatrices;
  82626. private _transformMatrixTexture;
  82627. private _meshesWithPoseMatrix;
  82628. private _animatables;
  82629. private _identity;
  82630. private _synchronizedWithMesh;
  82631. private _ranges;
  82632. private _lastAbsoluteTransformsUpdateId;
  82633. private _canUseTextureForBones;
  82634. private _uniqueId;
  82635. /** @hidden */
  82636. _numBonesWithLinkedTransformNode: number;
  82637. /** @hidden */
  82638. _hasWaitingData: Nullable<boolean>;
  82639. /**
  82640. * Specifies if the skeleton should be serialized
  82641. */
  82642. doNotSerialize: boolean;
  82643. private _useTextureToStoreBoneMatrices;
  82644. /**
  82645. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  82646. * Please note that this option is not available if the hardware does not support it
  82647. */
  82648. useTextureToStoreBoneMatrices: boolean;
  82649. private _animationPropertiesOverride;
  82650. /**
  82651. * Gets or sets the animation properties override
  82652. */
  82653. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  82654. /**
  82655. * List of inspectable custom properties (used by the Inspector)
  82656. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  82657. */
  82658. inspectableCustomProperties: IInspectable[];
  82659. /**
  82660. * An observable triggered before computing the skeleton's matrices
  82661. */
  82662. onBeforeComputeObservable: Observable<Skeleton>;
  82663. /**
  82664. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  82665. */
  82666. readonly isUsingTextureForMatrices: boolean;
  82667. /**
  82668. * Gets the unique ID of this skeleton
  82669. */
  82670. readonly uniqueId: number;
  82671. /**
  82672. * Creates a new skeleton
  82673. * @param name defines the skeleton name
  82674. * @param id defines the skeleton Id
  82675. * @param scene defines the hosting scene
  82676. */
  82677. constructor(
  82678. /** defines the skeleton name */
  82679. name: string,
  82680. /** defines the skeleton Id */
  82681. id: string, scene: Scene);
  82682. /**
  82683. * Gets the current object class name.
  82684. * @return the class name
  82685. */
  82686. getClassName(): string;
  82687. /**
  82688. * Returns an array containing the root bones
  82689. * @returns an array containing the root bones
  82690. */
  82691. getChildren(): Array<Bone>;
  82692. /**
  82693. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  82694. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  82695. * @returns a Float32Array containing matrices data
  82696. */
  82697. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  82698. /**
  82699. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  82700. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  82701. * @returns a raw texture containing the data
  82702. */
  82703. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  82704. /**
  82705. * Gets the current hosting scene
  82706. * @returns a scene object
  82707. */
  82708. getScene(): Scene;
  82709. /**
  82710. * Gets a string representing the current skeleton data
  82711. * @param fullDetails defines a boolean indicating if we want a verbose version
  82712. * @returns a string representing the current skeleton data
  82713. */
  82714. toString(fullDetails?: boolean): string;
  82715. /**
  82716. * Get bone's index searching by name
  82717. * @param name defines bone's name to search for
  82718. * @return the indice of the bone. Returns -1 if not found
  82719. */
  82720. getBoneIndexByName(name: string): number;
  82721. /**
  82722. * Creater a new animation range
  82723. * @param name defines the name of the range
  82724. * @param from defines the start key
  82725. * @param to defines the end key
  82726. */
  82727. createAnimationRange(name: string, from: number, to: number): void;
  82728. /**
  82729. * Delete a specific animation range
  82730. * @param name defines the name of the range
  82731. * @param deleteFrames defines if frames must be removed as well
  82732. */
  82733. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  82734. /**
  82735. * Gets a specific animation range
  82736. * @param name defines the name of the range to look for
  82737. * @returns the requested animation range or null if not found
  82738. */
  82739. getAnimationRange(name: string): Nullable<AnimationRange>;
  82740. /**
  82741. * Gets the list of all animation ranges defined on this skeleton
  82742. * @returns an array
  82743. */
  82744. getAnimationRanges(): Nullable<AnimationRange>[];
  82745. /**
  82746. * Copy animation range from a source skeleton.
  82747. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  82748. * @param source defines the source skeleton
  82749. * @param name defines the name of the range to copy
  82750. * @param rescaleAsRequired defines if rescaling must be applied if required
  82751. * @returns true if operation was successful
  82752. */
  82753. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  82754. /**
  82755. * Forces the skeleton to go to rest pose
  82756. */
  82757. returnToRest(): void;
  82758. private _getHighestAnimationFrame;
  82759. /**
  82760. * Begin a specific animation range
  82761. * @param name defines the name of the range to start
  82762. * @param loop defines if looping must be turned on (false by default)
  82763. * @param speedRatio defines the speed ratio to apply (1 by default)
  82764. * @param onAnimationEnd defines a callback which will be called when animation will end
  82765. * @returns a new animatable
  82766. */
  82767. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  82768. /** @hidden */
  82769. _markAsDirty(): void;
  82770. /** @hidden */
  82771. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  82772. /** @hidden */
  82773. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  82774. private _computeTransformMatrices;
  82775. /**
  82776. * Build all resources required to render a skeleton
  82777. */
  82778. prepare(): void;
  82779. /**
  82780. * Gets the list of animatables currently running for this skeleton
  82781. * @returns an array of animatables
  82782. */
  82783. getAnimatables(): IAnimatable[];
  82784. /**
  82785. * Clone the current skeleton
  82786. * @param name defines the name of the new skeleton
  82787. * @param id defines the id of the new skeleton
  82788. * @returns the new skeleton
  82789. */
  82790. clone(name: string, id?: string): Skeleton;
  82791. /**
  82792. * Enable animation blending for this skeleton
  82793. * @param blendingSpeed defines the blending speed to apply
  82794. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  82795. */
  82796. enableBlending(blendingSpeed?: number): void;
  82797. /**
  82798. * Releases all resources associated with the current skeleton
  82799. */
  82800. dispose(): void;
  82801. /**
  82802. * Serialize the skeleton in a JSON object
  82803. * @returns a JSON object
  82804. */
  82805. serialize(): any;
  82806. /**
  82807. * Creates a new skeleton from serialized data
  82808. * @param parsedSkeleton defines the serialized data
  82809. * @param scene defines the hosting scene
  82810. * @returns a new skeleton
  82811. */
  82812. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  82813. /**
  82814. * Compute all node absolute transforms
  82815. * @param forceUpdate defines if computation must be done even if cache is up to date
  82816. */
  82817. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  82818. /**
  82819. * Gets the root pose matrix
  82820. * @returns a matrix
  82821. */
  82822. getPoseMatrix(): Nullable<Matrix>;
  82823. /**
  82824. * Sorts bones per internal index
  82825. */
  82826. sortBones(): void;
  82827. private _sortBones;
  82828. }
  82829. }
  82830. declare module BABYLON {
  82831. /**
  82832. * Class used to store bone information
  82833. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  82834. */
  82835. export class Bone extends Node {
  82836. /**
  82837. * defines the bone name
  82838. */
  82839. name: string;
  82840. private static _tmpVecs;
  82841. private static _tmpQuat;
  82842. private static _tmpMats;
  82843. /**
  82844. * Gets the list of child bones
  82845. */
  82846. children: Bone[];
  82847. /** Gets the animations associated with this bone */
  82848. animations: Animation[];
  82849. /**
  82850. * Gets or sets bone length
  82851. */
  82852. length: number;
  82853. /**
  82854. * @hidden Internal only
  82855. * Set this value to map this bone to a different index in the transform matrices
  82856. * Set this value to -1 to exclude the bone from the transform matrices
  82857. */
  82858. _index: Nullable<number>;
  82859. private _skeleton;
  82860. private _localMatrix;
  82861. private _restPose;
  82862. private _baseMatrix;
  82863. private _absoluteTransform;
  82864. private _invertedAbsoluteTransform;
  82865. private _parent;
  82866. private _scalingDeterminant;
  82867. private _worldTransform;
  82868. private _localScaling;
  82869. private _localRotation;
  82870. private _localPosition;
  82871. private _needToDecompose;
  82872. private _needToCompose;
  82873. /** @hidden */
  82874. _linkedTransformNode: Nullable<TransformNode>;
  82875. /** @hidden */
  82876. _waitingTransformNodeId: Nullable<string>;
  82877. /** @hidden */
  82878. /** @hidden */
  82879. _matrix: Matrix;
  82880. /**
  82881. * Create a new bone
  82882. * @param name defines the bone name
  82883. * @param skeleton defines the parent skeleton
  82884. * @param parentBone defines the parent (can be null if the bone is the root)
  82885. * @param localMatrix defines the local matrix
  82886. * @param restPose defines the rest pose matrix
  82887. * @param baseMatrix defines the base matrix
  82888. * @param index defines index of the bone in the hiearchy
  82889. */
  82890. constructor(
  82891. /**
  82892. * defines the bone name
  82893. */
  82894. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  82895. /**
  82896. * Gets the current object class name.
  82897. * @return the class name
  82898. */
  82899. getClassName(): string;
  82900. /**
  82901. * Gets the parent skeleton
  82902. * @returns a skeleton
  82903. */
  82904. getSkeleton(): Skeleton;
  82905. /**
  82906. * Gets parent bone
  82907. * @returns a bone or null if the bone is the root of the bone hierarchy
  82908. */
  82909. getParent(): Nullable<Bone>;
  82910. /**
  82911. * Returns an array containing the root bones
  82912. * @returns an array containing the root bones
  82913. */
  82914. getChildren(): Array<Bone>;
  82915. /**
  82916. * Gets the node index in matrix array generated for rendering
  82917. * @returns the node index
  82918. */
  82919. getIndex(): number;
  82920. /**
  82921. * Sets the parent bone
  82922. * @param parent defines the parent (can be null if the bone is the root)
  82923. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  82924. */
  82925. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  82926. /**
  82927. * Gets the local matrix
  82928. * @returns a matrix
  82929. */
  82930. getLocalMatrix(): Matrix;
  82931. /**
  82932. * Gets the base matrix (initial matrix which remains unchanged)
  82933. * @returns a matrix
  82934. */
  82935. getBaseMatrix(): Matrix;
  82936. /**
  82937. * Gets the rest pose matrix
  82938. * @returns a matrix
  82939. */
  82940. getRestPose(): Matrix;
  82941. /**
  82942. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  82943. */
  82944. getWorldMatrix(): Matrix;
  82945. /**
  82946. * Sets the local matrix to rest pose matrix
  82947. */
  82948. returnToRest(): void;
  82949. /**
  82950. * Gets the inverse of the absolute transform matrix.
  82951. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  82952. * @returns a matrix
  82953. */
  82954. getInvertedAbsoluteTransform(): Matrix;
  82955. /**
  82956. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  82957. * @returns a matrix
  82958. */
  82959. getAbsoluteTransform(): Matrix;
  82960. /**
  82961. * Links with the given transform node.
  82962. * The local matrix of this bone is copied from the transform node every frame.
  82963. * @param transformNode defines the transform node to link to
  82964. */
  82965. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  82966. /**
  82967. * Gets the node used to drive the bone's transformation
  82968. * @returns a transform node or null
  82969. */
  82970. getTransformNode(): Nullable<TransformNode>;
  82971. /** Gets or sets current position (in local space) */
  82972. position: Vector3;
  82973. /** Gets or sets current rotation (in local space) */
  82974. rotation: Vector3;
  82975. /** Gets or sets current rotation quaternion (in local space) */
  82976. rotationQuaternion: Quaternion;
  82977. /** Gets or sets current scaling (in local space) */
  82978. scaling: Vector3;
  82979. /**
  82980. * Gets the animation properties override
  82981. */
  82982. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  82983. private _decompose;
  82984. private _compose;
  82985. /**
  82986. * Update the base and local matrices
  82987. * @param matrix defines the new base or local matrix
  82988. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  82989. * @param updateLocalMatrix defines if the local matrix should be updated
  82990. */
  82991. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  82992. /** @hidden */
  82993. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  82994. /**
  82995. * Flag the bone as dirty (Forcing it to update everything)
  82996. */
  82997. markAsDirty(): void;
  82998. /** @hidden */
  82999. _markAsDirtyAndCompose(): void;
  83000. private _markAsDirtyAndDecompose;
  83001. /**
  83002. * Translate the bone in local or world space
  83003. * @param vec The amount to translate the bone
  83004. * @param space The space that the translation is in
  83005. * @param mesh The mesh that this bone is attached to. This is only used in world space
  83006. */
  83007. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  83008. /**
  83009. * Set the postion of the bone in local or world space
  83010. * @param position The position to set the bone
  83011. * @param space The space that the position is in
  83012. * @param mesh The mesh that this bone is attached to. This is only used in world space
  83013. */
  83014. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  83015. /**
  83016. * Set the absolute position of the bone (world space)
  83017. * @param position The position to set the bone
  83018. * @param mesh The mesh that this bone is attached to
  83019. */
  83020. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  83021. /**
  83022. * Scale the bone on the x, y and z axes (in local space)
  83023. * @param x The amount to scale the bone on the x axis
  83024. * @param y The amount to scale the bone on the y axis
  83025. * @param z The amount to scale the bone on the z axis
  83026. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  83027. */
  83028. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  83029. /**
  83030. * Set the bone scaling in local space
  83031. * @param scale defines the scaling vector
  83032. */
  83033. setScale(scale: Vector3): void;
  83034. /**
  83035. * Gets the current scaling in local space
  83036. * @returns the current scaling vector
  83037. */
  83038. getScale(): Vector3;
  83039. /**
  83040. * Gets the current scaling in local space and stores it in a target vector
  83041. * @param result defines the target vector
  83042. */
  83043. getScaleToRef(result: Vector3): void;
  83044. /**
  83045. * Set the yaw, pitch, and roll of the bone in local or world space
  83046. * @param yaw The rotation of the bone on the y axis
  83047. * @param pitch The rotation of the bone on the x axis
  83048. * @param roll The rotation of the bone on the z axis
  83049. * @param space The space that the axes of rotation are in
  83050. * @param mesh The mesh that this bone is attached to. This is only used in world space
  83051. */
  83052. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  83053. /**
  83054. * Add a rotation to the bone on an axis in local or world space
  83055. * @param axis The axis to rotate the bone on
  83056. * @param amount The amount to rotate the bone
  83057. * @param space The space that the axis is in
  83058. * @param mesh The mesh that this bone is attached to. This is only used in world space
  83059. */
  83060. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  83061. /**
  83062. * Set the rotation of the bone to a particular axis angle in local or world space
  83063. * @param axis The axis to rotate the bone on
  83064. * @param angle The angle that the bone should be rotated to
  83065. * @param space The space that the axis is in
  83066. * @param mesh The mesh that this bone is attached to. This is only used in world space
  83067. */
  83068. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  83069. /**
  83070. * Set the euler rotation of the bone in local of world space
  83071. * @param rotation The euler rotation that the bone should be set to
  83072. * @param space The space that the rotation is in
  83073. * @param mesh The mesh that this bone is attached to. This is only used in world space
  83074. */
  83075. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  83076. /**
  83077. * Set the quaternion rotation of the bone in local of world space
  83078. * @param quat The quaternion rotation that the bone should be set to
  83079. * @param space The space that the rotation is in
  83080. * @param mesh The mesh that this bone is attached to. This is only used in world space
  83081. */
  83082. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  83083. /**
  83084. * Set the rotation matrix of the bone in local of world space
  83085. * @param rotMat The rotation matrix that the bone should be set to
  83086. * @param space The space that the rotation is in
  83087. * @param mesh The mesh that this bone is attached to. This is only used in world space
  83088. */
  83089. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  83090. private _rotateWithMatrix;
  83091. private _getNegativeRotationToRef;
  83092. /**
  83093. * Get the position of the bone in local or world space
  83094. * @param space The space that the returned position is in
  83095. * @param mesh The mesh that this bone is attached to. This is only used in world space
  83096. * @returns The position of the bone
  83097. */
  83098. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  83099. /**
  83100. * Copy the position of the bone to a vector3 in local or world space
  83101. * @param space The space that the returned position is in
  83102. * @param mesh The mesh that this bone is attached to. This is only used in world space
  83103. * @param result The vector3 to copy the position to
  83104. */
  83105. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  83106. /**
  83107. * Get the absolute position of the bone (world space)
  83108. * @param mesh The mesh that this bone is attached to
  83109. * @returns The absolute position of the bone
  83110. */
  83111. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  83112. /**
  83113. * Copy the absolute position of the bone (world space) to the result param
  83114. * @param mesh The mesh that this bone is attached to
  83115. * @param result The vector3 to copy the absolute position to
  83116. */
  83117. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  83118. /**
  83119. * Compute the absolute transforms of this bone and its children
  83120. */
  83121. computeAbsoluteTransforms(): void;
  83122. /**
  83123. * Get the world direction from an axis that is in the local space of the bone
  83124. * @param localAxis The local direction that is used to compute the world direction
  83125. * @param mesh The mesh that this bone is attached to
  83126. * @returns The world direction
  83127. */
  83128. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  83129. /**
  83130. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  83131. * @param localAxis The local direction that is used to compute the world direction
  83132. * @param mesh The mesh that this bone is attached to
  83133. * @param result The vector3 that the world direction will be copied to
  83134. */
  83135. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  83136. /**
  83137. * Get the euler rotation of the bone in local or world space
  83138. * @param space The space that the rotation should be in
  83139. * @param mesh The mesh that this bone is attached to. This is only used in world space
  83140. * @returns The euler rotation
  83141. */
  83142. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  83143. /**
  83144. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  83145. * @param space The space that the rotation should be in
  83146. * @param mesh The mesh that this bone is attached to. This is only used in world space
  83147. * @param result The vector3 that the rotation should be copied to
  83148. */
  83149. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  83150. /**
  83151. * Get the quaternion rotation of the bone in either local or world space
  83152. * @param space The space that the rotation should be in
  83153. * @param mesh The mesh that this bone is attached to. This is only used in world space
  83154. * @returns The quaternion rotation
  83155. */
  83156. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  83157. /**
  83158. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  83159. * @param space The space that the rotation should be in
  83160. * @param mesh The mesh that this bone is attached to. This is only used in world space
  83161. * @param result The quaternion that the rotation should be copied to
  83162. */
  83163. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  83164. /**
  83165. * Get the rotation matrix of the bone in local or world space
  83166. * @param space The space that the rotation should be in
  83167. * @param mesh The mesh that this bone is attached to. This is only used in world space
  83168. * @returns The rotation matrix
  83169. */
  83170. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  83171. /**
  83172. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  83173. * @param space The space that the rotation should be in
  83174. * @param mesh The mesh that this bone is attached to. This is only used in world space
  83175. * @param result The quaternion that the rotation should be copied to
  83176. */
  83177. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  83178. /**
  83179. * Get the world position of a point that is in the local space of the bone
  83180. * @param position The local position
  83181. * @param mesh The mesh that this bone is attached to
  83182. * @returns The world position
  83183. */
  83184. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  83185. /**
  83186. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  83187. * @param position The local position
  83188. * @param mesh The mesh that this bone is attached to
  83189. * @param result The vector3 that the world position should be copied to
  83190. */
  83191. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  83192. /**
  83193. * Get the local position of a point that is in world space
  83194. * @param position The world position
  83195. * @param mesh The mesh that this bone is attached to
  83196. * @returns The local position
  83197. */
  83198. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  83199. /**
  83200. * Get the local position of a point that is in world space and copy it to the result param
  83201. * @param position The world position
  83202. * @param mesh The mesh that this bone is attached to
  83203. * @param result The vector3 that the local position should be copied to
  83204. */
  83205. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  83206. }
  83207. }
  83208. declare module BABYLON {
  83209. /**
  83210. * 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.
  83211. * @see https://doc.babylonjs.com/how_to/transformnode
  83212. */
  83213. export class TransformNode extends Node {
  83214. /**
  83215. * Object will not rotate to face the camera
  83216. */
  83217. static BILLBOARDMODE_NONE: number;
  83218. /**
  83219. * Object will rotate to face the camera but only on the x axis
  83220. */
  83221. static BILLBOARDMODE_X: number;
  83222. /**
  83223. * Object will rotate to face the camera but only on the y axis
  83224. */
  83225. static BILLBOARDMODE_Y: number;
  83226. /**
  83227. * Object will rotate to face the camera but only on the z axis
  83228. */
  83229. static BILLBOARDMODE_Z: number;
  83230. /**
  83231. * Object will rotate to face the camera
  83232. */
  83233. static BILLBOARDMODE_ALL: number;
  83234. /**
  83235. * Object will rotate to face the camera's position instead of orientation
  83236. */
  83237. static BILLBOARDMODE_USE_POSITION: number;
  83238. private _forward;
  83239. private _forwardInverted;
  83240. private _up;
  83241. private _right;
  83242. private _rightInverted;
  83243. private _position;
  83244. private _rotation;
  83245. private _rotationQuaternion;
  83246. protected _scaling: Vector3;
  83247. protected _isDirty: boolean;
  83248. private _transformToBoneReferal;
  83249. private _isAbsoluteSynced;
  83250. private _billboardMode;
  83251. /**
  83252. * Gets or sets the billboard mode. Default is 0.
  83253. *
  83254. * | Value | Type | Description |
  83255. * | --- | --- | --- |
  83256. * | 0 | BILLBOARDMODE_NONE | |
  83257. * | 1 | BILLBOARDMODE_X | |
  83258. * | 2 | BILLBOARDMODE_Y | |
  83259. * | 4 | BILLBOARDMODE_Z | |
  83260. * | 7 | BILLBOARDMODE_ALL | |
  83261. *
  83262. */
  83263. billboardMode: number;
  83264. private _preserveParentRotationForBillboard;
  83265. /**
  83266. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  83267. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  83268. */
  83269. preserveParentRotationForBillboard: boolean;
  83270. /**
  83271. * 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
  83272. */
  83273. scalingDeterminant: number;
  83274. private _infiniteDistance;
  83275. /**
  83276. * Gets or sets the distance of the object to max, often used by skybox
  83277. */
  83278. infiniteDistance: boolean;
  83279. /**
  83280. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  83281. * By default the system will update normals to compensate
  83282. */
  83283. ignoreNonUniformScaling: boolean;
  83284. /**
  83285. * 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
  83286. */
  83287. reIntegrateRotationIntoRotationQuaternion: boolean;
  83288. /** @hidden */
  83289. _poseMatrix: Nullable<Matrix>;
  83290. /** @hidden */
  83291. _localMatrix: Matrix;
  83292. private _usePivotMatrix;
  83293. private _absolutePosition;
  83294. private _absoluteScaling;
  83295. private _absoluteRotationQuaternion;
  83296. private _pivotMatrix;
  83297. private _pivotMatrixInverse;
  83298. protected _postMultiplyPivotMatrix: boolean;
  83299. protected _isWorldMatrixFrozen: boolean;
  83300. /** @hidden */
  83301. _indexInSceneTransformNodesArray: number;
  83302. /**
  83303. * An event triggered after the world matrix is updated
  83304. */
  83305. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  83306. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  83307. /**
  83308. * Gets a string identifying the name of the class
  83309. * @returns "TransformNode" string
  83310. */
  83311. getClassName(): string;
  83312. /**
  83313. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  83314. */
  83315. position: Vector3;
  83316. /**
  83317. * 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)).
  83318. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  83319. */
  83320. rotation: Vector3;
  83321. /**
  83322. * 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)).
  83323. */
  83324. scaling: Vector3;
  83325. /**
  83326. * 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).
  83327. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  83328. */
  83329. rotationQuaternion: Nullable<Quaternion>;
  83330. /**
  83331. * The forward direction of that transform in world space.
  83332. */
  83333. readonly forward: Vector3;
  83334. /**
  83335. * The up direction of that transform in world space.
  83336. */
  83337. readonly up: Vector3;
  83338. /**
  83339. * The right direction of that transform in world space.
  83340. */
  83341. readonly right: Vector3;
  83342. /**
  83343. * Copies the parameter passed Matrix into the mesh Pose matrix.
  83344. * @param matrix the matrix to copy the pose from
  83345. * @returns this TransformNode.
  83346. */
  83347. updatePoseMatrix(matrix: Matrix): TransformNode;
  83348. /**
  83349. * Returns the mesh Pose matrix.
  83350. * @returns the pose matrix
  83351. */
  83352. getPoseMatrix(): Matrix;
  83353. /** @hidden */
  83354. _isSynchronized(): boolean;
  83355. /** @hidden */
  83356. _initCache(): void;
  83357. /**
  83358. * Flag the transform node as dirty (Forcing it to update everything)
  83359. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  83360. * @returns this transform node
  83361. */
  83362. markAsDirty(property: string): TransformNode;
  83363. /**
  83364. * Returns the current mesh absolute position.
  83365. * Returns a Vector3.
  83366. */
  83367. readonly absolutePosition: Vector3;
  83368. /**
  83369. * Returns the current mesh absolute scaling.
  83370. * Returns a Vector3.
  83371. */
  83372. readonly absoluteScaling: Vector3;
  83373. /**
  83374. * Returns the current mesh absolute rotation.
  83375. * Returns a Quaternion.
  83376. */
  83377. readonly absoluteRotationQuaternion: Quaternion;
  83378. /**
  83379. * Sets a new matrix to apply before all other transformation
  83380. * @param matrix defines the transform matrix
  83381. * @returns the current TransformNode
  83382. */
  83383. setPreTransformMatrix(matrix: Matrix): TransformNode;
  83384. /**
  83385. * Sets a new pivot matrix to the current node
  83386. * @param matrix defines the new pivot matrix to use
  83387. * @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
  83388. * @returns the current TransformNode
  83389. */
  83390. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  83391. /**
  83392. * Returns the mesh pivot matrix.
  83393. * Default : Identity.
  83394. * @returns the matrix
  83395. */
  83396. getPivotMatrix(): Matrix;
  83397. /**
  83398. * Instantiate (when possible) or clone that node with its hierarchy
  83399. * @param newParent defines the new parent to use for the instance (or clone)
  83400. * @param options defines options to configure how copy is done
  83401. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  83402. * @returns an instance (or a clone) of the current node with its hiearchy
  83403. */
  83404. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  83405. doNotInstantiate: boolean;
  83406. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  83407. /**
  83408. * Prevents the World matrix to be computed any longer
  83409. * @param newWorldMatrix defines an optional matrix to use as world matrix
  83410. * @returns the TransformNode.
  83411. */
  83412. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  83413. /**
  83414. * Allows back the World matrix computation.
  83415. * @returns the TransformNode.
  83416. */
  83417. unfreezeWorldMatrix(): this;
  83418. /**
  83419. * True if the World matrix has been frozen.
  83420. */
  83421. readonly isWorldMatrixFrozen: boolean;
  83422. /**
  83423. * Retuns the mesh absolute position in the World.
  83424. * @returns a Vector3.
  83425. */
  83426. getAbsolutePosition(): Vector3;
  83427. /**
  83428. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  83429. * @param absolutePosition the absolute position to set
  83430. * @returns the TransformNode.
  83431. */
  83432. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  83433. /**
  83434. * Sets the mesh position in its local space.
  83435. * @param vector3 the position to set in localspace
  83436. * @returns the TransformNode.
  83437. */
  83438. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  83439. /**
  83440. * Returns the mesh position in the local space from the current World matrix values.
  83441. * @returns a new Vector3.
  83442. */
  83443. getPositionExpressedInLocalSpace(): Vector3;
  83444. /**
  83445. * Translates the mesh along the passed Vector3 in its local space.
  83446. * @param vector3 the distance to translate in localspace
  83447. * @returns the TransformNode.
  83448. */
  83449. locallyTranslate(vector3: Vector3): TransformNode;
  83450. private static _lookAtVectorCache;
  83451. /**
  83452. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  83453. * @param targetPoint the position (must be in same space as current mesh) to look at
  83454. * @param yawCor optional yaw (y-axis) correction in radians
  83455. * @param pitchCor optional pitch (x-axis) correction in radians
  83456. * @param rollCor optional roll (z-axis) correction in radians
  83457. * @param space the choosen space of the target
  83458. * @returns the TransformNode.
  83459. */
  83460. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  83461. /**
  83462. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  83463. * This Vector3 is expressed in the World space.
  83464. * @param localAxis axis to rotate
  83465. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  83466. */
  83467. getDirection(localAxis: Vector3): Vector3;
  83468. /**
  83469. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  83470. * localAxis is expressed in the mesh local space.
  83471. * result is computed in the Wordl space from the mesh World matrix.
  83472. * @param localAxis axis to rotate
  83473. * @param result the resulting transformnode
  83474. * @returns this TransformNode.
  83475. */
  83476. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  83477. /**
  83478. * Sets this transform node rotation to the given local axis.
  83479. * @param localAxis the axis in local space
  83480. * @param yawCor optional yaw (y-axis) correction in radians
  83481. * @param pitchCor optional pitch (x-axis) correction in radians
  83482. * @param rollCor optional roll (z-axis) correction in radians
  83483. * @returns this TransformNode
  83484. */
  83485. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  83486. /**
  83487. * Sets a new pivot point to the current node
  83488. * @param point defines the new pivot point to use
  83489. * @param space defines if the point is in world or local space (local by default)
  83490. * @returns the current TransformNode
  83491. */
  83492. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  83493. /**
  83494. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  83495. * @returns the pivot point
  83496. */
  83497. getPivotPoint(): Vector3;
  83498. /**
  83499. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  83500. * @param result the vector3 to store the result
  83501. * @returns this TransformNode.
  83502. */
  83503. getPivotPointToRef(result: Vector3): TransformNode;
  83504. /**
  83505. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  83506. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  83507. */
  83508. getAbsolutePivotPoint(): Vector3;
  83509. /**
  83510. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  83511. * @param result vector3 to store the result
  83512. * @returns this TransformNode.
  83513. */
  83514. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  83515. /**
  83516. * Defines the passed node as the parent of the current node.
  83517. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  83518. * @see https://doc.babylonjs.com/how_to/parenting
  83519. * @param node the node ot set as the parent
  83520. * @returns this TransformNode.
  83521. */
  83522. setParent(node: Nullable<Node>): TransformNode;
  83523. private _nonUniformScaling;
  83524. /**
  83525. * True if the scaling property of this object is non uniform eg. (1,2,1)
  83526. */
  83527. readonly nonUniformScaling: boolean;
  83528. /** @hidden */
  83529. _updateNonUniformScalingState(value: boolean): boolean;
  83530. /**
  83531. * Attach the current TransformNode to another TransformNode associated with a bone
  83532. * @param bone Bone affecting the TransformNode
  83533. * @param affectedTransformNode TransformNode associated with the bone
  83534. * @returns this object
  83535. */
  83536. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  83537. /**
  83538. * Detach the transform node if its associated with a bone
  83539. * @returns this object
  83540. */
  83541. detachFromBone(): TransformNode;
  83542. private static _rotationAxisCache;
  83543. /**
  83544. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  83545. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  83546. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  83547. * The passed axis is also normalized.
  83548. * @param axis the axis to rotate around
  83549. * @param amount the amount to rotate in radians
  83550. * @param space Space to rotate in (Default: local)
  83551. * @returns the TransformNode.
  83552. */
  83553. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  83554. /**
  83555. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  83556. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  83557. * The passed axis is also normalized. .
  83558. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  83559. * @param point the point to rotate around
  83560. * @param axis the axis to rotate around
  83561. * @param amount the amount to rotate in radians
  83562. * @returns the TransformNode
  83563. */
  83564. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  83565. /**
  83566. * Translates the mesh along the axis vector for the passed distance in the given space.
  83567. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  83568. * @param axis the axis to translate in
  83569. * @param distance the distance to translate
  83570. * @param space Space to rotate in (Default: local)
  83571. * @returns the TransformNode.
  83572. */
  83573. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  83574. /**
  83575. * Adds a rotation step to the mesh current rotation.
  83576. * x, y, z are Euler angles expressed in radians.
  83577. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  83578. * This means this rotation is made in the mesh local space only.
  83579. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  83580. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  83581. * ```javascript
  83582. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  83583. * ```
  83584. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  83585. * 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.
  83586. * @param x Rotation to add
  83587. * @param y Rotation to add
  83588. * @param z Rotation to add
  83589. * @returns the TransformNode.
  83590. */
  83591. addRotation(x: number, y: number, z: number): TransformNode;
  83592. /**
  83593. * @hidden
  83594. */
  83595. protected _getEffectiveParent(): Nullable<Node>;
  83596. /**
  83597. * Computes the world matrix of the node
  83598. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  83599. * @returns the world matrix
  83600. */
  83601. computeWorldMatrix(force?: boolean): Matrix;
  83602. protected _afterComputeWorldMatrix(): void;
  83603. /**
  83604. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  83605. * @param func callback function to add
  83606. *
  83607. * @returns the TransformNode.
  83608. */
  83609. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  83610. /**
  83611. * Removes a registered callback function.
  83612. * @param func callback function to remove
  83613. * @returns the TransformNode.
  83614. */
  83615. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  83616. /**
  83617. * Gets the position of the current mesh in camera space
  83618. * @param camera defines the camera to use
  83619. * @returns a position
  83620. */
  83621. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  83622. /**
  83623. * Returns the distance from the mesh to the active camera
  83624. * @param camera defines the camera to use
  83625. * @returns the distance
  83626. */
  83627. getDistanceToCamera(camera?: Nullable<Camera>): number;
  83628. /**
  83629. * Clone the current transform node
  83630. * @param name Name of the new clone
  83631. * @param newParent New parent for the clone
  83632. * @param doNotCloneChildren Do not clone children hierarchy
  83633. * @returns the new transform node
  83634. */
  83635. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  83636. /**
  83637. * Serializes the objects information.
  83638. * @param currentSerializationObject defines the object to serialize in
  83639. * @returns the serialized object
  83640. */
  83641. serialize(currentSerializationObject?: any): any;
  83642. /**
  83643. * Returns a new TransformNode object parsed from the source provided.
  83644. * @param parsedTransformNode is the source.
  83645. * @param scene the scne the object belongs to
  83646. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  83647. * @returns a new TransformNode object parsed from the source provided.
  83648. */
  83649. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  83650. /**
  83651. * Get all child-transformNodes of this node
  83652. * @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
  83653. * @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
  83654. * @returns an array of TransformNode
  83655. */
  83656. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  83657. /**
  83658. * Releases resources associated with this transform node.
  83659. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  83660. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  83661. */
  83662. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  83663. /**
  83664. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  83665. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  83666. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  83667. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  83668. * @returns the current mesh
  83669. */
  83670. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  83671. private _syncAbsoluteScalingAndRotation;
  83672. }
  83673. }
  83674. declare module BABYLON {
  83675. /**
  83676. * Defines the types of pose enabled controllers that are supported
  83677. */
  83678. export enum PoseEnabledControllerType {
  83679. /**
  83680. * HTC Vive
  83681. */
  83682. VIVE = 0,
  83683. /**
  83684. * Oculus Rift
  83685. */
  83686. OCULUS = 1,
  83687. /**
  83688. * Windows mixed reality
  83689. */
  83690. WINDOWS = 2,
  83691. /**
  83692. * Samsung gear VR
  83693. */
  83694. GEAR_VR = 3,
  83695. /**
  83696. * Google Daydream
  83697. */
  83698. DAYDREAM = 4,
  83699. /**
  83700. * Generic
  83701. */
  83702. GENERIC = 5
  83703. }
  83704. /**
  83705. * Defines the MutableGamepadButton interface for the state of a gamepad button
  83706. */
  83707. export interface MutableGamepadButton {
  83708. /**
  83709. * Value of the button/trigger
  83710. */
  83711. value: number;
  83712. /**
  83713. * If the button/trigger is currently touched
  83714. */
  83715. touched: boolean;
  83716. /**
  83717. * If the button/trigger is currently pressed
  83718. */
  83719. pressed: boolean;
  83720. }
  83721. /**
  83722. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  83723. * @hidden
  83724. */
  83725. export interface ExtendedGamepadButton extends GamepadButton {
  83726. /**
  83727. * If the button/trigger is currently pressed
  83728. */
  83729. readonly pressed: boolean;
  83730. /**
  83731. * If the button/trigger is currently touched
  83732. */
  83733. readonly touched: boolean;
  83734. /**
  83735. * Value of the button/trigger
  83736. */
  83737. readonly value: number;
  83738. }
  83739. /** @hidden */
  83740. export interface _GamePadFactory {
  83741. /**
  83742. * Returns wether or not the current gamepad can be created for this type of controller.
  83743. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  83744. * @returns true if it can be created, otherwise false
  83745. */
  83746. canCreate(gamepadInfo: any): boolean;
  83747. /**
  83748. * Creates a new instance of the Gamepad.
  83749. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  83750. * @returns the new gamepad instance
  83751. */
  83752. create(gamepadInfo: any): Gamepad;
  83753. }
  83754. /**
  83755. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  83756. */
  83757. export class PoseEnabledControllerHelper {
  83758. /** @hidden */
  83759. static _ControllerFactories: _GamePadFactory[];
  83760. /** @hidden */
  83761. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  83762. /**
  83763. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  83764. * @param vrGamepad the gamepad to initialized
  83765. * @returns a vr controller of the type the gamepad identified as
  83766. */
  83767. static InitiateController(vrGamepad: any): Gamepad;
  83768. }
  83769. /**
  83770. * Defines the PoseEnabledController object that contains state of a vr capable controller
  83771. */
  83772. export class PoseEnabledController extends Gamepad implements PoseControlled {
  83773. /**
  83774. * If the controller is used in a webXR session
  83775. */
  83776. isXR: boolean;
  83777. private _deviceRoomPosition;
  83778. private _deviceRoomRotationQuaternion;
  83779. /**
  83780. * The device position in babylon space
  83781. */
  83782. devicePosition: Vector3;
  83783. /**
  83784. * The device rotation in babylon space
  83785. */
  83786. deviceRotationQuaternion: Quaternion;
  83787. /**
  83788. * The scale factor of the device in babylon space
  83789. */
  83790. deviceScaleFactor: number;
  83791. /**
  83792. * (Likely devicePosition should be used instead) The device position in its room space
  83793. */
  83794. position: Vector3;
  83795. /**
  83796. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  83797. */
  83798. rotationQuaternion: Quaternion;
  83799. /**
  83800. * The type of controller (Eg. Windows mixed reality)
  83801. */
  83802. controllerType: PoseEnabledControllerType;
  83803. protected _calculatedPosition: Vector3;
  83804. private _calculatedRotation;
  83805. /**
  83806. * The raw pose from the device
  83807. */
  83808. rawPose: DevicePose;
  83809. private _trackPosition;
  83810. private _maxRotationDistFromHeadset;
  83811. private _draggedRoomRotation;
  83812. /**
  83813. * @hidden
  83814. */
  83815. _disableTrackPosition(fixedPosition: Vector3): void;
  83816. /**
  83817. * Internal, the mesh attached to the controller
  83818. * @hidden
  83819. */
  83820. _mesh: Nullable<AbstractMesh>;
  83821. private _poseControlledCamera;
  83822. private _leftHandSystemQuaternion;
  83823. /**
  83824. * Internal, matrix used to convert room space to babylon space
  83825. * @hidden
  83826. */
  83827. _deviceToWorld: Matrix;
  83828. /**
  83829. * Node to be used when casting a ray from the controller
  83830. * @hidden
  83831. */
  83832. _pointingPoseNode: Nullable<TransformNode>;
  83833. /**
  83834. * Name of the child mesh that can be used to cast a ray from the controller
  83835. */
  83836. static readonly POINTING_POSE: string;
  83837. /**
  83838. * Creates a new PoseEnabledController from a gamepad
  83839. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  83840. */
  83841. constructor(browserGamepad: any);
  83842. private _workingMatrix;
  83843. /**
  83844. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  83845. */
  83846. update(): void;
  83847. /**
  83848. * Updates only the pose device and mesh without doing any button event checking
  83849. */
  83850. protected _updatePoseAndMesh(): void;
  83851. /**
  83852. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  83853. * @param poseData raw pose fromthe device
  83854. */
  83855. updateFromDevice(poseData: DevicePose): void;
  83856. /**
  83857. * @hidden
  83858. */
  83859. _meshAttachedObservable: Observable<AbstractMesh>;
  83860. /**
  83861. * Attaches a mesh to the controller
  83862. * @param mesh the mesh to be attached
  83863. */
  83864. attachToMesh(mesh: AbstractMesh): void;
  83865. /**
  83866. * Attaches the controllers mesh to a camera
  83867. * @param camera the camera the mesh should be attached to
  83868. */
  83869. attachToPoseControlledCamera(camera: TargetCamera): void;
  83870. /**
  83871. * Disposes of the controller
  83872. */
  83873. dispose(): void;
  83874. /**
  83875. * The mesh that is attached to the controller
  83876. */
  83877. readonly mesh: Nullable<AbstractMesh>;
  83878. /**
  83879. * Gets the ray of the controller in the direction the controller is pointing
  83880. * @param length the length the resulting ray should be
  83881. * @returns a ray in the direction the controller is pointing
  83882. */
  83883. getForwardRay(length?: number): Ray;
  83884. }
  83885. }
  83886. declare module BABYLON {
  83887. /**
  83888. * Defines the WebVRController object that represents controllers tracked in 3D space
  83889. */
  83890. export abstract class WebVRController extends PoseEnabledController {
  83891. /**
  83892. * Internal, the default controller model for the controller
  83893. */
  83894. protected _defaultModel: Nullable<AbstractMesh>;
  83895. /**
  83896. * Fired when the trigger state has changed
  83897. */
  83898. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  83899. /**
  83900. * Fired when the main button state has changed
  83901. */
  83902. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  83903. /**
  83904. * Fired when the secondary button state has changed
  83905. */
  83906. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  83907. /**
  83908. * Fired when the pad state has changed
  83909. */
  83910. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  83911. /**
  83912. * Fired when controllers stick values have changed
  83913. */
  83914. onPadValuesChangedObservable: Observable<StickValues>;
  83915. /**
  83916. * Array of button availible on the controller
  83917. */
  83918. protected _buttons: Array<MutableGamepadButton>;
  83919. private _onButtonStateChange;
  83920. /**
  83921. * Fired when a controller button's state has changed
  83922. * @param callback the callback containing the button that was modified
  83923. */
  83924. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  83925. /**
  83926. * X and Y axis corresponding to the controllers joystick
  83927. */
  83928. pad: StickValues;
  83929. /**
  83930. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  83931. */
  83932. hand: string;
  83933. /**
  83934. * The default controller model for the controller
  83935. */
  83936. readonly defaultModel: Nullable<AbstractMesh>;
  83937. /**
  83938. * Creates a new WebVRController from a gamepad
  83939. * @param vrGamepad the gamepad that the WebVRController should be created from
  83940. */
  83941. constructor(vrGamepad: any);
  83942. /**
  83943. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  83944. */
  83945. update(): void;
  83946. /**
  83947. * Function to be called when a button is modified
  83948. */
  83949. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  83950. /**
  83951. * Loads a mesh and attaches it to the controller
  83952. * @param scene the scene the mesh should be added to
  83953. * @param meshLoaded callback for when the mesh has been loaded
  83954. */
  83955. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  83956. private _setButtonValue;
  83957. private _changes;
  83958. private _checkChanges;
  83959. /**
  83960. * Disposes of th webVRCOntroller
  83961. */
  83962. dispose(): void;
  83963. }
  83964. }
  83965. declare module BABYLON {
  83966. /**
  83967. * The HemisphericLight simulates the ambient environment light,
  83968. * so the passed direction is the light reflection direction, not the incoming direction.
  83969. */
  83970. export class HemisphericLight extends Light {
  83971. /**
  83972. * The groundColor is the light in the opposite direction to the one specified during creation.
  83973. * 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.
  83974. */
  83975. groundColor: Color3;
  83976. /**
  83977. * The light reflection direction, not the incoming direction.
  83978. */
  83979. direction: Vector3;
  83980. /**
  83981. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  83982. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  83983. * The HemisphericLight can't cast shadows.
  83984. * Documentation : https://doc.babylonjs.com/babylon101/lights
  83985. * @param name The friendly name of the light
  83986. * @param direction The direction of the light reflection
  83987. * @param scene The scene the light belongs to
  83988. */
  83989. constructor(name: string, direction: Vector3, scene: Scene);
  83990. protected _buildUniformLayout(): void;
  83991. /**
  83992. * Returns the string "HemisphericLight".
  83993. * @return The class name
  83994. */
  83995. getClassName(): string;
  83996. /**
  83997. * Sets the HemisphericLight direction towards the passed target (Vector3).
  83998. * Returns the updated direction.
  83999. * @param target The target the direction should point to
  84000. * @return The computed direction
  84001. */
  84002. setDirectionToTarget(target: Vector3): Vector3;
  84003. /**
  84004. * Returns the shadow generator associated to the light.
  84005. * @returns Always null for hemispheric lights because it does not support shadows.
  84006. */
  84007. getShadowGenerator(): Nullable<IShadowGenerator>;
  84008. /**
  84009. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  84010. * @param effect The effect to update
  84011. * @param lightIndex The index of the light in the effect to update
  84012. * @returns The hemispheric light
  84013. */
  84014. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  84015. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  84016. /**
  84017. * Computes the world matrix of the node
  84018. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  84019. * @param useWasUpdatedFlag defines a reserved property
  84020. * @returns the world matrix
  84021. */
  84022. computeWorldMatrix(): Matrix;
  84023. /**
  84024. * Returns the integer 3.
  84025. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  84026. */
  84027. getTypeID(): number;
  84028. /**
  84029. * Prepares the list of defines specific to the light type.
  84030. * @param defines the list of defines
  84031. * @param lightIndex defines the index of the light for the effect
  84032. */
  84033. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  84034. }
  84035. }
  84036. declare module BABYLON {
  84037. /** @hidden */
  84038. export var vrMultiviewToSingleviewPixelShader: {
  84039. name: string;
  84040. shader: string;
  84041. };
  84042. }
  84043. declare module BABYLON {
  84044. /**
  84045. * Renders to multiple views with a single draw call
  84046. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  84047. */
  84048. export class MultiviewRenderTarget extends RenderTargetTexture {
  84049. /**
  84050. * Creates a multiview render target
  84051. * @param scene scene used with the render target
  84052. * @param size the size of the render target (used for each view)
  84053. */
  84054. constructor(scene: Scene, size?: number | {
  84055. width: number;
  84056. height: number;
  84057. } | {
  84058. ratio: number;
  84059. });
  84060. /**
  84061. * @hidden
  84062. * @param faceIndex the face index, if its a cube texture
  84063. */
  84064. _bindFrameBuffer(faceIndex?: number): void;
  84065. /**
  84066. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  84067. * @returns the view count
  84068. */
  84069. getViewCount(): number;
  84070. }
  84071. }
  84072. declare module BABYLON {
  84073. /**
  84074. * Represents a camera frustum
  84075. */
  84076. export class Frustum {
  84077. /**
  84078. * Gets the planes representing the frustum
  84079. * @param transform matrix to be applied to the returned planes
  84080. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  84081. */
  84082. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  84083. /**
  84084. * Gets the near frustum plane transformed by the transform matrix
  84085. * @param transform transformation matrix to be applied to the resulting frustum plane
  84086. * @param frustumPlane the resuling frustum plane
  84087. */
  84088. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  84089. /**
  84090. * Gets the far frustum plane transformed by the transform matrix
  84091. * @param transform transformation matrix to be applied to the resulting frustum plane
  84092. * @param frustumPlane the resuling frustum plane
  84093. */
  84094. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  84095. /**
  84096. * Gets the left frustum plane transformed by the transform matrix
  84097. * @param transform transformation matrix to be applied to the resulting frustum plane
  84098. * @param frustumPlane the resuling frustum plane
  84099. */
  84100. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  84101. /**
  84102. * Gets the right frustum plane transformed by the transform matrix
  84103. * @param transform transformation matrix to be applied to the resulting frustum plane
  84104. * @param frustumPlane the resuling frustum plane
  84105. */
  84106. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  84107. /**
  84108. * Gets the top frustum plane transformed by the transform matrix
  84109. * @param transform transformation matrix to be applied to the resulting frustum plane
  84110. * @param frustumPlane the resuling frustum plane
  84111. */
  84112. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  84113. /**
  84114. * Gets the bottom frustum plane transformed by the transform matrix
  84115. * @param transform transformation matrix to be applied to the resulting frustum plane
  84116. * @param frustumPlane the resuling frustum plane
  84117. */
  84118. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  84119. /**
  84120. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  84121. * @param transform transformation matrix to be applied to the resulting frustum planes
  84122. * @param frustumPlanes the resuling frustum planes
  84123. */
  84124. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  84125. }
  84126. }
  84127. declare module BABYLON {
  84128. interface Engine {
  84129. /**
  84130. * Creates a new multiview render target
  84131. * @param width defines the width of the texture
  84132. * @param height defines the height of the texture
  84133. * @returns the created multiview texture
  84134. */
  84135. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  84136. /**
  84137. * Binds a multiview framebuffer to be drawn to
  84138. * @param multiviewTexture texture to bind
  84139. */
  84140. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  84141. }
  84142. interface Camera {
  84143. /**
  84144. * @hidden
  84145. * 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)
  84146. */
  84147. _useMultiviewToSingleView: boolean;
  84148. /**
  84149. * @hidden
  84150. * 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)
  84151. */
  84152. _multiviewTexture: Nullable<RenderTargetTexture>;
  84153. /**
  84154. * @hidden
  84155. * ensures the multiview texture of the camera exists and has the specified width/height
  84156. * @param width height to set on the multiview texture
  84157. * @param height width to set on the multiview texture
  84158. */
  84159. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  84160. }
  84161. interface Scene {
  84162. /** @hidden */
  84163. _transformMatrixR: Matrix;
  84164. /** @hidden */
  84165. _multiviewSceneUbo: Nullable<UniformBuffer>;
  84166. /** @hidden */
  84167. _createMultiviewUbo(): void;
  84168. /** @hidden */
  84169. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  84170. /** @hidden */
  84171. _renderMultiviewToSingleView(camera: Camera): void;
  84172. }
  84173. }
  84174. declare module BABYLON {
  84175. /**
  84176. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  84177. * This will not be used for webXR as it supports displaying texture arrays directly
  84178. */
  84179. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  84180. /**
  84181. * Initializes a VRMultiviewToSingleview
  84182. * @param name name of the post process
  84183. * @param camera camera to be applied to
  84184. * @param scaleFactor scaling factor to the size of the output texture
  84185. */
  84186. constructor(name: string, camera: Camera, scaleFactor: number);
  84187. }
  84188. }
  84189. declare module BABYLON {
  84190. /**
  84191. * Interface used to define additional presentation attributes
  84192. */
  84193. export interface IVRPresentationAttributes {
  84194. /**
  84195. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  84196. */
  84197. highRefreshRate: boolean;
  84198. /**
  84199. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  84200. */
  84201. foveationLevel: number;
  84202. }
  84203. interface Engine {
  84204. /** @hidden */
  84205. _vrDisplay: any;
  84206. /** @hidden */
  84207. _vrSupported: boolean;
  84208. /** @hidden */
  84209. _oldSize: Size;
  84210. /** @hidden */
  84211. _oldHardwareScaleFactor: number;
  84212. /** @hidden */
  84213. _vrExclusivePointerMode: boolean;
  84214. /** @hidden */
  84215. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  84216. /** @hidden */
  84217. _onVRDisplayPointerRestricted: () => void;
  84218. /** @hidden */
  84219. _onVRDisplayPointerUnrestricted: () => void;
  84220. /** @hidden */
  84221. _onVrDisplayConnect: Nullable<(display: any) => void>;
  84222. /** @hidden */
  84223. _onVrDisplayDisconnect: Nullable<() => void>;
  84224. /** @hidden */
  84225. _onVrDisplayPresentChange: Nullable<() => void>;
  84226. /**
  84227. * Observable signaled when VR display mode changes
  84228. */
  84229. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  84230. /**
  84231. * Observable signaled when VR request present is complete
  84232. */
  84233. onVRRequestPresentComplete: Observable<boolean>;
  84234. /**
  84235. * Observable signaled when VR request present starts
  84236. */
  84237. onVRRequestPresentStart: Observable<Engine>;
  84238. /**
  84239. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  84240. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  84241. */
  84242. isInVRExclusivePointerMode: boolean;
  84243. /**
  84244. * Gets a boolean indicating if a webVR device was detected
  84245. * @returns true if a webVR device was detected
  84246. */
  84247. isVRDevicePresent(): boolean;
  84248. /**
  84249. * Gets the current webVR device
  84250. * @returns the current webVR device (or null)
  84251. */
  84252. getVRDevice(): any;
  84253. /**
  84254. * Initializes a webVR display and starts listening to display change events
  84255. * The onVRDisplayChangedObservable will be notified upon these changes
  84256. * @returns A promise containing a VRDisplay and if vr is supported
  84257. */
  84258. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  84259. /** @hidden */
  84260. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  84261. /**
  84262. * Gets or sets the presentation attributes used to configure VR rendering
  84263. */
  84264. vrPresentationAttributes?: IVRPresentationAttributes;
  84265. /**
  84266. * Call this function to switch to webVR mode
  84267. * Will do nothing if webVR is not supported or if there is no webVR device
  84268. * @param options the webvr options provided to the camera. mainly used for multiview
  84269. * @see http://doc.babylonjs.com/how_to/webvr_camera
  84270. */
  84271. enableVR(options: WebVROptions): void;
  84272. /** @hidden */
  84273. _onVRFullScreenTriggered(): void;
  84274. }
  84275. }
  84276. declare module BABYLON {
  84277. /**
  84278. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  84279. * IMPORTANT!! The data is right-hand data.
  84280. * @export
  84281. * @interface DevicePose
  84282. */
  84283. export interface DevicePose {
  84284. /**
  84285. * The position of the device, values in array are [x,y,z].
  84286. */
  84287. readonly position: Nullable<Float32Array>;
  84288. /**
  84289. * The linearVelocity of the device, values in array are [x,y,z].
  84290. */
  84291. readonly linearVelocity: Nullable<Float32Array>;
  84292. /**
  84293. * The linearAcceleration of the device, values in array are [x,y,z].
  84294. */
  84295. readonly linearAcceleration: Nullable<Float32Array>;
  84296. /**
  84297. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  84298. */
  84299. readonly orientation: Nullable<Float32Array>;
  84300. /**
  84301. * The angularVelocity of the device, values in array are [x,y,z].
  84302. */
  84303. readonly angularVelocity: Nullable<Float32Array>;
  84304. /**
  84305. * The angularAcceleration of the device, values in array are [x,y,z].
  84306. */
  84307. readonly angularAcceleration: Nullable<Float32Array>;
  84308. }
  84309. /**
  84310. * Interface representing a pose controlled object in Babylon.
  84311. * A pose controlled object has both regular pose values as well as pose values
  84312. * from an external device such as a VR head mounted display
  84313. */
  84314. export interface PoseControlled {
  84315. /**
  84316. * The position of the object in babylon space.
  84317. */
  84318. position: Vector3;
  84319. /**
  84320. * The rotation quaternion of the object in babylon space.
  84321. */
  84322. rotationQuaternion: Quaternion;
  84323. /**
  84324. * The position of the device in babylon space.
  84325. */
  84326. devicePosition?: Vector3;
  84327. /**
  84328. * The rotation quaternion of the device in babylon space.
  84329. */
  84330. deviceRotationQuaternion: Quaternion;
  84331. /**
  84332. * The raw pose coming from the device.
  84333. */
  84334. rawPose: Nullable<DevicePose>;
  84335. /**
  84336. * The scale of the device to be used when translating from device space to babylon space.
  84337. */
  84338. deviceScaleFactor: number;
  84339. /**
  84340. * Updates the poseControlled values based on the input device pose.
  84341. * @param poseData the pose data to update the object with
  84342. */
  84343. updateFromDevice(poseData: DevicePose): void;
  84344. }
  84345. /**
  84346. * Set of options to customize the webVRCamera
  84347. */
  84348. export interface WebVROptions {
  84349. /**
  84350. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  84351. */
  84352. trackPosition?: boolean;
  84353. /**
  84354. * Sets the scale of the vrDevice in babylon space. (default: 1)
  84355. */
  84356. positionScale?: number;
  84357. /**
  84358. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  84359. */
  84360. displayName?: string;
  84361. /**
  84362. * Should the native controller meshes be initialized. (default: true)
  84363. */
  84364. controllerMeshes?: boolean;
  84365. /**
  84366. * Creating a default HemiLight only on controllers. (default: true)
  84367. */
  84368. defaultLightingOnControllers?: boolean;
  84369. /**
  84370. * If you don't want to use the default VR button of the helper. (default: false)
  84371. */
  84372. useCustomVRButton?: boolean;
  84373. /**
  84374. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  84375. */
  84376. customVRButton?: HTMLButtonElement;
  84377. /**
  84378. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  84379. */
  84380. rayLength?: number;
  84381. /**
  84382. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  84383. */
  84384. defaultHeight?: number;
  84385. /**
  84386. * If multiview should be used if availible (default: false)
  84387. */
  84388. useMultiview?: boolean;
  84389. }
  84390. /**
  84391. * This represents a WebVR camera.
  84392. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  84393. * @example http://doc.babylonjs.com/how_to/webvr_camera
  84394. */
  84395. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  84396. private webVROptions;
  84397. /**
  84398. * @hidden
  84399. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  84400. */
  84401. _vrDevice: any;
  84402. /**
  84403. * The rawPose of the vrDevice.
  84404. */
  84405. rawPose: Nullable<DevicePose>;
  84406. private _onVREnabled;
  84407. private _specsVersion;
  84408. private _attached;
  84409. private _frameData;
  84410. protected _descendants: Array<Node>;
  84411. private _deviceRoomPosition;
  84412. /** @hidden */
  84413. _deviceRoomRotationQuaternion: Quaternion;
  84414. private _standingMatrix;
  84415. /**
  84416. * Represents device position in babylon space.
  84417. */
  84418. devicePosition: Vector3;
  84419. /**
  84420. * Represents device rotation in babylon space.
  84421. */
  84422. deviceRotationQuaternion: Quaternion;
  84423. /**
  84424. * The scale of the device to be used when translating from device space to babylon space.
  84425. */
  84426. deviceScaleFactor: number;
  84427. private _deviceToWorld;
  84428. private _worldToDevice;
  84429. /**
  84430. * References to the webVR controllers for the vrDevice.
  84431. */
  84432. controllers: Array<WebVRController>;
  84433. /**
  84434. * Emits an event when a controller is attached.
  84435. */
  84436. onControllersAttachedObservable: Observable<WebVRController[]>;
  84437. /**
  84438. * Emits an event when a controller's mesh has been loaded;
  84439. */
  84440. onControllerMeshLoadedObservable: Observable<WebVRController>;
  84441. /**
  84442. * Emits an event when the HMD's pose has been updated.
  84443. */
  84444. onPoseUpdatedFromDeviceObservable: Observable<any>;
  84445. private _poseSet;
  84446. /**
  84447. * If the rig cameras be used as parent instead of this camera.
  84448. */
  84449. rigParenting: boolean;
  84450. private _lightOnControllers;
  84451. private _defaultHeight?;
  84452. /**
  84453. * Instantiates a WebVRFreeCamera.
  84454. * @param name The name of the WebVRFreeCamera
  84455. * @param position The starting anchor position for the camera
  84456. * @param scene The scene the camera belongs to
  84457. * @param webVROptions a set of customizable options for the webVRCamera
  84458. */
  84459. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  84460. /**
  84461. * Gets the device distance from the ground in meters.
  84462. * @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.
  84463. */
  84464. deviceDistanceToRoomGround(): number;
  84465. /**
  84466. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  84467. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  84468. */
  84469. useStandingMatrix(callback?: (bool: boolean) => void): void;
  84470. /**
  84471. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  84472. * @returns A promise with a boolean set to if the standing matrix is supported.
  84473. */
  84474. useStandingMatrixAsync(): Promise<boolean>;
  84475. /**
  84476. * Disposes the camera
  84477. */
  84478. dispose(): void;
  84479. /**
  84480. * Gets a vrController by name.
  84481. * @param name The name of the controller to retreive
  84482. * @returns the controller matching the name specified or null if not found
  84483. */
  84484. getControllerByName(name: string): Nullable<WebVRController>;
  84485. private _leftController;
  84486. /**
  84487. * The controller corresponding to the users left hand.
  84488. */
  84489. readonly leftController: Nullable<WebVRController>;
  84490. private _rightController;
  84491. /**
  84492. * The controller corresponding to the users right hand.
  84493. */
  84494. readonly rightController: Nullable<WebVRController>;
  84495. /**
  84496. * Casts a ray forward from the vrCamera's gaze.
  84497. * @param length Length of the ray (default: 100)
  84498. * @returns the ray corresponding to the gaze
  84499. */
  84500. getForwardRay(length?: number): Ray;
  84501. /**
  84502. * @hidden
  84503. * Updates the camera based on device's frame data
  84504. */
  84505. _checkInputs(): void;
  84506. /**
  84507. * Updates the poseControlled values based on the input device pose.
  84508. * @param poseData Pose coming from the device
  84509. */
  84510. updateFromDevice(poseData: DevicePose): void;
  84511. private _htmlElementAttached;
  84512. private _detachIfAttached;
  84513. /**
  84514. * WebVR's attach control will start broadcasting frames to the device.
  84515. * Note that in certain browsers (chrome for example) this function must be called
  84516. * within a user-interaction callback. Example:
  84517. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  84518. *
  84519. * @param element html element to attach the vrDevice to
  84520. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  84521. */
  84522. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  84523. /**
  84524. * Detaches the camera from the html element and disables VR
  84525. *
  84526. * @param element html element to detach from
  84527. */
  84528. detachControl(element: HTMLElement): void;
  84529. /**
  84530. * @returns the name of this class
  84531. */
  84532. getClassName(): string;
  84533. /**
  84534. * Calls resetPose on the vrDisplay
  84535. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  84536. */
  84537. resetToCurrentRotation(): void;
  84538. /**
  84539. * @hidden
  84540. * Updates the rig cameras (left and right eye)
  84541. */
  84542. _updateRigCameras(): void;
  84543. private _workingVector;
  84544. private _oneVector;
  84545. private _workingMatrix;
  84546. private updateCacheCalled;
  84547. private _correctPositionIfNotTrackPosition;
  84548. /**
  84549. * @hidden
  84550. * Updates the cached values of the camera
  84551. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  84552. */
  84553. _updateCache(ignoreParentClass?: boolean): void;
  84554. /**
  84555. * @hidden
  84556. * Get current device position in babylon world
  84557. */
  84558. _computeDevicePosition(): void;
  84559. /**
  84560. * Updates the current device position and rotation in the babylon world
  84561. */
  84562. update(): void;
  84563. /**
  84564. * @hidden
  84565. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  84566. * @returns an identity matrix
  84567. */
  84568. _getViewMatrix(): Matrix;
  84569. private _tmpMatrix;
  84570. /**
  84571. * This function is called by the two RIG cameras.
  84572. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  84573. * @hidden
  84574. */
  84575. _getWebVRViewMatrix(): Matrix;
  84576. /** @hidden */
  84577. _getWebVRProjectionMatrix(): Matrix;
  84578. private _onGamepadConnectedObserver;
  84579. private _onGamepadDisconnectedObserver;
  84580. private _updateCacheWhenTrackingDisabledObserver;
  84581. /**
  84582. * Initializes the controllers and their meshes
  84583. */
  84584. initControllers(): void;
  84585. }
  84586. }
  84587. declare module BABYLON {
  84588. /**
  84589. * Size options for a post process
  84590. */
  84591. export type PostProcessOptions = {
  84592. width: number;
  84593. height: number;
  84594. };
  84595. /**
  84596. * PostProcess can be used to apply a shader to a texture after it has been rendered
  84597. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  84598. */
  84599. export class PostProcess {
  84600. /** Name of the PostProcess. */
  84601. name: string;
  84602. /**
  84603. * Gets or sets the unique id of the post process
  84604. */
  84605. uniqueId: number;
  84606. /**
  84607. * Width of the texture to apply the post process on
  84608. */
  84609. width: number;
  84610. /**
  84611. * Height of the texture to apply the post process on
  84612. */
  84613. height: number;
  84614. /**
  84615. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  84616. * @hidden
  84617. */
  84618. _outputTexture: Nullable<InternalTexture>;
  84619. /**
  84620. * Sampling mode used by the shader
  84621. * See https://doc.babylonjs.com/classes/3.1/texture
  84622. */
  84623. renderTargetSamplingMode: number;
  84624. /**
  84625. * Clear color to use when screen clearing
  84626. */
  84627. clearColor: Color4;
  84628. /**
  84629. * If the buffer needs to be cleared before applying the post process. (default: true)
  84630. * Should be set to false if shader will overwrite all previous pixels.
  84631. */
  84632. autoClear: boolean;
  84633. /**
  84634. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  84635. */
  84636. alphaMode: number;
  84637. /**
  84638. * Sets the setAlphaBlendConstants of the babylon engine
  84639. */
  84640. alphaConstants: Color4;
  84641. /**
  84642. * Animations to be used for the post processing
  84643. */
  84644. animations: Animation[];
  84645. /**
  84646. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  84647. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  84648. */
  84649. enablePixelPerfectMode: boolean;
  84650. /**
  84651. * Force the postprocess to be applied without taking in account viewport
  84652. */
  84653. forceFullscreenViewport: boolean;
  84654. /**
  84655. * List of inspectable custom properties (used by the Inspector)
  84656. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  84657. */
  84658. inspectableCustomProperties: IInspectable[];
  84659. /**
  84660. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  84661. *
  84662. * | Value | Type | Description |
  84663. * | ----- | ----------------------------------- | ----------- |
  84664. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  84665. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  84666. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  84667. *
  84668. */
  84669. scaleMode: number;
  84670. /**
  84671. * Force textures to be a power of two (default: false)
  84672. */
  84673. alwaysForcePOT: boolean;
  84674. private _samples;
  84675. /**
  84676. * Number of sample textures (default: 1)
  84677. */
  84678. samples: number;
  84679. /**
  84680. * Modify the scale of the post process to be the same as the viewport (default: false)
  84681. */
  84682. adaptScaleToCurrentViewport: boolean;
  84683. private _camera;
  84684. private _scene;
  84685. private _engine;
  84686. private _options;
  84687. private _reusable;
  84688. private _textureType;
  84689. /**
  84690. * Smart array of input and output textures for the post process.
  84691. * @hidden
  84692. */
  84693. _textures: SmartArray<InternalTexture>;
  84694. /**
  84695. * The index in _textures that corresponds to the output texture.
  84696. * @hidden
  84697. */
  84698. _currentRenderTextureInd: number;
  84699. private _effect;
  84700. private _samplers;
  84701. private _fragmentUrl;
  84702. private _vertexUrl;
  84703. private _parameters;
  84704. private _scaleRatio;
  84705. protected _indexParameters: any;
  84706. private _shareOutputWithPostProcess;
  84707. private _texelSize;
  84708. private _forcedOutputTexture;
  84709. /**
  84710. * Returns the fragment url or shader name used in the post process.
  84711. * @returns the fragment url or name in the shader store.
  84712. */
  84713. getEffectName(): string;
  84714. /**
  84715. * An event triggered when the postprocess is activated.
  84716. */
  84717. onActivateObservable: Observable<Camera>;
  84718. private _onActivateObserver;
  84719. /**
  84720. * A function that is added to the onActivateObservable
  84721. */
  84722. onActivate: Nullable<(camera: Camera) => void>;
  84723. /**
  84724. * An event triggered when the postprocess changes its size.
  84725. */
  84726. onSizeChangedObservable: Observable<PostProcess>;
  84727. private _onSizeChangedObserver;
  84728. /**
  84729. * A function that is added to the onSizeChangedObservable
  84730. */
  84731. onSizeChanged: (postProcess: PostProcess) => void;
  84732. /**
  84733. * An event triggered when the postprocess applies its effect.
  84734. */
  84735. onApplyObservable: Observable<Effect>;
  84736. private _onApplyObserver;
  84737. /**
  84738. * A function that is added to the onApplyObservable
  84739. */
  84740. onApply: (effect: Effect) => void;
  84741. /**
  84742. * An event triggered before rendering the postprocess
  84743. */
  84744. onBeforeRenderObservable: Observable<Effect>;
  84745. private _onBeforeRenderObserver;
  84746. /**
  84747. * A function that is added to the onBeforeRenderObservable
  84748. */
  84749. onBeforeRender: (effect: Effect) => void;
  84750. /**
  84751. * An event triggered after rendering the postprocess
  84752. */
  84753. onAfterRenderObservable: Observable<Effect>;
  84754. private _onAfterRenderObserver;
  84755. /**
  84756. * A function that is added to the onAfterRenderObservable
  84757. */
  84758. onAfterRender: (efect: Effect) => void;
  84759. /**
  84760. * 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
  84761. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  84762. */
  84763. inputTexture: InternalTexture;
  84764. /**
  84765. * Gets the camera which post process is applied to.
  84766. * @returns The camera the post process is applied to.
  84767. */
  84768. getCamera(): Camera;
  84769. /**
  84770. * Gets the texel size of the postprocess.
  84771. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  84772. */
  84773. readonly texelSize: Vector2;
  84774. /**
  84775. * Creates a new instance PostProcess
  84776. * @param name The name of the PostProcess.
  84777. * @param fragmentUrl The url of the fragment shader to be used.
  84778. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  84779. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  84780. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  84781. * @param camera The camera to apply the render pass to.
  84782. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  84783. * @param engine The engine which the post process will be applied. (default: current engine)
  84784. * @param reusable If the post process can be reused on the same frame. (default: false)
  84785. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  84786. * @param textureType Type of textures used when performing the post process. (default: 0)
  84787. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  84788. * @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
  84789. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  84790. */
  84791. constructor(
  84792. /** Name of the PostProcess. */
  84793. 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);
  84794. /**
  84795. * Gets a string idenfifying the name of the class
  84796. * @returns "PostProcess" string
  84797. */
  84798. getClassName(): string;
  84799. /**
  84800. * Gets the engine which this post process belongs to.
  84801. * @returns The engine the post process was enabled with.
  84802. */
  84803. getEngine(): Engine;
  84804. /**
  84805. * The effect that is created when initializing the post process.
  84806. * @returns The created effect corresponding the the postprocess.
  84807. */
  84808. getEffect(): Effect;
  84809. /**
  84810. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  84811. * @param postProcess The post process to share the output with.
  84812. * @returns This post process.
  84813. */
  84814. shareOutputWith(postProcess: PostProcess): PostProcess;
  84815. /**
  84816. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  84817. * This should be called if the post process that shares output with this post process is disabled/disposed.
  84818. */
  84819. useOwnOutput(): void;
  84820. /**
  84821. * Updates the effect with the current post process compile time values and recompiles the shader.
  84822. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  84823. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  84824. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  84825. * @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
  84826. * @param onCompiled Called when the shader has been compiled.
  84827. * @param onError Called if there is an error when compiling a shader.
  84828. */
  84829. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  84830. /**
  84831. * The post process is reusable if it can be used multiple times within one frame.
  84832. * @returns If the post process is reusable
  84833. */
  84834. isReusable(): boolean;
  84835. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  84836. markTextureDirty(): void;
  84837. /**
  84838. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  84839. * 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.
  84840. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  84841. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  84842. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  84843. * @returns The target texture that was bound to be written to.
  84844. */
  84845. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  84846. /**
  84847. * If the post process is supported.
  84848. */
  84849. readonly isSupported: boolean;
  84850. /**
  84851. * The aspect ratio of the output texture.
  84852. */
  84853. readonly aspectRatio: number;
  84854. /**
  84855. * Get a value indicating if the post-process is ready to be used
  84856. * @returns true if the post-process is ready (shader is compiled)
  84857. */
  84858. isReady(): boolean;
  84859. /**
  84860. * Binds all textures and uniforms to the shader, this will be run on every pass.
  84861. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  84862. */
  84863. apply(): Nullable<Effect>;
  84864. private _disposeTextures;
  84865. /**
  84866. * Disposes the post process.
  84867. * @param camera The camera to dispose the post process on.
  84868. */
  84869. dispose(camera?: Camera): void;
  84870. }
  84871. }
  84872. declare module BABYLON {
  84873. /** @hidden */
  84874. export var kernelBlurVaryingDeclaration: {
  84875. name: string;
  84876. shader: string;
  84877. };
  84878. }
  84879. declare module BABYLON {
  84880. /** @hidden */
  84881. export var kernelBlurFragment: {
  84882. name: string;
  84883. shader: string;
  84884. };
  84885. }
  84886. declare module BABYLON {
  84887. /** @hidden */
  84888. export var kernelBlurFragment2: {
  84889. name: string;
  84890. shader: string;
  84891. };
  84892. }
  84893. declare module BABYLON {
  84894. /** @hidden */
  84895. export var kernelBlurPixelShader: {
  84896. name: string;
  84897. shader: string;
  84898. };
  84899. }
  84900. declare module BABYLON {
  84901. /** @hidden */
  84902. export var kernelBlurVertex: {
  84903. name: string;
  84904. shader: string;
  84905. };
  84906. }
  84907. declare module BABYLON {
  84908. /** @hidden */
  84909. export var kernelBlurVertexShader: {
  84910. name: string;
  84911. shader: string;
  84912. };
  84913. }
  84914. declare module BABYLON {
  84915. /**
  84916. * The Blur Post Process which blurs an image based on a kernel and direction.
  84917. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  84918. */
  84919. export class BlurPostProcess extends PostProcess {
  84920. /** The direction in which to blur the image. */
  84921. direction: Vector2;
  84922. private blockCompilation;
  84923. protected _kernel: number;
  84924. protected _idealKernel: number;
  84925. protected _packedFloat: boolean;
  84926. private _staticDefines;
  84927. /**
  84928. * Sets the length in pixels of the blur sample region
  84929. */
  84930. /**
  84931. * Gets the length in pixels of the blur sample region
  84932. */
  84933. kernel: number;
  84934. /**
  84935. * Sets wether or not the blur needs to unpack/repack floats
  84936. */
  84937. /**
  84938. * Gets wether or not the blur is unpacking/repacking floats
  84939. */
  84940. packedFloat: boolean;
  84941. /**
  84942. * Creates a new instance BlurPostProcess
  84943. * @param name The name of the effect.
  84944. * @param direction The direction in which to blur the image.
  84945. * @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.
  84946. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  84947. * @param camera The camera to apply the render pass to.
  84948. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  84949. * @param engine The engine which the post process will be applied. (default: current engine)
  84950. * @param reusable If the post process can be reused on the same frame. (default: false)
  84951. * @param textureType Type of textures used when performing the post process. (default: 0)
  84952. * @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)
  84953. */
  84954. constructor(name: string,
  84955. /** The direction in which to blur the image. */
  84956. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  84957. /**
  84958. * Updates the effect with the current post process compile time values and recompiles the shader.
  84959. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  84960. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  84961. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  84962. * @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
  84963. * @param onCompiled Called when the shader has been compiled.
  84964. * @param onError Called if there is an error when compiling a shader.
  84965. */
  84966. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  84967. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  84968. /**
  84969. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  84970. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  84971. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  84972. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  84973. * The gaps between physical kernels are compensated for in the weighting of the samples
  84974. * @param idealKernel Ideal blur kernel.
  84975. * @return Nearest best kernel.
  84976. */
  84977. protected _nearestBestKernel(idealKernel: number): number;
  84978. /**
  84979. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  84980. * @param x The point on the Gaussian distribution to sample.
  84981. * @return the value of the Gaussian function at x.
  84982. */
  84983. protected _gaussianWeight(x: number): number;
  84984. /**
  84985. * Generates a string that can be used as a floating point number in GLSL.
  84986. * @param x Value to print.
  84987. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  84988. * @return GLSL float string.
  84989. */
  84990. protected _glslFloat(x: number, decimalFigures?: number): string;
  84991. }
  84992. }
  84993. declare module BABYLON {
  84994. /**
  84995. * Mirror texture can be used to simulate the view from a mirror in a scene.
  84996. * It will dynamically be rendered every frame to adapt to the camera point of view.
  84997. * You can then easily use it as a reflectionTexture on a flat surface.
  84998. * In case the surface is not a plane, please consider relying on reflection probes.
  84999. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  85000. */
  85001. export class MirrorTexture extends RenderTargetTexture {
  85002. private scene;
  85003. /**
  85004. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  85005. * 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.
  85006. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  85007. */
  85008. mirrorPlane: Plane;
  85009. /**
  85010. * Define the blur ratio used to blur the reflection if needed.
  85011. */
  85012. blurRatio: number;
  85013. /**
  85014. * Define the adaptive blur kernel used to blur the reflection if needed.
  85015. * This will autocompute the closest best match for the `blurKernel`
  85016. */
  85017. adaptiveBlurKernel: number;
  85018. /**
  85019. * Define the blur kernel used to blur the reflection if needed.
  85020. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  85021. */
  85022. blurKernel: number;
  85023. /**
  85024. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  85025. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  85026. */
  85027. blurKernelX: number;
  85028. /**
  85029. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  85030. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  85031. */
  85032. blurKernelY: number;
  85033. private _autoComputeBlurKernel;
  85034. protected _onRatioRescale(): void;
  85035. private _updateGammaSpace;
  85036. private _imageProcessingConfigChangeObserver;
  85037. private _transformMatrix;
  85038. private _mirrorMatrix;
  85039. private _savedViewMatrix;
  85040. private _blurX;
  85041. private _blurY;
  85042. private _adaptiveBlurKernel;
  85043. private _blurKernelX;
  85044. private _blurKernelY;
  85045. private _blurRatio;
  85046. /**
  85047. * Instantiates a Mirror Texture.
  85048. * Mirror texture can be used to simulate the view from a mirror in a scene.
  85049. * It will dynamically be rendered every frame to adapt to the camera point of view.
  85050. * You can then easily use it as a reflectionTexture on a flat surface.
  85051. * In case the surface is not a plane, please consider relying on reflection probes.
  85052. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  85053. * @param name
  85054. * @param size
  85055. * @param scene
  85056. * @param generateMipMaps
  85057. * @param type
  85058. * @param samplingMode
  85059. * @param generateDepthBuffer
  85060. */
  85061. constructor(name: string, size: number | {
  85062. width: number;
  85063. height: number;
  85064. } | {
  85065. ratio: number;
  85066. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  85067. private _preparePostProcesses;
  85068. /**
  85069. * Clone the mirror texture.
  85070. * @returns the cloned texture
  85071. */
  85072. clone(): MirrorTexture;
  85073. /**
  85074. * Serialize the texture to a JSON representation you could use in Parse later on
  85075. * @returns the serialized JSON representation
  85076. */
  85077. serialize(): any;
  85078. /**
  85079. * Dispose the texture and release its associated resources.
  85080. */
  85081. dispose(): void;
  85082. }
  85083. }
  85084. declare module BABYLON {
  85085. /**
  85086. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  85087. * @see http://doc.babylonjs.com/babylon101/materials#texture
  85088. */
  85089. export class Texture extends BaseTexture {
  85090. /**
  85091. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  85092. */
  85093. static SerializeBuffers: boolean;
  85094. /** @hidden */
  85095. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  85096. /** @hidden */
  85097. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  85098. /** @hidden */
  85099. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  85100. /** nearest is mag = nearest and min = nearest and mip = linear */
  85101. static readonly NEAREST_SAMPLINGMODE: number;
  85102. /** nearest is mag = nearest and min = nearest and mip = linear */
  85103. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  85104. /** Bilinear is mag = linear and min = linear and mip = nearest */
  85105. static readonly BILINEAR_SAMPLINGMODE: number;
  85106. /** Bilinear is mag = linear and min = linear and mip = nearest */
  85107. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  85108. /** Trilinear is mag = linear and min = linear and mip = linear */
  85109. static readonly TRILINEAR_SAMPLINGMODE: number;
  85110. /** Trilinear is mag = linear and min = linear and mip = linear */
  85111. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  85112. /** mag = nearest and min = nearest and mip = nearest */
  85113. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  85114. /** mag = nearest and min = linear and mip = nearest */
  85115. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  85116. /** mag = nearest and min = linear and mip = linear */
  85117. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  85118. /** mag = nearest and min = linear and mip = none */
  85119. static readonly NEAREST_LINEAR: number;
  85120. /** mag = nearest and min = nearest and mip = none */
  85121. static readonly NEAREST_NEAREST: number;
  85122. /** mag = linear and min = nearest and mip = nearest */
  85123. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  85124. /** mag = linear and min = nearest and mip = linear */
  85125. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  85126. /** mag = linear and min = linear and mip = none */
  85127. static readonly LINEAR_LINEAR: number;
  85128. /** mag = linear and min = nearest and mip = none */
  85129. static readonly LINEAR_NEAREST: number;
  85130. /** Explicit coordinates mode */
  85131. static readonly EXPLICIT_MODE: number;
  85132. /** Spherical coordinates mode */
  85133. static readonly SPHERICAL_MODE: number;
  85134. /** Planar coordinates mode */
  85135. static readonly PLANAR_MODE: number;
  85136. /** Cubic coordinates mode */
  85137. static readonly CUBIC_MODE: number;
  85138. /** Projection coordinates mode */
  85139. static readonly PROJECTION_MODE: number;
  85140. /** Inverse Cubic coordinates mode */
  85141. static readonly SKYBOX_MODE: number;
  85142. /** Inverse Cubic coordinates mode */
  85143. static readonly INVCUBIC_MODE: number;
  85144. /** Equirectangular coordinates mode */
  85145. static readonly EQUIRECTANGULAR_MODE: number;
  85146. /** Equirectangular Fixed coordinates mode */
  85147. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  85148. /** Equirectangular Fixed Mirrored coordinates mode */
  85149. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  85150. /** Texture is not repeating outside of 0..1 UVs */
  85151. static readonly CLAMP_ADDRESSMODE: number;
  85152. /** Texture is repeating outside of 0..1 UVs */
  85153. static readonly WRAP_ADDRESSMODE: number;
  85154. /** Texture is repeating and mirrored */
  85155. static readonly MIRROR_ADDRESSMODE: number;
  85156. /**
  85157. * 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
  85158. */
  85159. static UseSerializedUrlIfAny: boolean;
  85160. /**
  85161. * Define the url of the texture.
  85162. */
  85163. url: Nullable<string>;
  85164. /**
  85165. * Define an offset on the texture to offset the u coordinates of the UVs
  85166. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  85167. */
  85168. uOffset: number;
  85169. /**
  85170. * Define an offset on the texture to offset the v coordinates of the UVs
  85171. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  85172. */
  85173. vOffset: number;
  85174. /**
  85175. * Define an offset on the texture to scale the u coordinates of the UVs
  85176. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  85177. */
  85178. uScale: number;
  85179. /**
  85180. * Define an offset on the texture to scale the v coordinates of the UVs
  85181. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  85182. */
  85183. vScale: number;
  85184. /**
  85185. * Define an offset on the texture to rotate around the u coordinates of the UVs
  85186. * @see http://doc.babylonjs.com/how_to/more_materials
  85187. */
  85188. uAng: number;
  85189. /**
  85190. * Define an offset on the texture to rotate around the v coordinates of the UVs
  85191. * @see http://doc.babylonjs.com/how_to/more_materials
  85192. */
  85193. vAng: number;
  85194. /**
  85195. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  85196. * @see http://doc.babylonjs.com/how_to/more_materials
  85197. */
  85198. wAng: number;
  85199. /**
  85200. * Defines the center of rotation (U)
  85201. */
  85202. uRotationCenter: number;
  85203. /**
  85204. * Defines the center of rotation (V)
  85205. */
  85206. vRotationCenter: number;
  85207. /**
  85208. * Defines the center of rotation (W)
  85209. */
  85210. wRotationCenter: number;
  85211. /**
  85212. * Are mip maps generated for this texture or not.
  85213. */
  85214. readonly noMipmap: boolean;
  85215. /**
  85216. * List of inspectable custom properties (used by the Inspector)
  85217. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  85218. */
  85219. inspectableCustomProperties: Nullable<IInspectable[]>;
  85220. private _noMipmap;
  85221. /** @hidden */
  85222. _invertY: boolean;
  85223. private _rowGenerationMatrix;
  85224. private _cachedTextureMatrix;
  85225. private _projectionModeMatrix;
  85226. private _t0;
  85227. private _t1;
  85228. private _t2;
  85229. private _cachedUOffset;
  85230. private _cachedVOffset;
  85231. private _cachedUScale;
  85232. private _cachedVScale;
  85233. private _cachedUAng;
  85234. private _cachedVAng;
  85235. private _cachedWAng;
  85236. private _cachedProjectionMatrixId;
  85237. private _cachedCoordinatesMode;
  85238. /** @hidden */
  85239. protected _initialSamplingMode: number;
  85240. /** @hidden */
  85241. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  85242. private _deleteBuffer;
  85243. protected _format: Nullable<number>;
  85244. private _delayedOnLoad;
  85245. private _delayedOnError;
  85246. private _mimeType?;
  85247. /**
  85248. * Observable triggered once the texture has been loaded.
  85249. */
  85250. onLoadObservable: Observable<Texture>;
  85251. protected _isBlocking: boolean;
  85252. /**
  85253. * Is the texture preventing material to render while loading.
  85254. * If false, a default texture will be used instead of the loading one during the preparation step.
  85255. */
  85256. isBlocking: boolean;
  85257. /**
  85258. * Get the current sampling mode associated with the texture.
  85259. */
  85260. readonly samplingMode: number;
  85261. /**
  85262. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  85263. */
  85264. readonly invertY: boolean;
  85265. /**
  85266. * Instantiates a new texture.
  85267. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  85268. * @see http://doc.babylonjs.com/babylon101/materials#texture
  85269. * @param url defines the url of the picture to load as a texture
  85270. * @param scene defines the scene or engine the texture will belong to
  85271. * @param noMipmap defines if the texture will require mip maps or not
  85272. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  85273. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  85274. * @param onLoad defines a callback triggered when the texture has been loaded
  85275. * @param onError defines a callback triggered when an error occurred during the loading session
  85276. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  85277. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  85278. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  85279. * @param mimeType defines an optional mime type information
  85280. */
  85281. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string);
  85282. /**
  85283. * Update the url (and optional buffer) of this texture if url was null during construction.
  85284. * @param url the url of the texture
  85285. * @param buffer the buffer of the texture (defaults to null)
  85286. * @param onLoad callback called when the texture is loaded (defaults to null)
  85287. */
  85288. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  85289. /**
  85290. * Finish the loading sequence of a texture flagged as delayed load.
  85291. * @hidden
  85292. */
  85293. delayLoad(): void;
  85294. private _prepareRowForTextureGeneration;
  85295. /**
  85296. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  85297. * @returns the transform matrix of the texture.
  85298. */
  85299. getTextureMatrix(uBase?: number): Matrix;
  85300. /**
  85301. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  85302. * @returns The reflection texture transform
  85303. */
  85304. getReflectionTextureMatrix(): Matrix;
  85305. /**
  85306. * Clones the texture.
  85307. * @returns the cloned texture
  85308. */
  85309. clone(): Texture;
  85310. /**
  85311. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  85312. * @returns The JSON representation of the texture
  85313. */
  85314. serialize(): any;
  85315. /**
  85316. * Get the current class name of the texture useful for serialization or dynamic coding.
  85317. * @returns "Texture"
  85318. */
  85319. getClassName(): string;
  85320. /**
  85321. * Dispose the texture and release its associated resources.
  85322. */
  85323. dispose(): void;
  85324. /**
  85325. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  85326. * @param parsedTexture Define the JSON representation of the texture
  85327. * @param scene Define the scene the parsed texture should be instantiated in
  85328. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  85329. * @returns The parsed texture if successful
  85330. */
  85331. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  85332. /**
  85333. * Creates a texture from its base 64 representation.
  85334. * @param data Define the base64 payload without the data: prefix
  85335. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  85336. * @param scene Define the scene the texture should belong to
  85337. * @param noMipmap Forces the texture to not create mip map information if true
  85338. * @param invertY define if the texture needs to be inverted on the y axis during loading
  85339. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  85340. * @param onLoad define a callback triggered when the texture has been loaded
  85341. * @param onError define a callback triggered when an error occurred during the loading session
  85342. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  85343. * @returns the created texture
  85344. */
  85345. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  85346. /**
  85347. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  85348. * @param data Define the base64 payload without the data: prefix
  85349. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  85350. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  85351. * @param scene Define the scene the texture should belong to
  85352. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  85353. * @param noMipmap Forces the texture to not create mip map information if true
  85354. * @param invertY define if the texture needs to be inverted on the y axis during loading
  85355. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  85356. * @param onLoad define a callback triggered when the texture has been loaded
  85357. * @param onError define a callback triggered when an error occurred during the loading session
  85358. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  85359. * @returns the created texture
  85360. */
  85361. 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;
  85362. }
  85363. }
  85364. declare module BABYLON {
  85365. /**
  85366. * PostProcessManager is used to manage one or more post processes or post process pipelines
  85367. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  85368. */
  85369. export class PostProcessManager {
  85370. private _scene;
  85371. private _indexBuffer;
  85372. private _vertexBuffers;
  85373. /**
  85374. * Creates a new instance PostProcess
  85375. * @param scene The scene that the post process is associated with.
  85376. */
  85377. constructor(scene: Scene);
  85378. private _prepareBuffers;
  85379. private _buildIndexBuffer;
  85380. /**
  85381. * Rebuilds the vertex buffers of the manager.
  85382. * @hidden
  85383. */
  85384. _rebuild(): void;
  85385. /**
  85386. * Prepares a frame to be run through a post process.
  85387. * @param sourceTexture The input texture to the post procesess. (default: null)
  85388. * @param postProcesses An array of post processes to be run. (default: null)
  85389. * @returns True if the post processes were able to be run.
  85390. * @hidden
  85391. */
  85392. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  85393. /**
  85394. * Manually render a set of post processes to a texture.
  85395. * @param postProcesses An array of post processes to be run.
  85396. * @param targetTexture The target texture to render to.
  85397. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  85398. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  85399. * @param lodLevel defines which lod of the texture to render to
  85400. */
  85401. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  85402. /**
  85403. * Finalize the result of the output of the postprocesses.
  85404. * @param doNotPresent If true the result will not be displayed to the screen.
  85405. * @param targetTexture The target texture to render to.
  85406. * @param faceIndex The index of the face to bind the target texture to.
  85407. * @param postProcesses The array of post processes to render.
  85408. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  85409. * @hidden
  85410. */
  85411. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  85412. /**
  85413. * Disposes of the post process manager.
  85414. */
  85415. dispose(): void;
  85416. }
  85417. }
  85418. declare module BABYLON {
  85419. /** Interface used by value gradients (color, factor, ...) */
  85420. export interface IValueGradient {
  85421. /**
  85422. * Gets or sets the gradient value (between 0 and 1)
  85423. */
  85424. gradient: number;
  85425. }
  85426. /** Class used to store color4 gradient */
  85427. export class ColorGradient implements IValueGradient {
  85428. /**
  85429. * Gets or sets the gradient value (between 0 and 1)
  85430. */
  85431. gradient: number;
  85432. /**
  85433. * Gets or sets first associated color
  85434. */
  85435. color1: Color4;
  85436. /**
  85437. * Gets or sets second associated color
  85438. */
  85439. color2?: Color4;
  85440. /**
  85441. * Will get a color picked randomly between color1 and color2.
  85442. * If color2 is undefined then color1 will be used
  85443. * @param result defines the target Color4 to store the result in
  85444. */
  85445. getColorToRef(result: Color4): void;
  85446. }
  85447. /** Class used to store color 3 gradient */
  85448. export class Color3Gradient implements IValueGradient {
  85449. /**
  85450. * Gets or sets the gradient value (between 0 and 1)
  85451. */
  85452. gradient: number;
  85453. /**
  85454. * Gets or sets the associated color
  85455. */
  85456. color: Color3;
  85457. }
  85458. /** Class used to store factor gradient */
  85459. export class FactorGradient implements IValueGradient {
  85460. /**
  85461. * Gets or sets the gradient value (between 0 and 1)
  85462. */
  85463. gradient: number;
  85464. /**
  85465. * Gets or sets first associated factor
  85466. */
  85467. factor1: number;
  85468. /**
  85469. * Gets or sets second associated factor
  85470. */
  85471. factor2?: number;
  85472. /**
  85473. * Will get a number picked randomly between factor1 and factor2.
  85474. * If factor2 is undefined then factor1 will be used
  85475. * @returns the picked number
  85476. */
  85477. getFactor(): number;
  85478. }
  85479. /**
  85480. * Helper used to simplify some generic gradient tasks
  85481. */
  85482. export class GradientHelper {
  85483. /**
  85484. * Gets the current gradient from an array of IValueGradient
  85485. * @param ratio defines the current ratio to get
  85486. * @param gradients defines the array of IValueGradient
  85487. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  85488. */
  85489. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  85490. }
  85491. }
  85492. declare module BABYLON {
  85493. interface ThinEngine {
  85494. /**
  85495. * Creates a dynamic texture
  85496. * @param width defines the width of the texture
  85497. * @param height defines the height of the texture
  85498. * @param generateMipMaps defines if the engine should generate the mip levels
  85499. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  85500. * @returns the dynamic texture inside an InternalTexture
  85501. */
  85502. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  85503. /**
  85504. * Update the content of a dynamic texture
  85505. * @param texture defines the texture to update
  85506. * @param canvas defines the canvas containing the source
  85507. * @param invertY defines if data must be stored with Y axis inverted
  85508. * @param premulAlpha defines if alpha is stored as premultiplied
  85509. * @param format defines the format of the data
  85510. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  85511. */
  85512. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  85513. }
  85514. }
  85515. declare module BABYLON {
  85516. /**
  85517. * Helper class used to generate a canvas to manipulate images
  85518. */
  85519. export class CanvasGenerator {
  85520. /**
  85521. * Create a new canvas (or offscreen canvas depending on the context)
  85522. * @param width defines the expected width
  85523. * @param height defines the expected height
  85524. * @return a new canvas or offscreen canvas
  85525. */
  85526. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  85527. }
  85528. }
  85529. declare module BABYLON {
  85530. /**
  85531. * A class extending Texture allowing drawing on a texture
  85532. * @see http://doc.babylonjs.com/how_to/dynamictexture
  85533. */
  85534. export class DynamicTexture extends Texture {
  85535. private _generateMipMaps;
  85536. private _canvas;
  85537. private _context;
  85538. private _engine;
  85539. /**
  85540. * Creates a DynamicTexture
  85541. * @param name defines the name of the texture
  85542. * @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
  85543. * @param scene defines the scene where you want the texture
  85544. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  85545. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  85546. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  85547. */
  85548. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  85549. /**
  85550. * Get the current class name of the texture useful for serialization or dynamic coding.
  85551. * @returns "DynamicTexture"
  85552. */
  85553. getClassName(): string;
  85554. /**
  85555. * Gets the current state of canRescale
  85556. */
  85557. readonly canRescale: boolean;
  85558. private _recreate;
  85559. /**
  85560. * Scales the texture
  85561. * @param ratio the scale factor to apply to both width and height
  85562. */
  85563. scale(ratio: number): void;
  85564. /**
  85565. * Resizes the texture
  85566. * @param width the new width
  85567. * @param height the new height
  85568. */
  85569. scaleTo(width: number, height: number): void;
  85570. /**
  85571. * Gets the context of the canvas used by the texture
  85572. * @returns the canvas context of the dynamic texture
  85573. */
  85574. getContext(): CanvasRenderingContext2D;
  85575. /**
  85576. * Clears the texture
  85577. */
  85578. clear(): void;
  85579. /**
  85580. * Updates the texture
  85581. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  85582. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  85583. */
  85584. update(invertY?: boolean, premulAlpha?: boolean): void;
  85585. /**
  85586. * Draws text onto the texture
  85587. * @param text defines the text to be drawn
  85588. * @param x defines the placement of the text from the left
  85589. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  85590. * @param font defines the font to be used with font-style, font-size, font-name
  85591. * @param color defines the color used for the text
  85592. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  85593. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  85594. * @param update defines whether texture is immediately update (default is true)
  85595. */
  85596. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  85597. /**
  85598. * Clones the texture
  85599. * @returns the clone of the texture.
  85600. */
  85601. clone(): DynamicTexture;
  85602. /**
  85603. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  85604. * @returns a serialized dynamic texture object
  85605. */
  85606. serialize(): any;
  85607. /** @hidden */
  85608. _rebuild(): void;
  85609. }
  85610. }
  85611. declare module BABYLON {
  85612. interface AbstractScene {
  85613. /**
  85614. * The list of procedural textures added to the scene
  85615. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  85616. */
  85617. proceduralTextures: Array<ProceduralTexture>;
  85618. }
  85619. /**
  85620. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  85621. * in a given scene.
  85622. */
  85623. export class ProceduralTextureSceneComponent implements ISceneComponent {
  85624. /**
  85625. * The component name helpfull to identify the component in the list of scene components.
  85626. */
  85627. readonly name: string;
  85628. /**
  85629. * The scene the component belongs to.
  85630. */
  85631. scene: Scene;
  85632. /**
  85633. * Creates a new instance of the component for the given scene
  85634. * @param scene Defines the scene to register the component in
  85635. */
  85636. constructor(scene: Scene);
  85637. /**
  85638. * Registers the component in a given scene
  85639. */
  85640. register(): void;
  85641. /**
  85642. * Rebuilds the elements related to this component in case of
  85643. * context lost for instance.
  85644. */
  85645. rebuild(): void;
  85646. /**
  85647. * Disposes the component and the associated ressources.
  85648. */
  85649. dispose(): void;
  85650. private _beforeClear;
  85651. }
  85652. }
  85653. declare module BABYLON {
  85654. interface ThinEngine {
  85655. /**
  85656. * Creates a new render target cube texture
  85657. * @param size defines the size of the texture
  85658. * @param options defines the options used to create the texture
  85659. * @returns a new render target cube texture stored in an InternalTexture
  85660. */
  85661. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  85662. }
  85663. }
  85664. declare module BABYLON {
  85665. /** @hidden */
  85666. export var proceduralVertexShader: {
  85667. name: string;
  85668. shader: string;
  85669. };
  85670. }
  85671. declare module BABYLON {
  85672. /**
  85673. * 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.
  85674. * This is the base class of any Procedural texture and contains most of the shareable code.
  85675. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  85676. */
  85677. export class ProceduralTexture extends Texture {
  85678. isCube: boolean;
  85679. /**
  85680. * Define if the texture is enabled or not (disabled texture will not render)
  85681. */
  85682. isEnabled: boolean;
  85683. /**
  85684. * Define if the texture must be cleared before rendering (default is true)
  85685. */
  85686. autoClear: boolean;
  85687. /**
  85688. * Callback called when the texture is generated
  85689. */
  85690. onGenerated: () => void;
  85691. /**
  85692. * Event raised when the texture is generated
  85693. */
  85694. onGeneratedObservable: Observable<ProceduralTexture>;
  85695. /** @hidden */
  85696. _generateMipMaps: boolean;
  85697. /** @hidden **/
  85698. _effect: Effect;
  85699. /** @hidden */
  85700. _textures: {
  85701. [key: string]: Texture;
  85702. };
  85703. private _size;
  85704. private _currentRefreshId;
  85705. private _refreshRate;
  85706. private _vertexBuffers;
  85707. private _indexBuffer;
  85708. private _uniforms;
  85709. private _samplers;
  85710. private _fragment;
  85711. private _floats;
  85712. private _ints;
  85713. private _floatsArrays;
  85714. private _colors3;
  85715. private _colors4;
  85716. private _vectors2;
  85717. private _vectors3;
  85718. private _matrices;
  85719. private _fallbackTexture;
  85720. private _fallbackTextureUsed;
  85721. private _engine;
  85722. private _cachedDefines;
  85723. private _contentUpdateId;
  85724. private _contentData;
  85725. /**
  85726. * Instantiates a new procedural texture.
  85727. * 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.
  85728. * This is the base class of any Procedural texture and contains most of the shareable code.
  85729. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  85730. * @param name Define the name of the texture
  85731. * @param size Define the size of the texture to create
  85732. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  85733. * @param scene Define the scene the texture belongs to
  85734. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  85735. * @param generateMipMaps Define if the texture should creates mip maps or not
  85736. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  85737. */
  85738. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  85739. /**
  85740. * The effect that is created when initializing the post process.
  85741. * @returns The created effect corresponding the the postprocess.
  85742. */
  85743. getEffect(): Effect;
  85744. /**
  85745. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  85746. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  85747. */
  85748. getContent(): Nullable<ArrayBufferView>;
  85749. private _createIndexBuffer;
  85750. /** @hidden */
  85751. _rebuild(): void;
  85752. /**
  85753. * Resets the texture in order to recreate its associated resources.
  85754. * This can be called in case of context loss
  85755. */
  85756. reset(): void;
  85757. protected _getDefines(): string;
  85758. /**
  85759. * Is the texture ready to be used ? (rendered at least once)
  85760. * @returns true if ready, otherwise, false.
  85761. */
  85762. isReady(): boolean;
  85763. /**
  85764. * Resets the refresh counter of the texture and start bak from scratch.
  85765. * Could be useful to regenerate the texture if it is setup to render only once.
  85766. */
  85767. resetRefreshCounter(): void;
  85768. /**
  85769. * Set the fragment shader to use in order to render the texture.
  85770. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  85771. */
  85772. setFragment(fragment: any): void;
  85773. /**
  85774. * Define the refresh rate of the texture or the rendering frequency.
  85775. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  85776. */
  85777. refreshRate: number;
  85778. /** @hidden */
  85779. _shouldRender(): boolean;
  85780. /**
  85781. * Get the size the texture is rendering at.
  85782. * @returns the size (texture is always squared)
  85783. */
  85784. getRenderSize(): number;
  85785. /**
  85786. * Resize the texture to new value.
  85787. * @param size Define the new size the texture should have
  85788. * @param generateMipMaps Define whether the new texture should create mip maps
  85789. */
  85790. resize(size: number, generateMipMaps: boolean): void;
  85791. private _checkUniform;
  85792. /**
  85793. * Set a texture in the shader program used to render.
  85794. * @param name Define the name of the uniform samplers as defined in the shader
  85795. * @param texture Define the texture to bind to this sampler
  85796. * @return the texture itself allowing "fluent" like uniform updates
  85797. */
  85798. setTexture(name: string, texture: Texture): ProceduralTexture;
  85799. /**
  85800. * Set a float in the shader.
  85801. * @param name Define the name of the uniform as defined in the shader
  85802. * @param value Define the value to give to the uniform
  85803. * @return the texture itself allowing "fluent" like uniform updates
  85804. */
  85805. setFloat(name: string, value: number): ProceduralTexture;
  85806. /**
  85807. * Set a int in the shader.
  85808. * @param name Define the name of the uniform as defined in the shader
  85809. * @param value Define the value to give to the uniform
  85810. * @return the texture itself allowing "fluent" like uniform updates
  85811. */
  85812. setInt(name: string, value: number): ProceduralTexture;
  85813. /**
  85814. * Set an array of floats in the shader.
  85815. * @param name Define the name of the uniform as defined in the shader
  85816. * @param value Define the value to give to the uniform
  85817. * @return the texture itself allowing "fluent" like uniform updates
  85818. */
  85819. setFloats(name: string, value: number[]): ProceduralTexture;
  85820. /**
  85821. * Set a vec3 in the shader from a Color3.
  85822. * @param name Define the name of the uniform as defined in the shader
  85823. * @param value Define the value to give to the uniform
  85824. * @return the texture itself allowing "fluent" like uniform updates
  85825. */
  85826. setColor3(name: string, value: Color3): ProceduralTexture;
  85827. /**
  85828. * Set a vec4 in the shader from a Color4.
  85829. * @param name Define the name of the uniform as defined in the shader
  85830. * @param value Define the value to give to the uniform
  85831. * @return the texture itself allowing "fluent" like uniform updates
  85832. */
  85833. setColor4(name: string, value: Color4): ProceduralTexture;
  85834. /**
  85835. * Set a vec2 in the shader from a Vector2.
  85836. * @param name Define the name of the uniform as defined in the shader
  85837. * @param value Define the value to give to the uniform
  85838. * @return the texture itself allowing "fluent" like uniform updates
  85839. */
  85840. setVector2(name: string, value: Vector2): ProceduralTexture;
  85841. /**
  85842. * Set a vec3 in the shader from a Vector3.
  85843. * @param name Define the name of the uniform as defined in the shader
  85844. * @param value Define the value to give to the uniform
  85845. * @return the texture itself allowing "fluent" like uniform updates
  85846. */
  85847. setVector3(name: string, value: Vector3): ProceduralTexture;
  85848. /**
  85849. * Set a mat4 in the shader from a MAtrix.
  85850. * @param name Define the name of the uniform as defined in the shader
  85851. * @param value Define the value to give to the uniform
  85852. * @return the texture itself allowing "fluent" like uniform updates
  85853. */
  85854. setMatrix(name: string, value: Matrix): ProceduralTexture;
  85855. /**
  85856. * Render the texture to its associated render target.
  85857. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  85858. */
  85859. render(useCameraPostProcess?: boolean): void;
  85860. /**
  85861. * Clone the texture.
  85862. * @returns the cloned texture
  85863. */
  85864. clone(): ProceduralTexture;
  85865. /**
  85866. * Dispose the texture and release its asoociated resources.
  85867. */
  85868. dispose(): void;
  85869. }
  85870. }
  85871. declare module BABYLON {
  85872. /**
  85873. * This represents the base class for particle system in Babylon.
  85874. * 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.
  85875. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  85876. * @example https://doc.babylonjs.com/babylon101/particles
  85877. */
  85878. export class BaseParticleSystem {
  85879. /**
  85880. * Source color is added to the destination color without alpha affecting the result
  85881. */
  85882. static BLENDMODE_ONEONE: number;
  85883. /**
  85884. * Blend current color and particle color using particle’s alpha
  85885. */
  85886. static BLENDMODE_STANDARD: number;
  85887. /**
  85888. * Add current color and particle color multiplied by particle’s alpha
  85889. */
  85890. static BLENDMODE_ADD: number;
  85891. /**
  85892. * Multiply current color with particle color
  85893. */
  85894. static BLENDMODE_MULTIPLY: number;
  85895. /**
  85896. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  85897. */
  85898. static BLENDMODE_MULTIPLYADD: number;
  85899. /**
  85900. * List of animations used by the particle system.
  85901. */
  85902. animations: Animation[];
  85903. /**
  85904. * The id of the Particle system.
  85905. */
  85906. id: string;
  85907. /**
  85908. * The friendly name of the Particle system.
  85909. */
  85910. name: string;
  85911. /**
  85912. * The rendering group used by the Particle system to chose when to render.
  85913. */
  85914. renderingGroupId: number;
  85915. /**
  85916. * The emitter represents the Mesh or position we are attaching the particle system to.
  85917. */
  85918. emitter: Nullable<AbstractMesh | Vector3>;
  85919. /**
  85920. * The maximum number of particles to emit per frame
  85921. */
  85922. emitRate: number;
  85923. /**
  85924. * If you want to launch only a few particles at once, that can be done, as well.
  85925. */
  85926. manualEmitCount: number;
  85927. /**
  85928. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  85929. */
  85930. updateSpeed: number;
  85931. /**
  85932. * The amount of time the particle system is running (depends of the overall update speed).
  85933. */
  85934. targetStopDuration: number;
  85935. /**
  85936. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  85937. */
  85938. disposeOnStop: boolean;
  85939. /**
  85940. * Minimum power of emitting particles.
  85941. */
  85942. minEmitPower: number;
  85943. /**
  85944. * Maximum power of emitting particles.
  85945. */
  85946. maxEmitPower: number;
  85947. /**
  85948. * Minimum life time of emitting particles.
  85949. */
  85950. minLifeTime: number;
  85951. /**
  85952. * Maximum life time of emitting particles.
  85953. */
  85954. maxLifeTime: number;
  85955. /**
  85956. * Minimum Size of emitting particles.
  85957. */
  85958. minSize: number;
  85959. /**
  85960. * Maximum Size of emitting particles.
  85961. */
  85962. maxSize: number;
  85963. /**
  85964. * Minimum scale of emitting particles on X axis.
  85965. */
  85966. minScaleX: number;
  85967. /**
  85968. * Maximum scale of emitting particles on X axis.
  85969. */
  85970. maxScaleX: number;
  85971. /**
  85972. * Minimum scale of emitting particles on Y axis.
  85973. */
  85974. minScaleY: number;
  85975. /**
  85976. * Maximum scale of emitting particles on Y axis.
  85977. */
  85978. maxScaleY: number;
  85979. /**
  85980. * Gets or sets the minimal initial rotation in radians.
  85981. */
  85982. minInitialRotation: number;
  85983. /**
  85984. * Gets or sets the maximal initial rotation in radians.
  85985. */
  85986. maxInitialRotation: number;
  85987. /**
  85988. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  85989. */
  85990. minAngularSpeed: number;
  85991. /**
  85992. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  85993. */
  85994. maxAngularSpeed: number;
  85995. /**
  85996. * The texture used to render each particle. (this can be a spritesheet)
  85997. */
  85998. particleTexture: Nullable<Texture>;
  85999. /**
  86000. * The layer mask we are rendering the particles through.
  86001. */
  86002. layerMask: number;
  86003. /**
  86004. * This can help using your own shader to render the particle system.
  86005. * The according effect will be created
  86006. */
  86007. customShader: any;
  86008. /**
  86009. * By default particle system starts as soon as they are created. This prevents the
  86010. * automatic start to happen and let you decide when to start emitting particles.
  86011. */
  86012. preventAutoStart: boolean;
  86013. private _noiseTexture;
  86014. /**
  86015. * Gets or sets a texture used to add random noise to particle positions
  86016. */
  86017. noiseTexture: Nullable<ProceduralTexture>;
  86018. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  86019. noiseStrength: Vector3;
  86020. /**
  86021. * Callback triggered when the particle animation is ending.
  86022. */
  86023. onAnimationEnd: Nullable<() => void>;
  86024. /**
  86025. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  86026. */
  86027. blendMode: number;
  86028. /**
  86029. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  86030. * to override the particles.
  86031. */
  86032. forceDepthWrite: boolean;
  86033. /** 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 */
  86034. preWarmCycles: number;
  86035. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  86036. preWarmStepOffset: number;
  86037. /**
  86038. * 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)
  86039. */
  86040. spriteCellChangeSpeed: number;
  86041. /**
  86042. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  86043. */
  86044. startSpriteCellID: number;
  86045. /**
  86046. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  86047. */
  86048. endSpriteCellID: number;
  86049. /**
  86050. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  86051. */
  86052. spriteCellWidth: number;
  86053. /**
  86054. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  86055. */
  86056. spriteCellHeight: number;
  86057. /**
  86058. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  86059. */
  86060. spriteRandomStartCell: boolean;
  86061. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  86062. translationPivot: Vector2;
  86063. /** @hidden */
  86064. protected _isAnimationSheetEnabled: boolean;
  86065. /**
  86066. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  86067. */
  86068. beginAnimationOnStart: boolean;
  86069. /**
  86070. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  86071. */
  86072. beginAnimationFrom: number;
  86073. /**
  86074. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  86075. */
  86076. beginAnimationTo: number;
  86077. /**
  86078. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  86079. */
  86080. beginAnimationLoop: boolean;
  86081. /**
  86082. * Gets or sets a world offset applied to all particles
  86083. */
  86084. worldOffset: Vector3;
  86085. /**
  86086. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  86087. */
  86088. isAnimationSheetEnabled: boolean;
  86089. /**
  86090. * Get hosting scene
  86091. * @returns the scene
  86092. */
  86093. getScene(): Scene;
  86094. /**
  86095. * You can use gravity if you want to give an orientation to your particles.
  86096. */
  86097. gravity: Vector3;
  86098. protected _colorGradients: Nullable<Array<ColorGradient>>;
  86099. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  86100. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  86101. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  86102. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  86103. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  86104. protected _dragGradients: Nullable<Array<FactorGradient>>;
  86105. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  86106. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  86107. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  86108. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  86109. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  86110. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  86111. /**
  86112. * Defines the delay in milliseconds before starting the system (0 by default)
  86113. */
  86114. startDelay: number;
  86115. /**
  86116. * Gets the current list of drag gradients.
  86117. * You must use addDragGradient and removeDragGradient to udpate this list
  86118. * @returns the list of drag gradients
  86119. */
  86120. getDragGradients(): Nullable<Array<FactorGradient>>;
  86121. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  86122. limitVelocityDamping: number;
  86123. /**
  86124. * Gets the current list of limit velocity gradients.
  86125. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  86126. * @returns the list of limit velocity gradients
  86127. */
  86128. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  86129. /**
  86130. * Gets the current list of color gradients.
  86131. * You must use addColorGradient and removeColorGradient to udpate this list
  86132. * @returns the list of color gradients
  86133. */
  86134. getColorGradients(): Nullable<Array<ColorGradient>>;
  86135. /**
  86136. * Gets the current list of size gradients.
  86137. * You must use addSizeGradient and removeSizeGradient to udpate this list
  86138. * @returns the list of size gradients
  86139. */
  86140. getSizeGradients(): Nullable<Array<FactorGradient>>;
  86141. /**
  86142. * Gets the current list of color remap gradients.
  86143. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  86144. * @returns the list of color remap gradients
  86145. */
  86146. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  86147. /**
  86148. * Gets the current list of alpha remap gradients.
  86149. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  86150. * @returns the list of alpha remap gradients
  86151. */
  86152. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  86153. /**
  86154. * Gets the current list of life time gradients.
  86155. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  86156. * @returns the list of life time gradients
  86157. */
  86158. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  86159. /**
  86160. * Gets the current list of angular speed gradients.
  86161. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  86162. * @returns the list of angular speed gradients
  86163. */
  86164. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  86165. /**
  86166. * Gets the current list of velocity gradients.
  86167. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  86168. * @returns the list of velocity gradients
  86169. */
  86170. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  86171. /**
  86172. * Gets the current list of start size gradients.
  86173. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  86174. * @returns the list of start size gradients
  86175. */
  86176. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  86177. /**
  86178. * Gets the current list of emit rate gradients.
  86179. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  86180. * @returns the list of emit rate gradients
  86181. */
  86182. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  86183. /**
  86184. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86185. * This only works when particleEmitterTyps is a BoxParticleEmitter
  86186. */
  86187. direction1: Vector3;
  86188. /**
  86189. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86190. * This only works when particleEmitterTyps is a BoxParticleEmitter
  86191. */
  86192. direction2: Vector3;
  86193. /**
  86194. * 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.
  86195. * This only works when particleEmitterTyps is a BoxParticleEmitter
  86196. */
  86197. minEmitBox: Vector3;
  86198. /**
  86199. * 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.
  86200. * This only works when particleEmitterTyps is a BoxParticleEmitter
  86201. */
  86202. maxEmitBox: Vector3;
  86203. /**
  86204. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  86205. */
  86206. color1: Color4;
  86207. /**
  86208. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  86209. */
  86210. color2: Color4;
  86211. /**
  86212. * Color the particle will have at the end of its lifetime
  86213. */
  86214. colorDead: Color4;
  86215. /**
  86216. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  86217. */
  86218. textureMask: Color4;
  86219. /**
  86220. * The particle emitter type defines the emitter used by the particle system.
  86221. * It can be for example box, sphere, or cone...
  86222. */
  86223. particleEmitterType: IParticleEmitterType;
  86224. /** @hidden */
  86225. _isSubEmitter: boolean;
  86226. /**
  86227. * Gets or sets the billboard mode to use when isBillboardBased = true.
  86228. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  86229. */
  86230. billboardMode: number;
  86231. protected _isBillboardBased: boolean;
  86232. /**
  86233. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  86234. */
  86235. isBillboardBased: boolean;
  86236. /**
  86237. * The scene the particle system belongs to.
  86238. */
  86239. protected _scene: Scene;
  86240. /**
  86241. * Local cache of defines for image processing.
  86242. */
  86243. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  86244. /**
  86245. * Default configuration related to image processing available in the standard Material.
  86246. */
  86247. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  86248. /**
  86249. * Gets the image processing configuration used either in this material.
  86250. */
  86251. /**
  86252. * Sets the Default image processing configuration used either in the this material.
  86253. *
  86254. * If sets to null, the scene one is in use.
  86255. */
  86256. imageProcessingConfiguration: ImageProcessingConfiguration;
  86257. /**
  86258. * Attaches a new image processing configuration to the Standard Material.
  86259. * @param configuration
  86260. */
  86261. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  86262. /** @hidden */
  86263. protected _reset(): void;
  86264. /** @hidden */
  86265. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  86266. /**
  86267. * Instantiates a particle system.
  86268. * 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.
  86269. * @param name The name of the particle system
  86270. */
  86271. constructor(name: string);
  86272. /**
  86273. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  86274. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  86275. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  86276. * @returns the emitter
  86277. */
  86278. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  86279. /**
  86280. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  86281. * @param radius The radius of the hemisphere to emit from
  86282. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  86283. * @returns the emitter
  86284. */
  86285. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  86286. /**
  86287. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  86288. * @param radius The radius of the sphere to emit from
  86289. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  86290. * @returns the emitter
  86291. */
  86292. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  86293. /**
  86294. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  86295. * @param radius The radius of the sphere to emit from
  86296. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  86297. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  86298. * @returns the emitter
  86299. */
  86300. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  86301. /**
  86302. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  86303. * @param radius The radius of the emission cylinder
  86304. * @param height The height of the emission cylinder
  86305. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  86306. * @param directionRandomizer How much to randomize the particle direction [0-1]
  86307. * @returns the emitter
  86308. */
  86309. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  86310. /**
  86311. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  86312. * @param radius The radius of the cylinder to emit from
  86313. * @param height The height of the emission cylinder
  86314. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86315. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  86316. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  86317. * @returns the emitter
  86318. */
  86319. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  86320. /**
  86321. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  86322. * @param radius The radius of the cone to emit from
  86323. * @param angle The base angle of the cone
  86324. * @returns the emitter
  86325. */
  86326. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  86327. /**
  86328. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  86329. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  86330. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  86331. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86332. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86333. * @returns the emitter
  86334. */
  86335. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  86336. }
  86337. }
  86338. declare module BABYLON {
  86339. /**
  86340. * Type of sub emitter
  86341. */
  86342. export enum SubEmitterType {
  86343. /**
  86344. * Attached to the particle over it's lifetime
  86345. */
  86346. ATTACHED = 0,
  86347. /**
  86348. * Created when the particle dies
  86349. */
  86350. END = 1
  86351. }
  86352. /**
  86353. * Sub emitter class used to emit particles from an existing particle
  86354. */
  86355. export class SubEmitter {
  86356. /**
  86357. * the particle system to be used by the sub emitter
  86358. */
  86359. particleSystem: ParticleSystem;
  86360. /**
  86361. * Type of the submitter (Default: END)
  86362. */
  86363. type: SubEmitterType;
  86364. /**
  86365. * 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)
  86366. * Note: This only is supported when using an emitter of type Mesh
  86367. */
  86368. inheritDirection: boolean;
  86369. /**
  86370. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  86371. */
  86372. inheritedVelocityAmount: number;
  86373. /**
  86374. * Creates a sub emitter
  86375. * @param particleSystem the particle system to be used by the sub emitter
  86376. */
  86377. constructor(
  86378. /**
  86379. * the particle system to be used by the sub emitter
  86380. */
  86381. particleSystem: ParticleSystem);
  86382. /**
  86383. * Clones the sub emitter
  86384. * @returns the cloned sub emitter
  86385. */
  86386. clone(): SubEmitter;
  86387. /**
  86388. * Serialize current object to a JSON object
  86389. * @returns the serialized object
  86390. */
  86391. serialize(): any;
  86392. /** @hidden */
  86393. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  86394. /**
  86395. * Creates a new SubEmitter from a serialized JSON version
  86396. * @param serializationObject defines the JSON object to read from
  86397. * @param scene defines the hosting scene
  86398. * @param rootUrl defines the rootUrl for data loading
  86399. * @returns a new SubEmitter
  86400. */
  86401. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  86402. /** Release associated resources */
  86403. dispose(): void;
  86404. }
  86405. }
  86406. declare module BABYLON {
  86407. /** @hidden */
  86408. export var clipPlaneFragmentDeclaration: {
  86409. name: string;
  86410. shader: string;
  86411. };
  86412. }
  86413. declare module BABYLON {
  86414. /** @hidden */
  86415. export var imageProcessingDeclaration: {
  86416. name: string;
  86417. shader: string;
  86418. };
  86419. }
  86420. declare module BABYLON {
  86421. /** @hidden */
  86422. export var imageProcessingFunctions: {
  86423. name: string;
  86424. shader: string;
  86425. };
  86426. }
  86427. declare module BABYLON {
  86428. /** @hidden */
  86429. export var clipPlaneFragment: {
  86430. name: string;
  86431. shader: string;
  86432. };
  86433. }
  86434. declare module BABYLON {
  86435. /** @hidden */
  86436. export var particlesPixelShader: {
  86437. name: string;
  86438. shader: string;
  86439. };
  86440. }
  86441. declare module BABYLON {
  86442. /** @hidden */
  86443. export var clipPlaneVertexDeclaration: {
  86444. name: string;
  86445. shader: string;
  86446. };
  86447. }
  86448. declare module BABYLON {
  86449. /** @hidden */
  86450. export var clipPlaneVertex: {
  86451. name: string;
  86452. shader: string;
  86453. };
  86454. }
  86455. declare module BABYLON {
  86456. /** @hidden */
  86457. export var particlesVertexShader: {
  86458. name: string;
  86459. shader: string;
  86460. };
  86461. }
  86462. declare module BABYLON {
  86463. /**
  86464. * This represents a particle system in Babylon.
  86465. * 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.
  86466. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  86467. * @example https://doc.babylonjs.com/babylon101/particles
  86468. */
  86469. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  86470. /**
  86471. * Billboard mode will only apply to Y axis
  86472. */
  86473. static readonly BILLBOARDMODE_Y: number;
  86474. /**
  86475. * Billboard mode will apply to all axes
  86476. */
  86477. static readonly BILLBOARDMODE_ALL: number;
  86478. /**
  86479. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  86480. */
  86481. static readonly BILLBOARDMODE_STRETCHED: number;
  86482. /**
  86483. * This function can be defined to provide custom update for active particles.
  86484. * This function will be called instead of regular update (age, position, color, etc.).
  86485. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  86486. */
  86487. updateFunction: (particles: Particle[]) => void;
  86488. private _emitterWorldMatrix;
  86489. /**
  86490. * This function can be defined to specify initial direction for every new particle.
  86491. * It by default use the emitterType defined function
  86492. */
  86493. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  86494. /**
  86495. * This function can be defined to specify initial position for every new particle.
  86496. * It by default use the emitterType defined function
  86497. */
  86498. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  86499. /**
  86500. * @hidden
  86501. */
  86502. _inheritedVelocityOffset: Vector3;
  86503. /**
  86504. * An event triggered when the system is disposed
  86505. */
  86506. onDisposeObservable: Observable<ParticleSystem>;
  86507. private _onDisposeObserver;
  86508. /**
  86509. * Sets a callback that will be triggered when the system is disposed
  86510. */
  86511. onDispose: () => void;
  86512. private _particles;
  86513. private _epsilon;
  86514. private _capacity;
  86515. private _stockParticles;
  86516. private _newPartsExcess;
  86517. private _vertexData;
  86518. private _vertexBuffer;
  86519. private _vertexBuffers;
  86520. private _spriteBuffer;
  86521. private _indexBuffer;
  86522. private _effect;
  86523. private _customEffect;
  86524. private _cachedDefines;
  86525. private _scaledColorStep;
  86526. private _colorDiff;
  86527. private _scaledDirection;
  86528. private _scaledGravity;
  86529. private _currentRenderId;
  86530. private _alive;
  86531. private _useInstancing;
  86532. private _started;
  86533. private _stopped;
  86534. private _actualFrame;
  86535. private _scaledUpdateSpeed;
  86536. private _vertexBufferSize;
  86537. /** @hidden */
  86538. _currentEmitRateGradient: Nullable<FactorGradient>;
  86539. /** @hidden */
  86540. _currentEmitRate1: number;
  86541. /** @hidden */
  86542. _currentEmitRate2: number;
  86543. /** @hidden */
  86544. _currentStartSizeGradient: Nullable<FactorGradient>;
  86545. /** @hidden */
  86546. _currentStartSize1: number;
  86547. /** @hidden */
  86548. _currentStartSize2: number;
  86549. private readonly _rawTextureWidth;
  86550. private _rampGradientsTexture;
  86551. private _useRampGradients;
  86552. /** Gets or sets a boolean indicating that ramp gradients must be used
  86553. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  86554. */
  86555. useRampGradients: boolean;
  86556. /**
  86557. * 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.
  86558. * 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: [])
  86559. */
  86560. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  86561. private _subEmitters;
  86562. /**
  86563. * @hidden
  86564. * If the particle systems emitter should be disposed when the particle system is disposed
  86565. */
  86566. _disposeEmitterOnDispose: boolean;
  86567. /**
  86568. * The current active Sub-systems, this property is used by the root particle system only.
  86569. */
  86570. activeSubSystems: Array<ParticleSystem>;
  86571. private _rootParticleSystem;
  86572. /**
  86573. * Gets the current list of active particles
  86574. */
  86575. readonly particles: Particle[];
  86576. /**
  86577. * Returns the string "ParticleSystem"
  86578. * @returns a string containing the class name
  86579. */
  86580. getClassName(): string;
  86581. /**
  86582. * Instantiates a particle system.
  86583. * 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.
  86584. * @param name The name of the particle system
  86585. * @param capacity The max number of particles alive at the same time
  86586. * @param scene The scene the particle system belongs to
  86587. * @param customEffect a custom effect used to change the way particles are rendered by default
  86588. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  86589. * @param epsilon Offset used to render the particles
  86590. */
  86591. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  86592. private _addFactorGradient;
  86593. private _removeFactorGradient;
  86594. /**
  86595. * Adds a new life time gradient
  86596. * @param gradient defines the gradient to use (between 0 and 1)
  86597. * @param factor defines the life time factor to affect to the specified gradient
  86598. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86599. * @returns the current particle system
  86600. */
  86601. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86602. /**
  86603. * Remove a specific life time gradient
  86604. * @param gradient defines the gradient to remove
  86605. * @returns the current particle system
  86606. */
  86607. removeLifeTimeGradient(gradient: number): IParticleSystem;
  86608. /**
  86609. * Adds a new size gradient
  86610. * @param gradient defines the gradient to use (between 0 and 1)
  86611. * @param factor defines the size factor to affect to the specified gradient
  86612. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86613. * @returns the current particle system
  86614. */
  86615. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86616. /**
  86617. * Remove a specific size gradient
  86618. * @param gradient defines the gradient to remove
  86619. * @returns the current particle system
  86620. */
  86621. removeSizeGradient(gradient: number): IParticleSystem;
  86622. /**
  86623. * Adds a new color remap gradient
  86624. * @param gradient defines the gradient to use (between 0 and 1)
  86625. * @param min defines the color remap minimal range
  86626. * @param max defines the color remap maximal range
  86627. * @returns the current particle system
  86628. */
  86629. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86630. /**
  86631. * Remove a specific color remap gradient
  86632. * @param gradient defines the gradient to remove
  86633. * @returns the current particle system
  86634. */
  86635. removeColorRemapGradient(gradient: number): IParticleSystem;
  86636. /**
  86637. * Adds a new alpha remap gradient
  86638. * @param gradient defines the gradient to use (between 0 and 1)
  86639. * @param min defines the alpha remap minimal range
  86640. * @param max defines the alpha remap maximal range
  86641. * @returns the current particle system
  86642. */
  86643. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86644. /**
  86645. * Remove a specific alpha remap gradient
  86646. * @param gradient defines the gradient to remove
  86647. * @returns the current particle system
  86648. */
  86649. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  86650. /**
  86651. * Adds a new angular speed gradient
  86652. * @param gradient defines the gradient to use (between 0 and 1)
  86653. * @param factor defines the angular speed to affect to the specified gradient
  86654. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86655. * @returns the current particle system
  86656. */
  86657. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86658. /**
  86659. * Remove a specific angular speed gradient
  86660. * @param gradient defines the gradient to remove
  86661. * @returns the current particle system
  86662. */
  86663. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  86664. /**
  86665. * Adds a new velocity gradient
  86666. * @param gradient defines the gradient to use (between 0 and 1)
  86667. * @param factor defines the velocity to affect to the specified gradient
  86668. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86669. * @returns the current particle system
  86670. */
  86671. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86672. /**
  86673. * Remove a specific velocity gradient
  86674. * @param gradient defines the gradient to remove
  86675. * @returns the current particle system
  86676. */
  86677. removeVelocityGradient(gradient: number): IParticleSystem;
  86678. /**
  86679. * Adds a new limit velocity gradient
  86680. * @param gradient defines the gradient to use (between 0 and 1)
  86681. * @param factor defines the limit velocity value to affect to the specified gradient
  86682. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86683. * @returns the current particle system
  86684. */
  86685. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86686. /**
  86687. * Remove a specific limit velocity gradient
  86688. * @param gradient defines the gradient to remove
  86689. * @returns the current particle system
  86690. */
  86691. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  86692. /**
  86693. * Adds a new drag gradient
  86694. * @param gradient defines the gradient to use (between 0 and 1)
  86695. * @param factor defines the drag value to affect to the specified gradient
  86696. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86697. * @returns the current particle system
  86698. */
  86699. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86700. /**
  86701. * Remove a specific drag gradient
  86702. * @param gradient defines the gradient to remove
  86703. * @returns the current particle system
  86704. */
  86705. removeDragGradient(gradient: number): IParticleSystem;
  86706. /**
  86707. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  86708. * @param gradient defines the gradient to use (between 0 and 1)
  86709. * @param factor defines the emit rate value to affect to the specified gradient
  86710. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86711. * @returns the current particle system
  86712. */
  86713. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86714. /**
  86715. * Remove a specific emit rate gradient
  86716. * @param gradient defines the gradient to remove
  86717. * @returns the current particle system
  86718. */
  86719. removeEmitRateGradient(gradient: number): IParticleSystem;
  86720. /**
  86721. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  86722. * @param gradient defines the gradient to use (between 0 and 1)
  86723. * @param factor defines the start size value to affect to the specified gradient
  86724. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86725. * @returns the current particle system
  86726. */
  86727. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86728. /**
  86729. * Remove a specific start size gradient
  86730. * @param gradient defines the gradient to remove
  86731. * @returns the current particle system
  86732. */
  86733. removeStartSizeGradient(gradient: number): IParticleSystem;
  86734. private _createRampGradientTexture;
  86735. /**
  86736. * Gets the current list of ramp gradients.
  86737. * You must use addRampGradient and removeRampGradient to udpate this list
  86738. * @returns the list of ramp gradients
  86739. */
  86740. getRampGradients(): Nullable<Array<Color3Gradient>>;
  86741. /**
  86742. * Adds a new ramp gradient used to remap particle colors
  86743. * @param gradient defines the gradient to use (between 0 and 1)
  86744. * @param color defines the color to affect to the specified gradient
  86745. * @returns the current particle system
  86746. */
  86747. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  86748. /**
  86749. * Remove a specific ramp gradient
  86750. * @param gradient defines the gradient to remove
  86751. * @returns the current particle system
  86752. */
  86753. removeRampGradient(gradient: number): ParticleSystem;
  86754. /**
  86755. * Adds a new color gradient
  86756. * @param gradient defines the gradient to use (between 0 and 1)
  86757. * @param color1 defines the color to affect to the specified gradient
  86758. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  86759. * @returns this particle system
  86760. */
  86761. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  86762. /**
  86763. * Remove a specific color gradient
  86764. * @param gradient defines the gradient to remove
  86765. * @returns this particle system
  86766. */
  86767. removeColorGradient(gradient: number): IParticleSystem;
  86768. private _fetchR;
  86769. protected _reset(): void;
  86770. private _resetEffect;
  86771. private _createVertexBuffers;
  86772. private _createIndexBuffer;
  86773. /**
  86774. * Gets the maximum number of particles active at the same time.
  86775. * @returns The max number of active particles.
  86776. */
  86777. getCapacity(): number;
  86778. /**
  86779. * Gets whether there are still active particles in the system.
  86780. * @returns True if it is alive, otherwise false.
  86781. */
  86782. isAlive(): boolean;
  86783. /**
  86784. * Gets if the system has been started. (Note: this will still be true after stop is called)
  86785. * @returns True if it has been started, otherwise false.
  86786. */
  86787. isStarted(): boolean;
  86788. private _prepareSubEmitterInternalArray;
  86789. /**
  86790. * Starts the particle system and begins to emit
  86791. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  86792. */
  86793. start(delay?: number): void;
  86794. /**
  86795. * Stops the particle system.
  86796. * @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.
  86797. */
  86798. stop(stopSubEmitters?: boolean): void;
  86799. /**
  86800. * Remove all active particles
  86801. */
  86802. reset(): void;
  86803. /**
  86804. * @hidden (for internal use only)
  86805. */
  86806. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  86807. /**
  86808. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  86809. * Its lifetime will start back at 0.
  86810. */
  86811. recycleParticle: (particle: Particle) => void;
  86812. private _stopSubEmitters;
  86813. private _createParticle;
  86814. private _removeFromRoot;
  86815. private _emitFromParticle;
  86816. private _update;
  86817. /** @hidden */
  86818. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  86819. /** @hidden */
  86820. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  86821. /** @hidden */
  86822. private _getEffect;
  86823. /**
  86824. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  86825. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  86826. */
  86827. animate(preWarmOnly?: boolean): void;
  86828. private _appendParticleVertices;
  86829. /**
  86830. * Rebuilds the particle system.
  86831. */
  86832. rebuild(): void;
  86833. /**
  86834. * Is this system ready to be used/rendered
  86835. * @return true if the system is ready
  86836. */
  86837. isReady(): boolean;
  86838. private _render;
  86839. /**
  86840. * Renders the particle system in its current state.
  86841. * @returns the current number of particles
  86842. */
  86843. render(): number;
  86844. /**
  86845. * Disposes the particle system and free the associated resources
  86846. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  86847. */
  86848. dispose(disposeTexture?: boolean): void;
  86849. /**
  86850. * Clones the particle system.
  86851. * @param name The name of the cloned object
  86852. * @param newEmitter The new emitter to use
  86853. * @returns the cloned particle system
  86854. */
  86855. clone(name: string, newEmitter: any): ParticleSystem;
  86856. /**
  86857. * Serializes the particle system to a JSON object.
  86858. * @returns the JSON object
  86859. */
  86860. serialize(): any;
  86861. /** @hidden */
  86862. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  86863. /** @hidden */
  86864. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  86865. /**
  86866. * Parses a JSON object to create a particle system.
  86867. * @param parsedParticleSystem The JSON object to parse
  86868. * @param scene The scene to create the particle system in
  86869. * @param rootUrl The root url to use to load external dependencies like texture
  86870. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  86871. * @returns the Parsed particle system
  86872. */
  86873. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  86874. }
  86875. }
  86876. declare module BABYLON {
  86877. /**
  86878. * A particle represents one of the element emitted by a particle system.
  86879. * This is mainly define by its coordinates, direction, velocity and age.
  86880. */
  86881. export class Particle {
  86882. /**
  86883. * The particle system the particle belongs to.
  86884. */
  86885. particleSystem: ParticleSystem;
  86886. private static _Count;
  86887. /**
  86888. * Unique ID of the particle
  86889. */
  86890. id: number;
  86891. /**
  86892. * The world position of the particle in the scene.
  86893. */
  86894. position: Vector3;
  86895. /**
  86896. * The world direction of the particle in the scene.
  86897. */
  86898. direction: Vector3;
  86899. /**
  86900. * The color of the particle.
  86901. */
  86902. color: Color4;
  86903. /**
  86904. * The color change of the particle per step.
  86905. */
  86906. colorStep: Color4;
  86907. /**
  86908. * Defines how long will the life of the particle be.
  86909. */
  86910. lifeTime: number;
  86911. /**
  86912. * The current age of the particle.
  86913. */
  86914. age: number;
  86915. /**
  86916. * The current size of the particle.
  86917. */
  86918. size: number;
  86919. /**
  86920. * The current scale of the particle.
  86921. */
  86922. scale: Vector2;
  86923. /**
  86924. * The current angle of the particle.
  86925. */
  86926. angle: number;
  86927. /**
  86928. * Defines how fast is the angle changing.
  86929. */
  86930. angularSpeed: number;
  86931. /**
  86932. * Defines the cell index used by the particle to be rendered from a sprite.
  86933. */
  86934. cellIndex: number;
  86935. /**
  86936. * The information required to support color remapping
  86937. */
  86938. remapData: Vector4;
  86939. /** @hidden */
  86940. _randomCellOffset?: number;
  86941. /** @hidden */
  86942. _initialDirection: Nullable<Vector3>;
  86943. /** @hidden */
  86944. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  86945. /** @hidden */
  86946. _initialStartSpriteCellID: number;
  86947. /** @hidden */
  86948. _initialEndSpriteCellID: number;
  86949. /** @hidden */
  86950. _currentColorGradient: Nullable<ColorGradient>;
  86951. /** @hidden */
  86952. _currentColor1: Color4;
  86953. /** @hidden */
  86954. _currentColor2: Color4;
  86955. /** @hidden */
  86956. _currentSizeGradient: Nullable<FactorGradient>;
  86957. /** @hidden */
  86958. _currentSize1: number;
  86959. /** @hidden */
  86960. _currentSize2: number;
  86961. /** @hidden */
  86962. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  86963. /** @hidden */
  86964. _currentAngularSpeed1: number;
  86965. /** @hidden */
  86966. _currentAngularSpeed2: number;
  86967. /** @hidden */
  86968. _currentVelocityGradient: Nullable<FactorGradient>;
  86969. /** @hidden */
  86970. _currentVelocity1: number;
  86971. /** @hidden */
  86972. _currentVelocity2: number;
  86973. /** @hidden */
  86974. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  86975. /** @hidden */
  86976. _currentLimitVelocity1: number;
  86977. /** @hidden */
  86978. _currentLimitVelocity2: number;
  86979. /** @hidden */
  86980. _currentDragGradient: Nullable<FactorGradient>;
  86981. /** @hidden */
  86982. _currentDrag1: number;
  86983. /** @hidden */
  86984. _currentDrag2: number;
  86985. /** @hidden */
  86986. _randomNoiseCoordinates1: Vector3;
  86987. /** @hidden */
  86988. _randomNoiseCoordinates2: Vector3;
  86989. /**
  86990. * Creates a new instance Particle
  86991. * @param particleSystem the particle system the particle belongs to
  86992. */
  86993. constructor(
  86994. /**
  86995. * The particle system the particle belongs to.
  86996. */
  86997. particleSystem: ParticleSystem);
  86998. private updateCellInfoFromSystem;
  86999. /**
  87000. * Defines how the sprite cell index is updated for the particle
  87001. */
  87002. updateCellIndex(): void;
  87003. /** @hidden */
  87004. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  87005. /** @hidden */
  87006. _inheritParticleInfoToSubEmitters(): void;
  87007. /** @hidden */
  87008. _reset(): void;
  87009. /**
  87010. * Copy the properties of particle to another one.
  87011. * @param other the particle to copy the information to.
  87012. */
  87013. copyTo(other: Particle): void;
  87014. }
  87015. }
  87016. declare module BABYLON {
  87017. /**
  87018. * Particle emitter represents a volume emitting particles.
  87019. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  87020. */
  87021. export interface IParticleEmitterType {
  87022. /**
  87023. * Called by the particle System when the direction is computed for the created particle.
  87024. * @param worldMatrix is the world matrix of the particle system
  87025. * @param directionToUpdate is the direction vector to update with the result
  87026. * @param particle is the particle we are computed the direction for
  87027. */
  87028. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  87029. /**
  87030. * Called by the particle System when the position is computed for the created particle.
  87031. * @param worldMatrix is the world matrix of the particle system
  87032. * @param positionToUpdate is the position vector to update with the result
  87033. * @param particle is the particle we are computed the position for
  87034. */
  87035. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  87036. /**
  87037. * Clones the current emitter and returns a copy of it
  87038. * @returns the new emitter
  87039. */
  87040. clone(): IParticleEmitterType;
  87041. /**
  87042. * Called by the GPUParticleSystem to setup the update shader
  87043. * @param effect defines the update shader
  87044. */
  87045. applyToShader(effect: Effect): void;
  87046. /**
  87047. * Returns a string to use to update the GPU particles update shader
  87048. * @returns the effect defines string
  87049. */
  87050. getEffectDefines(): string;
  87051. /**
  87052. * Returns a string representing the class name
  87053. * @returns a string containing the class name
  87054. */
  87055. getClassName(): string;
  87056. /**
  87057. * Serializes the particle system to a JSON object.
  87058. * @returns the JSON object
  87059. */
  87060. serialize(): any;
  87061. /**
  87062. * Parse properties from a JSON object
  87063. * @param serializationObject defines the JSON object
  87064. */
  87065. parse(serializationObject: any): void;
  87066. }
  87067. }
  87068. declare module BABYLON {
  87069. /**
  87070. * Particle emitter emitting particles from the inside of a box.
  87071. * It emits the particles randomly between 2 given directions.
  87072. */
  87073. export class BoxParticleEmitter implements IParticleEmitterType {
  87074. /**
  87075. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  87076. */
  87077. direction1: Vector3;
  87078. /**
  87079. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  87080. */
  87081. direction2: Vector3;
  87082. /**
  87083. * 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.
  87084. */
  87085. minEmitBox: Vector3;
  87086. /**
  87087. * 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.
  87088. */
  87089. maxEmitBox: Vector3;
  87090. /**
  87091. * Creates a new instance BoxParticleEmitter
  87092. */
  87093. constructor();
  87094. /**
  87095. * Called by the particle System when the direction is computed for the created particle.
  87096. * @param worldMatrix is the world matrix of the particle system
  87097. * @param directionToUpdate is the direction vector to update with the result
  87098. * @param particle is the particle we are computed the direction for
  87099. */
  87100. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  87101. /**
  87102. * Called by the particle System when the position is computed for the created particle.
  87103. * @param worldMatrix is the world matrix of the particle system
  87104. * @param positionToUpdate is the position vector to update with the result
  87105. * @param particle is the particle we are computed the position for
  87106. */
  87107. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  87108. /**
  87109. * Clones the current emitter and returns a copy of it
  87110. * @returns the new emitter
  87111. */
  87112. clone(): BoxParticleEmitter;
  87113. /**
  87114. * Called by the GPUParticleSystem to setup the update shader
  87115. * @param effect defines the update shader
  87116. */
  87117. applyToShader(effect: Effect): void;
  87118. /**
  87119. * Returns a string to use to update the GPU particles update shader
  87120. * @returns a string containng the defines string
  87121. */
  87122. getEffectDefines(): string;
  87123. /**
  87124. * Returns the string "BoxParticleEmitter"
  87125. * @returns a string containing the class name
  87126. */
  87127. getClassName(): string;
  87128. /**
  87129. * Serializes the particle system to a JSON object.
  87130. * @returns the JSON object
  87131. */
  87132. serialize(): any;
  87133. /**
  87134. * Parse properties from a JSON object
  87135. * @param serializationObject defines the JSON object
  87136. */
  87137. parse(serializationObject: any): void;
  87138. }
  87139. }
  87140. declare module BABYLON {
  87141. /**
  87142. * Particle emitter emitting particles from the inside of a cone.
  87143. * It emits the particles alongside the cone volume from the base to the particle.
  87144. * The emission direction might be randomized.
  87145. */
  87146. export class ConeParticleEmitter implements IParticleEmitterType {
  87147. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  87148. directionRandomizer: number;
  87149. private _radius;
  87150. private _angle;
  87151. private _height;
  87152. /**
  87153. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  87154. */
  87155. radiusRange: number;
  87156. /**
  87157. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  87158. */
  87159. heightRange: number;
  87160. /**
  87161. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  87162. */
  87163. emitFromSpawnPointOnly: boolean;
  87164. /**
  87165. * Gets or sets the radius of the emission cone
  87166. */
  87167. radius: number;
  87168. /**
  87169. * Gets or sets the angle of the emission cone
  87170. */
  87171. angle: number;
  87172. private _buildHeight;
  87173. /**
  87174. * Creates a new instance ConeParticleEmitter
  87175. * @param radius the radius of the emission cone (1 by default)
  87176. * @param angle the cone base angle (PI by default)
  87177. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  87178. */
  87179. constructor(radius?: number, angle?: number,
  87180. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  87181. directionRandomizer?: number);
  87182. /**
  87183. * Called by the particle System when the direction is computed for the created particle.
  87184. * @param worldMatrix is the world matrix of the particle system
  87185. * @param directionToUpdate is the direction vector to update with the result
  87186. * @param particle is the particle we are computed the direction for
  87187. */
  87188. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  87189. /**
  87190. * Called by the particle System when the position is computed for the created particle.
  87191. * @param worldMatrix is the world matrix of the particle system
  87192. * @param positionToUpdate is the position vector to update with the result
  87193. * @param particle is the particle we are computed the position for
  87194. */
  87195. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  87196. /**
  87197. * Clones the current emitter and returns a copy of it
  87198. * @returns the new emitter
  87199. */
  87200. clone(): ConeParticleEmitter;
  87201. /**
  87202. * Called by the GPUParticleSystem to setup the update shader
  87203. * @param effect defines the update shader
  87204. */
  87205. applyToShader(effect: Effect): void;
  87206. /**
  87207. * Returns a string to use to update the GPU particles update shader
  87208. * @returns a string containng the defines string
  87209. */
  87210. getEffectDefines(): string;
  87211. /**
  87212. * Returns the string "ConeParticleEmitter"
  87213. * @returns a string containing the class name
  87214. */
  87215. getClassName(): string;
  87216. /**
  87217. * Serializes the particle system to a JSON object.
  87218. * @returns the JSON object
  87219. */
  87220. serialize(): any;
  87221. /**
  87222. * Parse properties from a JSON object
  87223. * @param serializationObject defines the JSON object
  87224. */
  87225. parse(serializationObject: any): void;
  87226. }
  87227. }
  87228. declare module BABYLON {
  87229. /**
  87230. * Particle emitter emitting particles from the inside of a cylinder.
  87231. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  87232. */
  87233. export class CylinderParticleEmitter implements IParticleEmitterType {
  87234. /**
  87235. * The radius of the emission cylinder.
  87236. */
  87237. radius: number;
  87238. /**
  87239. * The height of the emission cylinder.
  87240. */
  87241. height: number;
  87242. /**
  87243. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  87244. */
  87245. radiusRange: number;
  87246. /**
  87247. * How much to randomize the particle direction [0-1].
  87248. */
  87249. directionRandomizer: number;
  87250. /**
  87251. * Creates a new instance CylinderParticleEmitter
  87252. * @param radius the radius of the emission cylinder (1 by default)
  87253. * @param height the height of the emission cylinder (1 by default)
  87254. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  87255. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  87256. */
  87257. constructor(
  87258. /**
  87259. * The radius of the emission cylinder.
  87260. */
  87261. radius?: number,
  87262. /**
  87263. * The height of the emission cylinder.
  87264. */
  87265. height?: number,
  87266. /**
  87267. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  87268. */
  87269. radiusRange?: number,
  87270. /**
  87271. * How much to randomize the particle direction [0-1].
  87272. */
  87273. directionRandomizer?: number);
  87274. /**
  87275. * Called by the particle System when the direction is computed for the created particle.
  87276. * @param worldMatrix is the world matrix of the particle system
  87277. * @param directionToUpdate is the direction vector to update with the result
  87278. * @param particle is the particle we are computed the direction for
  87279. */
  87280. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  87281. /**
  87282. * Called by the particle System when the position is computed for the created particle.
  87283. * @param worldMatrix is the world matrix of the particle system
  87284. * @param positionToUpdate is the position vector to update with the result
  87285. * @param particle is the particle we are computed the position for
  87286. */
  87287. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  87288. /**
  87289. * Clones the current emitter and returns a copy of it
  87290. * @returns the new emitter
  87291. */
  87292. clone(): CylinderParticleEmitter;
  87293. /**
  87294. * Called by the GPUParticleSystem to setup the update shader
  87295. * @param effect defines the update shader
  87296. */
  87297. applyToShader(effect: Effect): void;
  87298. /**
  87299. * Returns a string to use to update the GPU particles update shader
  87300. * @returns a string containng the defines string
  87301. */
  87302. getEffectDefines(): string;
  87303. /**
  87304. * Returns the string "CylinderParticleEmitter"
  87305. * @returns a string containing the class name
  87306. */
  87307. getClassName(): string;
  87308. /**
  87309. * Serializes the particle system to a JSON object.
  87310. * @returns the JSON object
  87311. */
  87312. serialize(): any;
  87313. /**
  87314. * Parse properties from a JSON object
  87315. * @param serializationObject defines the JSON object
  87316. */
  87317. parse(serializationObject: any): void;
  87318. }
  87319. /**
  87320. * Particle emitter emitting particles from the inside of a cylinder.
  87321. * It emits the particles randomly between two vectors.
  87322. */
  87323. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  87324. /**
  87325. * The min limit of the emission direction.
  87326. */
  87327. direction1: Vector3;
  87328. /**
  87329. * The max limit of the emission direction.
  87330. */
  87331. direction2: Vector3;
  87332. /**
  87333. * Creates a new instance CylinderDirectedParticleEmitter
  87334. * @param radius the radius of the emission cylinder (1 by default)
  87335. * @param height the height of the emission cylinder (1 by default)
  87336. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  87337. * @param direction1 the min limit of the emission direction (up vector by default)
  87338. * @param direction2 the max limit of the emission direction (up vector by default)
  87339. */
  87340. constructor(radius?: number, height?: number, radiusRange?: number,
  87341. /**
  87342. * The min limit of the emission direction.
  87343. */
  87344. direction1?: Vector3,
  87345. /**
  87346. * The max limit of the emission direction.
  87347. */
  87348. direction2?: Vector3);
  87349. /**
  87350. * Called by the particle System when the direction is computed for the created particle.
  87351. * @param worldMatrix is the world matrix of the particle system
  87352. * @param directionToUpdate is the direction vector to update with the result
  87353. * @param particle is the particle we are computed the direction for
  87354. */
  87355. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  87356. /**
  87357. * Clones the current emitter and returns a copy of it
  87358. * @returns the new emitter
  87359. */
  87360. clone(): CylinderDirectedParticleEmitter;
  87361. /**
  87362. * Called by the GPUParticleSystem to setup the update shader
  87363. * @param effect defines the update shader
  87364. */
  87365. applyToShader(effect: Effect): void;
  87366. /**
  87367. * Returns a string to use to update the GPU particles update shader
  87368. * @returns a string containng the defines string
  87369. */
  87370. getEffectDefines(): string;
  87371. /**
  87372. * Returns the string "CylinderDirectedParticleEmitter"
  87373. * @returns a string containing the class name
  87374. */
  87375. getClassName(): string;
  87376. /**
  87377. * Serializes the particle system to a JSON object.
  87378. * @returns the JSON object
  87379. */
  87380. serialize(): any;
  87381. /**
  87382. * Parse properties from a JSON object
  87383. * @param serializationObject defines the JSON object
  87384. */
  87385. parse(serializationObject: any): void;
  87386. }
  87387. }
  87388. declare module BABYLON {
  87389. /**
  87390. * Particle emitter emitting particles from the inside of a hemisphere.
  87391. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  87392. */
  87393. export class HemisphericParticleEmitter implements IParticleEmitterType {
  87394. /**
  87395. * The radius of the emission hemisphere.
  87396. */
  87397. radius: number;
  87398. /**
  87399. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  87400. */
  87401. radiusRange: number;
  87402. /**
  87403. * How much to randomize the particle direction [0-1].
  87404. */
  87405. directionRandomizer: number;
  87406. /**
  87407. * Creates a new instance HemisphericParticleEmitter
  87408. * @param radius the radius of the emission hemisphere (1 by default)
  87409. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  87410. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  87411. */
  87412. constructor(
  87413. /**
  87414. * The radius of the emission hemisphere.
  87415. */
  87416. radius?: number,
  87417. /**
  87418. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  87419. */
  87420. radiusRange?: number,
  87421. /**
  87422. * How much to randomize the particle direction [0-1].
  87423. */
  87424. directionRandomizer?: number);
  87425. /**
  87426. * Called by the particle System when the direction is computed for the created particle.
  87427. * @param worldMatrix is the world matrix of the particle system
  87428. * @param directionToUpdate is the direction vector to update with the result
  87429. * @param particle is the particle we are computed the direction for
  87430. */
  87431. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  87432. /**
  87433. * Called by the particle System when the position is computed for the created particle.
  87434. * @param worldMatrix is the world matrix of the particle system
  87435. * @param positionToUpdate is the position vector to update with the result
  87436. * @param particle is the particle we are computed the position for
  87437. */
  87438. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  87439. /**
  87440. * Clones the current emitter and returns a copy of it
  87441. * @returns the new emitter
  87442. */
  87443. clone(): HemisphericParticleEmitter;
  87444. /**
  87445. * Called by the GPUParticleSystem to setup the update shader
  87446. * @param effect defines the update shader
  87447. */
  87448. applyToShader(effect: Effect): void;
  87449. /**
  87450. * Returns a string to use to update the GPU particles update shader
  87451. * @returns a string containng the defines string
  87452. */
  87453. getEffectDefines(): string;
  87454. /**
  87455. * Returns the string "HemisphericParticleEmitter"
  87456. * @returns a string containing the class name
  87457. */
  87458. getClassName(): string;
  87459. /**
  87460. * Serializes the particle system to a JSON object.
  87461. * @returns the JSON object
  87462. */
  87463. serialize(): any;
  87464. /**
  87465. * Parse properties from a JSON object
  87466. * @param serializationObject defines the JSON object
  87467. */
  87468. parse(serializationObject: any): void;
  87469. }
  87470. }
  87471. declare module BABYLON {
  87472. /**
  87473. * Particle emitter emitting particles from a point.
  87474. * It emits the particles randomly between 2 given directions.
  87475. */
  87476. export class PointParticleEmitter implements IParticleEmitterType {
  87477. /**
  87478. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  87479. */
  87480. direction1: Vector3;
  87481. /**
  87482. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  87483. */
  87484. direction2: Vector3;
  87485. /**
  87486. * Creates a new instance PointParticleEmitter
  87487. */
  87488. constructor();
  87489. /**
  87490. * Called by the particle System when the direction is computed for the created particle.
  87491. * @param worldMatrix is the world matrix of the particle system
  87492. * @param directionToUpdate is the direction vector to update with the result
  87493. * @param particle is the particle we are computed the direction for
  87494. */
  87495. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  87496. /**
  87497. * Called by the particle System when the position is computed for the created particle.
  87498. * @param worldMatrix is the world matrix of the particle system
  87499. * @param positionToUpdate is the position vector to update with the result
  87500. * @param particle is the particle we are computed the position for
  87501. */
  87502. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  87503. /**
  87504. * Clones the current emitter and returns a copy of it
  87505. * @returns the new emitter
  87506. */
  87507. clone(): PointParticleEmitter;
  87508. /**
  87509. * Called by the GPUParticleSystem to setup the update shader
  87510. * @param effect defines the update shader
  87511. */
  87512. applyToShader(effect: Effect): void;
  87513. /**
  87514. * Returns a string to use to update the GPU particles update shader
  87515. * @returns a string containng the defines string
  87516. */
  87517. getEffectDefines(): string;
  87518. /**
  87519. * Returns the string "PointParticleEmitter"
  87520. * @returns a string containing the class name
  87521. */
  87522. getClassName(): string;
  87523. /**
  87524. * Serializes the particle system to a JSON object.
  87525. * @returns the JSON object
  87526. */
  87527. serialize(): any;
  87528. /**
  87529. * Parse properties from a JSON object
  87530. * @param serializationObject defines the JSON object
  87531. */
  87532. parse(serializationObject: any): void;
  87533. }
  87534. }
  87535. declare module BABYLON {
  87536. /**
  87537. * Particle emitter emitting particles from the inside of a sphere.
  87538. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  87539. */
  87540. export class SphereParticleEmitter implements IParticleEmitterType {
  87541. /**
  87542. * The radius of the emission sphere.
  87543. */
  87544. radius: number;
  87545. /**
  87546. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  87547. */
  87548. radiusRange: number;
  87549. /**
  87550. * How much to randomize the particle direction [0-1].
  87551. */
  87552. directionRandomizer: number;
  87553. /**
  87554. * Creates a new instance SphereParticleEmitter
  87555. * @param radius the radius of the emission sphere (1 by default)
  87556. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  87557. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  87558. */
  87559. constructor(
  87560. /**
  87561. * The radius of the emission sphere.
  87562. */
  87563. radius?: number,
  87564. /**
  87565. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  87566. */
  87567. radiusRange?: number,
  87568. /**
  87569. * How much to randomize the particle direction [0-1].
  87570. */
  87571. directionRandomizer?: number);
  87572. /**
  87573. * Called by the particle System when the direction is computed for the created particle.
  87574. * @param worldMatrix is the world matrix of the particle system
  87575. * @param directionToUpdate is the direction vector to update with the result
  87576. * @param particle is the particle we are computed the direction for
  87577. */
  87578. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  87579. /**
  87580. * Called by the particle System when the position is computed for the created particle.
  87581. * @param worldMatrix is the world matrix of the particle system
  87582. * @param positionToUpdate is the position vector to update with the result
  87583. * @param particle is the particle we are computed the position for
  87584. */
  87585. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  87586. /**
  87587. * Clones the current emitter and returns a copy of it
  87588. * @returns the new emitter
  87589. */
  87590. clone(): SphereParticleEmitter;
  87591. /**
  87592. * Called by the GPUParticleSystem to setup the update shader
  87593. * @param effect defines the update shader
  87594. */
  87595. applyToShader(effect: Effect): void;
  87596. /**
  87597. * Returns a string to use to update the GPU particles update shader
  87598. * @returns a string containng the defines string
  87599. */
  87600. getEffectDefines(): string;
  87601. /**
  87602. * Returns the string "SphereParticleEmitter"
  87603. * @returns a string containing the class name
  87604. */
  87605. getClassName(): string;
  87606. /**
  87607. * Serializes the particle system to a JSON object.
  87608. * @returns the JSON object
  87609. */
  87610. serialize(): any;
  87611. /**
  87612. * Parse properties from a JSON object
  87613. * @param serializationObject defines the JSON object
  87614. */
  87615. parse(serializationObject: any): void;
  87616. }
  87617. /**
  87618. * Particle emitter emitting particles from the inside of a sphere.
  87619. * It emits the particles randomly between two vectors.
  87620. */
  87621. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  87622. /**
  87623. * The min limit of the emission direction.
  87624. */
  87625. direction1: Vector3;
  87626. /**
  87627. * The max limit of the emission direction.
  87628. */
  87629. direction2: Vector3;
  87630. /**
  87631. * Creates a new instance SphereDirectedParticleEmitter
  87632. * @param radius the radius of the emission sphere (1 by default)
  87633. * @param direction1 the min limit of the emission direction (up vector by default)
  87634. * @param direction2 the max limit of the emission direction (up vector by default)
  87635. */
  87636. constructor(radius?: number,
  87637. /**
  87638. * The min limit of the emission direction.
  87639. */
  87640. direction1?: Vector3,
  87641. /**
  87642. * The max limit of the emission direction.
  87643. */
  87644. direction2?: Vector3);
  87645. /**
  87646. * Called by the particle System when the direction is computed for the created particle.
  87647. * @param worldMatrix is the world matrix of the particle system
  87648. * @param directionToUpdate is the direction vector to update with the result
  87649. * @param particle is the particle we are computed the direction for
  87650. */
  87651. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  87652. /**
  87653. * Clones the current emitter and returns a copy of it
  87654. * @returns the new emitter
  87655. */
  87656. clone(): SphereDirectedParticleEmitter;
  87657. /**
  87658. * Called by the GPUParticleSystem to setup the update shader
  87659. * @param effect defines the update shader
  87660. */
  87661. applyToShader(effect: Effect): void;
  87662. /**
  87663. * Returns a string to use to update the GPU particles update shader
  87664. * @returns a string containng the defines string
  87665. */
  87666. getEffectDefines(): string;
  87667. /**
  87668. * Returns the string "SphereDirectedParticleEmitter"
  87669. * @returns a string containing the class name
  87670. */
  87671. getClassName(): string;
  87672. /**
  87673. * Serializes the particle system to a JSON object.
  87674. * @returns the JSON object
  87675. */
  87676. serialize(): any;
  87677. /**
  87678. * Parse properties from a JSON object
  87679. * @param serializationObject defines the JSON object
  87680. */
  87681. parse(serializationObject: any): void;
  87682. }
  87683. }
  87684. declare module BABYLON {
  87685. /**
  87686. * Interface representing a particle system in Babylon.js.
  87687. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  87688. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  87689. */
  87690. export interface IParticleSystem {
  87691. /**
  87692. * List of animations used by the particle system.
  87693. */
  87694. animations: Animation[];
  87695. /**
  87696. * The id of the Particle system.
  87697. */
  87698. id: string;
  87699. /**
  87700. * The name of the Particle system.
  87701. */
  87702. name: string;
  87703. /**
  87704. * The emitter represents the Mesh or position we are attaching the particle system to.
  87705. */
  87706. emitter: Nullable<AbstractMesh | Vector3>;
  87707. /**
  87708. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  87709. */
  87710. isBillboardBased: boolean;
  87711. /**
  87712. * The rendering group used by the Particle system to chose when to render.
  87713. */
  87714. renderingGroupId: number;
  87715. /**
  87716. * The layer mask we are rendering the particles through.
  87717. */
  87718. layerMask: number;
  87719. /**
  87720. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  87721. */
  87722. updateSpeed: number;
  87723. /**
  87724. * The amount of time the particle system is running (depends of the overall update speed).
  87725. */
  87726. targetStopDuration: number;
  87727. /**
  87728. * The texture used to render each particle. (this can be a spritesheet)
  87729. */
  87730. particleTexture: Nullable<Texture>;
  87731. /**
  87732. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  87733. */
  87734. blendMode: number;
  87735. /**
  87736. * Minimum life time of emitting particles.
  87737. */
  87738. minLifeTime: number;
  87739. /**
  87740. * Maximum life time of emitting particles.
  87741. */
  87742. maxLifeTime: number;
  87743. /**
  87744. * Minimum Size of emitting particles.
  87745. */
  87746. minSize: number;
  87747. /**
  87748. * Maximum Size of emitting particles.
  87749. */
  87750. maxSize: number;
  87751. /**
  87752. * Minimum scale of emitting particles on X axis.
  87753. */
  87754. minScaleX: number;
  87755. /**
  87756. * Maximum scale of emitting particles on X axis.
  87757. */
  87758. maxScaleX: number;
  87759. /**
  87760. * Minimum scale of emitting particles on Y axis.
  87761. */
  87762. minScaleY: number;
  87763. /**
  87764. * Maximum scale of emitting particles on Y axis.
  87765. */
  87766. maxScaleY: number;
  87767. /**
  87768. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  87769. */
  87770. color1: Color4;
  87771. /**
  87772. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  87773. */
  87774. color2: Color4;
  87775. /**
  87776. * Color the particle will have at the end of its lifetime.
  87777. */
  87778. colorDead: Color4;
  87779. /**
  87780. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  87781. */
  87782. emitRate: number;
  87783. /**
  87784. * You can use gravity if you want to give an orientation to your particles.
  87785. */
  87786. gravity: Vector3;
  87787. /**
  87788. * Minimum power of emitting particles.
  87789. */
  87790. minEmitPower: number;
  87791. /**
  87792. * Maximum power of emitting particles.
  87793. */
  87794. maxEmitPower: number;
  87795. /**
  87796. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  87797. */
  87798. minAngularSpeed: number;
  87799. /**
  87800. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  87801. */
  87802. maxAngularSpeed: number;
  87803. /**
  87804. * Gets or sets the minimal initial rotation in radians.
  87805. */
  87806. minInitialRotation: number;
  87807. /**
  87808. * Gets or sets the maximal initial rotation in radians.
  87809. */
  87810. maxInitialRotation: number;
  87811. /**
  87812. * The particle emitter type defines the emitter used by the particle system.
  87813. * It can be for example box, sphere, or cone...
  87814. */
  87815. particleEmitterType: Nullable<IParticleEmitterType>;
  87816. /**
  87817. * Defines the delay in milliseconds before starting the system (0 by default)
  87818. */
  87819. startDelay: number;
  87820. /**
  87821. * 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
  87822. */
  87823. preWarmCycles: number;
  87824. /**
  87825. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  87826. */
  87827. preWarmStepOffset: number;
  87828. /**
  87829. * 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)
  87830. */
  87831. spriteCellChangeSpeed: number;
  87832. /**
  87833. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  87834. */
  87835. startSpriteCellID: number;
  87836. /**
  87837. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  87838. */
  87839. endSpriteCellID: number;
  87840. /**
  87841. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  87842. */
  87843. spriteCellWidth: number;
  87844. /**
  87845. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  87846. */
  87847. spriteCellHeight: number;
  87848. /**
  87849. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  87850. */
  87851. spriteRandomStartCell: boolean;
  87852. /**
  87853. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  87854. */
  87855. isAnimationSheetEnabled: boolean;
  87856. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  87857. translationPivot: Vector2;
  87858. /**
  87859. * Gets or sets a texture used to add random noise to particle positions
  87860. */
  87861. noiseTexture: Nullable<BaseTexture>;
  87862. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  87863. noiseStrength: Vector3;
  87864. /**
  87865. * Gets or sets the billboard mode to use when isBillboardBased = true.
  87866. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  87867. */
  87868. billboardMode: number;
  87869. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  87870. limitVelocityDamping: number;
  87871. /**
  87872. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  87873. */
  87874. beginAnimationOnStart: boolean;
  87875. /**
  87876. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  87877. */
  87878. beginAnimationFrom: number;
  87879. /**
  87880. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  87881. */
  87882. beginAnimationTo: number;
  87883. /**
  87884. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  87885. */
  87886. beginAnimationLoop: boolean;
  87887. /**
  87888. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  87889. */
  87890. disposeOnStop: boolean;
  87891. /**
  87892. * Gets the maximum number of particles active at the same time.
  87893. * @returns The max number of active particles.
  87894. */
  87895. getCapacity(): number;
  87896. /**
  87897. * Gets if the system has been started. (Note: this will still be true after stop is called)
  87898. * @returns True if it has been started, otherwise false.
  87899. */
  87900. isStarted(): boolean;
  87901. /**
  87902. * Animates the particle system for this frame.
  87903. */
  87904. animate(): void;
  87905. /**
  87906. * Renders the particle system in its current state.
  87907. * @returns the current number of particles
  87908. */
  87909. render(): number;
  87910. /**
  87911. * Dispose the particle system and frees its associated resources.
  87912. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  87913. */
  87914. dispose(disposeTexture?: boolean): void;
  87915. /**
  87916. * Clones the particle system.
  87917. * @param name The name of the cloned object
  87918. * @param newEmitter The new emitter to use
  87919. * @returns the cloned particle system
  87920. */
  87921. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  87922. /**
  87923. * Serializes the particle system to a JSON object.
  87924. * @returns the JSON object
  87925. */
  87926. serialize(): any;
  87927. /**
  87928. * Rebuild the particle system
  87929. */
  87930. rebuild(): void;
  87931. /**
  87932. * Starts the particle system and begins to emit
  87933. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  87934. */
  87935. start(delay?: number): void;
  87936. /**
  87937. * Stops the particle system.
  87938. */
  87939. stop(): void;
  87940. /**
  87941. * Remove all active particles
  87942. */
  87943. reset(): void;
  87944. /**
  87945. * Is this system ready to be used/rendered
  87946. * @return true if the system is ready
  87947. */
  87948. isReady(): boolean;
  87949. /**
  87950. * Adds a new color gradient
  87951. * @param gradient defines the gradient to use (between 0 and 1)
  87952. * @param color1 defines the color to affect to the specified gradient
  87953. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  87954. * @returns the current particle system
  87955. */
  87956. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  87957. /**
  87958. * Remove a specific color gradient
  87959. * @param gradient defines the gradient to remove
  87960. * @returns the current particle system
  87961. */
  87962. removeColorGradient(gradient: number): IParticleSystem;
  87963. /**
  87964. * Adds a new size gradient
  87965. * @param gradient defines the gradient to use (between 0 and 1)
  87966. * @param factor defines the size factor to affect to the specified gradient
  87967. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87968. * @returns the current particle system
  87969. */
  87970. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87971. /**
  87972. * Remove a specific size gradient
  87973. * @param gradient defines the gradient to remove
  87974. * @returns the current particle system
  87975. */
  87976. removeSizeGradient(gradient: number): IParticleSystem;
  87977. /**
  87978. * Gets the current list of color gradients.
  87979. * You must use addColorGradient and removeColorGradient to udpate this list
  87980. * @returns the list of color gradients
  87981. */
  87982. getColorGradients(): Nullable<Array<ColorGradient>>;
  87983. /**
  87984. * Gets the current list of size gradients.
  87985. * You must use addSizeGradient and removeSizeGradient to udpate this list
  87986. * @returns the list of size gradients
  87987. */
  87988. getSizeGradients(): Nullable<Array<FactorGradient>>;
  87989. /**
  87990. * Gets the current list of angular speed gradients.
  87991. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  87992. * @returns the list of angular speed gradients
  87993. */
  87994. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  87995. /**
  87996. * Adds a new angular speed gradient
  87997. * @param gradient defines the gradient to use (between 0 and 1)
  87998. * @param factor defines the angular speed to affect to the specified gradient
  87999. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88000. * @returns the current particle system
  88001. */
  88002. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88003. /**
  88004. * Remove a specific angular speed gradient
  88005. * @param gradient defines the gradient to remove
  88006. * @returns the current particle system
  88007. */
  88008. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  88009. /**
  88010. * Gets the current list of velocity gradients.
  88011. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  88012. * @returns the list of velocity gradients
  88013. */
  88014. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  88015. /**
  88016. * Adds a new velocity gradient
  88017. * @param gradient defines the gradient to use (between 0 and 1)
  88018. * @param factor defines the velocity to affect to the specified gradient
  88019. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88020. * @returns the current particle system
  88021. */
  88022. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88023. /**
  88024. * Remove a specific velocity gradient
  88025. * @param gradient defines the gradient to remove
  88026. * @returns the current particle system
  88027. */
  88028. removeVelocityGradient(gradient: number): IParticleSystem;
  88029. /**
  88030. * Gets the current list of limit velocity gradients.
  88031. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  88032. * @returns the list of limit velocity gradients
  88033. */
  88034. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  88035. /**
  88036. * Adds a new limit velocity gradient
  88037. * @param gradient defines the gradient to use (between 0 and 1)
  88038. * @param factor defines the limit velocity to affect to the specified gradient
  88039. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88040. * @returns the current particle system
  88041. */
  88042. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88043. /**
  88044. * Remove a specific limit velocity gradient
  88045. * @param gradient defines the gradient to remove
  88046. * @returns the current particle system
  88047. */
  88048. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  88049. /**
  88050. * Adds a new drag gradient
  88051. * @param gradient defines the gradient to use (between 0 and 1)
  88052. * @param factor defines the drag to affect to the specified gradient
  88053. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88054. * @returns the current particle system
  88055. */
  88056. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88057. /**
  88058. * Remove a specific drag gradient
  88059. * @param gradient defines the gradient to remove
  88060. * @returns the current particle system
  88061. */
  88062. removeDragGradient(gradient: number): IParticleSystem;
  88063. /**
  88064. * Gets the current list of drag gradients.
  88065. * You must use addDragGradient and removeDragGradient to udpate this list
  88066. * @returns the list of drag gradients
  88067. */
  88068. getDragGradients(): Nullable<Array<FactorGradient>>;
  88069. /**
  88070. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  88071. * @param gradient defines the gradient to use (between 0 and 1)
  88072. * @param factor defines the emit rate to affect to the specified gradient
  88073. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88074. * @returns the current particle system
  88075. */
  88076. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88077. /**
  88078. * Remove a specific emit rate gradient
  88079. * @param gradient defines the gradient to remove
  88080. * @returns the current particle system
  88081. */
  88082. removeEmitRateGradient(gradient: number): IParticleSystem;
  88083. /**
  88084. * Gets the current list of emit rate gradients.
  88085. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  88086. * @returns the list of emit rate gradients
  88087. */
  88088. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  88089. /**
  88090. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  88091. * @param gradient defines the gradient to use (between 0 and 1)
  88092. * @param factor defines the start size to affect to the specified gradient
  88093. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88094. * @returns the current particle system
  88095. */
  88096. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88097. /**
  88098. * Remove a specific start size gradient
  88099. * @param gradient defines the gradient to remove
  88100. * @returns the current particle system
  88101. */
  88102. removeStartSizeGradient(gradient: number): IParticleSystem;
  88103. /**
  88104. * Gets the current list of start size gradients.
  88105. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  88106. * @returns the list of start size gradients
  88107. */
  88108. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  88109. /**
  88110. * Adds a new life time gradient
  88111. * @param gradient defines the gradient to use (between 0 and 1)
  88112. * @param factor defines the life time factor to affect to the specified gradient
  88113. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88114. * @returns the current particle system
  88115. */
  88116. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88117. /**
  88118. * Remove a specific life time gradient
  88119. * @param gradient defines the gradient to remove
  88120. * @returns the current particle system
  88121. */
  88122. removeLifeTimeGradient(gradient: number): IParticleSystem;
  88123. /**
  88124. * Gets the current list of life time gradients.
  88125. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  88126. * @returns the list of life time gradients
  88127. */
  88128. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  88129. /**
  88130. * Gets the current list of color gradients.
  88131. * You must use addColorGradient and removeColorGradient to udpate this list
  88132. * @returns the list of color gradients
  88133. */
  88134. getColorGradients(): Nullable<Array<ColorGradient>>;
  88135. /**
  88136. * Adds a new ramp gradient used to remap particle colors
  88137. * @param gradient defines the gradient to use (between 0 and 1)
  88138. * @param color defines the color to affect to the specified gradient
  88139. * @returns the current particle system
  88140. */
  88141. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  88142. /**
  88143. * Gets the current list of ramp gradients.
  88144. * You must use addRampGradient and removeRampGradient to udpate this list
  88145. * @returns the list of ramp gradients
  88146. */
  88147. getRampGradients(): Nullable<Array<Color3Gradient>>;
  88148. /** Gets or sets a boolean indicating that ramp gradients must be used
  88149. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  88150. */
  88151. useRampGradients: boolean;
  88152. /**
  88153. * Adds a new color remap gradient
  88154. * @param gradient defines the gradient to use (between 0 and 1)
  88155. * @param min defines the color remap minimal range
  88156. * @param max defines the color remap maximal range
  88157. * @returns the current particle system
  88158. */
  88159. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  88160. /**
  88161. * Gets the current list of color remap gradients.
  88162. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  88163. * @returns the list of color remap gradients
  88164. */
  88165. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  88166. /**
  88167. * Adds a new alpha remap gradient
  88168. * @param gradient defines the gradient to use (between 0 and 1)
  88169. * @param min defines the alpha remap minimal range
  88170. * @param max defines the alpha remap maximal range
  88171. * @returns the current particle system
  88172. */
  88173. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  88174. /**
  88175. * Gets the current list of alpha remap gradients.
  88176. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  88177. * @returns the list of alpha remap gradients
  88178. */
  88179. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  88180. /**
  88181. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  88182. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  88183. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  88184. * @returns the emitter
  88185. */
  88186. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  88187. /**
  88188. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  88189. * @param radius The radius of the hemisphere to emit from
  88190. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  88191. * @returns the emitter
  88192. */
  88193. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  88194. /**
  88195. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  88196. * @param radius The radius of the sphere to emit from
  88197. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  88198. * @returns the emitter
  88199. */
  88200. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  88201. /**
  88202. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  88203. * @param radius The radius of the sphere to emit from
  88204. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  88205. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  88206. * @returns the emitter
  88207. */
  88208. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  88209. /**
  88210. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  88211. * @param radius The radius of the emission cylinder
  88212. * @param height The height of the emission cylinder
  88213. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  88214. * @param directionRandomizer How much to randomize the particle direction [0-1]
  88215. * @returns the emitter
  88216. */
  88217. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  88218. /**
  88219. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  88220. * @param radius The radius of the cylinder to emit from
  88221. * @param height The height of the emission cylinder
  88222. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  88223. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  88224. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  88225. * @returns the emitter
  88226. */
  88227. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  88228. /**
  88229. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  88230. * @param radius The radius of the cone to emit from
  88231. * @param angle The base angle of the cone
  88232. * @returns the emitter
  88233. */
  88234. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  88235. /**
  88236. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  88237. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  88238. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  88239. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  88240. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  88241. * @returns the emitter
  88242. */
  88243. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  88244. /**
  88245. * Get hosting scene
  88246. * @returns the scene
  88247. */
  88248. getScene(): Scene;
  88249. }
  88250. }
  88251. declare module BABYLON {
  88252. /**
  88253. * Creates an instance based on a source mesh.
  88254. */
  88255. export class InstancedMesh extends AbstractMesh {
  88256. private _sourceMesh;
  88257. private _currentLOD;
  88258. /** @hidden */
  88259. _indexInSourceMeshInstanceArray: number;
  88260. constructor(name: string, source: Mesh);
  88261. /**
  88262. * Returns the string "InstancedMesh".
  88263. */
  88264. getClassName(): string;
  88265. /** Gets the list of lights affecting that mesh */
  88266. readonly lightSources: Light[];
  88267. _resyncLightSources(): void;
  88268. _resyncLightSource(light: Light): void;
  88269. _removeLightSource(light: Light, dispose: boolean): void;
  88270. /**
  88271. * If the source mesh receives shadows
  88272. */
  88273. readonly receiveShadows: boolean;
  88274. /**
  88275. * The material of the source mesh
  88276. */
  88277. readonly material: Nullable<Material>;
  88278. /**
  88279. * Visibility of the source mesh
  88280. */
  88281. readonly visibility: number;
  88282. /**
  88283. * Skeleton of the source mesh
  88284. */
  88285. readonly skeleton: Nullable<Skeleton>;
  88286. /**
  88287. * Rendering ground id of the source mesh
  88288. */
  88289. renderingGroupId: number;
  88290. /**
  88291. * Returns the total number of vertices (integer).
  88292. */
  88293. getTotalVertices(): number;
  88294. /**
  88295. * Returns a positive integer : the total number of indices in this mesh geometry.
  88296. * @returns the numner of indices or zero if the mesh has no geometry.
  88297. */
  88298. getTotalIndices(): number;
  88299. /**
  88300. * The source mesh of the instance
  88301. */
  88302. readonly sourceMesh: Mesh;
  88303. /**
  88304. * Is this node ready to be used/rendered
  88305. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  88306. * @return {boolean} is it ready
  88307. */
  88308. isReady(completeCheck?: boolean): boolean;
  88309. /**
  88310. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  88311. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  88312. * @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.
  88313. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  88314. */
  88315. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  88316. /**
  88317. * Sets the vertex data of the mesh geometry for the requested `kind`.
  88318. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  88319. * The `data` are either a numeric array either a Float32Array.
  88320. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  88321. * 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).
  88322. * Note that a new underlying VertexBuffer object is created each call.
  88323. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  88324. *
  88325. * Possible `kind` values :
  88326. * - VertexBuffer.PositionKind
  88327. * - VertexBuffer.UVKind
  88328. * - VertexBuffer.UV2Kind
  88329. * - VertexBuffer.UV3Kind
  88330. * - VertexBuffer.UV4Kind
  88331. * - VertexBuffer.UV5Kind
  88332. * - VertexBuffer.UV6Kind
  88333. * - VertexBuffer.ColorKind
  88334. * - VertexBuffer.MatricesIndicesKind
  88335. * - VertexBuffer.MatricesIndicesExtraKind
  88336. * - VertexBuffer.MatricesWeightsKind
  88337. * - VertexBuffer.MatricesWeightsExtraKind
  88338. *
  88339. * Returns the Mesh.
  88340. */
  88341. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  88342. /**
  88343. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  88344. * If the mesh has no geometry, it is simply returned as it is.
  88345. * The `data` are either a numeric array either a Float32Array.
  88346. * No new underlying VertexBuffer object is created.
  88347. * 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.
  88348. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  88349. *
  88350. * Possible `kind` values :
  88351. * - VertexBuffer.PositionKind
  88352. * - VertexBuffer.UVKind
  88353. * - VertexBuffer.UV2Kind
  88354. * - VertexBuffer.UV3Kind
  88355. * - VertexBuffer.UV4Kind
  88356. * - VertexBuffer.UV5Kind
  88357. * - VertexBuffer.UV6Kind
  88358. * - VertexBuffer.ColorKind
  88359. * - VertexBuffer.MatricesIndicesKind
  88360. * - VertexBuffer.MatricesIndicesExtraKind
  88361. * - VertexBuffer.MatricesWeightsKind
  88362. * - VertexBuffer.MatricesWeightsExtraKind
  88363. *
  88364. * Returns the Mesh.
  88365. */
  88366. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  88367. /**
  88368. * Sets the mesh indices.
  88369. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  88370. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  88371. * This method creates a new index buffer each call.
  88372. * Returns the Mesh.
  88373. */
  88374. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  88375. /**
  88376. * Boolean : True if the mesh owns the requested kind of data.
  88377. */
  88378. isVerticesDataPresent(kind: string): boolean;
  88379. /**
  88380. * Returns an array of indices (IndicesArray).
  88381. */
  88382. getIndices(): Nullable<IndicesArray>;
  88383. readonly _positions: Nullable<Vector3[]>;
  88384. /**
  88385. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  88386. * This means the mesh underlying bounding box and sphere are recomputed.
  88387. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  88388. * @returns the current mesh
  88389. */
  88390. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  88391. /** @hidden */
  88392. _preActivate(): InstancedMesh;
  88393. /** @hidden */
  88394. _activate(renderId: number, intermediateRendering: boolean): boolean;
  88395. /** @hidden */
  88396. _postActivate(): void;
  88397. getWorldMatrix(): Matrix;
  88398. readonly isAnInstance: boolean;
  88399. /**
  88400. * Returns the current associated LOD AbstractMesh.
  88401. */
  88402. getLOD(camera: Camera): AbstractMesh;
  88403. /** @hidden */
  88404. _syncSubMeshes(): InstancedMesh;
  88405. /** @hidden */
  88406. _generatePointsArray(): boolean;
  88407. /**
  88408. * Creates a new InstancedMesh from the current mesh.
  88409. * - name (string) : the cloned mesh name
  88410. * - newParent (optional Node) : the optional Node to parent the clone to.
  88411. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  88412. *
  88413. * Returns the clone.
  88414. */
  88415. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  88416. /**
  88417. * Disposes the InstancedMesh.
  88418. * Returns nothing.
  88419. */
  88420. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88421. }
  88422. interface Mesh {
  88423. /**
  88424. * Register a custom buffer that will be instanced
  88425. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  88426. * @param kind defines the buffer kind
  88427. * @param stride defines the stride in floats
  88428. */
  88429. registerInstancedBuffer(kind: string, stride: number): void;
  88430. /** @hidden */
  88431. _userInstancedBuffersStorage: {
  88432. data: {
  88433. [key: string]: Float32Array;
  88434. };
  88435. sizes: {
  88436. [key: string]: number;
  88437. };
  88438. vertexBuffers: {
  88439. [key: string]: Nullable<VertexBuffer>;
  88440. };
  88441. strides: {
  88442. [key: string]: number;
  88443. };
  88444. };
  88445. }
  88446. interface AbstractMesh {
  88447. /**
  88448. * Object used to store instanced buffers defined by user
  88449. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  88450. */
  88451. instancedBuffers: {
  88452. [key: string]: any;
  88453. };
  88454. }
  88455. }
  88456. declare module BABYLON {
  88457. /**
  88458. * Defines the options associated with the creation of a shader material.
  88459. */
  88460. export interface IShaderMaterialOptions {
  88461. /**
  88462. * Does the material work in alpha blend mode
  88463. */
  88464. needAlphaBlending: boolean;
  88465. /**
  88466. * Does the material work in alpha test mode
  88467. */
  88468. needAlphaTesting: boolean;
  88469. /**
  88470. * The list of attribute names used in the shader
  88471. */
  88472. attributes: string[];
  88473. /**
  88474. * The list of unifrom names used in the shader
  88475. */
  88476. uniforms: string[];
  88477. /**
  88478. * The list of UBO names used in the shader
  88479. */
  88480. uniformBuffers: string[];
  88481. /**
  88482. * The list of sampler names used in the shader
  88483. */
  88484. samplers: string[];
  88485. /**
  88486. * The list of defines used in the shader
  88487. */
  88488. defines: string[];
  88489. }
  88490. /**
  88491. * 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.
  88492. *
  88493. * This returned material effects how the mesh will look based on the code in the shaders.
  88494. *
  88495. * @see http://doc.babylonjs.com/how_to/shader_material
  88496. */
  88497. export class ShaderMaterial extends Material {
  88498. private _shaderPath;
  88499. private _options;
  88500. private _textures;
  88501. private _textureArrays;
  88502. private _floats;
  88503. private _ints;
  88504. private _floatsArrays;
  88505. private _colors3;
  88506. private _colors3Arrays;
  88507. private _colors4;
  88508. private _colors4Arrays;
  88509. private _vectors2;
  88510. private _vectors3;
  88511. private _vectors4;
  88512. private _matrices;
  88513. private _matrixArrays;
  88514. private _matrices3x3;
  88515. private _matrices2x2;
  88516. private _vectors2Arrays;
  88517. private _vectors3Arrays;
  88518. private _vectors4Arrays;
  88519. private _cachedWorldViewMatrix;
  88520. private _cachedWorldViewProjectionMatrix;
  88521. private _renderId;
  88522. private _multiview;
  88523. /**
  88524. * Instantiate a new shader material.
  88525. * 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.
  88526. * This returned material effects how the mesh will look based on the code in the shaders.
  88527. * @see http://doc.babylonjs.com/how_to/shader_material
  88528. * @param name Define the name of the material in the scene
  88529. * @param scene Define the scene the material belongs to
  88530. * @param shaderPath Defines the route to the shader code in one of three ways:
  88531. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  88532. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  88533. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  88534. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  88535. * @param options Define the options used to create the shader
  88536. */
  88537. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  88538. /**
  88539. * Gets the shader path used to define the shader code
  88540. * It can be modified to trigger a new compilation
  88541. */
  88542. /**
  88543. * Sets the shader path used to define the shader code
  88544. * It can be modified to trigger a new compilation
  88545. */
  88546. shaderPath: any;
  88547. /**
  88548. * Gets the options used to compile the shader.
  88549. * They can be modified to trigger a new compilation
  88550. */
  88551. readonly options: IShaderMaterialOptions;
  88552. /**
  88553. * Gets the current class name of the material e.g. "ShaderMaterial"
  88554. * Mainly use in serialization.
  88555. * @returns the class name
  88556. */
  88557. getClassName(): string;
  88558. /**
  88559. * Specifies if the material will require alpha blending
  88560. * @returns a boolean specifying if alpha blending is needed
  88561. */
  88562. needAlphaBlending(): boolean;
  88563. /**
  88564. * Specifies if this material should be rendered in alpha test mode
  88565. * @returns a boolean specifying if an alpha test is needed.
  88566. */
  88567. needAlphaTesting(): boolean;
  88568. private _checkUniform;
  88569. /**
  88570. * Set a texture in the shader.
  88571. * @param name Define the name of the uniform samplers as defined in the shader
  88572. * @param texture Define the texture to bind to this sampler
  88573. * @return the material itself allowing "fluent" like uniform updates
  88574. */
  88575. setTexture(name: string, texture: Texture): ShaderMaterial;
  88576. /**
  88577. * Set a texture array in the shader.
  88578. * @param name Define the name of the uniform sampler array as defined in the shader
  88579. * @param textures Define the list of textures to bind to this sampler
  88580. * @return the material itself allowing "fluent" like uniform updates
  88581. */
  88582. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  88583. /**
  88584. * Set a float in the shader.
  88585. * @param name Define the name of the uniform as defined in the shader
  88586. * @param value Define the value to give to the uniform
  88587. * @return the material itself allowing "fluent" like uniform updates
  88588. */
  88589. setFloat(name: string, value: number): ShaderMaterial;
  88590. /**
  88591. * Set a int in the shader.
  88592. * @param name Define the name of the uniform as defined in the shader
  88593. * @param value Define the value to give to the uniform
  88594. * @return the material itself allowing "fluent" like uniform updates
  88595. */
  88596. setInt(name: string, value: number): ShaderMaterial;
  88597. /**
  88598. * Set an array of floats in the shader.
  88599. * @param name Define the name of the uniform as defined in the shader
  88600. * @param value Define the value to give to the uniform
  88601. * @return the material itself allowing "fluent" like uniform updates
  88602. */
  88603. setFloats(name: string, value: number[]): ShaderMaterial;
  88604. /**
  88605. * Set a vec3 in the shader from a Color3.
  88606. * @param name Define the name of the uniform as defined in the shader
  88607. * @param value Define the value to give to the uniform
  88608. * @return the material itself allowing "fluent" like uniform updates
  88609. */
  88610. setColor3(name: string, value: Color3): ShaderMaterial;
  88611. /**
  88612. * Set a vec3 array in the shader from a Color3 array.
  88613. * @param name Define the name of the uniform as defined in the shader
  88614. * @param value Define the value to give to the uniform
  88615. * @return the material itself allowing "fluent" like uniform updates
  88616. */
  88617. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  88618. /**
  88619. * Set a vec4 in the shader from a Color4.
  88620. * @param name Define the name of the uniform as defined in the shader
  88621. * @param value Define the value to give to the uniform
  88622. * @return the material itself allowing "fluent" like uniform updates
  88623. */
  88624. setColor4(name: string, value: Color4): ShaderMaterial;
  88625. /**
  88626. * Set a vec4 array in the shader from a Color4 array.
  88627. * @param name Define the name of the uniform as defined in the shader
  88628. * @param value Define the value to give to the uniform
  88629. * @return the material itself allowing "fluent" like uniform updates
  88630. */
  88631. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  88632. /**
  88633. * Set a vec2 in the shader from a Vector2.
  88634. * @param name Define the name of the uniform as defined in the shader
  88635. * @param value Define the value to give to the uniform
  88636. * @return the material itself allowing "fluent" like uniform updates
  88637. */
  88638. setVector2(name: string, value: Vector2): ShaderMaterial;
  88639. /**
  88640. * Set a vec3 in the shader from a Vector3.
  88641. * @param name Define the name of the uniform as defined in the shader
  88642. * @param value Define the value to give to the uniform
  88643. * @return the material itself allowing "fluent" like uniform updates
  88644. */
  88645. setVector3(name: string, value: Vector3): ShaderMaterial;
  88646. /**
  88647. * Set a vec4 in the shader from a Vector4.
  88648. * @param name Define the name of the uniform as defined in the shader
  88649. * @param value Define the value to give to the uniform
  88650. * @return the material itself allowing "fluent" like uniform updates
  88651. */
  88652. setVector4(name: string, value: Vector4): ShaderMaterial;
  88653. /**
  88654. * Set a mat4 in the shader from a Matrix.
  88655. * @param name Define the name of the uniform as defined in the shader
  88656. * @param value Define the value to give to the uniform
  88657. * @return the material itself allowing "fluent" like uniform updates
  88658. */
  88659. setMatrix(name: string, value: Matrix): ShaderMaterial;
  88660. /**
  88661. * Set a float32Array in the shader from a matrix array.
  88662. * @param name Define the name of the uniform as defined in the shader
  88663. * @param value Define the value to give to the uniform
  88664. * @return the material itself allowing "fluent" like uniform updates
  88665. */
  88666. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  88667. /**
  88668. * Set a mat3 in the shader from a Float32Array.
  88669. * @param name Define the name of the uniform as defined in the shader
  88670. * @param value Define the value to give to the uniform
  88671. * @return the material itself allowing "fluent" like uniform updates
  88672. */
  88673. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  88674. /**
  88675. * Set a mat2 in the shader from a Float32Array.
  88676. * @param name Define the name of the uniform as defined in the shader
  88677. * @param value Define the value to give to the uniform
  88678. * @return the material itself allowing "fluent" like uniform updates
  88679. */
  88680. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  88681. /**
  88682. * Set a vec2 array in the shader from a number array.
  88683. * @param name Define the name of the uniform as defined in the shader
  88684. * @param value Define the value to give to the uniform
  88685. * @return the material itself allowing "fluent" like uniform updates
  88686. */
  88687. setArray2(name: string, value: number[]): ShaderMaterial;
  88688. /**
  88689. * Set a vec3 array in the shader from a number array.
  88690. * @param name Define the name of the uniform as defined in the shader
  88691. * @param value Define the value to give to the uniform
  88692. * @return the material itself allowing "fluent" like uniform updates
  88693. */
  88694. setArray3(name: string, value: number[]): ShaderMaterial;
  88695. /**
  88696. * Set a vec4 array in the shader from a number array.
  88697. * @param name Define the name of the uniform as defined in the shader
  88698. * @param value Define the value to give to the uniform
  88699. * @return the material itself allowing "fluent" like uniform updates
  88700. */
  88701. setArray4(name: string, value: number[]): ShaderMaterial;
  88702. private _checkCache;
  88703. /**
  88704. * Specifies that the submesh is ready to be used
  88705. * @param mesh defines the mesh to check
  88706. * @param subMesh defines which submesh to check
  88707. * @param useInstances specifies that instances should be used
  88708. * @returns a boolean indicating that the submesh is ready or not
  88709. */
  88710. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  88711. /**
  88712. * Checks if the material is ready to render the requested mesh
  88713. * @param mesh Define the mesh to render
  88714. * @param useInstances Define whether or not the material is used with instances
  88715. * @returns true if ready, otherwise false
  88716. */
  88717. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  88718. /**
  88719. * Binds the world matrix to the material
  88720. * @param world defines the world transformation matrix
  88721. */
  88722. bindOnlyWorldMatrix(world: Matrix): void;
  88723. /**
  88724. * Binds the material to the mesh
  88725. * @param world defines the world transformation matrix
  88726. * @param mesh defines the mesh to bind the material to
  88727. */
  88728. bind(world: Matrix, mesh?: Mesh): void;
  88729. /**
  88730. * Gets the active textures from the material
  88731. * @returns an array of textures
  88732. */
  88733. getActiveTextures(): BaseTexture[];
  88734. /**
  88735. * Specifies if the material uses a texture
  88736. * @param texture defines the texture to check against the material
  88737. * @returns a boolean specifying if the material uses the texture
  88738. */
  88739. hasTexture(texture: BaseTexture): boolean;
  88740. /**
  88741. * Makes a duplicate of the material, and gives it a new name
  88742. * @param name defines the new name for the duplicated material
  88743. * @returns the cloned material
  88744. */
  88745. clone(name: string): ShaderMaterial;
  88746. /**
  88747. * Disposes the material
  88748. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  88749. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  88750. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  88751. */
  88752. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  88753. /**
  88754. * Serializes this material in a JSON representation
  88755. * @returns the serialized material object
  88756. */
  88757. serialize(): any;
  88758. /**
  88759. * Creates a shader material from parsed shader material data
  88760. * @param source defines the JSON represnetation of the material
  88761. * @param scene defines the hosting scene
  88762. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  88763. * @returns a new material
  88764. */
  88765. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  88766. }
  88767. }
  88768. declare module BABYLON {
  88769. /** @hidden */
  88770. export var colorPixelShader: {
  88771. name: string;
  88772. shader: string;
  88773. };
  88774. }
  88775. declare module BABYLON {
  88776. /** @hidden */
  88777. export var colorVertexShader: {
  88778. name: string;
  88779. shader: string;
  88780. };
  88781. }
  88782. declare module BABYLON {
  88783. /**
  88784. * Line mesh
  88785. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  88786. */
  88787. export class LinesMesh extends Mesh {
  88788. /**
  88789. * If vertex color should be applied to the mesh
  88790. */
  88791. readonly useVertexColor?: boolean | undefined;
  88792. /**
  88793. * If vertex alpha should be applied to the mesh
  88794. */
  88795. readonly useVertexAlpha?: boolean | undefined;
  88796. /**
  88797. * Color of the line (Default: White)
  88798. */
  88799. color: Color3;
  88800. /**
  88801. * Alpha of the line (Default: 1)
  88802. */
  88803. alpha: number;
  88804. /**
  88805. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  88806. * This margin is expressed in world space coordinates, so its value may vary.
  88807. * Default value is 0.1
  88808. */
  88809. intersectionThreshold: number;
  88810. private _colorShader;
  88811. private color4;
  88812. /**
  88813. * Creates a new LinesMesh
  88814. * @param name defines the name
  88815. * @param scene defines the hosting scene
  88816. * @param parent defines the parent mesh if any
  88817. * @param source defines the optional source LinesMesh used to clone data from
  88818. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  88819. * When false, achieved by calling a clone(), also passing False.
  88820. * This will make creation of children, recursive.
  88821. * @param useVertexColor defines if this LinesMesh supports vertex color
  88822. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  88823. */
  88824. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  88825. /**
  88826. * If vertex color should be applied to the mesh
  88827. */
  88828. useVertexColor?: boolean | undefined,
  88829. /**
  88830. * If vertex alpha should be applied to the mesh
  88831. */
  88832. useVertexAlpha?: boolean | undefined);
  88833. private _addClipPlaneDefine;
  88834. private _removeClipPlaneDefine;
  88835. isReady(): boolean;
  88836. /**
  88837. * Returns the string "LineMesh"
  88838. */
  88839. getClassName(): string;
  88840. /**
  88841. * @hidden
  88842. */
  88843. /**
  88844. * @hidden
  88845. */
  88846. material: Material;
  88847. /**
  88848. * @hidden
  88849. */
  88850. readonly checkCollisions: boolean;
  88851. /** @hidden */
  88852. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  88853. /** @hidden */
  88854. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  88855. /**
  88856. * Disposes of the line mesh
  88857. * @param doNotRecurse If children should be disposed
  88858. */
  88859. dispose(doNotRecurse?: boolean): void;
  88860. /**
  88861. * Returns a new LineMesh object cloned from the current one.
  88862. */
  88863. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  88864. /**
  88865. * Creates a new InstancedLinesMesh object from the mesh model.
  88866. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  88867. * @param name defines the name of the new instance
  88868. * @returns a new InstancedLinesMesh
  88869. */
  88870. createInstance(name: string): InstancedLinesMesh;
  88871. }
  88872. /**
  88873. * Creates an instance based on a source LinesMesh
  88874. */
  88875. export class InstancedLinesMesh extends InstancedMesh {
  88876. /**
  88877. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  88878. * This margin is expressed in world space coordinates, so its value may vary.
  88879. * Initilized with the intersectionThreshold value of the source LinesMesh
  88880. */
  88881. intersectionThreshold: number;
  88882. constructor(name: string, source: LinesMesh);
  88883. /**
  88884. * Returns the string "InstancedLinesMesh".
  88885. */
  88886. getClassName(): string;
  88887. }
  88888. }
  88889. declare module BABYLON {
  88890. /** @hidden */
  88891. export var linePixelShader: {
  88892. name: string;
  88893. shader: string;
  88894. };
  88895. }
  88896. declare module BABYLON {
  88897. /** @hidden */
  88898. export var lineVertexShader: {
  88899. name: string;
  88900. shader: string;
  88901. };
  88902. }
  88903. declare module BABYLON {
  88904. interface AbstractMesh {
  88905. /**
  88906. * Gets the edgesRenderer associated with the mesh
  88907. */
  88908. edgesRenderer: Nullable<EdgesRenderer>;
  88909. }
  88910. interface LinesMesh {
  88911. /**
  88912. * Enables the edge rendering mode on the mesh.
  88913. * This mode makes the mesh edges visible
  88914. * @param epsilon defines the maximal distance between two angles to detect a face
  88915. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  88916. * @returns the currentAbstractMesh
  88917. * @see https://www.babylonjs-playground.com/#19O9TU#0
  88918. */
  88919. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  88920. }
  88921. interface InstancedLinesMesh {
  88922. /**
  88923. * Enables the edge rendering mode on the mesh.
  88924. * This mode makes the mesh edges visible
  88925. * @param epsilon defines the maximal distance between two angles to detect a face
  88926. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  88927. * @returns the current InstancedLinesMesh
  88928. * @see https://www.babylonjs-playground.com/#19O9TU#0
  88929. */
  88930. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  88931. }
  88932. /**
  88933. * Defines the minimum contract an Edges renderer should follow.
  88934. */
  88935. export interface IEdgesRenderer extends IDisposable {
  88936. /**
  88937. * Gets or sets a boolean indicating if the edgesRenderer is active
  88938. */
  88939. isEnabled: boolean;
  88940. /**
  88941. * Renders the edges of the attached mesh,
  88942. */
  88943. render(): void;
  88944. /**
  88945. * Checks wether or not the edges renderer is ready to render.
  88946. * @return true if ready, otherwise false.
  88947. */
  88948. isReady(): boolean;
  88949. }
  88950. /**
  88951. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  88952. */
  88953. export class EdgesRenderer implements IEdgesRenderer {
  88954. /**
  88955. * Define the size of the edges with an orthographic camera
  88956. */
  88957. edgesWidthScalerForOrthographic: number;
  88958. /**
  88959. * Define the size of the edges with a perspective camera
  88960. */
  88961. edgesWidthScalerForPerspective: number;
  88962. protected _source: AbstractMesh;
  88963. protected _linesPositions: number[];
  88964. protected _linesNormals: number[];
  88965. protected _linesIndices: number[];
  88966. protected _epsilon: number;
  88967. protected _indicesCount: number;
  88968. protected _lineShader: ShaderMaterial;
  88969. protected _ib: DataBuffer;
  88970. protected _buffers: {
  88971. [key: string]: Nullable<VertexBuffer>;
  88972. };
  88973. protected _checkVerticesInsteadOfIndices: boolean;
  88974. private _meshRebuildObserver;
  88975. private _meshDisposeObserver;
  88976. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  88977. isEnabled: boolean;
  88978. /**
  88979. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  88980. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  88981. * @param source Mesh used to create edges
  88982. * @param epsilon sum of angles in adjacency to check for edge
  88983. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  88984. * @param generateEdgesLines - should generate Lines or only prepare resources.
  88985. */
  88986. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  88987. protected _prepareRessources(): void;
  88988. /** @hidden */
  88989. _rebuild(): void;
  88990. /**
  88991. * Releases the required resources for the edges renderer
  88992. */
  88993. dispose(): void;
  88994. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  88995. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  88996. /**
  88997. * Checks if the pair of p0 and p1 is en edge
  88998. * @param faceIndex
  88999. * @param edge
  89000. * @param faceNormals
  89001. * @param p0
  89002. * @param p1
  89003. * @private
  89004. */
  89005. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  89006. /**
  89007. * push line into the position, normal and index buffer
  89008. * @protected
  89009. */
  89010. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  89011. /**
  89012. * Generates lines edges from adjacencjes
  89013. * @private
  89014. */
  89015. _generateEdgesLines(): void;
  89016. /**
  89017. * Checks wether or not the edges renderer is ready to render.
  89018. * @return true if ready, otherwise false.
  89019. */
  89020. isReady(): boolean;
  89021. /**
  89022. * Renders the edges of the attached mesh,
  89023. */
  89024. render(): void;
  89025. }
  89026. /**
  89027. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  89028. */
  89029. export class LineEdgesRenderer extends EdgesRenderer {
  89030. /**
  89031. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  89032. * @param source LineMesh used to generate edges
  89033. * @param epsilon not important (specified angle for edge detection)
  89034. * @param checkVerticesInsteadOfIndices not important for LineMesh
  89035. */
  89036. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  89037. /**
  89038. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  89039. */
  89040. _generateEdgesLines(): void;
  89041. }
  89042. }
  89043. declare module BABYLON {
  89044. /**
  89045. * This represents the object necessary to create a rendering group.
  89046. * This is exclusively used and created by the rendering manager.
  89047. * To modify the behavior, you use the available helpers in your scene or meshes.
  89048. * @hidden
  89049. */
  89050. export class RenderingGroup {
  89051. index: number;
  89052. private static _zeroVector;
  89053. private _scene;
  89054. private _opaqueSubMeshes;
  89055. private _transparentSubMeshes;
  89056. private _alphaTestSubMeshes;
  89057. private _depthOnlySubMeshes;
  89058. private _particleSystems;
  89059. private _spriteManagers;
  89060. private _opaqueSortCompareFn;
  89061. private _alphaTestSortCompareFn;
  89062. private _transparentSortCompareFn;
  89063. private _renderOpaque;
  89064. private _renderAlphaTest;
  89065. private _renderTransparent;
  89066. /** @hidden */
  89067. _edgesRenderers: SmartArray<IEdgesRenderer>;
  89068. onBeforeTransparentRendering: () => void;
  89069. /**
  89070. * Set the opaque sort comparison function.
  89071. * If null the sub meshes will be render in the order they were created
  89072. */
  89073. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  89074. /**
  89075. * Set the alpha test sort comparison function.
  89076. * If null the sub meshes will be render in the order they were created
  89077. */
  89078. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  89079. /**
  89080. * Set the transparent sort comparison function.
  89081. * If null the sub meshes will be render in the order they were created
  89082. */
  89083. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  89084. /**
  89085. * Creates a new rendering group.
  89086. * @param index The rendering group index
  89087. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  89088. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  89089. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  89090. */
  89091. 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>);
  89092. /**
  89093. * Render all the sub meshes contained in the group.
  89094. * @param customRenderFunction Used to override the default render behaviour of the group.
  89095. * @returns true if rendered some submeshes.
  89096. */
  89097. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  89098. /**
  89099. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  89100. * @param subMeshes The submeshes to render
  89101. */
  89102. private renderOpaqueSorted;
  89103. /**
  89104. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  89105. * @param subMeshes The submeshes to render
  89106. */
  89107. private renderAlphaTestSorted;
  89108. /**
  89109. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  89110. * @param subMeshes The submeshes to render
  89111. */
  89112. private renderTransparentSorted;
  89113. /**
  89114. * Renders the submeshes in a specified order.
  89115. * @param subMeshes The submeshes to sort before render
  89116. * @param sortCompareFn The comparison function use to sort
  89117. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  89118. * @param transparent Specifies to activate blending if true
  89119. */
  89120. private static renderSorted;
  89121. /**
  89122. * Renders the submeshes in the order they were dispatched (no sort applied).
  89123. * @param subMeshes The submeshes to render
  89124. */
  89125. private static renderUnsorted;
  89126. /**
  89127. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  89128. * are rendered back to front if in the same alpha index.
  89129. *
  89130. * @param a The first submesh
  89131. * @param b The second submesh
  89132. * @returns The result of the comparison
  89133. */
  89134. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  89135. /**
  89136. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  89137. * are rendered back to front.
  89138. *
  89139. * @param a The first submesh
  89140. * @param b The second submesh
  89141. * @returns The result of the comparison
  89142. */
  89143. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  89144. /**
  89145. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  89146. * are rendered front to back (prevent overdraw).
  89147. *
  89148. * @param a The first submesh
  89149. * @param b The second submesh
  89150. * @returns The result of the comparison
  89151. */
  89152. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  89153. /**
  89154. * Resets the different lists of submeshes to prepare a new frame.
  89155. */
  89156. prepare(): void;
  89157. dispose(): void;
  89158. /**
  89159. * Inserts the submesh in its correct queue depending on its material.
  89160. * @param subMesh The submesh to dispatch
  89161. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  89162. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  89163. */
  89164. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  89165. dispatchSprites(spriteManager: ISpriteManager): void;
  89166. dispatchParticles(particleSystem: IParticleSystem): void;
  89167. private _renderParticles;
  89168. private _renderSprites;
  89169. }
  89170. }
  89171. declare module BABYLON {
  89172. /**
  89173. * Interface describing the different options available in the rendering manager
  89174. * regarding Auto Clear between groups.
  89175. */
  89176. export interface IRenderingManagerAutoClearSetup {
  89177. /**
  89178. * Defines whether or not autoclear is enable.
  89179. */
  89180. autoClear: boolean;
  89181. /**
  89182. * Defines whether or not to autoclear the depth buffer.
  89183. */
  89184. depth: boolean;
  89185. /**
  89186. * Defines whether or not to autoclear the stencil buffer.
  89187. */
  89188. stencil: boolean;
  89189. }
  89190. /**
  89191. * This class is used by the onRenderingGroupObservable
  89192. */
  89193. export class RenderingGroupInfo {
  89194. /**
  89195. * The Scene that being rendered
  89196. */
  89197. scene: Scene;
  89198. /**
  89199. * The camera currently used for the rendering pass
  89200. */
  89201. camera: Nullable<Camera>;
  89202. /**
  89203. * The ID of the renderingGroup being processed
  89204. */
  89205. renderingGroupId: number;
  89206. }
  89207. /**
  89208. * This is the manager responsible of all the rendering for meshes sprites and particles.
  89209. * It is enable to manage the different groups as well as the different necessary sort functions.
  89210. * This should not be used directly aside of the few static configurations
  89211. */
  89212. export class RenderingManager {
  89213. /**
  89214. * The max id used for rendering groups (not included)
  89215. */
  89216. static MAX_RENDERINGGROUPS: number;
  89217. /**
  89218. * The min id used for rendering groups (included)
  89219. */
  89220. static MIN_RENDERINGGROUPS: number;
  89221. /**
  89222. * Used to globally prevent autoclearing scenes.
  89223. */
  89224. static AUTOCLEAR: boolean;
  89225. /**
  89226. * @hidden
  89227. */
  89228. _useSceneAutoClearSetup: boolean;
  89229. private _scene;
  89230. private _renderingGroups;
  89231. private _depthStencilBufferAlreadyCleaned;
  89232. private _autoClearDepthStencil;
  89233. private _customOpaqueSortCompareFn;
  89234. private _customAlphaTestSortCompareFn;
  89235. private _customTransparentSortCompareFn;
  89236. private _renderingGroupInfo;
  89237. /**
  89238. * Instantiates a new rendering group for a particular scene
  89239. * @param scene Defines the scene the groups belongs to
  89240. */
  89241. constructor(scene: Scene);
  89242. private _clearDepthStencilBuffer;
  89243. /**
  89244. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  89245. * @hidden
  89246. */
  89247. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  89248. /**
  89249. * Resets the different information of the group to prepare a new frame
  89250. * @hidden
  89251. */
  89252. reset(): void;
  89253. /**
  89254. * Dispose and release the group and its associated resources.
  89255. * @hidden
  89256. */
  89257. dispose(): void;
  89258. /**
  89259. * Clear the info related to rendering groups preventing retention points during dispose.
  89260. */
  89261. freeRenderingGroups(): void;
  89262. private _prepareRenderingGroup;
  89263. /**
  89264. * Add a sprite manager to the rendering manager in order to render it this frame.
  89265. * @param spriteManager Define the sprite manager to render
  89266. */
  89267. dispatchSprites(spriteManager: ISpriteManager): void;
  89268. /**
  89269. * Add a particle system to the rendering manager in order to render it this frame.
  89270. * @param particleSystem Define the particle system to render
  89271. */
  89272. dispatchParticles(particleSystem: IParticleSystem): void;
  89273. /**
  89274. * Add a submesh to the manager in order to render it this frame
  89275. * @param subMesh The submesh to dispatch
  89276. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  89277. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  89278. */
  89279. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  89280. /**
  89281. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  89282. * This allowed control for front to back rendering or reversly depending of the special needs.
  89283. *
  89284. * @param renderingGroupId The rendering group id corresponding to its index
  89285. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  89286. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  89287. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  89288. */
  89289. 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;
  89290. /**
  89291. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  89292. *
  89293. * @param renderingGroupId The rendering group id corresponding to its index
  89294. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  89295. * @param depth Automatically clears depth between groups if true and autoClear is true.
  89296. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  89297. */
  89298. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  89299. /**
  89300. * Gets the current auto clear configuration for one rendering group of the rendering
  89301. * manager.
  89302. * @param index the rendering group index to get the information for
  89303. * @returns The auto clear setup for the requested rendering group
  89304. */
  89305. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  89306. }
  89307. }
  89308. declare module BABYLON {
  89309. /**
  89310. * This Helps creating a texture that will be created from a camera in your scene.
  89311. * It is basically a dynamic texture that could be used to create special effects for instance.
  89312. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  89313. */
  89314. export class RenderTargetTexture extends Texture {
  89315. isCube: boolean;
  89316. /**
  89317. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  89318. */
  89319. static readonly REFRESHRATE_RENDER_ONCE: number;
  89320. /**
  89321. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  89322. */
  89323. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  89324. /**
  89325. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  89326. * the central point of your effect and can save a lot of performances.
  89327. */
  89328. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  89329. /**
  89330. * Use this predicate to dynamically define the list of mesh you want to render.
  89331. * If set, the renderList property will be overwritten.
  89332. */
  89333. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  89334. private _renderList;
  89335. /**
  89336. * Use this list to define the list of mesh you want to render.
  89337. */
  89338. renderList: Nullable<Array<AbstractMesh>>;
  89339. private _hookArray;
  89340. /**
  89341. * Define if particles should be rendered in your texture.
  89342. */
  89343. renderParticles: boolean;
  89344. /**
  89345. * Define if sprites should be rendered in your texture.
  89346. */
  89347. renderSprites: boolean;
  89348. /**
  89349. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  89350. */
  89351. coordinatesMode: number;
  89352. /**
  89353. * Define the camera used to render the texture.
  89354. */
  89355. activeCamera: Nullable<Camera>;
  89356. /**
  89357. * Override the render function of the texture with your own one.
  89358. */
  89359. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  89360. /**
  89361. * Define if camera post processes should be use while rendering the texture.
  89362. */
  89363. useCameraPostProcesses: boolean;
  89364. /**
  89365. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  89366. */
  89367. ignoreCameraViewport: boolean;
  89368. private _postProcessManager;
  89369. private _postProcesses;
  89370. private _resizeObserver;
  89371. /**
  89372. * An event triggered when the texture is unbind.
  89373. */
  89374. onBeforeBindObservable: Observable<RenderTargetTexture>;
  89375. /**
  89376. * An event triggered when the texture is unbind.
  89377. */
  89378. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  89379. private _onAfterUnbindObserver;
  89380. /**
  89381. * Set a after unbind callback in the texture.
  89382. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  89383. */
  89384. onAfterUnbind: () => void;
  89385. /**
  89386. * An event triggered before rendering the texture
  89387. */
  89388. onBeforeRenderObservable: Observable<number>;
  89389. private _onBeforeRenderObserver;
  89390. /**
  89391. * Set a before render callback in the texture.
  89392. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  89393. */
  89394. onBeforeRender: (faceIndex: number) => void;
  89395. /**
  89396. * An event triggered after rendering the texture
  89397. */
  89398. onAfterRenderObservable: Observable<number>;
  89399. private _onAfterRenderObserver;
  89400. /**
  89401. * Set a after render callback in the texture.
  89402. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  89403. */
  89404. onAfterRender: (faceIndex: number) => void;
  89405. /**
  89406. * An event triggered after the texture clear
  89407. */
  89408. onClearObservable: Observable<Engine>;
  89409. private _onClearObserver;
  89410. /**
  89411. * Set a clear callback in the texture.
  89412. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  89413. */
  89414. onClear: (Engine: Engine) => void;
  89415. /**
  89416. * An event triggered when the texture is resized.
  89417. */
  89418. onResizeObservable: Observable<RenderTargetTexture>;
  89419. /**
  89420. * Define the clear color of the Render Target if it should be different from the scene.
  89421. */
  89422. clearColor: Color4;
  89423. protected _size: number | {
  89424. width: number;
  89425. height: number;
  89426. };
  89427. protected _initialSizeParameter: number | {
  89428. width: number;
  89429. height: number;
  89430. } | {
  89431. ratio: number;
  89432. };
  89433. protected _sizeRatio: Nullable<number>;
  89434. /** @hidden */
  89435. _generateMipMaps: boolean;
  89436. protected _renderingManager: RenderingManager;
  89437. /** @hidden */
  89438. _waitingRenderList: string[];
  89439. protected _doNotChangeAspectRatio: boolean;
  89440. protected _currentRefreshId: number;
  89441. protected _refreshRate: number;
  89442. protected _textureMatrix: Matrix;
  89443. protected _samples: number;
  89444. protected _renderTargetOptions: RenderTargetCreationOptions;
  89445. /**
  89446. * Gets render target creation options that were used.
  89447. */
  89448. readonly renderTargetOptions: RenderTargetCreationOptions;
  89449. protected _engine: Engine;
  89450. protected _onRatioRescale(): void;
  89451. /**
  89452. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  89453. * It must define where the camera used to render the texture is set
  89454. */
  89455. boundingBoxPosition: Vector3;
  89456. private _boundingBoxSize;
  89457. /**
  89458. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  89459. * When defined, the cubemap will switch to local mode
  89460. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  89461. * @example https://www.babylonjs-playground.com/#RNASML
  89462. */
  89463. boundingBoxSize: Vector3;
  89464. /**
  89465. * In case the RTT has been created with a depth texture, get the associated
  89466. * depth texture.
  89467. * Otherwise, return null.
  89468. */
  89469. depthStencilTexture: Nullable<InternalTexture>;
  89470. /**
  89471. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  89472. * or used a shadow, depth texture...
  89473. * @param name The friendly name of the texture
  89474. * @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)
  89475. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  89476. * @param generateMipMaps True if mip maps need to be generated after render.
  89477. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  89478. * @param type The type of the buffer in the RTT (int, half float, float...)
  89479. * @param isCube True if a cube texture needs to be created
  89480. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  89481. * @param generateDepthBuffer True to generate a depth buffer
  89482. * @param generateStencilBuffer True to generate a stencil buffer
  89483. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  89484. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  89485. * @param delayAllocation if the texture allocation should be delayed (default: false)
  89486. */
  89487. constructor(name: string, size: number | {
  89488. width: number;
  89489. height: number;
  89490. } | {
  89491. ratio: number;
  89492. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  89493. /**
  89494. * Creates a depth stencil texture.
  89495. * This is only available in WebGL 2 or with the depth texture extension available.
  89496. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  89497. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  89498. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  89499. */
  89500. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  89501. private _processSizeParameter;
  89502. /**
  89503. * Define the number of samples to use in case of MSAA.
  89504. * It defaults to one meaning no MSAA has been enabled.
  89505. */
  89506. samples: number;
  89507. /**
  89508. * Resets the refresh counter of the texture and start bak from scratch.
  89509. * Could be useful to regenerate the texture if it is setup to render only once.
  89510. */
  89511. resetRefreshCounter(): void;
  89512. /**
  89513. * Define the refresh rate of the texture or the rendering frequency.
  89514. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  89515. */
  89516. refreshRate: number;
  89517. /**
  89518. * Adds a post process to the render target rendering passes.
  89519. * @param postProcess define the post process to add
  89520. */
  89521. addPostProcess(postProcess: PostProcess): void;
  89522. /**
  89523. * Clear all the post processes attached to the render target
  89524. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  89525. */
  89526. clearPostProcesses(dispose?: boolean): void;
  89527. /**
  89528. * Remove one of the post process from the list of attached post processes to the texture
  89529. * @param postProcess define the post process to remove from the list
  89530. */
  89531. removePostProcess(postProcess: PostProcess): void;
  89532. /** @hidden */
  89533. _shouldRender(): boolean;
  89534. /**
  89535. * Gets the actual render size of the texture.
  89536. * @returns the width of the render size
  89537. */
  89538. getRenderSize(): number;
  89539. /**
  89540. * Gets the actual render width of the texture.
  89541. * @returns the width of the render size
  89542. */
  89543. getRenderWidth(): number;
  89544. /**
  89545. * Gets the actual render height of the texture.
  89546. * @returns the height of the render size
  89547. */
  89548. getRenderHeight(): number;
  89549. /**
  89550. * Get if the texture can be rescaled or not.
  89551. */
  89552. readonly canRescale: boolean;
  89553. /**
  89554. * Resize the texture using a ratio.
  89555. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  89556. */
  89557. scale(ratio: number): void;
  89558. /**
  89559. * Get the texture reflection matrix used to rotate/transform the reflection.
  89560. * @returns the reflection matrix
  89561. */
  89562. getReflectionTextureMatrix(): Matrix;
  89563. /**
  89564. * Resize the texture to a new desired size.
  89565. * Be carrefull as it will recreate all the data in the new texture.
  89566. * @param size Define the new size. It can be:
  89567. * - a number for squared texture,
  89568. * - an object containing { width: number, height: number }
  89569. * - or an object containing a ratio { ratio: number }
  89570. */
  89571. resize(size: number | {
  89572. width: number;
  89573. height: number;
  89574. } | {
  89575. ratio: number;
  89576. }): void;
  89577. /**
  89578. * Renders all the objects from the render list into the texture.
  89579. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  89580. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  89581. */
  89582. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  89583. private _bestReflectionRenderTargetDimension;
  89584. /**
  89585. * @hidden
  89586. * @param faceIndex face index to bind to if this is a cubetexture
  89587. */
  89588. _bindFrameBuffer(faceIndex?: number): void;
  89589. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  89590. private renderToTarget;
  89591. /**
  89592. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  89593. * This allowed control for front to back rendering or reversly depending of the special needs.
  89594. *
  89595. * @param renderingGroupId The rendering group id corresponding to its index
  89596. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  89597. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  89598. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  89599. */
  89600. 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;
  89601. /**
  89602. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  89603. *
  89604. * @param renderingGroupId The rendering group id corresponding to its index
  89605. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  89606. */
  89607. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  89608. /**
  89609. * Clones the texture.
  89610. * @returns the cloned texture
  89611. */
  89612. clone(): RenderTargetTexture;
  89613. /**
  89614. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  89615. * @returns The JSON representation of the texture
  89616. */
  89617. serialize(): any;
  89618. /**
  89619. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  89620. */
  89621. disposeFramebufferObjects(): void;
  89622. /**
  89623. * Dispose the texture and release its associated resources.
  89624. */
  89625. dispose(): void;
  89626. /** @hidden */
  89627. _rebuild(): void;
  89628. /**
  89629. * Clear the info related to rendering groups preventing retention point in material dispose.
  89630. */
  89631. freeRenderingGroups(): void;
  89632. /**
  89633. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  89634. * @returns the view count
  89635. */
  89636. getViewCount(): number;
  89637. }
  89638. }
  89639. declare module BABYLON {
  89640. /**
  89641. * Options for compiling materials.
  89642. */
  89643. export interface IMaterialCompilationOptions {
  89644. /**
  89645. * Defines whether clip planes are enabled.
  89646. */
  89647. clipPlane: boolean;
  89648. /**
  89649. * Defines whether instances are enabled.
  89650. */
  89651. useInstances: boolean;
  89652. }
  89653. /**
  89654. * Base class for the main features of a material in Babylon.js
  89655. */
  89656. export class Material implements IAnimatable {
  89657. /**
  89658. * Returns the triangle fill mode
  89659. */
  89660. static readonly TriangleFillMode: number;
  89661. /**
  89662. * Returns the wireframe mode
  89663. */
  89664. static readonly WireFrameFillMode: number;
  89665. /**
  89666. * Returns the point fill mode
  89667. */
  89668. static readonly PointFillMode: number;
  89669. /**
  89670. * Returns the point list draw mode
  89671. */
  89672. static readonly PointListDrawMode: number;
  89673. /**
  89674. * Returns the line list draw mode
  89675. */
  89676. static readonly LineListDrawMode: number;
  89677. /**
  89678. * Returns the line loop draw mode
  89679. */
  89680. static readonly LineLoopDrawMode: number;
  89681. /**
  89682. * Returns the line strip draw mode
  89683. */
  89684. static readonly LineStripDrawMode: number;
  89685. /**
  89686. * Returns the triangle strip draw mode
  89687. */
  89688. static readonly TriangleStripDrawMode: number;
  89689. /**
  89690. * Returns the triangle fan draw mode
  89691. */
  89692. static readonly TriangleFanDrawMode: number;
  89693. /**
  89694. * Stores the clock-wise side orientation
  89695. */
  89696. static readonly ClockWiseSideOrientation: number;
  89697. /**
  89698. * Stores the counter clock-wise side orientation
  89699. */
  89700. static readonly CounterClockWiseSideOrientation: number;
  89701. /**
  89702. * The dirty texture flag value
  89703. */
  89704. static readonly TextureDirtyFlag: number;
  89705. /**
  89706. * The dirty light flag value
  89707. */
  89708. static readonly LightDirtyFlag: number;
  89709. /**
  89710. * The dirty fresnel flag value
  89711. */
  89712. static readonly FresnelDirtyFlag: number;
  89713. /**
  89714. * The dirty attribute flag value
  89715. */
  89716. static readonly AttributesDirtyFlag: number;
  89717. /**
  89718. * The dirty misc flag value
  89719. */
  89720. static readonly MiscDirtyFlag: number;
  89721. /**
  89722. * The all dirty flag value
  89723. */
  89724. static readonly AllDirtyFlag: number;
  89725. /**
  89726. * The ID of the material
  89727. */
  89728. id: string;
  89729. /**
  89730. * Gets or sets the unique id of the material
  89731. */
  89732. uniqueId: number;
  89733. /**
  89734. * The name of the material
  89735. */
  89736. name: string;
  89737. /**
  89738. * Gets or sets user defined metadata
  89739. */
  89740. metadata: any;
  89741. /**
  89742. * For internal use only. Please do not use.
  89743. */
  89744. reservedDataStore: any;
  89745. /**
  89746. * Specifies if the ready state should be checked on each call
  89747. */
  89748. checkReadyOnEveryCall: boolean;
  89749. /**
  89750. * Specifies if the ready state should be checked once
  89751. */
  89752. checkReadyOnlyOnce: boolean;
  89753. /**
  89754. * The state of the material
  89755. */
  89756. state: string;
  89757. /**
  89758. * The alpha value of the material
  89759. */
  89760. protected _alpha: number;
  89761. /**
  89762. * List of inspectable custom properties (used by the Inspector)
  89763. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  89764. */
  89765. inspectableCustomProperties: IInspectable[];
  89766. /**
  89767. * Sets the alpha value of the material
  89768. */
  89769. /**
  89770. * Gets the alpha value of the material
  89771. */
  89772. alpha: number;
  89773. /**
  89774. * Specifies if back face culling is enabled
  89775. */
  89776. protected _backFaceCulling: boolean;
  89777. /**
  89778. * Sets the back-face culling state
  89779. */
  89780. /**
  89781. * Gets the back-face culling state
  89782. */
  89783. backFaceCulling: boolean;
  89784. /**
  89785. * Stores the value for side orientation
  89786. */
  89787. sideOrientation: number;
  89788. /**
  89789. * Callback triggered when the material is compiled
  89790. */
  89791. onCompiled: Nullable<(effect: Effect) => void>;
  89792. /**
  89793. * Callback triggered when an error occurs
  89794. */
  89795. onError: Nullable<(effect: Effect, errors: string) => void>;
  89796. /**
  89797. * Callback triggered to get the render target textures
  89798. */
  89799. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  89800. /**
  89801. * Gets a boolean indicating that current material needs to register RTT
  89802. */
  89803. readonly hasRenderTargetTextures: boolean;
  89804. /**
  89805. * Specifies if the material should be serialized
  89806. */
  89807. doNotSerialize: boolean;
  89808. /**
  89809. * @hidden
  89810. */
  89811. _storeEffectOnSubMeshes: boolean;
  89812. /**
  89813. * Stores the animations for the material
  89814. */
  89815. animations: Nullable<Array<Animation>>;
  89816. /**
  89817. * An event triggered when the material is disposed
  89818. */
  89819. onDisposeObservable: Observable<Material>;
  89820. /**
  89821. * An observer which watches for dispose events
  89822. */
  89823. private _onDisposeObserver;
  89824. private _onUnBindObservable;
  89825. /**
  89826. * Called during a dispose event
  89827. */
  89828. onDispose: () => void;
  89829. private _onBindObservable;
  89830. /**
  89831. * An event triggered when the material is bound
  89832. */
  89833. readonly onBindObservable: Observable<AbstractMesh>;
  89834. /**
  89835. * An observer which watches for bind events
  89836. */
  89837. private _onBindObserver;
  89838. /**
  89839. * Called during a bind event
  89840. */
  89841. onBind: (Mesh: AbstractMesh) => void;
  89842. /**
  89843. * An event triggered when the material is unbound
  89844. */
  89845. readonly onUnBindObservable: Observable<Material>;
  89846. /**
  89847. * Stores the value of the alpha mode
  89848. */
  89849. private _alphaMode;
  89850. /**
  89851. * Sets the value of the alpha mode.
  89852. *
  89853. * | Value | Type | Description |
  89854. * | --- | --- | --- |
  89855. * | 0 | ALPHA_DISABLE | |
  89856. * | 1 | ALPHA_ADD | |
  89857. * | 2 | ALPHA_COMBINE | |
  89858. * | 3 | ALPHA_SUBTRACT | |
  89859. * | 4 | ALPHA_MULTIPLY | |
  89860. * | 5 | ALPHA_MAXIMIZED | |
  89861. * | 6 | ALPHA_ONEONE | |
  89862. * | 7 | ALPHA_PREMULTIPLIED | |
  89863. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  89864. * | 9 | ALPHA_INTERPOLATE | |
  89865. * | 10 | ALPHA_SCREENMODE | |
  89866. *
  89867. */
  89868. /**
  89869. * Gets the value of the alpha mode
  89870. */
  89871. alphaMode: number;
  89872. /**
  89873. * Stores the state of the need depth pre-pass value
  89874. */
  89875. private _needDepthPrePass;
  89876. /**
  89877. * Sets the need depth pre-pass value
  89878. */
  89879. /**
  89880. * Gets the depth pre-pass value
  89881. */
  89882. needDepthPrePass: boolean;
  89883. /**
  89884. * Specifies if depth writing should be disabled
  89885. */
  89886. disableDepthWrite: boolean;
  89887. /**
  89888. * Specifies if depth writing should be forced
  89889. */
  89890. forceDepthWrite: boolean;
  89891. /**
  89892. * Specifies the depth function that should be used. 0 means the default engine function
  89893. */
  89894. depthFunction: number;
  89895. /**
  89896. * Specifies if there should be a separate pass for culling
  89897. */
  89898. separateCullingPass: boolean;
  89899. /**
  89900. * Stores the state specifing if fog should be enabled
  89901. */
  89902. private _fogEnabled;
  89903. /**
  89904. * Sets the state for enabling fog
  89905. */
  89906. /**
  89907. * Gets the value of the fog enabled state
  89908. */
  89909. fogEnabled: boolean;
  89910. /**
  89911. * Stores the size of points
  89912. */
  89913. pointSize: number;
  89914. /**
  89915. * Stores the z offset value
  89916. */
  89917. zOffset: number;
  89918. /**
  89919. * Gets a value specifying if wireframe mode is enabled
  89920. */
  89921. /**
  89922. * Sets the state of wireframe mode
  89923. */
  89924. wireframe: boolean;
  89925. /**
  89926. * Gets the value specifying if point clouds are enabled
  89927. */
  89928. /**
  89929. * Sets the state of point cloud mode
  89930. */
  89931. pointsCloud: boolean;
  89932. /**
  89933. * Gets the material fill mode
  89934. */
  89935. /**
  89936. * Sets the material fill mode
  89937. */
  89938. fillMode: number;
  89939. /**
  89940. * @hidden
  89941. * Stores the effects for the material
  89942. */
  89943. _effect: Nullable<Effect>;
  89944. /**
  89945. * @hidden
  89946. * Specifies if the material was previously ready
  89947. */
  89948. _wasPreviouslyReady: boolean;
  89949. /**
  89950. * Specifies if uniform buffers should be used
  89951. */
  89952. private _useUBO;
  89953. /**
  89954. * Stores a reference to the scene
  89955. */
  89956. private _scene;
  89957. /**
  89958. * Stores the fill mode state
  89959. */
  89960. private _fillMode;
  89961. /**
  89962. * Specifies if the depth write state should be cached
  89963. */
  89964. private _cachedDepthWriteState;
  89965. /**
  89966. * Specifies if the depth function state should be cached
  89967. */
  89968. private _cachedDepthFunctionState;
  89969. /**
  89970. * Stores the uniform buffer
  89971. */
  89972. protected _uniformBuffer: UniformBuffer;
  89973. /** @hidden */
  89974. _indexInSceneMaterialArray: number;
  89975. /** @hidden */
  89976. meshMap: Nullable<{
  89977. [id: string]: AbstractMesh | undefined;
  89978. }>;
  89979. /**
  89980. * Creates a material instance
  89981. * @param name defines the name of the material
  89982. * @param scene defines the scene to reference
  89983. * @param doNotAdd specifies if the material should be added to the scene
  89984. */
  89985. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  89986. /**
  89987. * Returns a string representation of the current material
  89988. * @param fullDetails defines a boolean indicating which levels of logging is desired
  89989. * @returns a string with material information
  89990. */
  89991. toString(fullDetails?: boolean): string;
  89992. /**
  89993. * Gets the class name of the material
  89994. * @returns a string with the class name of the material
  89995. */
  89996. getClassName(): string;
  89997. /**
  89998. * Specifies if updates for the material been locked
  89999. */
  90000. readonly isFrozen: boolean;
  90001. /**
  90002. * Locks updates for the material
  90003. */
  90004. freeze(): void;
  90005. /**
  90006. * Unlocks updates for the material
  90007. */
  90008. unfreeze(): void;
  90009. /**
  90010. * Specifies if the material is ready to be used
  90011. * @param mesh defines the mesh to check
  90012. * @param useInstances specifies if instances should be used
  90013. * @returns a boolean indicating if the material is ready to be used
  90014. */
  90015. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  90016. /**
  90017. * Specifies that the submesh is ready to be used
  90018. * @param mesh defines the mesh to check
  90019. * @param subMesh defines which submesh to check
  90020. * @param useInstances specifies that instances should be used
  90021. * @returns a boolean indicating that the submesh is ready or not
  90022. */
  90023. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  90024. /**
  90025. * Returns the material effect
  90026. * @returns the effect associated with the material
  90027. */
  90028. getEffect(): Nullable<Effect>;
  90029. /**
  90030. * Returns the current scene
  90031. * @returns a Scene
  90032. */
  90033. getScene(): Scene;
  90034. /**
  90035. * Specifies if the material will require alpha blending
  90036. * @returns a boolean specifying if alpha blending is needed
  90037. */
  90038. needAlphaBlending(): boolean;
  90039. /**
  90040. * Specifies if the mesh will require alpha blending
  90041. * @param mesh defines the mesh to check
  90042. * @returns a boolean specifying if alpha blending is needed for the mesh
  90043. */
  90044. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  90045. /**
  90046. * Specifies if this material should be rendered in alpha test mode
  90047. * @returns a boolean specifying if an alpha test is needed.
  90048. */
  90049. needAlphaTesting(): boolean;
  90050. /**
  90051. * Gets the texture used for the alpha test
  90052. * @returns the texture to use for alpha testing
  90053. */
  90054. getAlphaTestTexture(): Nullable<BaseTexture>;
  90055. /**
  90056. * Marks the material to indicate that it needs to be re-calculated
  90057. */
  90058. markDirty(): void;
  90059. /** @hidden */
  90060. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  90061. /**
  90062. * Binds the material to the mesh
  90063. * @param world defines the world transformation matrix
  90064. * @param mesh defines the mesh to bind the material to
  90065. */
  90066. bind(world: Matrix, mesh?: Mesh): void;
  90067. /**
  90068. * Binds the submesh to the material
  90069. * @param world defines the world transformation matrix
  90070. * @param mesh defines the mesh containing the submesh
  90071. * @param subMesh defines the submesh to bind the material to
  90072. */
  90073. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  90074. /**
  90075. * Binds the world matrix to the material
  90076. * @param world defines the world transformation matrix
  90077. */
  90078. bindOnlyWorldMatrix(world: Matrix): void;
  90079. /**
  90080. * Binds the scene's uniform buffer to the effect.
  90081. * @param effect defines the effect to bind to the scene uniform buffer
  90082. * @param sceneUbo defines the uniform buffer storing scene data
  90083. */
  90084. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  90085. /**
  90086. * Binds the view matrix to the effect
  90087. * @param effect defines the effect to bind the view matrix to
  90088. */
  90089. bindView(effect: Effect): void;
  90090. /**
  90091. * Binds the view projection matrix to the effect
  90092. * @param effect defines the effect to bind the view projection matrix to
  90093. */
  90094. bindViewProjection(effect: Effect): void;
  90095. /**
  90096. * Specifies if material alpha testing should be turned on for the mesh
  90097. * @param mesh defines the mesh to check
  90098. */
  90099. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  90100. /**
  90101. * Processes to execute after binding the material to a mesh
  90102. * @param mesh defines the rendered mesh
  90103. */
  90104. protected _afterBind(mesh?: Mesh): void;
  90105. /**
  90106. * Unbinds the material from the mesh
  90107. */
  90108. unbind(): void;
  90109. /**
  90110. * Gets the active textures from the material
  90111. * @returns an array of textures
  90112. */
  90113. getActiveTextures(): BaseTexture[];
  90114. /**
  90115. * Specifies if the material uses a texture
  90116. * @param texture defines the texture to check against the material
  90117. * @returns a boolean specifying if the material uses the texture
  90118. */
  90119. hasTexture(texture: BaseTexture): boolean;
  90120. /**
  90121. * Makes a duplicate of the material, and gives it a new name
  90122. * @param name defines the new name for the duplicated material
  90123. * @returns the cloned material
  90124. */
  90125. clone(name: string): Nullable<Material>;
  90126. /**
  90127. * Gets the meshes bound to the material
  90128. * @returns an array of meshes bound to the material
  90129. */
  90130. getBindedMeshes(): AbstractMesh[];
  90131. /**
  90132. * Force shader compilation
  90133. * @param mesh defines the mesh associated with this material
  90134. * @param onCompiled defines a function to execute once the material is compiled
  90135. * @param options defines the options to configure the compilation
  90136. * @param onError defines a function to execute if the material fails compiling
  90137. */
  90138. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  90139. /**
  90140. * Force shader compilation
  90141. * @param mesh defines the mesh that will use this material
  90142. * @param options defines additional options for compiling the shaders
  90143. * @returns a promise that resolves when the compilation completes
  90144. */
  90145. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  90146. private static readonly _AllDirtyCallBack;
  90147. private static readonly _ImageProcessingDirtyCallBack;
  90148. private static readonly _TextureDirtyCallBack;
  90149. private static readonly _FresnelDirtyCallBack;
  90150. private static readonly _MiscDirtyCallBack;
  90151. private static readonly _LightsDirtyCallBack;
  90152. private static readonly _AttributeDirtyCallBack;
  90153. private static _FresnelAndMiscDirtyCallBack;
  90154. private static _TextureAndMiscDirtyCallBack;
  90155. private static readonly _DirtyCallbackArray;
  90156. private static readonly _RunDirtyCallBacks;
  90157. /**
  90158. * Marks a define in the material to indicate that it needs to be re-computed
  90159. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  90160. */
  90161. markAsDirty(flag: number): void;
  90162. /**
  90163. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  90164. * @param func defines a function which checks material defines against the submeshes
  90165. */
  90166. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  90167. /**
  90168. * Indicates that we need to re-calculated for all submeshes
  90169. */
  90170. protected _markAllSubMeshesAsAllDirty(): void;
  90171. /**
  90172. * Indicates that image processing needs to be re-calculated for all submeshes
  90173. */
  90174. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  90175. /**
  90176. * Indicates that textures need to be re-calculated for all submeshes
  90177. */
  90178. protected _markAllSubMeshesAsTexturesDirty(): void;
  90179. /**
  90180. * Indicates that fresnel needs to be re-calculated for all submeshes
  90181. */
  90182. protected _markAllSubMeshesAsFresnelDirty(): void;
  90183. /**
  90184. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  90185. */
  90186. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  90187. /**
  90188. * Indicates that lights need to be re-calculated for all submeshes
  90189. */
  90190. protected _markAllSubMeshesAsLightsDirty(): void;
  90191. /**
  90192. * Indicates that attributes need to be re-calculated for all submeshes
  90193. */
  90194. protected _markAllSubMeshesAsAttributesDirty(): void;
  90195. /**
  90196. * Indicates that misc needs to be re-calculated for all submeshes
  90197. */
  90198. protected _markAllSubMeshesAsMiscDirty(): void;
  90199. /**
  90200. * Indicates that textures and misc need to be re-calculated for all submeshes
  90201. */
  90202. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  90203. /**
  90204. * Disposes the material
  90205. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  90206. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  90207. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  90208. */
  90209. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  90210. /** @hidden */
  90211. private releaseVertexArrayObject;
  90212. /**
  90213. * Serializes this material
  90214. * @returns the serialized material object
  90215. */
  90216. serialize(): any;
  90217. /**
  90218. * Creates a material from parsed material data
  90219. * @param parsedMaterial defines parsed material data
  90220. * @param scene defines the hosting scene
  90221. * @param rootUrl defines the root URL to use to load textures
  90222. * @returns a new material
  90223. */
  90224. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  90225. }
  90226. }
  90227. declare module BABYLON {
  90228. /**
  90229. * A multi-material is used to apply different materials to different parts of the same object without the need of
  90230. * separate meshes. This can be use to improve performances.
  90231. * @see http://doc.babylonjs.com/how_to/multi_materials
  90232. */
  90233. export class MultiMaterial extends Material {
  90234. private _subMaterials;
  90235. /**
  90236. * Gets or Sets the list of Materials used within the multi material.
  90237. * They need to be ordered according to the submeshes order in the associated mesh
  90238. */
  90239. subMaterials: Nullable<Material>[];
  90240. /**
  90241. * Function used to align with Node.getChildren()
  90242. * @returns the list of Materials used within the multi material
  90243. */
  90244. getChildren(): Nullable<Material>[];
  90245. /**
  90246. * Instantiates a new Multi Material
  90247. * A multi-material is used to apply different materials to different parts of the same object without the need of
  90248. * separate meshes. This can be use to improve performances.
  90249. * @see http://doc.babylonjs.com/how_to/multi_materials
  90250. * @param name Define the name in the scene
  90251. * @param scene Define the scene the material belongs to
  90252. */
  90253. constructor(name: string, scene: Scene);
  90254. private _hookArray;
  90255. /**
  90256. * Get one of the submaterial by its index in the submaterials array
  90257. * @param index The index to look the sub material at
  90258. * @returns The Material if the index has been defined
  90259. */
  90260. getSubMaterial(index: number): Nullable<Material>;
  90261. /**
  90262. * Get the list of active textures for the whole sub materials list.
  90263. * @returns All the textures that will be used during the rendering
  90264. */
  90265. getActiveTextures(): BaseTexture[];
  90266. /**
  90267. * Gets the current class name of the material e.g. "MultiMaterial"
  90268. * Mainly use in serialization.
  90269. * @returns the class name
  90270. */
  90271. getClassName(): string;
  90272. /**
  90273. * Checks if the material is ready to render the requested sub mesh
  90274. * @param mesh Define the mesh the submesh belongs to
  90275. * @param subMesh Define the sub mesh to look readyness for
  90276. * @param useInstances Define whether or not the material is used with instances
  90277. * @returns true if ready, otherwise false
  90278. */
  90279. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  90280. /**
  90281. * Clones the current material and its related sub materials
  90282. * @param name Define the name of the newly cloned material
  90283. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  90284. * @returns the cloned material
  90285. */
  90286. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  90287. /**
  90288. * Serializes the materials into a JSON representation.
  90289. * @returns the JSON representation
  90290. */
  90291. serialize(): any;
  90292. /**
  90293. * Dispose the material and release its associated resources
  90294. * @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)
  90295. * @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)
  90296. * @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)
  90297. */
  90298. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  90299. /**
  90300. * Creates a MultiMaterial from parsed MultiMaterial data.
  90301. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  90302. * @param scene defines the hosting scene
  90303. * @returns a new MultiMaterial
  90304. */
  90305. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  90306. }
  90307. }
  90308. declare module BABYLON {
  90309. /**
  90310. * Base class for submeshes
  90311. */
  90312. export class BaseSubMesh {
  90313. /** @hidden */
  90314. _materialDefines: Nullable<MaterialDefines>;
  90315. /** @hidden */
  90316. _materialEffect: Nullable<Effect>;
  90317. /**
  90318. * Gets material defines used by the effect associated to the sub mesh
  90319. */
  90320. /**
  90321. * Sets material defines used by the effect associated to the sub mesh
  90322. */
  90323. materialDefines: Nullable<MaterialDefines>;
  90324. /**
  90325. * Gets associated effect
  90326. */
  90327. readonly effect: Nullable<Effect>;
  90328. /**
  90329. * Sets associated effect (effect used to render this submesh)
  90330. * @param effect defines the effect to associate with
  90331. * @param defines defines the set of defines used to compile this effect
  90332. */
  90333. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  90334. }
  90335. /**
  90336. * Defines a subdivision inside a mesh
  90337. */
  90338. export class SubMesh extends BaseSubMesh implements ICullable {
  90339. /** the material index to use */
  90340. materialIndex: number;
  90341. /** vertex index start */
  90342. verticesStart: number;
  90343. /** vertices count */
  90344. verticesCount: number;
  90345. /** index start */
  90346. indexStart: number;
  90347. /** indices count */
  90348. indexCount: number;
  90349. /** @hidden */
  90350. _linesIndexCount: number;
  90351. private _mesh;
  90352. private _renderingMesh;
  90353. private _boundingInfo;
  90354. private _linesIndexBuffer;
  90355. /** @hidden */
  90356. _lastColliderWorldVertices: Nullable<Vector3[]>;
  90357. /** @hidden */
  90358. _trianglePlanes: Plane[];
  90359. /** @hidden */
  90360. _lastColliderTransformMatrix: Nullable<Matrix>;
  90361. /** @hidden */
  90362. _renderId: number;
  90363. /** @hidden */
  90364. _alphaIndex: number;
  90365. /** @hidden */
  90366. _distanceToCamera: number;
  90367. /** @hidden */
  90368. _id: number;
  90369. private _currentMaterial;
  90370. /**
  90371. * Add a new submesh to a mesh
  90372. * @param materialIndex defines the material index to use
  90373. * @param verticesStart defines vertex index start
  90374. * @param verticesCount defines vertices count
  90375. * @param indexStart defines index start
  90376. * @param indexCount defines indices count
  90377. * @param mesh defines the parent mesh
  90378. * @param renderingMesh defines an optional rendering mesh
  90379. * @param createBoundingBox defines if bounding box should be created for this submesh
  90380. * @returns the new submesh
  90381. */
  90382. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  90383. /**
  90384. * Creates a new submesh
  90385. * @param materialIndex defines the material index to use
  90386. * @param verticesStart defines vertex index start
  90387. * @param verticesCount defines vertices count
  90388. * @param indexStart defines index start
  90389. * @param indexCount defines indices count
  90390. * @param mesh defines the parent mesh
  90391. * @param renderingMesh defines an optional rendering mesh
  90392. * @param createBoundingBox defines if bounding box should be created for this submesh
  90393. */
  90394. constructor(
  90395. /** the material index to use */
  90396. materialIndex: number,
  90397. /** vertex index start */
  90398. verticesStart: number,
  90399. /** vertices count */
  90400. verticesCount: number,
  90401. /** index start */
  90402. indexStart: number,
  90403. /** indices count */
  90404. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  90405. /**
  90406. * Returns true if this submesh covers the entire parent mesh
  90407. * @ignorenaming
  90408. */
  90409. readonly IsGlobal: boolean;
  90410. /**
  90411. * Returns the submesh BoudingInfo object
  90412. * @returns current bounding info (or mesh's one if the submesh is global)
  90413. */
  90414. getBoundingInfo(): BoundingInfo;
  90415. /**
  90416. * Sets the submesh BoundingInfo
  90417. * @param boundingInfo defines the new bounding info to use
  90418. * @returns the SubMesh
  90419. */
  90420. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  90421. /**
  90422. * Returns the mesh of the current submesh
  90423. * @return the parent mesh
  90424. */
  90425. getMesh(): AbstractMesh;
  90426. /**
  90427. * Returns the rendering mesh of the submesh
  90428. * @returns the rendering mesh (could be different from parent mesh)
  90429. */
  90430. getRenderingMesh(): Mesh;
  90431. /**
  90432. * Returns the submesh material
  90433. * @returns null or the current material
  90434. */
  90435. getMaterial(): Nullable<Material>;
  90436. /**
  90437. * Sets a new updated BoundingInfo object to the submesh
  90438. * @param data defines an optional position array to use to determine the bounding info
  90439. * @returns the SubMesh
  90440. */
  90441. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  90442. /** @hidden */
  90443. _checkCollision(collider: Collider): boolean;
  90444. /**
  90445. * Updates the submesh BoundingInfo
  90446. * @param world defines the world matrix to use to update the bounding info
  90447. * @returns the submesh
  90448. */
  90449. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  90450. /**
  90451. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  90452. * @param frustumPlanes defines the frustum planes
  90453. * @returns true if the submesh is intersecting with the frustum
  90454. */
  90455. isInFrustum(frustumPlanes: Plane[]): boolean;
  90456. /**
  90457. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  90458. * @param frustumPlanes defines the frustum planes
  90459. * @returns true if the submesh is inside the frustum
  90460. */
  90461. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  90462. /**
  90463. * Renders the submesh
  90464. * @param enableAlphaMode defines if alpha needs to be used
  90465. * @returns the submesh
  90466. */
  90467. render(enableAlphaMode: boolean): SubMesh;
  90468. /**
  90469. * @hidden
  90470. */
  90471. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  90472. /**
  90473. * Checks if the submesh intersects with a ray
  90474. * @param ray defines the ray to test
  90475. * @returns true is the passed ray intersects the submesh bounding box
  90476. */
  90477. canIntersects(ray: Ray): boolean;
  90478. /**
  90479. * Intersects current submesh with a ray
  90480. * @param ray defines the ray to test
  90481. * @param positions defines mesh's positions array
  90482. * @param indices defines mesh's indices array
  90483. * @param fastCheck defines if only bounding info should be used
  90484. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  90485. * @returns intersection info or null if no intersection
  90486. */
  90487. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  90488. /** @hidden */
  90489. private _intersectLines;
  90490. /** @hidden */
  90491. private _intersectUnIndexedLines;
  90492. /** @hidden */
  90493. private _intersectTriangles;
  90494. /** @hidden */
  90495. private _intersectUnIndexedTriangles;
  90496. /** @hidden */
  90497. _rebuild(): void;
  90498. /**
  90499. * Creates a new submesh from the passed mesh
  90500. * @param newMesh defines the new hosting mesh
  90501. * @param newRenderingMesh defines an optional rendering mesh
  90502. * @returns the new submesh
  90503. */
  90504. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  90505. /**
  90506. * Release associated resources
  90507. */
  90508. dispose(): void;
  90509. /**
  90510. * Gets the class name
  90511. * @returns the string "SubMesh".
  90512. */
  90513. getClassName(): string;
  90514. /**
  90515. * Creates a new submesh from indices data
  90516. * @param materialIndex the index of the main mesh material
  90517. * @param startIndex the index where to start the copy in the mesh indices array
  90518. * @param indexCount the number of indices to copy then from the startIndex
  90519. * @param mesh the main mesh to create the submesh from
  90520. * @param renderingMesh the optional rendering mesh
  90521. * @returns a new submesh
  90522. */
  90523. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  90524. }
  90525. }
  90526. declare module BABYLON {
  90527. /**
  90528. * Class used to represent data loading progression
  90529. */
  90530. export class SceneLoaderFlags {
  90531. private static _ForceFullSceneLoadingForIncremental;
  90532. private static _ShowLoadingScreen;
  90533. private static _CleanBoneMatrixWeights;
  90534. private static _loggingLevel;
  90535. /**
  90536. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  90537. */
  90538. static ForceFullSceneLoadingForIncremental: boolean;
  90539. /**
  90540. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  90541. */
  90542. static ShowLoadingScreen: boolean;
  90543. /**
  90544. * Defines the current logging level (while loading the scene)
  90545. * @ignorenaming
  90546. */
  90547. static loggingLevel: number;
  90548. /**
  90549. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  90550. */
  90551. static CleanBoneMatrixWeights: boolean;
  90552. }
  90553. }
  90554. declare module BABYLON {
  90555. /**
  90556. * Class used to store geometry data (vertex buffers + index buffer)
  90557. */
  90558. export class Geometry implements IGetSetVerticesData {
  90559. /**
  90560. * Gets or sets the ID of the geometry
  90561. */
  90562. id: string;
  90563. /**
  90564. * Gets or sets the unique ID of the geometry
  90565. */
  90566. uniqueId: number;
  90567. /**
  90568. * Gets the delay loading state of the geometry (none by default which means not delayed)
  90569. */
  90570. delayLoadState: number;
  90571. /**
  90572. * Gets the file containing the data to load when running in delay load state
  90573. */
  90574. delayLoadingFile: Nullable<string>;
  90575. /**
  90576. * Callback called when the geometry is updated
  90577. */
  90578. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  90579. private _scene;
  90580. private _engine;
  90581. private _meshes;
  90582. private _totalVertices;
  90583. /** @hidden */
  90584. _indices: IndicesArray;
  90585. /** @hidden */
  90586. _vertexBuffers: {
  90587. [key: string]: VertexBuffer;
  90588. };
  90589. private _isDisposed;
  90590. private _extend;
  90591. private _boundingBias;
  90592. /** @hidden */
  90593. _delayInfo: Array<string>;
  90594. private _indexBuffer;
  90595. private _indexBufferIsUpdatable;
  90596. /** @hidden */
  90597. _boundingInfo: Nullable<BoundingInfo>;
  90598. /** @hidden */
  90599. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  90600. /** @hidden */
  90601. _softwareSkinningFrameId: number;
  90602. private _vertexArrayObjects;
  90603. private _updatable;
  90604. /** @hidden */
  90605. _positions: Nullable<Vector3[]>;
  90606. /**
  90607. * 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
  90608. */
  90609. /**
  90610. * 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
  90611. */
  90612. boundingBias: Vector2;
  90613. /**
  90614. * Static function used to attach a new empty geometry to a mesh
  90615. * @param mesh defines the mesh to attach the geometry to
  90616. * @returns the new Geometry
  90617. */
  90618. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  90619. /**
  90620. * Creates a new geometry
  90621. * @param id defines the unique ID
  90622. * @param scene defines the hosting scene
  90623. * @param vertexData defines the VertexData used to get geometry data
  90624. * @param updatable defines if geometry must be updatable (false by default)
  90625. * @param mesh defines the mesh that will be associated with the geometry
  90626. */
  90627. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  90628. /**
  90629. * Gets the current extend of the geometry
  90630. */
  90631. readonly extend: {
  90632. minimum: Vector3;
  90633. maximum: Vector3;
  90634. };
  90635. /**
  90636. * Gets the hosting scene
  90637. * @returns the hosting Scene
  90638. */
  90639. getScene(): Scene;
  90640. /**
  90641. * Gets the hosting engine
  90642. * @returns the hosting Engine
  90643. */
  90644. getEngine(): Engine;
  90645. /**
  90646. * Defines if the geometry is ready to use
  90647. * @returns true if the geometry is ready to be used
  90648. */
  90649. isReady(): boolean;
  90650. /**
  90651. * Gets a value indicating that the geometry should not be serialized
  90652. */
  90653. readonly doNotSerialize: boolean;
  90654. /** @hidden */
  90655. _rebuild(): void;
  90656. /**
  90657. * Affects all geometry data in one call
  90658. * @param vertexData defines the geometry data
  90659. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  90660. */
  90661. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  90662. /**
  90663. * Set specific vertex data
  90664. * @param kind defines the data kind (Position, normal, etc...)
  90665. * @param data defines the vertex data to use
  90666. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  90667. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  90668. */
  90669. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  90670. /**
  90671. * Removes a specific vertex data
  90672. * @param kind defines the data kind (Position, normal, etc...)
  90673. */
  90674. removeVerticesData(kind: string): void;
  90675. /**
  90676. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  90677. * @param buffer defines the vertex buffer to use
  90678. * @param totalVertices defines the total number of vertices for position kind (could be null)
  90679. */
  90680. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  90681. /**
  90682. * Update a specific vertex buffer
  90683. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  90684. * It will do nothing if the buffer is not updatable
  90685. * @param kind defines the data kind (Position, normal, etc...)
  90686. * @param data defines the data to use
  90687. * @param offset defines the offset in the target buffer where to store the data
  90688. * @param useBytes set to true if the offset is in bytes
  90689. */
  90690. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  90691. /**
  90692. * Update a specific vertex buffer
  90693. * This function will create a new buffer if the current one is not updatable
  90694. * @param kind defines the data kind (Position, normal, etc...)
  90695. * @param data defines the data to use
  90696. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  90697. */
  90698. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  90699. private _updateBoundingInfo;
  90700. /** @hidden */
  90701. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  90702. /**
  90703. * Gets total number of vertices
  90704. * @returns the total number of vertices
  90705. */
  90706. getTotalVertices(): number;
  90707. /**
  90708. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  90709. * @param kind defines the data kind (Position, normal, etc...)
  90710. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  90711. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  90712. * @returns a float array containing vertex data
  90713. */
  90714. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  90715. /**
  90716. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  90717. * @param kind defines the data kind (Position, normal, etc...)
  90718. * @returns true if the vertex buffer with the specified kind is updatable
  90719. */
  90720. isVertexBufferUpdatable(kind: string): boolean;
  90721. /**
  90722. * Gets a specific vertex buffer
  90723. * @param kind defines the data kind (Position, normal, etc...)
  90724. * @returns a VertexBuffer
  90725. */
  90726. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  90727. /**
  90728. * Returns all vertex buffers
  90729. * @return an object holding all vertex buffers indexed by kind
  90730. */
  90731. getVertexBuffers(): Nullable<{
  90732. [key: string]: VertexBuffer;
  90733. }>;
  90734. /**
  90735. * Gets a boolean indicating if specific vertex buffer is present
  90736. * @param kind defines the data kind (Position, normal, etc...)
  90737. * @returns true if data is present
  90738. */
  90739. isVerticesDataPresent(kind: string): boolean;
  90740. /**
  90741. * Gets a list of all attached data kinds (Position, normal, etc...)
  90742. * @returns a list of string containing all kinds
  90743. */
  90744. getVerticesDataKinds(): string[];
  90745. /**
  90746. * Update index buffer
  90747. * @param indices defines the indices to store in the index buffer
  90748. * @param offset defines the offset in the target buffer where to store the data
  90749. * @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)
  90750. */
  90751. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  90752. /**
  90753. * Creates a new index buffer
  90754. * @param indices defines the indices to store in the index buffer
  90755. * @param totalVertices defines the total number of vertices (could be null)
  90756. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  90757. */
  90758. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  90759. /**
  90760. * Return the total number of indices
  90761. * @returns the total number of indices
  90762. */
  90763. getTotalIndices(): number;
  90764. /**
  90765. * Gets the index buffer array
  90766. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  90767. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  90768. * @returns the index buffer array
  90769. */
  90770. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  90771. /**
  90772. * Gets the index buffer
  90773. * @return the index buffer
  90774. */
  90775. getIndexBuffer(): Nullable<DataBuffer>;
  90776. /** @hidden */
  90777. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  90778. /**
  90779. * Release the associated resources for a specific mesh
  90780. * @param mesh defines the source mesh
  90781. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  90782. */
  90783. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  90784. /**
  90785. * Apply current geometry to a given mesh
  90786. * @param mesh defines the mesh to apply geometry to
  90787. */
  90788. applyToMesh(mesh: Mesh): void;
  90789. private _updateExtend;
  90790. private _applyToMesh;
  90791. private notifyUpdate;
  90792. /**
  90793. * Load the geometry if it was flagged as delay loaded
  90794. * @param scene defines the hosting scene
  90795. * @param onLoaded defines a callback called when the geometry is loaded
  90796. */
  90797. load(scene: Scene, onLoaded?: () => void): void;
  90798. private _queueLoad;
  90799. /**
  90800. * Invert the geometry to move from a right handed system to a left handed one.
  90801. */
  90802. toLeftHanded(): void;
  90803. /** @hidden */
  90804. _resetPointsArrayCache(): void;
  90805. /** @hidden */
  90806. _generatePointsArray(): boolean;
  90807. /**
  90808. * Gets a value indicating if the geometry is disposed
  90809. * @returns true if the geometry was disposed
  90810. */
  90811. isDisposed(): boolean;
  90812. private _disposeVertexArrayObjects;
  90813. /**
  90814. * Free all associated resources
  90815. */
  90816. dispose(): void;
  90817. /**
  90818. * Clone the current geometry into a new geometry
  90819. * @param id defines the unique ID of the new geometry
  90820. * @returns a new geometry object
  90821. */
  90822. copy(id: string): Geometry;
  90823. /**
  90824. * Serialize the current geometry info (and not the vertices data) into a JSON object
  90825. * @return a JSON representation of the current geometry data (without the vertices data)
  90826. */
  90827. serialize(): any;
  90828. private toNumberArray;
  90829. /**
  90830. * Serialize all vertices data into a JSON oject
  90831. * @returns a JSON representation of the current geometry data
  90832. */
  90833. serializeVerticeData(): any;
  90834. /**
  90835. * Extracts a clone of a mesh geometry
  90836. * @param mesh defines the source mesh
  90837. * @param id defines the unique ID of the new geometry object
  90838. * @returns the new geometry object
  90839. */
  90840. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  90841. /**
  90842. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  90843. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  90844. * Be aware Math.random() could cause collisions, but:
  90845. * "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"
  90846. * @returns a string containing a new GUID
  90847. */
  90848. static RandomId(): string;
  90849. /** @hidden */
  90850. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  90851. private static _CleanMatricesWeights;
  90852. /**
  90853. * Create a new geometry from persisted data (Using .babylon file format)
  90854. * @param parsedVertexData defines the persisted data
  90855. * @param scene defines the hosting scene
  90856. * @param rootUrl defines the root url to use to load assets (like delayed data)
  90857. * @returns the new geometry object
  90858. */
  90859. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  90860. }
  90861. }
  90862. declare module BABYLON {
  90863. /**
  90864. * Define an interface for all classes that will get and set the data on vertices
  90865. */
  90866. export interface IGetSetVerticesData {
  90867. /**
  90868. * Gets a boolean indicating if specific vertex data is present
  90869. * @param kind defines the vertex data kind to use
  90870. * @returns true is data kind is present
  90871. */
  90872. isVerticesDataPresent(kind: string): boolean;
  90873. /**
  90874. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  90875. * @param kind defines the data kind (Position, normal, etc...)
  90876. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  90877. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  90878. * @returns a float array containing vertex data
  90879. */
  90880. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  90881. /**
  90882. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  90883. * @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.
  90884. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  90885. * @returns the indices array or an empty array if the mesh has no geometry
  90886. */
  90887. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  90888. /**
  90889. * Set specific vertex data
  90890. * @param kind defines the data kind (Position, normal, etc...)
  90891. * @param data defines the vertex data to use
  90892. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  90893. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  90894. */
  90895. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  90896. /**
  90897. * Update a specific associated vertex buffer
  90898. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  90899. * - VertexBuffer.PositionKind
  90900. * - VertexBuffer.UVKind
  90901. * - VertexBuffer.UV2Kind
  90902. * - VertexBuffer.UV3Kind
  90903. * - VertexBuffer.UV4Kind
  90904. * - VertexBuffer.UV5Kind
  90905. * - VertexBuffer.UV6Kind
  90906. * - VertexBuffer.ColorKind
  90907. * - VertexBuffer.MatricesIndicesKind
  90908. * - VertexBuffer.MatricesIndicesExtraKind
  90909. * - VertexBuffer.MatricesWeightsKind
  90910. * - VertexBuffer.MatricesWeightsExtraKind
  90911. * @param data defines the data source
  90912. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  90913. * @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)
  90914. */
  90915. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  90916. /**
  90917. * Creates a new index buffer
  90918. * @param indices defines the indices to store in the index buffer
  90919. * @param totalVertices defines the total number of vertices (could be null)
  90920. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  90921. */
  90922. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  90923. }
  90924. /**
  90925. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  90926. */
  90927. export class VertexData {
  90928. /**
  90929. * Mesh side orientation : usually the external or front surface
  90930. */
  90931. static readonly FRONTSIDE: number;
  90932. /**
  90933. * Mesh side orientation : usually the internal or back surface
  90934. */
  90935. static readonly BACKSIDE: number;
  90936. /**
  90937. * Mesh side orientation : both internal and external or front and back surfaces
  90938. */
  90939. static readonly DOUBLESIDE: number;
  90940. /**
  90941. * Mesh side orientation : by default, `FRONTSIDE`
  90942. */
  90943. static readonly DEFAULTSIDE: number;
  90944. /**
  90945. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  90946. */
  90947. positions: Nullable<FloatArray>;
  90948. /**
  90949. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  90950. */
  90951. normals: Nullable<FloatArray>;
  90952. /**
  90953. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  90954. */
  90955. tangents: Nullable<FloatArray>;
  90956. /**
  90957. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  90958. */
  90959. uvs: Nullable<FloatArray>;
  90960. /**
  90961. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  90962. */
  90963. uvs2: Nullable<FloatArray>;
  90964. /**
  90965. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  90966. */
  90967. uvs3: Nullable<FloatArray>;
  90968. /**
  90969. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  90970. */
  90971. uvs4: Nullable<FloatArray>;
  90972. /**
  90973. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  90974. */
  90975. uvs5: Nullable<FloatArray>;
  90976. /**
  90977. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  90978. */
  90979. uvs6: Nullable<FloatArray>;
  90980. /**
  90981. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  90982. */
  90983. colors: Nullable<FloatArray>;
  90984. /**
  90985. * 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).
  90986. */
  90987. matricesIndices: Nullable<FloatArray>;
  90988. /**
  90989. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  90990. */
  90991. matricesWeights: Nullable<FloatArray>;
  90992. /**
  90993. * An array extending the number of possible indices
  90994. */
  90995. matricesIndicesExtra: Nullable<FloatArray>;
  90996. /**
  90997. * An array extending the number of possible weights when the number of indices is extended
  90998. */
  90999. matricesWeightsExtra: Nullable<FloatArray>;
  91000. /**
  91001. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  91002. */
  91003. indices: Nullable<IndicesArray>;
  91004. /**
  91005. * Uses the passed data array to set the set the values for the specified kind of data
  91006. * @param data a linear array of floating numbers
  91007. * @param kind the type of data that is being set, eg positions, colors etc
  91008. */
  91009. set(data: FloatArray, kind: string): void;
  91010. /**
  91011. * Associates the vertexData to the passed Mesh.
  91012. * Sets it as updatable or not (default `false`)
  91013. * @param mesh the mesh the vertexData is applied to
  91014. * @param updatable when used and having the value true allows new data to update the vertexData
  91015. * @returns the VertexData
  91016. */
  91017. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  91018. /**
  91019. * Associates the vertexData to the passed Geometry.
  91020. * Sets it as updatable or not (default `false`)
  91021. * @param geometry the geometry the vertexData is applied to
  91022. * @param updatable when used and having the value true allows new data to update the vertexData
  91023. * @returns VertexData
  91024. */
  91025. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  91026. /**
  91027. * Updates the associated mesh
  91028. * @param mesh the mesh to be updated
  91029. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  91030. * @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
  91031. * @returns VertexData
  91032. */
  91033. updateMesh(mesh: Mesh): VertexData;
  91034. /**
  91035. * Updates the associated geometry
  91036. * @param geometry the geometry to be updated
  91037. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  91038. * @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
  91039. * @returns VertexData.
  91040. */
  91041. updateGeometry(geometry: Geometry): VertexData;
  91042. private _applyTo;
  91043. private _update;
  91044. /**
  91045. * Transforms each position and each normal of the vertexData according to the passed Matrix
  91046. * @param matrix the transforming matrix
  91047. * @returns the VertexData
  91048. */
  91049. transform(matrix: Matrix): VertexData;
  91050. /**
  91051. * Merges the passed VertexData into the current one
  91052. * @param other the VertexData to be merged into the current one
  91053. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  91054. * @returns the modified VertexData
  91055. */
  91056. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  91057. private _mergeElement;
  91058. private _validate;
  91059. /**
  91060. * Serializes the VertexData
  91061. * @returns a serialized object
  91062. */
  91063. serialize(): any;
  91064. /**
  91065. * Extracts the vertexData from a mesh
  91066. * @param mesh the mesh from which to extract the VertexData
  91067. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  91068. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  91069. * @returns the object VertexData associated to the passed mesh
  91070. */
  91071. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  91072. /**
  91073. * Extracts the vertexData from the geometry
  91074. * @param geometry the geometry from which to extract the VertexData
  91075. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  91076. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  91077. * @returns the object VertexData associated to the passed mesh
  91078. */
  91079. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  91080. private static _ExtractFrom;
  91081. /**
  91082. * Creates the VertexData for a Ribbon
  91083. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  91084. * * pathArray array of paths, each of which an array of successive Vector3
  91085. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  91086. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  91087. * * 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
  91088. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91089. * * 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)
  91090. * * 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)
  91091. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  91092. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  91093. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  91094. * @returns the VertexData of the ribbon
  91095. */
  91096. static CreateRibbon(options: {
  91097. pathArray: Vector3[][];
  91098. closeArray?: boolean;
  91099. closePath?: boolean;
  91100. offset?: number;
  91101. sideOrientation?: number;
  91102. frontUVs?: Vector4;
  91103. backUVs?: Vector4;
  91104. invertUV?: boolean;
  91105. uvs?: Vector2[];
  91106. colors?: Color4[];
  91107. }): VertexData;
  91108. /**
  91109. * Creates the VertexData for a box
  91110. * @param options an object used to set the following optional parameters for the box, required but can be empty
  91111. * * size sets the width, height and depth of the box to the value of size, optional default 1
  91112. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  91113. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  91114. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  91115. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  91116. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  91117. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91118. * * 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)
  91119. * * 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)
  91120. * @returns the VertexData of the box
  91121. */
  91122. static CreateBox(options: {
  91123. size?: number;
  91124. width?: number;
  91125. height?: number;
  91126. depth?: number;
  91127. faceUV?: Vector4[];
  91128. faceColors?: Color4[];
  91129. sideOrientation?: number;
  91130. frontUVs?: Vector4;
  91131. backUVs?: Vector4;
  91132. }): VertexData;
  91133. /**
  91134. * Creates the VertexData for a tiled box
  91135. * @param options an object used to set the following optional parameters for the box, required but can be empty
  91136. * * faceTiles sets the pattern, tile size and number of tiles for a face
  91137. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  91138. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  91139. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91140. * @returns the VertexData of the box
  91141. */
  91142. static CreateTiledBox(options: {
  91143. pattern?: number;
  91144. width?: number;
  91145. height?: number;
  91146. depth?: number;
  91147. tileSize?: number;
  91148. tileWidth?: number;
  91149. tileHeight?: number;
  91150. alignHorizontal?: number;
  91151. alignVertical?: number;
  91152. faceUV?: Vector4[];
  91153. faceColors?: Color4[];
  91154. sideOrientation?: number;
  91155. }): VertexData;
  91156. /**
  91157. * Creates the VertexData for a tiled plane
  91158. * @param options an object used to set the following optional parameters for the box, required but can be empty
  91159. * * pattern a limited pattern arrangement depending on the number
  91160. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  91161. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  91162. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  91163. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91164. * * 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)
  91165. * * 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)
  91166. * @returns the VertexData of the tiled plane
  91167. */
  91168. static CreateTiledPlane(options: {
  91169. pattern?: number;
  91170. tileSize?: number;
  91171. tileWidth?: number;
  91172. tileHeight?: number;
  91173. size?: number;
  91174. width?: number;
  91175. height?: number;
  91176. alignHorizontal?: number;
  91177. alignVertical?: number;
  91178. sideOrientation?: number;
  91179. frontUVs?: Vector4;
  91180. backUVs?: Vector4;
  91181. }): VertexData;
  91182. /**
  91183. * Creates the VertexData for an ellipsoid, defaults to a sphere
  91184. * @param options an object used to set the following optional parameters for the box, required but can be empty
  91185. * * segments sets the number of horizontal strips optional, default 32
  91186. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  91187. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  91188. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  91189. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  91190. * * 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
  91191. * * 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
  91192. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91193. * * 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)
  91194. * * 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)
  91195. * @returns the VertexData of the ellipsoid
  91196. */
  91197. static CreateSphere(options: {
  91198. segments?: number;
  91199. diameter?: number;
  91200. diameterX?: number;
  91201. diameterY?: number;
  91202. diameterZ?: number;
  91203. arc?: number;
  91204. slice?: number;
  91205. sideOrientation?: number;
  91206. frontUVs?: Vector4;
  91207. backUVs?: Vector4;
  91208. }): VertexData;
  91209. /**
  91210. * Creates the VertexData for a cylinder, cone or prism
  91211. * @param options an object used to set the following optional parameters for the box, required but can be empty
  91212. * * height sets the height (y direction) of the cylinder, optional, default 2
  91213. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  91214. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  91215. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  91216. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  91217. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  91218. * * 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
  91219. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  91220. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  91221. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  91222. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  91223. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91224. * * 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)
  91225. * * 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)
  91226. * @returns the VertexData of the cylinder, cone or prism
  91227. */
  91228. static CreateCylinder(options: {
  91229. height?: number;
  91230. diameterTop?: number;
  91231. diameterBottom?: number;
  91232. diameter?: number;
  91233. tessellation?: number;
  91234. subdivisions?: number;
  91235. arc?: number;
  91236. faceColors?: Color4[];
  91237. faceUV?: Vector4[];
  91238. hasRings?: boolean;
  91239. enclose?: boolean;
  91240. sideOrientation?: number;
  91241. frontUVs?: Vector4;
  91242. backUVs?: Vector4;
  91243. }): VertexData;
  91244. /**
  91245. * Creates the VertexData for a torus
  91246. * @param options an object used to set the following optional parameters for the box, required but can be empty
  91247. * * diameter the diameter of the torus, optional default 1
  91248. * * thickness the diameter of the tube forming the torus, optional default 0.5
  91249. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  91250. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91251. * * 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)
  91252. * * 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)
  91253. * @returns the VertexData of the torus
  91254. */
  91255. static CreateTorus(options: {
  91256. diameter?: number;
  91257. thickness?: number;
  91258. tessellation?: number;
  91259. sideOrientation?: number;
  91260. frontUVs?: Vector4;
  91261. backUVs?: Vector4;
  91262. }): VertexData;
  91263. /**
  91264. * Creates the VertexData of the LineSystem
  91265. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  91266. * - lines an array of lines, each line being an array of successive Vector3
  91267. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  91268. * @returns the VertexData of the LineSystem
  91269. */
  91270. static CreateLineSystem(options: {
  91271. lines: Vector3[][];
  91272. colors?: Nullable<Color4[][]>;
  91273. }): VertexData;
  91274. /**
  91275. * Create the VertexData for a DashedLines
  91276. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  91277. * - points an array successive Vector3
  91278. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  91279. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  91280. * - dashNb the intended total number of dashes, optional, default 200
  91281. * @returns the VertexData for the DashedLines
  91282. */
  91283. static CreateDashedLines(options: {
  91284. points: Vector3[];
  91285. dashSize?: number;
  91286. gapSize?: number;
  91287. dashNb?: number;
  91288. }): VertexData;
  91289. /**
  91290. * Creates the VertexData for a Ground
  91291. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  91292. * - width the width (x direction) of the ground, optional, default 1
  91293. * - height the height (z direction) of the ground, optional, default 1
  91294. * - subdivisions the number of subdivisions per side, optional, default 1
  91295. * @returns the VertexData of the Ground
  91296. */
  91297. static CreateGround(options: {
  91298. width?: number;
  91299. height?: number;
  91300. subdivisions?: number;
  91301. subdivisionsX?: number;
  91302. subdivisionsY?: number;
  91303. }): VertexData;
  91304. /**
  91305. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  91306. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  91307. * * xmin the ground minimum X coordinate, optional, default -1
  91308. * * zmin the ground minimum Z coordinate, optional, default -1
  91309. * * xmax the ground maximum X coordinate, optional, default 1
  91310. * * zmax the ground maximum Z coordinate, optional, default 1
  91311. * * 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}
  91312. * * 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}
  91313. * @returns the VertexData of the TiledGround
  91314. */
  91315. static CreateTiledGround(options: {
  91316. xmin: number;
  91317. zmin: number;
  91318. xmax: number;
  91319. zmax: number;
  91320. subdivisions?: {
  91321. w: number;
  91322. h: number;
  91323. };
  91324. precision?: {
  91325. w: number;
  91326. h: number;
  91327. };
  91328. }): VertexData;
  91329. /**
  91330. * Creates the VertexData of the Ground designed from a heightmap
  91331. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  91332. * * width the width (x direction) of the ground
  91333. * * height the height (z direction) of the ground
  91334. * * subdivisions the number of subdivisions per side
  91335. * * minHeight the minimum altitude on the ground, optional, default 0
  91336. * * maxHeight the maximum altitude on the ground, optional default 1
  91337. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  91338. * * buffer the array holding the image color data
  91339. * * bufferWidth the width of image
  91340. * * bufferHeight the height of image
  91341. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  91342. * @returns the VertexData of the Ground designed from a heightmap
  91343. */
  91344. static CreateGroundFromHeightMap(options: {
  91345. width: number;
  91346. height: number;
  91347. subdivisions: number;
  91348. minHeight: number;
  91349. maxHeight: number;
  91350. colorFilter: Color3;
  91351. buffer: Uint8Array;
  91352. bufferWidth: number;
  91353. bufferHeight: number;
  91354. alphaFilter: number;
  91355. }): VertexData;
  91356. /**
  91357. * Creates the VertexData for a Plane
  91358. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  91359. * * size sets the width and height of the plane to the value of size, optional default 1
  91360. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  91361. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  91362. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91363. * * 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)
  91364. * * 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)
  91365. * @returns the VertexData of the box
  91366. */
  91367. static CreatePlane(options: {
  91368. size?: number;
  91369. width?: number;
  91370. height?: number;
  91371. sideOrientation?: number;
  91372. frontUVs?: Vector4;
  91373. backUVs?: Vector4;
  91374. }): VertexData;
  91375. /**
  91376. * Creates the VertexData of the Disc or regular Polygon
  91377. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  91378. * * radius the radius of the disc, optional default 0.5
  91379. * * tessellation the number of polygon sides, optional, default 64
  91380. * * 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
  91381. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91382. * * 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)
  91383. * * 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)
  91384. * @returns the VertexData of the box
  91385. */
  91386. static CreateDisc(options: {
  91387. radius?: number;
  91388. tessellation?: number;
  91389. arc?: number;
  91390. sideOrientation?: number;
  91391. frontUVs?: Vector4;
  91392. backUVs?: Vector4;
  91393. }): VertexData;
  91394. /**
  91395. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  91396. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  91397. * @param polygon a mesh built from polygonTriangulation.build()
  91398. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91399. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  91400. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  91401. * @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)
  91402. * @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)
  91403. * @returns the VertexData of the Polygon
  91404. */
  91405. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  91406. /**
  91407. * Creates the VertexData of the IcoSphere
  91408. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  91409. * * radius the radius of the IcoSphere, optional default 1
  91410. * * radiusX allows stretching in the x direction, optional, default radius
  91411. * * radiusY allows stretching in the y direction, optional, default radius
  91412. * * radiusZ allows stretching in the z direction, optional, default radius
  91413. * * flat when true creates a flat shaded mesh, optional, default true
  91414. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  91415. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91416. * * 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)
  91417. * * 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)
  91418. * @returns the VertexData of the IcoSphere
  91419. */
  91420. static CreateIcoSphere(options: {
  91421. radius?: number;
  91422. radiusX?: number;
  91423. radiusY?: number;
  91424. radiusZ?: number;
  91425. flat?: boolean;
  91426. subdivisions?: number;
  91427. sideOrientation?: number;
  91428. frontUVs?: Vector4;
  91429. backUVs?: Vector4;
  91430. }): VertexData;
  91431. /**
  91432. * Creates the VertexData for a Polyhedron
  91433. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  91434. * * type provided types are:
  91435. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  91436. * * 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)
  91437. * * size the size of the IcoSphere, optional default 1
  91438. * * sizeX allows stretching in the x direction, optional, default size
  91439. * * sizeY allows stretching in the y direction, optional, default size
  91440. * * sizeZ allows stretching in the z direction, optional, default size
  91441. * * 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
  91442. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  91443. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  91444. * * flat when true creates a flat shaded mesh, optional, default true
  91445. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  91446. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91447. * * 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)
  91448. * * 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)
  91449. * @returns the VertexData of the Polyhedron
  91450. */
  91451. static CreatePolyhedron(options: {
  91452. type?: number;
  91453. size?: number;
  91454. sizeX?: number;
  91455. sizeY?: number;
  91456. sizeZ?: number;
  91457. custom?: any;
  91458. faceUV?: Vector4[];
  91459. faceColors?: Color4[];
  91460. flat?: boolean;
  91461. sideOrientation?: number;
  91462. frontUVs?: Vector4;
  91463. backUVs?: Vector4;
  91464. }): VertexData;
  91465. /**
  91466. * Creates the VertexData for a TorusKnot
  91467. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  91468. * * radius the radius of the torus knot, optional, default 2
  91469. * * tube the thickness of the tube, optional, default 0.5
  91470. * * radialSegments the number of sides on each tube segments, optional, default 32
  91471. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  91472. * * p the number of windings around the z axis, optional, default 2
  91473. * * q the number of windings around the x axis, optional, default 3
  91474. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91475. * * 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)
  91476. * * 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)
  91477. * @returns the VertexData of the Torus Knot
  91478. */
  91479. static CreateTorusKnot(options: {
  91480. radius?: number;
  91481. tube?: number;
  91482. radialSegments?: number;
  91483. tubularSegments?: number;
  91484. p?: number;
  91485. q?: number;
  91486. sideOrientation?: number;
  91487. frontUVs?: Vector4;
  91488. backUVs?: Vector4;
  91489. }): VertexData;
  91490. /**
  91491. * Compute normals for given positions and indices
  91492. * @param positions an array of vertex positions, [...., x, y, z, ......]
  91493. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  91494. * @param normals an array of vertex normals, [...., x, y, z, ......]
  91495. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  91496. * * facetNormals : optional array of facet normals (vector3)
  91497. * * facetPositions : optional array of facet positions (vector3)
  91498. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  91499. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  91500. * * bInfo : optional bounding info, required for facetPartitioning computation
  91501. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  91502. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  91503. * * useRightHandedSystem: optional boolean to for right handed system computation
  91504. * * depthSort : optional boolean to enable the facet depth sort computation
  91505. * * distanceTo : optional Vector3 to compute the facet depth from this location
  91506. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  91507. */
  91508. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  91509. facetNormals?: any;
  91510. facetPositions?: any;
  91511. facetPartitioning?: any;
  91512. ratio?: number;
  91513. bInfo?: any;
  91514. bbSize?: Vector3;
  91515. subDiv?: any;
  91516. useRightHandedSystem?: boolean;
  91517. depthSort?: boolean;
  91518. distanceTo?: Vector3;
  91519. depthSortedFacets?: any;
  91520. }): void;
  91521. /** @hidden */
  91522. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  91523. /**
  91524. * Applies VertexData created from the imported parameters to the geometry
  91525. * @param parsedVertexData the parsed data from an imported file
  91526. * @param geometry the geometry to apply the VertexData to
  91527. */
  91528. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  91529. }
  91530. }
  91531. declare module BABYLON {
  91532. /**
  91533. * Defines a target to use with MorphTargetManager
  91534. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  91535. */
  91536. export class MorphTarget implements IAnimatable {
  91537. /** defines the name of the target */
  91538. name: string;
  91539. /**
  91540. * Gets or sets the list of animations
  91541. */
  91542. animations: Animation[];
  91543. private _scene;
  91544. private _positions;
  91545. private _normals;
  91546. private _tangents;
  91547. private _uvs;
  91548. private _influence;
  91549. private _uniqueId;
  91550. /**
  91551. * Observable raised when the influence changes
  91552. */
  91553. onInfluenceChanged: Observable<boolean>;
  91554. /** @hidden */
  91555. _onDataLayoutChanged: Observable<void>;
  91556. /**
  91557. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  91558. */
  91559. influence: number;
  91560. /**
  91561. * Gets or sets the id of the morph Target
  91562. */
  91563. id: string;
  91564. private _animationPropertiesOverride;
  91565. /**
  91566. * Gets or sets the animation properties override
  91567. */
  91568. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  91569. /**
  91570. * Creates a new MorphTarget
  91571. * @param name defines the name of the target
  91572. * @param influence defines the influence to use
  91573. * @param scene defines the scene the morphtarget belongs to
  91574. */
  91575. constructor(
  91576. /** defines the name of the target */
  91577. name: string, influence?: number, scene?: Nullable<Scene>);
  91578. /**
  91579. * Gets the unique ID of this manager
  91580. */
  91581. readonly uniqueId: number;
  91582. /**
  91583. * Gets a boolean defining if the target contains position data
  91584. */
  91585. readonly hasPositions: boolean;
  91586. /**
  91587. * Gets a boolean defining if the target contains normal data
  91588. */
  91589. readonly hasNormals: boolean;
  91590. /**
  91591. * Gets a boolean defining if the target contains tangent data
  91592. */
  91593. readonly hasTangents: boolean;
  91594. /**
  91595. * Gets a boolean defining if the target contains texture coordinates data
  91596. */
  91597. readonly hasUVs: boolean;
  91598. /**
  91599. * Affects position data to this target
  91600. * @param data defines the position data to use
  91601. */
  91602. setPositions(data: Nullable<FloatArray>): void;
  91603. /**
  91604. * Gets the position data stored in this target
  91605. * @returns a FloatArray containing the position data (or null if not present)
  91606. */
  91607. getPositions(): Nullable<FloatArray>;
  91608. /**
  91609. * Affects normal data to this target
  91610. * @param data defines the normal data to use
  91611. */
  91612. setNormals(data: Nullable<FloatArray>): void;
  91613. /**
  91614. * Gets the normal data stored in this target
  91615. * @returns a FloatArray containing the normal data (or null if not present)
  91616. */
  91617. getNormals(): Nullable<FloatArray>;
  91618. /**
  91619. * Affects tangent data to this target
  91620. * @param data defines the tangent data to use
  91621. */
  91622. setTangents(data: Nullable<FloatArray>): void;
  91623. /**
  91624. * Gets the tangent data stored in this target
  91625. * @returns a FloatArray containing the tangent data (or null if not present)
  91626. */
  91627. getTangents(): Nullable<FloatArray>;
  91628. /**
  91629. * Affects texture coordinates data to this target
  91630. * @param data defines the texture coordinates data to use
  91631. */
  91632. setUVs(data: Nullable<FloatArray>): void;
  91633. /**
  91634. * Gets the texture coordinates data stored in this target
  91635. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  91636. */
  91637. getUVs(): Nullable<FloatArray>;
  91638. /**
  91639. * Clone the current target
  91640. * @returns a new MorphTarget
  91641. */
  91642. clone(): MorphTarget;
  91643. /**
  91644. * Serializes the current target into a Serialization object
  91645. * @returns the serialized object
  91646. */
  91647. serialize(): any;
  91648. /**
  91649. * Returns the string "MorphTarget"
  91650. * @returns "MorphTarget"
  91651. */
  91652. getClassName(): string;
  91653. /**
  91654. * Creates a new target from serialized data
  91655. * @param serializationObject defines the serialized data to use
  91656. * @returns a new MorphTarget
  91657. */
  91658. static Parse(serializationObject: any): MorphTarget;
  91659. /**
  91660. * Creates a MorphTarget from mesh data
  91661. * @param mesh defines the source mesh
  91662. * @param name defines the name to use for the new target
  91663. * @param influence defines the influence to attach to the target
  91664. * @returns a new MorphTarget
  91665. */
  91666. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  91667. }
  91668. }
  91669. declare module BABYLON {
  91670. /**
  91671. * This class is used to deform meshes using morphing between different targets
  91672. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  91673. */
  91674. export class MorphTargetManager {
  91675. private _targets;
  91676. private _targetInfluenceChangedObservers;
  91677. private _targetDataLayoutChangedObservers;
  91678. private _activeTargets;
  91679. private _scene;
  91680. private _influences;
  91681. private _supportsNormals;
  91682. private _supportsTangents;
  91683. private _supportsUVs;
  91684. private _vertexCount;
  91685. private _uniqueId;
  91686. private _tempInfluences;
  91687. /**
  91688. * Gets or sets a boolean indicating if normals must be morphed
  91689. */
  91690. enableNormalMorphing: boolean;
  91691. /**
  91692. * Gets or sets a boolean indicating if tangents must be morphed
  91693. */
  91694. enableTangentMorphing: boolean;
  91695. /**
  91696. * Gets or sets a boolean indicating if UV must be morphed
  91697. */
  91698. enableUVMorphing: boolean;
  91699. /**
  91700. * Creates a new MorphTargetManager
  91701. * @param scene defines the current scene
  91702. */
  91703. constructor(scene?: Nullable<Scene>);
  91704. /**
  91705. * Gets the unique ID of this manager
  91706. */
  91707. readonly uniqueId: number;
  91708. /**
  91709. * Gets the number of vertices handled by this manager
  91710. */
  91711. readonly vertexCount: number;
  91712. /**
  91713. * Gets a boolean indicating if this manager supports morphing of normals
  91714. */
  91715. readonly supportsNormals: boolean;
  91716. /**
  91717. * Gets a boolean indicating if this manager supports morphing of tangents
  91718. */
  91719. readonly supportsTangents: boolean;
  91720. /**
  91721. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  91722. */
  91723. readonly supportsUVs: boolean;
  91724. /**
  91725. * Gets the number of targets stored in this manager
  91726. */
  91727. readonly numTargets: number;
  91728. /**
  91729. * Gets the number of influencers (ie. the number of targets with influences > 0)
  91730. */
  91731. readonly numInfluencers: number;
  91732. /**
  91733. * Gets the list of influences (one per target)
  91734. */
  91735. readonly influences: Float32Array;
  91736. /**
  91737. * Gets the active target at specified index. An active target is a target with an influence > 0
  91738. * @param index defines the index to check
  91739. * @returns the requested target
  91740. */
  91741. getActiveTarget(index: number): MorphTarget;
  91742. /**
  91743. * Gets the target at specified index
  91744. * @param index defines the index to check
  91745. * @returns the requested target
  91746. */
  91747. getTarget(index: number): MorphTarget;
  91748. /**
  91749. * Add a new target to this manager
  91750. * @param target defines the target to add
  91751. */
  91752. addTarget(target: MorphTarget): void;
  91753. /**
  91754. * Removes a target from the manager
  91755. * @param target defines the target to remove
  91756. */
  91757. removeTarget(target: MorphTarget): void;
  91758. /**
  91759. * Clone the current manager
  91760. * @returns a new MorphTargetManager
  91761. */
  91762. clone(): MorphTargetManager;
  91763. /**
  91764. * Serializes the current manager into a Serialization object
  91765. * @returns the serialized object
  91766. */
  91767. serialize(): any;
  91768. private _syncActiveTargets;
  91769. /**
  91770. * Syncrhonize the targets with all the meshes using this morph target manager
  91771. */
  91772. synchronize(): void;
  91773. /**
  91774. * Creates a new MorphTargetManager from serialized data
  91775. * @param serializationObject defines the serialized data
  91776. * @param scene defines the hosting scene
  91777. * @returns the new MorphTargetManager
  91778. */
  91779. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  91780. }
  91781. }
  91782. declare module BABYLON {
  91783. /**
  91784. * Class used to represent a specific level of detail of a mesh
  91785. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  91786. */
  91787. export class MeshLODLevel {
  91788. /** Defines the distance where this level should start being displayed */
  91789. distance: number;
  91790. /** Defines the mesh to use to render this level */
  91791. mesh: Nullable<Mesh>;
  91792. /**
  91793. * Creates a new LOD level
  91794. * @param distance defines the distance where this level should star being displayed
  91795. * @param mesh defines the mesh to use to render this level
  91796. */
  91797. constructor(
  91798. /** Defines the distance where this level should start being displayed */
  91799. distance: number,
  91800. /** Defines the mesh to use to render this level */
  91801. mesh: Nullable<Mesh>);
  91802. }
  91803. }
  91804. declare module BABYLON {
  91805. /**
  91806. * Mesh representing the gorund
  91807. */
  91808. export class GroundMesh extends Mesh {
  91809. /** If octree should be generated */
  91810. generateOctree: boolean;
  91811. private _heightQuads;
  91812. /** @hidden */
  91813. _subdivisionsX: number;
  91814. /** @hidden */
  91815. _subdivisionsY: number;
  91816. /** @hidden */
  91817. _width: number;
  91818. /** @hidden */
  91819. _height: number;
  91820. /** @hidden */
  91821. _minX: number;
  91822. /** @hidden */
  91823. _maxX: number;
  91824. /** @hidden */
  91825. _minZ: number;
  91826. /** @hidden */
  91827. _maxZ: number;
  91828. constructor(name: string, scene: Scene);
  91829. /**
  91830. * "GroundMesh"
  91831. * @returns "GroundMesh"
  91832. */
  91833. getClassName(): string;
  91834. /**
  91835. * The minimum of x and y subdivisions
  91836. */
  91837. readonly subdivisions: number;
  91838. /**
  91839. * X subdivisions
  91840. */
  91841. readonly subdivisionsX: number;
  91842. /**
  91843. * Y subdivisions
  91844. */
  91845. readonly subdivisionsY: number;
  91846. /**
  91847. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  91848. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  91849. * @param chunksCount the number of subdivisions for x and y
  91850. * @param octreeBlocksSize (Default: 32)
  91851. */
  91852. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  91853. /**
  91854. * Returns a height (y) value in the Worl system :
  91855. * the ground altitude at the coordinates (x, z) expressed in the World system.
  91856. * @param x x coordinate
  91857. * @param z z coordinate
  91858. * @returns the ground y position if (x, z) are outside the ground surface.
  91859. */
  91860. getHeightAtCoordinates(x: number, z: number): number;
  91861. /**
  91862. * Returns a normalized vector (Vector3) orthogonal to the ground
  91863. * at the ground coordinates (x, z) expressed in the World system.
  91864. * @param x x coordinate
  91865. * @param z z coordinate
  91866. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  91867. */
  91868. getNormalAtCoordinates(x: number, z: number): Vector3;
  91869. /**
  91870. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  91871. * at the ground coordinates (x, z) expressed in the World system.
  91872. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  91873. * @param x x coordinate
  91874. * @param z z coordinate
  91875. * @param ref vector to store the result
  91876. * @returns the GroundMesh.
  91877. */
  91878. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  91879. /**
  91880. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  91881. * if the ground has been updated.
  91882. * This can be used in the render loop.
  91883. * @returns the GroundMesh.
  91884. */
  91885. updateCoordinateHeights(): GroundMesh;
  91886. private _getFacetAt;
  91887. private _initHeightQuads;
  91888. private _computeHeightQuads;
  91889. /**
  91890. * Serializes this ground mesh
  91891. * @param serializationObject object to write serialization to
  91892. */
  91893. serialize(serializationObject: any): void;
  91894. /**
  91895. * Parses a serialized ground mesh
  91896. * @param parsedMesh the serialized mesh
  91897. * @param scene the scene to create the ground mesh in
  91898. * @returns the created ground mesh
  91899. */
  91900. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  91901. }
  91902. }
  91903. declare module BABYLON {
  91904. /**
  91905. * Interface for Physics-Joint data
  91906. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91907. */
  91908. export interface PhysicsJointData {
  91909. /**
  91910. * The main pivot of the joint
  91911. */
  91912. mainPivot?: Vector3;
  91913. /**
  91914. * The connected pivot of the joint
  91915. */
  91916. connectedPivot?: Vector3;
  91917. /**
  91918. * The main axis of the joint
  91919. */
  91920. mainAxis?: Vector3;
  91921. /**
  91922. * The connected axis of the joint
  91923. */
  91924. connectedAxis?: Vector3;
  91925. /**
  91926. * The collision of the joint
  91927. */
  91928. collision?: boolean;
  91929. /**
  91930. * Native Oimo/Cannon/Energy data
  91931. */
  91932. nativeParams?: any;
  91933. }
  91934. /**
  91935. * This is a holder class for the physics joint created by the physics plugin
  91936. * It holds a set of functions to control the underlying joint
  91937. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91938. */
  91939. export class PhysicsJoint {
  91940. /**
  91941. * The type of the physics joint
  91942. */
  91943. type: number;
  91944. /**
  91945. * The data for the physics joint
  91946. */
  91947. jointData: PhysicsJointData;
  91948. private _physicsJoint;
  91949. protected _physicsPlugin: IPhysicsEnginePlugin;
  91950. /**
  91951. * Initializes the physics joint
  91952. * @param type The type of the physics joint
  91953. * @param jointData The data for the physics joint
  91954. */
  91955. constructor(
  91956. /**
  91957. * The type of the physics joint
  91958. */
  91959. type: number,
  91960. /**
  91961. * The data for the physics joint
  91962. */
  91963. jointData: PhysicsJointData);
  91964. /**
  91965. * Gets the physics joint
  91966. */
  91967. /**
  91968. * Sets the physics joint
  91969. */
  91970. physicsJoint: any;
  91971. /**
  91972. * Sets the physics plugin
  91973. */
  91974. physicsPlugin: IPhysicsEnginePlugin;
  91975. /**
  91976. * Execute a function that is physics-plugin specific.
  91977. * @param {Function} func the function that will be executed.
  91978. * It accepts two parameters: the physics world and the physics joint
  91979. */
  91980. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  91981. /**
  91982. * Distance-Joint type
  91983. */
  91984. static DistanceJoint: number;
  91985. /**
  91986. * Hinge-Joint type
  91987. */
  91988. static HingeJoint: number;
  91989. /**
  91990. * Ball-and-Socket joint type
  91991. */
  91992. static BallAndSocketJoint: number;
  91993. /**
  91994. * Wheel-Joint type
  91995. */
  91996. static WheelJoint: number;
  91997. /**
  91998. * Slider-Joint type
  91999. */
  92000. static SliderJoint: number;
  92001. /**
  92002. * Prismatic-Joint type
  92003. */
  92004. static PrismaticJoint: number;
  92005. /**
  92006. * Universal-Joint type
  92007. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  92008. */
  92009. static UniversalJoint: number;
  92010. /**
  92011. * Hinge-Joint 2 type
  92012. */
  92013. static Hinge2Joint: number;
  92014. /**
  92015. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  92016. */
  92017. static PointToPointJoint: number;
  92018. /**
  92019. * Spring-Joint type
  92020. */
  92021. static SpringJoint: number;
  92022. /**
  92023. * Lock-Joint type
  92024. */
  92025. static LockJoint: number;
  92026. }
  92027. /**
  92028. * A class representing a physics distance joint
  92029. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  92030. */
  92031. export class DistanceJoint extends PhysicsJoint {
  92032. /**
  92033. *
  92034. * @param jointData The data for the Distance-Joint
  92035. */
  92036. constructor(jointData: DistanceJointData);
  92037. /**
  92038. * Update the predefined distance.
  92039. * @param maxDistance The maximum preferred distance
  92040. * @param minDistance The minimum preferred distance
  92041. */
  92042. updateDistance(maxDistance: number, minDistance?: number): void;
  92043. }
  92044. /**
  92045. * Represents a Motor-Enabled Joint
  92046. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  92047. */
  92048. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  92049. /**
  92050. * Initializes the Motor-Enabled Joint
  92051. * @param type The type of the joint
  92052. * @param jointData The physica joint data for the joint
  92053. */
  92054. constructor(type: number, jointData: PhysicsJointData);
  92055. /**
  92056. * Set the motor values.
  92057. * Attention, this function is plugin specific. Engines won't react 100% the same.
  92058. * @param force the force to apply
  92059. * @param maxForce max force for this motor.
  92060. */
  92061. setMotor(force?: number, maxForce?: number): void;
  92062. /**
  92063. * Set the motor's limits.
  92064. * Attention, this function is plugin specific. Engines won't react 100% the same.
  92065. * @param upperLimit The upper limit of the motor
  92066. * @param lowerLimit The lower limit of the motor
  92067. */
  92068. setLimit(upperLimit: number, lowerLimit?: number): void;
  92069. }
  92070. /**
  92071. * This class represents a single physics Hinge-Joint
  92072. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  92073. */
  92074. export class HingeJoint extends MotorEnabledJoint {
  92075. /**
  92076. * Initializes the Hinge-Joint
  92077. * @param jointData The joint data for the Hinge-Joint
  92078. */
  92079. constructor(jointData: PhysicsJointData);
  92080. /**
  92081. * Set the motor values.
  92082. * Attention, this function is plugin specific. Engines won't react 100% the same.
  92083. * @param {number} force the force to apply
  92084. * @param {number} maxForce max force for this motor.
  92085. */
  92086. setMotor(force?: number, maxForce?: number): void;
  92087. /**
  92088. * Set the motor's limits.
  92089. * Attention, this function is plugin specific. Engines won't react 100% the same.
  92090. * @param upperLimit The upper limit of the motor
  92091. * @param lowerLimit The lower limit of the motor
  92092. */
  92093. setLimit(upperLimit: number, lowerLimit?: number): void;
  92094. }
  92095. /**
  92096. * This class represents a dual hinge physics joint (same as wheel joint)
  92097. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  92098. */
  92099. export class Hinge2Joint extends MotorEnabledJoint {
  92100. /**
  92101. * Initializes the Hinge2-Joint
  92102. * @param jointData The joint data for the Hinge2-Joint
  92103. */
  92104. constructor(jointData: PhysicsJointData);
  92105. /**
  92106. * Set the motor values.
  92107. * Attention, this function is plugin specific. Engines won't react 100% the same.
  92108. * @param {number} targetSpeed the speed the motor is to reach
  92109. * @param {number} maxForce max force for this motor.
  92110. * @param {motorIndex} the motor's index, 0 or 1.
  92111. */
  92112. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  92113. /**
  92114. * Set the motor limits.
  92115. * Attention, this function is plugin specific. Engines won't react 100% the same.
  92116. * @param {number} upperLimit the upper limit
  92117. * @param {number} lowerLimit lower limit
  92118. * @param {motorIndex} the motor's index, 0 or 1.
  92119. */
  92120. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  92121. }
  92122. /**
  92123. * Interface for a motor enabled joint
  92124. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  92125. */
  92126. export interface IMotorEnabledJoint {
  92127. /**
  92128. * Physics joint
  92129. */
  92130. physicsJoint: any;
  92131. /**
  92132. * Sets the motor of the motor-enabled joint
  92133. * @param force The force of the motor
  92134. * @param maxForce The maximum force of the motor
  92135. * @param motorIndex The index of the motor
  92136. */
  92137. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  92138. /**
  92139. * Sets the limit of the motor
  92140. * @param upperLimit The upper limit of the motor
  92141. * @param lowerLimit The lower limit of the motor
  92142. * @param motorIndex The index of the motor
  92143. */
  92144. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  92145. }
  92146. /**
  92147. * Joint data for a Distance-Joint
  92148. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  92149. */
  92150. export interface DistanceJointData extends PhysicsJointData {
  92151. /**
  92152. * Max distance the 2 joint objects can be apart
  92153. */
  92154. maxDistance: number;
  92155. }
  92156. /**
  92157. * Joint data from a spring joint
  92158. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  92159. */
  92160. export interface SpringJointData extends PhysicsJointData {
  92161. /**
  92162. * Length of the spring
  92163. */
  92164. length: number;
  92165. /**
  92166. * Stiffness of the spring
  92167. */
  92168. stiffness: number;
  92169. /**
  92170. * Damping of the spring
  92171. */
  92172. damping: number;
  92173. /** this callback will be called when applying the force to the impostors. */
  92174. forceApplicationCallback: () => void;
  92175. }
  92176. }
  92177. declare module BABYLON {
  92178. /**
  92179. * Holds the data for the raycast result
  92180. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  92181. */
  92182. export class PhysicsRaycastResult {
  92183. private _hasHit;
  92184. private _hitDistance;
  92185. private _hitNormalWorld;
  92186. private _hitPointWorld;
  92187. private _rayFromWorld;
  92188. private _rayToWorld;
  92189. /**
  92190. * Gets if there was a hit
  92191. */
  92192. readonly hasHit: boolean;
  92193. /**
  92194. * Gets the distance from the hit
  92195. */
  92196. readonly hitDistance: number;
  92197. /**
  92198. * Gets the hit normal/direction in the world
  92199. */
  92200. readonly hitNormalWorld: Vector3;
  92201. /**
  92202. * Gets the hit point in the world
  92203. */
  92204. readonly hitPointWorld: Vector3;
  92205. /**
  92206. * Gets the ray "start point" of the ray in the world
  92207. */
  92208. readonly rayFromWorld: Vector3;
  92209. /**
  92210. * Gets the ray "end point" of the ray in the world
  92211. */
  92212. readonly rayToWorld: Vector3;
  92213. /**
  92214. * Sets the hit data (normal & point in world space)
  92215. * @param hitNormalWorld defines the normal in world space
  92216. * @param hitPointWorld defines the point in world space
  92217. */
  92218. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  92219. /**
  92220. * Sets the distance from the start point to the hit point
  92221. * @param distance
  92222. */
  92223. setHitDistance(distance: number): void;
  92224. /**
  92225. * Calculates the distance manually
  92226. */
  92227. calculateHitDistance(): void;
  92228. /**
  92229. * Resets all the values to default
  92230. * @param from The from point on world space
  92231. * @param to The to point on world space
  92232. */
  92233. reset(from?: Vector3, to?: Vector3): void;
  92234. }
  92235. /**
  92236. * Interface for the size containing width and height
  92237. */
  92238. interface IXYZ {
  92239. /**
  92240. * X
  92241. */
  92242. x: number;
  92243. /**
  92244. * Y
  92245. */
  92246. y: number;
  92247. /**
  92248. * Z
  92249. */
  92250. z: number;
  92251. }
  92252. }
  92253. declare module BABYLON {
  92254. /**
  92255. * Interface used to describe a physics joint
  92256. */
  92257. export interface PhysicsImpostorJoint {
  92258. /** Defines the main impostor to which the joint is linked */
  92259. mainImpostor: PhysicsImpostor;
  92260. /** Defines the impostor that is connected to the main impostor using this joint */
  92261. connectedImpostor: PhysicsImpostor;
  92262. /** Defines the joint itself */
  92263. joint: PhysicsJoint;
  92264. }
  92265. /** @hidden */
  92266. export interface IPhysicsEnginePlugin {
  92267. world: any;
  92268. name: string;
  92269. setGravity(gravity: Vector3): void;
  92270. setTimeStep(timeStep: number): void;
  92271. getTimeStep(): number;
  92272. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  92273. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  92274. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  92275. generatePhysicsBody(impostor: PhysicsImpostor): void;
  92276. removePhysicsBody(impostor: PhysicsImpostor): void;
  92277. generateJoint(joint: PhysicsImpostorJoint): void;
  92278. removeJoint(joint: PhysicsImpostorJoint): void;
  92279. isSupported(): boolean;
  92280. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  92281. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  92282. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  92283. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  92284. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  92285. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  92286. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  92287. getBodyMass(impostor: PhysicsImpostor): number;
  92288. getBodyFriction(impostor: PhysicsImpostor): number;
  92289. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  92290. getBodyRestitution(impostor: PhysicsImpostor): number;
  92291. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  92292. getBodyPressure?(impostor: PhysicsImpostor): number;
  92293. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  92294. getBodyStiffness?(impostor: PhysicsImpostor): number;
  92295. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  92296. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  92297. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  92298. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  92299. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  92300. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  92301. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  92302. sleepBody(impostor: PhysicsImpostor): void;
  92303. wakeUpBody(impostor: PhysicsImpostor): void;
  92304. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  92305. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  92306. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  92307. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  92308. getRadius(impostor: PhysicsImpostor): number;
  92309. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  92310. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  92311. dispose(): void;
  92312. }
  92313. /**
  92314. * Interface used to define a physics engine
  92315. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  92316. */
  92317. export interface IPhysicsEngine {
  92318. /**
  92319. * Gets the gravity vector used by the simulation
  92320. */
  92321. gravity: Vector3;
  92322. /**
  92323. * Sets the gravity vector used by the simulation
  92324. * @param gravity defines the gravity vector to use
  92325. */
  92326. setGravity(gravity: Vector3): void;
  92327. /**
  92328. * Set the time step of the physics engine.
  92329. * Default is 1/60.
  92330. * To slow it down, enter 1/600 for example.
  92331. * To speed it up, 1/30
  92332. * @param newTimeStep the new timestep to apply to this world.
  92333. */
  92334. setTimeStep(newTimeStep: number): void;
  92335. /**
  92336. * Get the time step of the physics engine.
  92337. * @returns the current time step
  92338. */
  92339. getTimeStep(): number;
  92340. /**
  92341. * Set the sub time step of the physics engine.
  92342. * Default is 0 meaning there is no sub steps
  92343. * To increase physics resolution precision, set a small value (like 1 ms)
  92344. * @param subTimeStep defines the new sub timestep used for physics resolution.
  92345. */
  92346. setSubTimeStep(subTimeStep: number): void;
  92347. /**
  92348. * Get the sub time step of the physics engine.
  92349. * @returns the current sub time step
  92350. */
  92351. getSubTimeStep(): number;
  92352. /**
  92353. * Release all resources
  92354. */
  92355. dispose(): void;
  92356. /**
  92357. * Gets the name of the current physics plugin
  92358. * @returns the name of the plugin
  92359. */
  92360. getPhysicsPluginName(): string;
  92361. /**
  92362. * Adding a new impostor for the impostor tracking.
  92363. * This will be done by the impostor itself.
  92364. * @param impostor the impostor to add
  92365. */
  92366. addImpostor(impostor: PhysicsImpostor): void;
  92367. /**
  92368. * Remove an impostor from the engine.
  92369. * This impostor and its mesh will not longer be updated by the physics engine.
  92370. * @param impostor the impostor to remove
  92371. */
  92372. removeImpostor(impostor: PhysicsImpostor): void;
  92373. /**
  92374. * Add a joint to the physics engine
  92375. * @param mainImpostor defines the main impostor to which the joint is added.
  92376. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  92377. * @param joint defines the joint that will connect both impostors.
  92378. */
  92379. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  92380. /**
  92381. * Removes a joint from the simulation
  92382. * @param mainImpostor defines the impostor used with the joint
  92383. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  92384. * @param joint defines the joint to remove
  92385. */
  92386. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  92387. /**
  92388. * Gets the current plugin used to run the simulation
  92389. * @returns current plugin
  92390. */
  92391. getPhysicsPlugin(): IPhysicsEnginePlugin;
  92392. /**
  92393. * Gets the list of physic impostors
  92394. * @returns an array of PhysicsImpostor
  92395. */
  92396. getImpostors(): Array<PhysicsImpostor>;
  92397. /**
  92398. * Gets the impostor for a physics enabled object
  92399. * @param object defines the object impersonated by the impostor
  92400. * @returns the PhysicsImpostor or null if not found
  92401. */
  92402. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  92403. /**
  92404. * Gets the impostor for a physics body object
  92405. * @param body defines physics body used by the impostor
  92406. * @returns the PhysicsImpostor or null if not found
  92407. */
  92408. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  92409. /**
  92410. * Does a raycast in the physics world
  92411. * @param from when should the ray start?
  92412. * @param to when should the ray end?
  92413. * @returns PhysicsRaycastResult
  92414. */
  92415. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  92416. /**
  92417. * Called by the scene. No need to call it.
  92418. * @param delta defines the timespam between frames
  92419. */
  92420. _step(delta: number): void;
  92421. }
  92422. }
  92423. declare module BABYLON {
  92424. /**
  92425. * The interface for the physics imposter parameters
  92426. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  92427. */
  92428. export interface PhysicsImpostorParameters {
  92429. /**
  92430. * The mass of the physics imposter
  92431. */
  92432. mass: number;
  92433. /**
  92434. * The friction of the physics imposter
  92435. */
  92436. friction?: number;
  92437. /**
  92438. * The coefficient of restitution of the physics imposter
  92439. */
  92440. restitution?: number;
  92441. /**
  92442. * The native options of the physics imposter
  92443. */
  92444. nativeOptions?: any;
  92445. /**
  92446. * Specifies if the parent should be ignored
  92447. */
  92448. ignoreParent?: boolean;
  92449. /**
  92450. * Specifies if bi-directional transformations should be disabled
  92451. */
  92452. disableBidirectionalTransformation?: boolean;
  92453. /**
  92454. * The pressure inside the physics imposter, soft object only
  92455. */
  92456. pressure?: number;
  92457. /**
  92458. * The stiffness the physics imposter, soft object only
  92459. */
  92460. stiffness?: number;
  92461. /**
  92462. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  92463. */
  92464. velocityIterations?: number;
  92465. /**
  92466. * The number of iterations used in maintaining consistent vertex positions, soft object only
  92467. */
  92468. positionIterations?: number;
  92469. /**
  92470. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  92471. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  92472. * Add to fix multiple points
  92473. */
  92474. fixedPoints?: number;
  92475. /**
  92476. * The collision margin around a soft object
  92477. */
  92478. margin?: number;
  92479. /**
  92480. * The collision margin around a soft object
  92481. */
  92482. damping?: number;
  92483. /**
  92484. * The path for a rope based on an extrusion
  92485. */
  92486. path?: any;
  92487. /**
  92488. * The shape of an extrusion used for a rope based on an extrusion
  92489. */
  92490. shape?: any;
  92491. }
  92492. /**
  92493. * Interface for a physics-enabled object
  92494. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  92495. */
  92496. export interface IPhysicsEnabledObject {
  92497. /**
  92498. * The position of the physics-enabled object
  92499. */
  92500. position: Vector3;
  92501. /**
  92502. * The rotation of the physics-enabled object
  92503. */
  92504. rotationQuaternion: Nullable<Quaternion>;
  92505. /**
  92506. * The scale of the physics-enabled object
  92507. */
  92508. scaling: Vector3;
  92509. /**
  92510. * The rotation of the physics-enabled object
  92511. */
  92512. rotation?: Vector3;
  92513. /**
  92514. * The parent of the physics-enabled object
  92515. */
  92516. parent?: any;
  92517. /**
  92518. * The bounding info of the physics-enabled object
  92519. * @returns The bounding info of the physics-enabled object
  92520. */
  92521. getBoundingInfo(): BoundingInfo;
  92522. /**
  92523. * Computes the world matrix
  92524. * @param force Specifies if the world matrix should be computed by force
  92525. * @returns A world matrix
  92526. */
  92527. computeWorldMatrix(force: boolean): Matrix;
  92528. /**
  92529. * Gets the world matrix
  92530. * @returns A world matrix
  92531. */
  92532. getWorldMatrix?(): Matrix;
  92533. /**
  92534. * Gets the child meshes
  92535. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  92536. * @returns An array of abstract meshes
  92537. */
  92538. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  92539. /**
  92540. * Gets the vertex data
  92541. * @param kind The type of vertex data
  92542. * @returns A nullable array of numbers, or a float32 array
  92543. */
  92544. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  92545. /**
  92546. * Gets the indices from the mesh
  92547. * @returns A nullable array of index arrays
  92548. */
  92549. getIndices?(): Nullable<IndicesArray>;
  92550. /**
  92551. * Gets the scene from the mesh
  92552. * @returns the indices array or null
  92553. */
  92554. getScene?(): Scene;
  92555. /**
  92556. * Gets the absolute position from the mesh
  92557. * @returns the absolute position
  92558. */
  92559. getAbsolutePosition(): Vector3;
  92560. /**
  92561. * Gets the absolute pivot point from the mesh
  92562. * @returns the absolute pivot point
  92563. */
  92564. getAbsolutePivotPoint(): Vector3;
  92565. /**
  92566. * Rotates the mesh
  92567. * @param axis The axis of rotation
  92568. * @param amount The amount of rotation
  92569. * @param space The space of the rotation
  92570. * @returns The rotation transform node
  92571. */
  92572. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  92573. /**
  92574. * Translates the mesh
  92575. * @param axis The axis of translation
  92576. * @param distance The distance of translation
  92577. * @param space The space of the translation
  92578. * @returns The transform node
  92579. */
  92580. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  92581. /**
  92582. * Sets the absolute position of the mesh
  92583. * @param absolutePosition The absolute position of the mesh
  92584. * @returns The transform node
  92585. */
  92586. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  92587. /**
  92588. * Gets the class name of the mesh
  92589. * @returns The class name
  92590. */
  92591. getClassName(): string;
  92592. }
  92593. /**
  92594. * Represents a physics imposter
  92595. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  92596. */
  92597. export class PhysicsImpostor {
  92598. /**
  92599. * The physics-enabled object used as the physics imposter
  92600. */
  92601. object: IPhysicsEnabledObject;
  92602. /**
  92603. * The type of the physics imposter
  92604. */
  92605. type: number;
  92606. private _options;
  92607. private _scene?;
  92608. /**
  92609. * The default object size of the imposter
  92610. */
  92611. static DEFAULT_OBJECT_SIZE: Vector3;
  92612. /**
  92613. * The identity quaternion of the imposter
  92614. */
  92615. static IDENTITY_QUATERNION: Quaternion;
  92616. /** @hidden */
  92617. _pluginData: any;
  92618. private _physicsEngine;
  92619. private _physicsBody;
  92620. private _bodyUpdateRequired;
  92621. private _onBeforePhysicsStepCallbacks;
  92622. private _onAfterPhysicsStepCallbacks;
  92623. /** @hidden */
  92624. _onPhysicsCollideCallbacks: Array<{
  92625. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  92626. otherImpostors: Array<PhysicsImpostor>;
  92627. }>;
  92628. private _deltaPosition;
  92629. private _deltaRotation;
  92630. private _deltaRotationConjugated;
  92631. /** @hidden */
  92632. _isFromLine: boolean;
  92633. private _parent;
  92634. private _isDisposed;
  92635. private static _tmpVecs;
  92636. private static _tmpQuat;
  92637. /**
  92638. * Specifies if the physics imposter is disposed
  92639. */
  92640. readonly isDisposed: boolean;
  92641. /**
  92642. * Gets the mass of the physics imposter
  92643. */
  92644. mass: number;
  92645. /**
  92646. * Gets the coefficient of friction
  92647. */
  92648. /**
  92649. * Sets the coefficient of friction
  92650. */
  92651. friction: number;
  92652. /**
  92653. * Gets the coefficient of restitution
  92654. */
  92655. /**
  92656. * Sets the coefficient of restitution
  92657. */
  92658. restitution: number;
  92659. /**
  92660. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  92661. */
  92662. /**
  92663. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  92664. */
  92665. pressure: number;
  92666. /**
  92667. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  92668. */
  92669. /**
  92670. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  92671. */
  92672. stiffness: number;
  92673. /**
  92674. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  92675. */
  92676. /**
  92677. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  92678. */
  92679. velocityIterations: number;
  92680. /**
  92681. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  92682. */
  92683. /**
  92684. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  92685. */
  92686. positionIterations: number;
  92687. /**
  92688. * The unique id of the physics imposter
  92689. * set by the physics engine when adding this impostor to the array
  92690. */
  92691. uniqueId: number;
  92692. /**
  92693. * @hidden
  92694. */
  92695. soft: boolean;
  92696. /**
  92697. * @hidden
  92698. */
  92699. segments: number;
  92700. private _joints;
  92701. /**
  92702. * Initializes the physics imposter
  92703. * @param object The physics-enabled object used as the physics imposter
  92704. * @param type The type of the physics imposter
  92705. * @param _options The options for the physics imposter
  92706. * @param _scene The Babylon scene
  92707. */
  92708. constructor(
  92709. /**
  92710. * The physics-enabled object used as the physics imposter
  92711. */
  92712. object: IPhysicsEnabledObject,
  92713. /**
  92714. * The type of the physics imposter
  92715. */
  92716. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  92717. /**
  92718. * This function will completly initialize this impostor.
  92719. * It will create a new body - but only if this mesh has no parent.
  92720. * If it has, this impostor will not be used other than to define the impostor
  92721. * of the child mesh.
  92722. * @hidden
  92723. */
  92724. _init(): void;
  92725. private _getPhysicsParent;
  92726. /**
  92727. * Should a new body be generated.
  92728. * @returns boolean specifying if body initialization is required
  92729. */
  92730. isBodyInitRequired(): boolean;
  92731. /**
  92732. * Sets the updated scaling
  92733. * @param updated Specifies if the scaling is updated
  92734. */
  92735. setScalingUpdated(): void;
  92736. /**
  92737. * Force a regeneration of this or the parent's impostor's body.
  92738. * Use under cautious - This will remove all joints already implemented.
  92739. */
  92740. forceUpdate(): void;
  92741. /**
  92742. * Gets the body that holds this impostor. Either its own, or its parent.
  92743. */
  92744. /**
  92745. * Set the physics body. Used mainly by the physics engine/plugin
  92746. */
  92747. physicsBody: any;
  92748. /**
  92749. * Get the parent of the physics imposter
  92750. * @returns Physics imposter or null
  92751. */
  92752. /**
  92753. * Sets the parent of the physics imposter
  92754. */
  92755. parent: Nullable<PhysicsImpostor>;
  92756. /**
  92757. * Resets the update flags
  92758. */
  92759. resetUpdateFlags(): void;
  92760. /**
  92761. * Gets the object extend size
  92762. * @returns the object extend size
  92763. */
  92764. getObjectExtendSize(): Vector3;
  92765. /**
  92766. * Gets the object center
  92767. * @returns The object center
  92768. */
  92769. getObjectCenter(): Vector3;
  92770. /**
  92771. * Get a specific parametes from the options parameter
  92772. * @param paramName The object parameter name
  92773. * @returns The object parameter
  92774. */
  92775. getParam(paramName: string): any;
  92776. /**
  92777. * Sets a specific parameter in the options given to the physics plugin
  92778. * @param paramName The parameter name
  92779. * @param value The value of the parameter
  92780. */
  92781. setParam(paramName: string, value: number): void;
  92782. /**
  92783. * Specifically change the body's mass option. Won't recreate the physics body object
  92784. * @param mass The mass of the physics imposter
  92785. */
  92786. setMass(mass: number): void;
  92787. /**
  92788. * Gets the linear velocity
  92789. * @returns linear velocity or null
  92790. */
  92791. getLinearVelocity(): Nullable<Vector3>;
  92792. /**
  92793. * Sets the linear velocity
  92794. * @param velocity linear velocity or null
  92795. */
  92796. setLinearVelocity(velocity: Nullable<Vector3>): void;
  92797. /**
  92798. * Gets the angular velocity
  92799. * @returns angular velocity or null
  92800. */
  92801. getAngularVelocity(): Nullable<Vector3>;
  92802. /**
  92803. * Sets the angular velocity
  92804. * @param velocity The velocity or null
  92805. */
  92806. setAngularVelocity(velocity: Nullable<Vector3>): void;
  92807. /**
  92808. * Execute a function with the physics plugin native code
  92809. * Provide a function the will have two variables - the world object and the physics body object
  92810. * @param func The function to execute with the physics plugin native code
  92811. */
  92812. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  92813. /**
  92814. * Register a function that will be executed before the physics world is stepping forward
  92815. * @param func The function to execute before the physics world is stepped forward
  92816. */
  92817. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  92818. /**
  92819. * Unregister a function that will be executed before the physics world is stepping forward
  92820. * @param func The function to execute before the physics world is stepped forward
  92821. */
  92822. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  92823. /**
  92824. * Register a function that will be executed after the physics step
  92825. * @param func The function to execute after physics step
  92826. */
  92827. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  92828. /**
  92829. * Unregisters a function that will be executed after the physics step
  92830. * @param func The function to execute after physics step
  92831. */
  92832. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  92833. /**
  92834. * register a function that will be executed when this impostor collides against a different body
  92835. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  92836. * @param func Callback that is executed on collision
  92837. */
  92838. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  92839. /**
  92840. * Unregisters the physics imposter on contact
  92841. * @param collideAgainst The physics object to collide against
  92842. * @param func Callback to execute on collision
  92843. */
  92844. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  92845. private _tmpQuat;
  92846. private _tmpQuat2;
  92847. /**
  92848. * Get the parent rotation
  92849. * @returns The parent rotation
  92850. */
  92851. getParentsRotation(): Quaternion;
  92852. /**
  92853. * this function is executed by the physics engine.
  92854. */
  92855. beforeStep: () => void;
  92856. /**
  92857. * this function is executed by the physics engine
  92858. */
  92859. afterStep: () => void;
  92860. /**
  92861. * Legacy collision detection event support
  92862. */
  92863. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  92864. /**
  92865. * event and body object due to cannon's event-based architecture.
  92866. */
  92867. onCollide: (e: {
  92868. body: any;
  92869. }) => void;
  92870. /**
  92871. * Apply a force
  92872. * @param force The force to apply
  92873. * @param contactPoint The contact point for the force
  92874. * @returns The physics imposter
  92875. */
  92876. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  92877. /**
  92878. * Apply an impulse
  92879. * @param force The impulse force
  92880. * @param contactPoint The contact point for the impulse force
  92881. * @returns The physics imposter
  92882. */
  92883. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  92884. /**
  92885. * A help function to create a joint
  92886. * @param otherImpostor A physics imposter used to create a joint
  92887. * @param jointType The type of joint
  92888. * @param jointData The data for the joint
  92889. * @returns The physics imposter
  92890. */
  92891. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  92892. /**
  92893. * Add a joint to this impostor with a different impostor
  92894. * @param otherImpostor A physics imposter used to add a joint
  92895. * @param joint The joint to add
  92896. * @returns The physics imposter
  92897. */
  92898. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  92899. /**
  92900. * Add an anchor to a cloth impostor
  92901. * @param otherImpostor rigid impostor to anchor to
  92902. * @param width ratio across width from 0 to 1
  92903. * @param height ratio up height from 0 to 1
  92904. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  92905. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  92906. * @returns impostor the soft imposter
  92907. */
  92908. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  92909. /**
  92910. * Add a hook to a rope impostor
  92911. * @param otherImpostor rigid impostor to anchor to
  92912. * @param length ratio across rope from 0 to 1
  92913. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  92914. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  92915. * @returns impostor the rope imposter
  92916. */
  92917. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  92918. /**
  92919. * Will keep this body still, in a sleep mode.
  92920. * @returns the physics imposter
  92921. */
  92922. sleep(): PhysicsImpostor;
  92923. /**
  92924. * Wake the body up.
  92925. * @returns The physics imposter
  92926. */
  92927. wakeUp(): PhysicsImpostor;
  92928. /**
  92929. * Clones the physics imposter
  92930. * @param newObject The physics imposter clones to this physics-enabled object
  92931. * @returns A nullable physics imposter
  92932. */
  92933. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  92934. /**
  92935. * Disposes the physics imposter
  92936. */
  92937. dispose(): void;
  92938. /**
  92939. * Sets the delta position
  92940. * @param position The delta position amount
  92941. */
  92942. setDeltaPosition(position: Vector3): void;
  92943. /**
  92944. * Sets the delta rotation
  92945. * @param rotation The delta rotation amount
  92946. */
  92947. setDeltaRotation(rotation: Quaternion): void;
  92948. /**
  92949. * Gets the box size of the physics imposter and stores the result in the input parameter
  92950. * @param result Stores the box size
  92951. * @returns The physics imposter
  92952. */
  92953. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  92954. /**
  92955. * Gets the radius of the physics imposter
  92956. * @returns Radius of the physics imposter
  92957. */
  92958. getRadius(): number;
  92959. /**
  92960. * Sync a bone with this impostor
  92961. * @param bone The bone to sync to the impostor.
  92962. * @param boneMesh The mesh that the bone is influencing.
  92963. * @param jointPivot The pivot of the joint / bone in local space.
  92964. * @param distToJoint Optional distance from the impostor to the joint.
  92965. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  92966. */
  92967. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  92968. /**
  92969. * Sync impostor to a bone
  92970. * @param bone The bone that the impostor will be synced to.
  92971. * @param boneMesh The mesh that the bone is influencing.
  92972. * @param jointPivot The pivot of the joint / bone in local space.
  92973. * @param distToJoint Optional distance from the impostor to the joint.
  92974. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  92975. * @param boneAxis Optional vector3 axis the bone is aligned with
  92976. */
  92977. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  92978. /**
  92979. * No-Imposter type
  92980. */
  92981. static NoImpostor: number;
  92982. /**
  92983. * Sphere-Imposter type
  92984. */
  92985. static SphereImpostor: number;
  92986. /**
  92987. * Box-Imposter type
  92988. */
  92989. static BoxImpostor: number;
  92990. /**
  92991. * Plane-Imposter type
  92992. */
  92993. static PlaneImpostor: number;
  92994. /**
  92995. * Mesh-imposter type
  92996. */
  92997. static MeshImpostor: number;
  92998. /**
  92999. * Capsule-Impostor type (Ammo.js plugin only)
  93000. */
  93001. static CapsuleImpostor: number;
  93002. /**
  93003. * Cylinder-Imposter type
  93004. */
  93005. static CylinderImpostor: number;
  93006. /**
  93007. * Particle-Imposter type
  93008. */
  93009. static ParticleImpostor: number;
  93010. /**
  93011. * Heightmap-Imposter type
  93012. */
  93013. static HeightmapImpostor: number;
  93014. /**
  93015. * ConvexHull-Impostor type (Ammo.js plugin only)
  93016. */
  93017. static ConvexHullImpostor: number;
  93018. /**
  93019. * Custom-Imposter type (Ammo.js plugin only)
  93020. */
  93021. static CustomImpostor: number;
  93022. /**
  93023. * Rope-Imposter type
  93024. */
  93025. static RopeImpostor: number;
  93026. /**
  93027. * Cloth-Imposter type
  93028. */
  93029. static ClothImpostor: number;
  93030. /**
  93031. * Softbody-Imposter type
  93032. */
  93033. static SoftbodyImpostor: number;
  93034. }
  93035. }
  93036. declare module BABYLON {
  93037. /**
  93038. * @hidden
  93039. **/
  93040. export class _CreationDataStorage {
  93041. closePath?: boolean;
  93042. closeArray?: boolean;
  93043. idx: number[];
  93044. dashSize: number;
  93045. gapSize: number;
  93046. path3D: Path3D;
  93047. pathArray: Vector3[][];
  93048. arc: number;
  93049. radius: number;
  93050. cap: number;
  93051. tessellation: number;
  93052. }
  93053. /**
  93054. * @hidden
  93055. **/
  93056. class _InstanceDataStorage {
  93057. visibleInstances: any;
  93058. batchCache: _InstancesBatch;
  93059. instancesBufferSize: number;
  93060. instancesBuffer: Nullable<Buffer>;
  93061. instancesData: Float32Array;
  93062. overridenInstanceCount: number;
  93063. isFrozen: boolean;
  93064. previousBatch: Nullable<_InstancesBatch>;
  93065. hardwareInstancedRendering: boolean;
  93066. sideOrientation: number;
  93067. manualUpdate: boolean;
  93068. }
  93069. /**
  93070. * @hidden
  93071. **/
  93072. export class _InstancesBatch {
  93073. mustReturn: boolean;
  93074. visibleInstances: Nullable<InstancedMesh[]>[];
  93075. renderSelf: boolean[];
  93076. hardwareInstancedRendering: boolean[];
  93077. }
  93078. /**
  93079. * Class used to represent renderable models
  93080. */
  93081. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  93082. /**
  93083. * Mesh side orientation : usually the external or front surface
  93084. */
  93085. static readonly FRONTSIDE: number;
  93086. /**
  93087. * Mesh side orientation : usually the internal or back surface
  93088. */
  93089. static readonly BACKSIDE: number;
  93090. /**
  93091. * Mesh side orientation : both internal and external or front and back surfaces
  93092. */
  93093. static readonly DOUBLESIDE: number;
  93094. /**
  93095. * Mesh side orientation : by default, `FRONTSIDE`
  93096. */
  93097. static readonly DEFAULTSIDE: number;
  93098. /**
  93099. * Mesh cap setting : no cap
  93100. */
  93101. static readonly NO_CAP: number;
  93102. /**
  93103. * Mesh cap setting : one cap at the beginning of the mesh
  93104. */
  93105. static readonly CAP_START: number;
  93106. /**
  93107. * Mesh cap setting : one cap at the end of the mesh
  93108. */
  93109. static readonly CAP_END: number;
  93110. /**
  93111. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  93112. */
  93113. static readonly CAP_ALL: number;
  93114. /**
  93115. * Mesh pattern setting : no flip or rotate
  93116. */
  93117. static readonly NO_FLIP: number;
  93118. /**
  93119. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  93120. */
  93121. static readonly FLIP_TILE: number;
  93122. /**
  93123. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  93124. */
  93125. static readonly ROTATE_TILE: number;
  93126. /**
  93127. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  93128. */
  93129. static readonly FLIP_ROW: number;
  93130. /**
  93131. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  93132. */
  93133. static readonly ROTATE_ROW: number;
  93134. /**
  93135. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  93136. */
  93137. static readonly FLIP_N_ROTATE_TILE: number;
  93138. /**
  93139. * Mesh pattern setting : rotate pattern and rotate
  93140. */
  93141. static readonly FLIP_N_ROTATE_ROW: number;
  93142. /**
  93143. * Mesh tile positioning : part tiles same on left/right or top/bottom
  93144. */
  93145. static readonly CENTER: number;
  93146. /**
  93147. * Mesh tile positioning : part tiles on left
  93148. */
  93149. static readonly LEFT: number;
  93150. /**
  93151. * Mesh tile positioning : part tiles on right
  93152. */
  93153. static readonly RIGHT: number;
  93154. /**
  93155. * Mesh tile positioning : part tiles on top
  93156. */
  93157. static readonly TOP: number;
  93158. /**
  93159. * Mesh tile positioning : part tiles on bottom
  93160. */
  93161. static readonly BOTTOM: number;
  93162. /**
  93163. * Gets the default side orientation.
  93164. * @param orientation the orientation to value to attempt to get
  93165. * @returns the default orientation
  93166. * @hidden
  93167. */
  93168. static _GetDefaultSideOrientation(orientation?: number): number;
  93169. private _internalMeshDataInfo;
  93170. /**
  93171. * An event triggered before rendering the mesh
  93172. */
  93173. readonly onBeforeRenderObservable: Observable<Mesh>;
  93174. /**
  93175. * An event triggered before binding the mesh
  93176. */
  93177. readonly onBeforeBindObservable: Observable<Mesh>;
  93178. /**
  93179. * An event triggered after rendering the mesh
  93180. */
  93181. readonly onAfterRenderObservable: Observable<Mesh>;
  93182. /**
  93183. * An event triggered before drawing the mesh
  93184. */
  93185. readonly onBeforeDrawObservable: Observable<Mesh>;
  93186. private _onBeforeDrawObserver;
  93187. /**
  93188. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  93189. */
  93190. onBeforeDraw: () => void;
  93191. readonly hasInstances: boolean;
  93192. /**
  93193. * Gets the delay loading state of the mesh (when delay loading is turned on)
  93194. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  93195. */
  93196. delayLoadState: number;
  93197. /**
  93198. * Gets the list of instances created from this mesh
  93199. * it is not supposed to be modified manually.
  93200. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  93201. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  93202. */
  93203. instances: InstancedMesh[];
  93204. /**
  93205. * Gets the file containing delay loading data for this mesh
  93206. */
  93207. delayLoadingFile: string;
  93208. /** @hidden */
  93209. _binaryInfo: any;
  93210. /**
  93211. * User defined function used to change how LOD level selection is done
  93212. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  93213. */
  93214. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  93215. /**
  93216. * Gets or sets the morph target manager
  93217. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  93218. */
  93219. morphTargetManager: Nullable<MorphTargetManager>;
  93220. /** @hidden */
  93221. _creationDataStorage: Nullable<_CreationDataStorage>;
  93222. /** @hidden */
  93223. _geometry: Nullable<Geometry>;
  93224. /** @hidden */
  93225. _delayInfo: Array<string>;
  93226. /** @hidden */
  93227. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  93228. /** @hidden */
  93229. _instanceDataStorage: _InstanceDataStorage;
  93230. private _effectiveMaterial;
  93231. /** @hidden */
  93232. _shouldGenerateFlatShading: boolean;
  93233. /** @hidden */
  93234. _originalBuilderSideOrientation: number;
  93235. /**
  93236. * Use this property to change the original side orientation defined at construction time
  93237. */
  93238. overrideMaterialSideOrientation: Nullable<number>;
  93239. /**
  93240. * Gets the source mesh (the one used to clone this one from)
  93241. */
  93242. readonly source: Nullable<Mesh>;
  93243. /**
  93244. * Gets or sets a boolean indicating that this mesh does not use index buffer
  93245. */
  93246. isUnIndexed: boolean;
  93247. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  93248. readonly worldMatrixInstancedBuffer: Float32Array;
  93249. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  93250. manualUpdateOfWorldMatrixInstancedBuffer: boolean;
  93251. /**
  93252. * @constructor
  93253. * @param name The value used by scene.getMeshByName() to do a lookup.
  93254. * @param scene The scene to add this mesh to.
  93255. * @param parent The parent of this mesh, if it has one
  93256. * @param source An optional Mesh from which geometry is shared, cloned.
  93257. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  93258. * When false, achieved by calling a clone(), also passing False.
  93259. * This will make creation of children, recursive.
  93260. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  93261. */
  93262. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  93263. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  93264. doNotInstantiate: boolean;
  93265. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  93266. /**
  93267. * Gets the class name
  93268. * @returns the string "Mesh".
  93269. */
  93270. getClassName(): string;
  93271. /** @hidden */
  93272. readonly _isMesh: boolean;
  93273. /**
  93274. * Returns a description of this mesh
  93275. * @param fullDetails define if full details about this mesh must be used
  93276. * @returns a descriptive string representing this mesh
  93277. */
  93278. toString(fullDetails?: boolean): string;
  93279. /** @hidden */
  93280. _unBindEffect(): void;
  93281. /**
  93282. * Gets a boolean indicating if this mesh has LOD
  93283. */
  93284. readonly hasLODLevels: boolean;
  93285. /**
  93286. * Gets the list of MeshLODLevel associated with the current mesh
  93287. * @returns an array of MeshLODLevel
  93288. */
  93289. getLODLevels(): MeshLODLevel[];
  93290. private _sortLODLevels;
  93291. /**
  93292. * Add a mesh as LOD level triggered at the given distance.
  93293. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  93294. * @param distance The distance from the center of the object to show this level
  93295. * @param mesh The mesh to be added as LOD level (can be null)
  93296. * @return This mesh (for chaining)
  93297. */
  93298. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  93299. /**
  93300. * Returns the LOD level mesh at the passed distance or null if not found.
  93301. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  93302. * @param distance The distance from the center of the object to show this level
  93303. * @returns a Mesh or `null`
  93304. */
  93305. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  93306. /**
  93307. * Remove a mesh from the LOD array
  93308. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  93309. * @param mesh defines the mesh to be removed
  93310. * @return This mesh (for chaining)
  93311. */
  93312. removeLODLevel(mesh: Mesh): Mesh;
  93313. /**
  93314. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  93315. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  93316. * @param camera defines the camera to use to compute distance
  93317. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  93318. * @return This mesh (for chaining)
  93319. */
  93320. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  93321. /**
  93322. * Gets the mesh internal Geometry object
  93323. */
  93324. readonly geometry: Nullable<Geometry>;
  93325. /**
  93326. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  93327. * @returns the total number of vertices
  93328. */
  93329. getTotalVertices(): number;
  93330. /**
  93331. * Returns the content of an associated vertex buffer
  93332. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  93333. * - VertexBuffer.PositionKind
  93334. * - VertexBuffer.UVKind
  93335. * - VertexBuffer.UV2Kind
  93336. * - VertexBuffer.UV3Kind
  93337. * - VertexBuffer.UV4Kind
  93338. * - VertexBuffer.UV5Kind
  93339. * - VertexBuffer.UV6Kind
  93340. * - VertexBuffer.ColorKind
  93341. * - VertexBuffer.MatricesIndicesKind
  93342. * - VertexBuffer.MatricesIndicesExtraKind
  93343. * - VertexBuffer.MatricesWeightsKind
  93344. * - VertexBuffer.MatricesWeightsExtraKind
  93345. * @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
  93346. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  93347. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  93348. */
  93349. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  93350. /**
  93351. * Returns the mesh VertexBuffer object from the requested `kind`
  93352. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  93353. * - VertexBuffer.PositionKind
  93354. * - VertexBuffer.NormalKind
  93355. * - VertexBuffer.UVKind
  93356. * - VertexBuffer.UV2Kind
  93357. * - VertexBuffer.UV3Kind
  93358. * - VertexBuffer.UV4Kind
  93359. * - VertexBuffer.UV5Kind
  93360. * - VertexBuffer.UV6Kind
  93361. * - VertexBuffer.ColorKind
  93362. * - VertexBuffer.MatricesIndicesKind
  93363. * - VertexBuffer.MatricesIndicesExtraKind
  93364. * - VertexBuffer.MatricesWeightsKind
  93365. * - VertexBuffer.MatricesWeightsExtraKind
  93366. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  93367. */
  93368. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  93369. /**
  93370. * Tests if a specific vertex buffer is associated with this mesh
  93371. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  93372. * - VertexBuffer.PositionKind
  93373. * - VertexBuffer.NormalKind
  93374. * - VertexBuffer.UVKind
  93375. * - VertexBuffer.UV2Kind
  93376. * - VertexBuffer.UV3Kind
  93377. * - VertexBuffer.UV4Kind
  93378. * - VertexBuffer.UV5Kind
  93379. * - VertexBuffer.UV6Kind
  93380. * - VertexBuffer.ColorKind
  93381. * - VertexBuffer.MatricesIndicesKind
  93382. * - VertexBuffer.MatricesIndicesExtraKind
  93383. * - VertexBuffer.MatricesWeightsKind
  93384. * - VertexBuffer.MatricesWeightsExtraKind
  93385. * @returns a boolean
  93386. */
  93387. isVerticesDataPresent(kind: string): boolean;
  93388. /**
  93389. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  93390. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  93391. * - VertexBuffer.PositionKind
  93392. * - VertexBuffer.UVKind
  93393. * - VertexBuffer.UV2Kind
  93394. * - VertexBuffer.UV3Kind
  93395. * - VertexBuffer.UV4Kind
  93396. * - VertexBuffer.UV5Kind
  93397. * - VertexBuffer.UV6Kind
  93398. * - VertexBuffer.ColorKind
  93399. * - VertexBuffer.MatricesIndicesKind
  93400. * - VertexBuffer.MatricesIndicesExtraKind
  93401. * - VertexBuffer.MatricesWeightsKind
  93402. * - VertexBuffer.MatricesWeightsExtraKind
  93403. * @returns a boolean
  93404. */
  93405. isVertexBufferUpdatable(kind: string): boolean;
  93406. /**
  93407. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  93408. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  93409. * - VertexBuffer.PositionKind
  93410. * - VertexBuffer.NormalKind
  93411. * - VertexBuffer.UVKind
  93412. * - VertexBuffer.UV2Kind
  93413. * - VertexBuffer.UV3Kind
  93414. * - VertexBuffer.UV4Kind
  93415. * - VertexBuffer.UV5Kind
  93416. * - VertexBuffer.UV6Kind
  93417. * - VertexBuffer.ColorKind
  93418. * - VertexBuffer.MatricesIndicesKind
  93419. * - VertexBuffer.MatricesIndicesExtraKind
  93420. * - VertexBuffer.MatricesWeightsKind
  93421. * - VertexBuffer.MatricesWeightsExtraKind
  93422. * @returns an array of strings
  93423. */
  93424. getVerticesDataKinds(): string[];
  93425. /**
  93426. * Returns a positive integer : the total number of indices in this mesh geometry.
  93427. * @returns the numner of indices or zero if the mesh has no geometry.
  93428. */
  93429. getTotalIndices(): number;
  93430. /**
  93431. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  93432. * @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.
  93433. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  93434. * @returns the indices array or an empty array if the mesh has no geometry
  93435. */
  93436. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  93437. readonly isBlocked: boolean;
  93438. /**
  93439. * Determine if the current mesh is ready to be rendered
  93440. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  93441. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  93442. * @returns true if all associated assets are ready (material, textures, shaders)
  93443. */
  93444. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  93445. /**
  93446. * 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.
  93447. */
  93448. readonly areNormalsFrozen: boolean;
  93449. /**
  93450. * 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.
  93451. * @returns the current mesh
  93452. */
  93453. freezeNormals(): Mesh;
  93454. /**
  93455. * 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
  93456. * @returns the current mesh
  93457. */
  93458. unfreezeNormals(): Mesh;
  93459. /**
  93460. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  93461. */
  93462. overridenInstanceCount: number;
  93463. /** @hidden */
  93464. _preActivate(): Mesh;
  93465. /** @hidden */
  93466. _preActivateForIntermediateRendering(renderId: number): Mesh;
  93467. /** @hidden */
  93468. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  93469. /**
  93470. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  93471. * This means the mesh underlying bounding box and sphere are recomputed.
  93472. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  93473. * @returns the current mesh
  93474. */
  93475. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  93476. /** @hidden */
  93477. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  93478. /**
  93479. * This function will subdivide the mesh into multiple submeshes
  93480. * @param count defines the expected number of submeshes
  93481. */
  93482. subdivide(count: number): void;
  93483. /**
  93484. * Copy a FloatArray into a specific associated vertex buffer
  93485. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  93486. * - VertexBuffer.PositionKind
  93487. * - VertexBuffer.UVKind
  93488. * - VertexBuffer.UV2Kind
  93489. * - VertexBuffer.UV3Kind
  93490. * - VertexBuffer.UV4Kind
  93491. * - VertexBuffer.UV5Kind
  93492. * - VertexBuffer.UV6Kind
  93493. * - VertexBuffer.ColorKind
  93494. * - VertexBuffer.MatricesIndicesKind
  93495. * - VertexBuffer.MatricesIndicesExtraKind
  93496. * - VertexBuffer.MatricesWeightsKind
  93497. * - VertexBuffer.MatricesWeightsExtraKind
  93498. * @param data defines the data source
  93499. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  93500. * @param stride defines the data stride size (can be null)
  93501. * @returns the current mesh
  93502. */
  93503. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  93504. /**
  93505. * Delete a vertex buffer associated with this mesh
  93506. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  93507. * - VertexBuffer.PositionKind
  93508. * - VertexBuffer.UVKind
  93509. * - VertexBuffer.UV2Kind
  93510. * - VertexBuffer.UV3Kind
  93511. * - VertexBuffer.UV4Kind
  93512. * - VertexBuffer.UV5Kind
  93513. * - VertexBuffer.UV6Kind
  93514. * - VertexBuffer.ColorKind
  93515. * - VertexBuffer.MatricesIndicesKind
  93516. * - VertexBuffer.MatricesIndicesExtraKind
  93517. * - VertexBuffer.MatricesWeightsKind
  93518. * - VertexBuffer.MatricesWeightsExtraKind
  93519. */
  93520. removeVerticesData(kind: string): void;
  93521. /**
  93522. * Flags an associated vertex buffer as updatable
  93523. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  93524. * - VertexBuffer.PositionKind
  93525. * - VertexBuffer.UVKind
  93526. * - VertexBuffer.UV2Kind
  93527. * - VertexBuffer.UV3Kind
  93528. * - VertexBuffer.UV4Kind
  93529. * - VertexBuffer.UV5Kind
  93530. * - VertexBuffer.UV6Kind
  93531. * - VertexBuffer.ColorKind
  93532. * - VertexBuffer.MatricesIndicesKind
  93533. * - VertexBuffer.MatricesIndicesExtraKind
  93534. * - VertexBuffer.MatricesWeightsKind
  93535. * - VertexBuffer.MatricesWeightsExtraKind
  93536. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  93537. */
  93538. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  93539. /**
  93540. * Sets the mesh global Vertex Buffer
  93541. * @param buffer defines the buffer to use
  93542. * @returns the current mesh
  93543. */
  93544. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  93545. /**
  93546. * Update a specific associated vertex buffer
  93547. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  93548. * - VertexBuffer.PositionKind
  93549. * - VertexBuffer.UVKind
  93550. * - VertexBuffer.UV2Kind
  93551. * - VertexBuffer.UV3Kind
  93552. * - VertexBuffer.UV4Kind
  93553. * - VertexBuffer.UV5Kind
  93554. * - VertexBuffer.UV6Kind
  93555. * - VertexBuffer.ColorKind
  93556. * - VertexBuffer.MatricesIndicesKind
  93557. * - VertexBuffer.MatricesIndicesExtraKind
  93558. * - VertexBuffer.MatricesWeightsKind
  93559. * - VertexBuffer.MatricesWeightsExtraKind
  93560. * @param data defines the data source
  93561. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  93562. * @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)
  93563. * @returns the current mesh
  93564. */
  93565. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  93566. /**
  93567. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  93568. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  93569. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  93570. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  93571. * @returns the current mesh
  93572. */
  93573. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  93574. /**
  93575. * Creates a un-shared specific occurence of the geometry for the mesh.
  93576. * @returns the current mesh
  93577. */
  93578. makeGeometryUnique(): Mesh;
  93579. /**
  93580. * Set the index buffer of this mesh
  93581. * @param indices defines the source data
  93582. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  93583. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  93584. * @returns the current mesh
  93585. */
  93586. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  93587. /**
  93588. * Update the current index buffer
  93589. * @param indices defines the source data
  93590. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  93591. * @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)
  93592. * @returns the current mesh
  93593. */
  93594. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  93595. /**
  93596. * Invert the geometry to move from a right handed system to a left handed one.
  93597. * @returns the current mesh
  93598. */
  93599. toLeftHanded(): Mesh;
  93600. /** @hidden */
  93601. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  93602. /** @hidden */
  93603. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  93604. /**
  93605. * Registers for this mesh a javascript function called just before the rendering process
  93606. * @param func defines the function to call before rendering this mesh
  93607. * @returns the current mesh
  93608. */
  93609. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  93610. /**
  93611. * Disposes a previously registered javascript function called before the rendering
  93612. * @param func defines the function to remove
  93613. * @returns the current mesh
  93614. */
  93615. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  93616. /**
  93617. * Registers for this mesh a javascript function called just after the rendering is complete
  93618. * @param func defines the function to call after rendering this mesh
  93619. * @returns the current mesh
  93620. */
  93621. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  93622. /**
  93623. * Disposes a previously registered javascript function called after the rendering.
  93624. * @param func defines the function to remove
  93625. * @returns the current mesh
  93626. */
  93627. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  93628. /** @hidden */
  93629. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  93630. /** @hidden */
  93631. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  93632. /** @hidden */
  93633. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  93634. /** @hidden */
  93635. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  93636. /** @hidden */
  93637. _rebuild(): void;
  93638. /** @hidden */
  93639. _freeze(): void;
  93640. /** @hidden */
  93641. _unFreeze(): void;
  93642. /**
  93643. * 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
  93644. * @param subMesh defines the subMesh to render
  93645. * @param enableAlphaMode defines if alpha mode can be changed
  93646. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  93647. * @returns the current mesh
  93648. */
  93649. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  93650. private _onBeforeDraw;
  93651. /**
  93652. * Renormalize the mesh and patch it up if there are no weights
  93653. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  93654. * However in the case of zero weights then we set just a single influence to 1.
  93655. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  93656. */
  93657. cleanMatrixWeights(): void;
  93658. private normalizeSkinFourWeights;
  93659. private normalizeSkinWeightsAndExtra;
  93660. /**
  93661. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  93662. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  93663. * the user know there was an issue with importing the mesh
  93664. * @returns a validation object with skinned, valid and report string
  93665. */
  93666. validateSkinning(): {
  93667. skinned: boolean;
  93668. valid: boolean;
  93669. report: string;
  93670. };
  93671. /** @hidden */
  93672. _checkDelayState(): Mesh;
  93673. private _queueLoad;
  93674. /**
  93675. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  93676. * A mesh is in the frustum if its bounding box intersects the frustum
  93677. * @param frustumPlanes defines the frustum to test
  93678. * @returns true if the mesh is in the frustum planes
  93679. */
  93680. isInFrustum(frustumPlanes: Plane[]): boolean;
  93681. /**
  93682. * Sets the mesh material by the material or multiMaterial `id` property
  93683. * @param id is a string identifying the material or the multiMaterial
  93684. * @returns the current mesh
  93685. */
  93686. setMaterialByID(id: string): Mesh;
  93687. /**
  93688. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  93689. * @returns an array of IAnimatable
  93690. */
  93691. getAnimatables(): IAnimatable[];
  93692. /**
  93693. * Modifies the mesh geometry according to the passed transformation matrix.
  93694. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  93695. * The mesh normals are modified using the same transformation.
  93696. * Note that, under the hood, this method sets a new VertexBuffer each call.
  93697. * @param transform defines the transform matrix to use
  93698. * @see http://doc.babylonjs.com/resources/baking_transformations
  93699. * @returns the current mesh
  93700. */
  93701. bakeTransformIntoVertices(transform: Matrix): Mesh;
  93702. /**
  93703. * Modifies the mesh geometry according to its own current World Matrix.
  93704. * The mesh World Matrix is then reset.
  93705. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  93706. * Note that, under the hood, this method sets a new VertexBuffer each call.
  93707. * @see http://doc.babylonjs.com/resources/baking_transformations
  93708. * @returns the current mesh
  93709. */
  93710. bakeCurrentTransformIntoVertices(): Mesh;
  93711. /** @hidden */
  93712. readonly _positions: Nullable<Vector3[]>;
  93713. /** @hidden */
  93714. _resetPointsArrayCache(): Mesh;
  93715. /** @hidden */
  93716. _generatePointsArray(): boolean;
  93717. /**
  93718. * Returns a new Mesh object generated from the current mesh properties.
  93719. * This method must not get confused with createInstance()
  93720. * @param name is a string, the name given to the new mesh
  93721. * @param newParent can be any Node object (default `null`)
  93722. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  93723. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  93724. * @returns a new mesh
  93725. */
  93726. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  93727. /**
  93728. * Releases resources associated with this mesh.
  93729. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93730. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93731. */
  93732. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93733. /** @hidden */
  93734. _disposeInstanceSpecificData(): void;
  93735. /**
  93736. * Modifies the mesh geometry according to a displacement map.
  93737. * 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.
  93738. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  93739. * @param url is a string, the URL from the image file is to be downloaded.
  93740. * @param minHeight is the lower limit of the displacement.
  93741. * @param maxHeight is the upper limit of the displacement.
  93742. * @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.
  93743. * @param uvOffset is an optional vector2 used to offset UV.
  93744. * @param uvScale is an optional vector2 used to scale UV.
  93745. * @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.
  93746. * @returns the Mesh.
  93747. */
  93748. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  93749. /**
  93750. * Modifies the mesh geometry according to a displacementMap buffer.
  93751. * 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.
  93752. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  93753. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  93754. * @param heightMapWidth is the width of the buffer image.
  93755. * @param heightMapHeight is the height of the buffer image.
  93756. * @param minHeight is the lower limit of the displacement.
  93757. * @param maxHeight is the upper limit of the displacement.
  93758. * @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.
  93759. * @param uvOffset is an optional vector2 used to offset UV.
  93760. * @param uvScale is an optional vector2 used to scale UV.
  93761. * @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.
  93762. * @returns the Mesh.
  93763. */
  93764. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  93765. /**
  93766. * Modify the mesh to get a flat shading rendering.
  93767. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  93768. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  93769. * @returns current mesh
  93770. */
  93771. convertToFlatShadedMesh(): Mesh;
  93772. /**
  93773. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  93774. * In other words, more vertices, no more indices and a single bigger VBO.
  93775. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  93776. * @returns current mesh
  93777. */
  93778. convertToUnIndexedMesh(): Mesh;
  93779. /**
  93780. * Inverses facet orientations.
  93781. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  93782. * @param flipNormals will also inverts the normals
  93783. * @returns current mesh
  93784. */
  93785. flipFaces(flipNormals?: boolean): Mesh;
  93786. /**
  93787. * Increase the number of facets and hence vertices in a mesh
  93788. * Vertex normals are interpolated from existing vertex normals
  93789. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  93790. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  93791. */
  93792. increaseVertices(numberPerEdge: number): void;
  93793. /**
  93794. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  93795. * This will undo any application of covertToFlatShadedMesh
  93796. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  93797. */
  93798. forceSharedVertices(): void;
  93799. /** @hidden */
  93800. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  93801. /** @hidden */
  93802. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  93803. /**
  93804. * Creates a new InstancedMesh object from the mesh model.
  93805. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  93806. * @param name defines the name of the new instance
  93807. * @returns a new InstancedMesh
  93808. */
  93809. createInstance(name: string): InstancedMesh;
  93810. /**
  93811. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  93812. * After this call, all the mesh instances have the same submeshes than the current mesh.
  93813. * @returns the current mesh
  93814. */
  93815. synchronizeInstances(): Mesh;
  93816. /**
  93817. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  93818. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  93819. * This should be used together with the simplification to avoid disappearing triangles.
  93820. * @param successCallback an optional success callback to be called after the optimization finished.
  93821. * @returns the current mesh
  93822. */
  93823. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  93824. /**
  93825. * Serialize current mesh
  93826. * @param serializationObject defines the object which will receive the serialization data
  93827. */
  93828. serialize(serializationObject: any): void;
  93829. /** @hidden */
  93830. _syncGeometryWithMorphTargetManager(): void;
  93831. /** @hidden */
  93832. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  93833. /**
  93834. * Returns a new Mesh object parsed from the source provided.
  93835. * @param parsedMesh is the source
  93836. * @param scene defines the hosting scene
  93837. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  93838. * @returns a new Mesh
  93839. */
  93840. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  93841. /**
  93842. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  93843. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  93844. * @param name defines the name of the mesh to create
  93845. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  93846. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  93847. * @param closePath creates a seam between the first and the last points of each path of the path array
  93848. * @param offset is taken in account only if the `pathArray` is containing a single path
  93849. * @param scene defines the hosting scene
  93850. * @param updatable defines if the mesh must be flagged as updatable
  93851. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93852. * @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)
  93853. * @returns a new Mesh
  93854. */
  93855. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  93856. /**
  93857. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  93858. * @param name defines the name of the mesh to create
  93859. * @param radius sets the radius size (float) of the polygon (default 0.5)
  93860. * @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
  93861. * @param scene defines the hosting scene
  93862. * @param updatable defines if the mesh must be flagged as updatable
  93863. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93864. * @returns a new Mesh
  93865. */
  93866. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  93867. /**
  93868. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  93869. * @param name defines the name of the mesh to create
  93870. * @param size sets the size (float) of each box side (default 1)
  93871. * @param scene defines the hosting scene
  93872. * @param updatable defines if the mesh must be flagged as updatable
  93873. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93874. * @returns a new Mesh
  93875. */
  93876. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  93877. /**
  93878. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  93879. * @param name defines the name of the mesh to create
  93880. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  93881. * @param diameter sets the diameter size (float) of the sphere (default 1)
  93882. * @param scene defines the hosting scene
  93883. * @param updatable defines if the mesh must be flagged as updatable
  93884. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93885. * @returns a new Mesh
  93886. */
  93887. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  93888. /**
  93889. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  93890. * @param name defines the name of the mesh to create
  93891. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  93892. * @param diameter sets the diameter size (float) of the sphere (default 1)
  93893. * @param scene defines the hosting scene
  93894. * @returns a new Mesh
  93895. */
  93896. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  93897. /**
  93898. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  93899. * @param name defines the name of the mesh to create
  93900. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  93901. * @param diameterTop set the top cap diameter (floats, default 1)
  93902. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  93903. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  93904. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  93905. * @param scene defines the hosting scene
  93906. * @param updatable defines if the mesh must be flagged as updatable
  93907. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93908. * @returns a new Mesh
  93909. */
  93910. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  93911. /**
  93912. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  93913. * @param name defines the name of the mesh to create
  93914. * @param diameter sets the diameter size (float) of the torus (default 1)
  93915. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  93916. * @param tessellation sets the number of torus sides (postive integer, default 16)
  93917. * @param scene defines the hosting scene
  93918. * @param updatable defines if the mesh must be flagged as updatable
  93919. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93920. * @returns a new Mesh
  93921. */
  93922. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  93923. /**
  93924. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  93925. * @param name defines the name of the mesh to create
  93926. * @param radius sets the global radius size (float) of the torus knot (default 2)
  93927. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  93928. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  93929. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  93930. * @param p the number of windings on X axis (positive integers, default 2)
  93931. * @param q the number of windings on Y axis (positive integers, default 3)
  93932. * @param scene defines the hosting scene
  93933. * @param updatable defines if the mesh must be flagged as updatable
  93934. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93935. * @returns a new Mesh
  93936. */
  93937. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  93938. /**
  93939. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  93940. * @param name defines the name of the mesh to create
  93941. * @param points is an array successive Vector3
  93942. * @param scene defines the hosting scene
  93943. * @param updatable defines if the mesh must be flagged as updatable
  93944. * @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).
  93945. * @returns a new Mesh
  93946. */
  93947. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  93948. /**
  93949. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  93950. * @param name defines the name of the mesh to create
  93951. * @param points is an array successive Vector3
  93952. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  93953. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  93954. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  93955. * @param scene defines the hosting scene
  93956. * @param updatable defines if the mesh must be flagged as updatable
  93957. * @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)
  93958. * @returns a new Mesh
  93959. */
  93960. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  93961. /**
  93962. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  93963. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  93964. * 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.
  93965. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93966. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  93967. * Remember you can only change the shape positions, not their number when updating a polygon.
  93968. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  93969. * @param name defines the name of the mesh to create
  93970. * @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
  93971. * @param scene defines the hosting scene
  93972. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  93973. * @param updatable defines if the mesh must be flagged as updatable
  93974. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93975. * @param earcutInjection can be used to inject your own earcut reference
  93976. * @returns a new Mesh
  93977. */
  93978. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  93979. /**
  93980. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  93981. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  93982. * @param name defines the name of the mesh to create
  93983. * @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
  93984. * @param depth defines the height of extrusion
  93985. * @param scene defines the hosting scene
  93986. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  93987. * @param updatable defines if the mesh must be flagged as updatable
  93988. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93989. * @param earcutInjection can be used to inject your own earcut reference
  93990. * @returns a new Mesh
  93991. */
  93992. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  93993. /**
  93994. * Creates an extruded shape mesh.
  93995. * 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
  93996. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  93997. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  93998. * @param name defines the name of the mesh to create
  93999. * @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
  94000. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  94001. * @param scale is the value to scale the shape
  94002. * @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
  94003. * @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
  94004. * @param scene defines the hosting scene
  94005. * @param updatable defines if the mesh must be flagged as updatable
  94006. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  94007. * @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)
  94008. * @returns a new Mesh
  94009. */
  94010. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  94011. /**
  94012. * Creates an custom extruded shape mesh.
  94013. * The custom extrusion is a parametric shape.
  94014. * It has no predefined shape. Its final shape will depend on the input parameters.
  94015. * Please consider using the same method from the MeshBuilder class instead
  94016. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  94017. * @param name defines the name of the mesh to create
  94018. * @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
  94019. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  94020. * @param scaleFunction is a custom Javascript function called on each path point
  94021. * @param rotationFunction is a custom Javascript function called on each path point
  94022. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  94023. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  94024. * @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
  94025. * @param scene defines the hosting scene
  94026. * @param updatable defines if the mesh must be flagged as updatable
  94027. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  94028. * @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)
  94029. * @returns a new Mesh
  94030. */
  94031. 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;
  94032. /**
  94033. * Creates lathe mesh.
  94034. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  94035. * Please consider using the same method from the MeshBuilder class instead
  94036. * @param name defines the name of the mesh to create
  94037. * @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
  94038. * @param radius is the radius value of the lathe
  94039. * @param tessellation is the side number of the lathe.
  94040. * @param scene defines the hosting scene
  94041. * @param updatable defines if the mesh must be flagged as updatable
  94042. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  94043. * @returns a new Mesh
  94044. */
  94045. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  94046. /**
  94047. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  94048. * @param name defines the name of the mesh to create
  94049. * @param size sets the size (float) of both sides of the plane at once (default 1)
  94050. * @param scene defines the hosting scene
  94051. * @param updatable defines if the mesh must be flagged as updatable
  94052. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  94053. * @returns a new Mesh
  94054. */
  94055. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  94056. /**
  94057. * Creates a ground mesh.
  94058. * Please consider using the same method from the MeshBuilder class instead
  94059. * @param name defines the name of the mesh to create
  94060. * @param width set the width of the ground
  94061. * @param height set the height of the ground
  94062. * @param subdivisions sets the number of subdivisions per side
  94063. * @param scene defines the hosting scene
  94064. * @param updatable defines if the mesh must be flagged as updatable
  94065. * @returns a new Mesh
  94066. */
  94067. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  94068. /**
  94069. * Creates a tiled ground mesh.
  94070. * Please consider using the same method from the MeshBuilder class instead
  94071. * @param name defines the name of the mesh to create
  94072. * @param xmin set the ground minimum X coordinate
  94073. * @param zmin set the ground minimum Y coordinate
  94074. * @param xmax set the ground maximum X coordinate
  94075. * @param zmax set the ground maximum Z coordinate
  94076. * @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
  94077. * @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
  94078. * @param scene defines the hosting scene
  94079. * @param updatable defines if the mesh must be flagged as updatable
  94080. * @returns a new Mesh
  94081. */
  94082. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  94083. w: number;
  94084. h: number;
  94085. }, precision: {
  94086. w: number;
  94087. h: number;
  94088. }, scene: Scene, updatable?: boolean): Mesh;
  94089. /**
  94090. * Creates a ground mesh from a height map.
  94091. * Please consider using the same method from the MeshBuilder class instead
  94092. * @see http://doc.babylonjs.com/babylon101/height_map
  94093. * @param name defines the name of the mesh to create
  94094. * @param url sets the URL of the height map image resource
  94095. * @param width set the ground width size
  94096. * @param height set the ground height size
  94097. * @param subdivisions sets the number of subdivision per side
  94098. * @param minHeight is the minimum altitude on the ground
  94099. * @param maxHeight is the maximum altitude on the ground
  94100. * @param scene defines the hosting scene
  94101. * @param updatable defines if the mesh must be flagged as updatable
  94102. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  94103. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  94104. * @returns a new Mesh
  94105. */
  94106. 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;
  94107. /**
  94108. * Creates a tube mesh.
  94109. * The tube is a parametric shape.
  94110. * It has no predefined shape. Its final shape will depend on the input parameters.
  94111. * Please consider using the same method from the MeshBuilder class instead
  94112. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  94113. * @param name defines the name of the mesh to create
  94114. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  94115. * @param radius sets the tube radius size
  94116. * @param tessellation is the number of sides on the tubular surface
  94117. * @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
  94118. * @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
  94119. * @param scene defines the hosting scene
  94120. * @param updatable defines if the mesh must be flagged as updatable
  94121. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  94122. * @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)
  94123. * @returns a new Mesh
  94124. */
  94125. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  94126. (i: number, distance: number): number;
  94127. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  94128. /**
  94129. * Creates a polyhedron mesh.
  94130. * Please consider using the same method from the MeshBuilder class instead.
  94131. * * 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
  94132. * * The parameter `size` (positive float, default 1) sets the polygon size
  94133. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  94134. * * 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`
  94135. * * 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
  94136. * * 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)`)
  94137. * * 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
  94138. * * 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
  94139. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  94140. * * If you create a double-sided mesh, you can choose what parts of 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
  94141. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  94142. * @param name defines the name of the mesh to create
  94143. * @param options defines the options used to create the mesh
  94144. * @param scene defines the hosting scene
  94145. * @returns a new Mesh
  94146. */
  94147. static CreatePolyhedron(name: string, options: {
  94148. type?: number;
  94149. size?: number;
  94150. sizeX?: number;
  94151. sizeY?: number;
  94152. sizeZ?: number;
  94153. custom?: any;
  94154. faceUV?: Vector4[];
  94155. faceColors?: Color4[];
  94156. updatable?: boolean;
  94157. sideOrientation?: number;
  94158. }, scene: Scene): Mesh;
  94159. /**
  94160. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  94161. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  94162. * * 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`)
  94163. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  94164. * * 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
  94165. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  94166. * * If you create a double-sided mesh, you can choose what parts of 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
  94167. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  94168. * @param name defines the name of the mesh
  94169. * @param options defines the options used to create the mesh
  94170. * @param scene defines the hosting scene
  94171. * @returns a new Mesh
  94172. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  94173. */
  94174. static CreateIcoSphere(name: string, options: {
  94175. radius?: number;
  94176. flat?: boolean;
  94177. subdivisions?: number;
  94178. sideOrientation?: number;
  94179. updatable?: boolean;
  94180. }, scene: Scene): Mesh;
  94181. /**
  94182. * Creates a decal mesh.
  94183. * Please consider using the same method from the MeshBuilder class instead.
  94184. * A decal is a mesh usually applied as a model onto the surface of another mesh
  94185. * @param name defines the name of the mesh
  94186. * @param sourceMesh defines the mesh receiving the decal
  94187. * @param position sets the position of the decal in world coordinates
  94188. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  94189. * @param size sets the decal scaling
  94190. * @param angle sets the angle to rotate the decal
  94191. * @returns a new Mesh
  94192. */
  94193. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  94194. /**
  94195. * Prepare internal position array for software CPU skinning
  94196. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  94197. */
  94198. setPositionsForCPUSkinning(): Float32Array;
  94199. /**
  94200. * Prepare internal normal array for software CPU skinning
  94201. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  94202. */
  94203. setNormalsForCPUSkinning(): Float32Array;
  94204. /**
  94205. * Updates the vertex buffer by applying transformation from the bones
  94206. * @param skeleton defines the skeleton to apply to current mesh
  94207. * @returns the current mesh
  94208. */
  94209. applySkeleton(skeleton: Skeleton): Mesh;
  94210. /**
  94211. * 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
  94212. * @param meshes defines the list of meshes to scan
  94213. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  94214. */
  94215. static MinMax(meshes: AbstractMesh[]): {
  94216. min: Vector3;
  94217. max: Vector3;
  94218. };
  94219. /**
  94220. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  94221. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  94222. * @returns a vector3
  94223. */
  94224. static Center(meshesOrMinMaxVector: {
  94225. min: Vector3;
  94226. max: Vector3;
  94227. } | AbstractMesh[]): Vector3;
  94228. /**
  94229. * Merge the array of meshes into a single mesh for performance reasons.
  94230. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  94231. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  94232. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  94233. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  94234. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  94235. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  94236. * @returns a new mesh
  94237. */
  94238. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  94239. /** @hidden */
  94240. addInstance(instance: InstancedMesh): void;
  94241. /** @hidden */
  94242. removeInstance(instance: InstancedMesh): void;
  94243. }
  94244. }
  94245. declare module BABYLON {
  94246. /**
  94247. * This is the base class of all the camera used in the application.
  94248. * @see http://doc.babylonjs.com/features/cameras
  94249. */
  94250. export class Camera extends Node {
  94251. /** @hidden */
  94252. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  94253. /**
  94254. * This is the default projection mode used by the cameras.
  94255. * It helps recreating a feeling of perspective and better appreciate depth.
  94256. * This is the best way to simulate real life cameras.
  94257. */
  94258. static readonly PERSPECTIVE_CAMERA: number;
  94259. /**
  94260. * This helps creating camera with an orthographic mode.
  94261. * 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.
  94262. */
  94263. static readonly ORTHOGRAPHIC_CAMERA: number;
  94264. /**
  94265. * This is the default FOV mode for perspective cameras.
  94266. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  94267. */
  94268. static readonly FOVMODE_VERTICAL_FIXED: number;
  94269. /**
  94270. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  94271. */
  94272. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  94273. /**
  94274. * This specifies ther is no need for a camera rig.
  94275. * Basically only one eye is rendered corresponding to the camera.
  94276. */
  94277. static readonly RIG_MODE_NONE: number;
  94278. /**
  94279. * Simulates a camera Rig with one blue eye and one red eye.
  94280. * This can be use with 3d blue and red glasses.
  94281. */
  94282. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  94283. /**
  94284. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  94285. */
  94286. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  94287. /**
  94288. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  94289. */
  94290. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  94291. /**
  94292. * Defines that both eyes of the camera will be rendered over under each other.
  94293. */
  94294. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  94295. /**
  94296. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  94297. */
  94298. static readonly RIG_MODE_VR: number;
  94299. /**
  94300. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  94301. */
  94302. static readonly RIG_MODE_WEBVR: number;
  94303. /**
  94304. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  94305. */
  94306. static readonly RIG_MODE_CUSTOM: number;
  94307. /**
  94308. * Defines if by default attaching controls should prevent the default javascript event to continue.
  94309. */
  94310. static ForceAttachControlToAlwaysPreventDefault: boolean;
  94311. /**
  94312. * Define the input manager associated with the camera.
  94313. */
  94314. inputs: CameraInputsManager<Camera>;
  94315. /** @hidden */
  94316. _position: Vector3;
  94317. /**
  94318. * Define the current local position of the camera in the scene
  94319. */
  94320. position: Vector3;
  94321. /**
  94322. * The vector the camera should consider as up.
  94323. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  94324. */
  94325. upVector: Vector3;
  94326. /**
  94327. * Define the current limit on the left side for an orthographic camera
  94328. * In scene unit
  94329. */
  94330. orthoLeft: Nullable<number>;
  94331. /**
  94332. * Define the current limit on the right side for an orthographic camera
  94333. * In scene unit
  94334. */
  94335. orthoRight: Nullable<number>;
  94336. /**
  94337. * Define the current limit on the bottom side for an orthographic camera
  94338. * In scene unit
  94339. */
  94340. orthoBottom: Nullable<number>;
  94341. /**
  94342. * Define the current limit on the top side for an orthographic camera
  94343. * In scene unit
  94344. */
  94345. orthoTop: Nullable<number>;
  94346. /**
  94347. * Field Of View is set in Radians. (default is 0.8)
  94348. */
  94349. fov: number;
  94350. /**
  94351. * Define the minimum distance the camera can see from.
  94352. * This is important to note that the depth buffer are not infinite and the closer it starts
  94353. * the more your scene might encounter depth fighting issue.
  94354. */
  94355. minZ: number;
  94356. /**
  94357. * Define the maximum distance the camera can see to.
  94358. * This is important to note that the depth buffer are not infinite and the further it end
  94359. * the more your scene might encounter depth fighting issue.
  94360. */
  94361. maxZ: number;
  94362. /**
  94363. * Define the default inertia of the camera.
  94364. * This helps giving a smooth feeling to the camera movement.
  94365. */
  94366. inertia: number;
  94367. /**
  94368. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  94369. */
  94370. mode: number;
  94371. /**
  94372. * Define wether the camera is intermediate.
  94373. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  94374. */
  94375. isIntermediate: boolean;
  94376. /**
  94377. * Define the viewport of the camera.
  94378. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  94379. */
  94380. viewport: Viewport;
  94381. /**
  94382. * Restricts the camera to viewing objects with the same layerMask.
  94383. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  94384. */
  94385. layerMask: number;
  94386. /**
  94387. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  94388. */
  94389. fovMode: number;
  94390. /**
  94391. * Rig mode of the camera.
  94392. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  94393. * This is normally controlled byt the camera themselves as internal use.
  94394. */
  94395. cameraRigMode: number;
  94396. /**
  94397. * Defines the distance between both "eyes" in case of a RIG
  94398. */
  94399. interaxialDistance: number;
  94400. /**
  94401. * Defines if stereoscopic rendering is done side by side or over under.
  94402. */
  94403. isStereoscopicSideBySide: boolean;
  94404. /**
  94405. * 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
  94406. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  94407. * else in the scene. (Eg. security camera)
  94408. *
  94409. * To change the final output target of the camera, camera.outputRenderTarget should be used instead (eg. webXR renders to a render target corrisponding to an HMD)
  94410. */
  94411. customRenderTargets: RenderTargetTexture[];
  94412. /**
  94413. * When set, the camera will render to this render target instead of the default canvas
  94414. *
  94415. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  94416. */
  94417. outputRenderTarget: Nullable<RenderTargetTexture>;
  94418. /**
  94419. * Observable triggered when the camera view matrix has changed.
  94420. */
  94421. onViewMatrixChangedObservable: Observable<Camera>;
  94422. /**
  94423. * Observable triggered when the camera Projection matrix has changed.
  94424. */
  94425. onProjectionMatrixChangedObservable: Observable<Camera>;
  94426. /**
  94427. * Observable triggered when the inputs have been processed.
  94428. */
  94429. onAfterCheckInputsObservable: Observable<Camera>;
  94430. /**
  94431. * Observable triggered when reset has been called and applied to the camera.
  94432. */
  94433. onRestoreStateObservable: Observable<Camera>;
  94434. /** @hidden */
  94435. _cameraRigParams: any;
  94436. /** @hidden */
  94437. _rigCameras: Camera[];
  94438. /** @hidden */
  94439. _rigPostProcess: Nullable<PostProcess>;
  94440. protected _webvrViewMatrix: Matrix;
  94441. /** @hidden */
  94442. _skipRendering: boolean;
  94443. /** @hidden */
  94444. _projectionMatrix: Matrix;
  94445. /** @hidden */
  94446. _postProcesses: Nullable<PostProcess>[];
  94447. /** @hidden */
  94448. _activeMeshes: SmartArray<AbstractMesh>;
  94449. protected _globalPosition: Vector3;
  94450. /** @hidden */
  94451. _computedViewMatrix: Matrix;
  94452. private _doNotComputeProjectionMatrix;
  94453. private _transformMatrix;
  94454. private _frustumPlanes;
  94455. private _refreshFrustumPlanes;
  94456. private _storedFov;
  94457. private _stateStored;
  94458. /**
  94459. * Instantiates a new camera object.
  94460. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  94461. * @see http://doc.babylonjs.com/features/cameras
  94462. * @param name Defines the name of the camera in the scene
  94463. * @param position Defines the position of the camera
  94464. * @param scene Defines the scene the camera belongs too
  94465. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  94466. */
  94467. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  94468. /**
  94469. * Store current camera state (fov, position, etc..)
  94470. * @returns the camera
  94471. */
  94472. storeState(): Camera;
  94473. /**
  94474. * Restores the camera state values if it has been stored. You must call storeState() first
  94475. */
  94476. protected _restoreStateValues(): boolean;
  94477. /**
  94478. * Restored camera state. You must call storeState() first.
  94479. * @returns true if restored and false otherwise
  94480. */
  94481. restoreState(): boolean;
  94482. /**
  94483. * Gets the class name of the camera.
  94484. * @returns the class name
  94485. */
  94486. getClassName(): string;
  94487. /** @hidden */
  94488. readonly _isCamera: boolean;
  94489. /**
  94490. * Gets a string representation of the camera useful for debug purpose.
  94491. * @param fullDetails Defines that a more verboe level of logging is required
  94492. * @returns the string representation
  94493. */
  94494. toString(fullDetails?: boolean): string;
  94495. /**
  94496. * Gets the current world space position of the camera.
  94497. */
  94498. readonly globalPosition: Vector3;
  94499. /**
  94500. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  94501. * @returns the active meshe list
  94502. */
  94503. getActiveMeshes(): SmartArray<AbstractMesh>;
  94504. /**
  94505. * Check wether a mesh is part of the current active mesh list of the camera
  94506. * @param mesh Defines the mesh to check
  94507. * @returns true if active, false otherwise
  94508. */
  94509. isActiveMesh(mesh: Mesh): boolean;
  94510. /**
  94511. * Is this camera ready to be used/rendered
  94512. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  94513. * @return true if the camera is ready
  94514. */
  94515. isReady(completeCheck?: boolean): boolean;
  94516. /** @hidden */
  94517. _initCache(): void;
  94518. /** @hidden */
  94519. _updateCache(ignoreParentClass?: boolean): void;
  94520. /** @hidden */
  94521. _isSynchronized(): boolean;
  94522. /** @hidden */
  94523. _isSynchronizedViewMatrix(): boolean;
  94524. /** @hidden */
  94525. _isSynchronizedProjectionMatrix(): boolean;
  94526. /**
  94527. * Attach the input controls to a specific dom element to get the input from.
  94528. * @param element Defines the element the controls should be listened from
  94529. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94530. */
  94531. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94532. /**
  94533. * Detach the current controls from the specified dom element.
  94534. * @param element Defines the element to stop listening the inputs from
  94535. */
  94536. detachControl(element: HTMLElement): void;
  94537. /**
  94538. * Update the camera state according to the different inputs gathered during the frame.
  94539. */
  94540. update(): void;
  94541. /** @hidden */
  94542. _checkInputs(): void;
  94543. /** @hidden */
  94544. readonly rigCameras: Camera[];
  94545. /**
  94546. * Gets the post process used by the rig cameras
  94547. */
  94548. readonly rigPostProcess: Nullable<PostProcess>;
  94549. /**
  94550. * Internal, gets the first post proces.
  94551. * @returns the first post process to be run on this camera.
  94552. */
  94553. _getFirstPostProcess(): Nullable<PostProcess>;
  94554. private _cascadePostProcessesToRigCams;
  94555. /**
  94556. * Attach a post process to the camera.
  94557. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  94558. * @param postProcess The post process to attach to the camera
  94559. * @param insertAt The position of the post process in case several of them are in use in the scene
  94560. * @returns the position the post process has been inserted at
  94561. */
  94562. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  94563. /**
  94564. * Detach a post process to the camera.
  94565. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  94566. * @param postProcess The post process to detach from the camera
  94567. */
  94568. detachPostProcess(postProcess: PostProcess): void;
  94569. /**
  94570. * Gets the current world matrix of the camera
  94571. */
  94572. getWorldMatrix(): Matrix;
  94573. /** @hidden */
  94574. _getViewMatrix(): Matrix;
  94575. /**
  94576. * Gets the current view matrix of the camera.
  94577. * @param force forces the camera to recompute the matrix without looking at the cached state
  94578. * @returns the view matrix
  94579. */
  94580. getViewMatrix(force?: boolean): Matrix;
  94581. /**
  94582. * Freeze the projection matrix.
  94583. * It will prevent the cache check of the camera projection compute and can speed up perf
  94584. * if no parameter of the camera are meant to change
  94585. * @param projection Defines manually a projection if necessary
  94586. */
  94587. freezeProjectionMatrix(projection?: Matrix): void;
  94588. /**
  94589. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  94590. */
  94591. unfreezeProjectionMatrix(): void;
  94592. /**
  94593. * Gets the current projection matrix of the camera.
  94594. * @param force forces the camera to recompute the matrix without looking at the cached state
  94595. * @returns the projection matrix
  94596. */
  94597. getProjectionMatrix(force?: boolean): Matrix;
  94598. /**
  94599. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  94600. * @returns a Matrix
  94601. */
  94602. getTransformationMatrix(): Matrix;
  94603. private _updateFrustumPlanes;
  94604. /**
  94605. * Checks if a cullable object (mesh...) is in the camera frustum
  94606. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  94607. * @param target The object to check
  94608. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  94609. * @returns true if the object is in frustum otherwise false
  94610. */
  94611. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  94612. /**
  94613. * Checks if a cullable object (mesh...) is in the camera frustum
  94614. * Unlike isInFrustum this cheks the full bounding box
  94615. * @param target The object to check
  94616. * @returns true if the object is in frustum otherwise false
  94617. */
  94618. isCompletelyInFrustum(target: ICullable): boolean;
  94619. /**
  94620. * Gets a ray in the forward direction from the camera.
  94621. * @param length Defines the length of the ray to create
  94622. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  94623. * @param origin Defines the start point of the ray which defaults to the camera position
  94624. * @returns the forward ray
  94625. */
  94626. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  94627. /**
  94628. * Releases resources associated with this node.
  94629. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  94630. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  94631. */
  94632. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  94633. /** @hidden */
  94634. _isLeftCamera: boolean;
  94635. /**
  94636. * Gets the left camera of a rig setup in case of Rigged Camera
  94637. */
  94638. readonly isLeftCamera: boolean;
  94639. /** @hidden */
  94640. _isRightCamera: boolean;
  94641. /**
  94642. * Gets the right camera of a rig setup in case of Rigged Camera
  94643. */
  94644. readonly isRightCamera: boolean;
  94645. /**
  94646. * Gets the left camera of a rig setup in case of Rigged Camera
  94647. */
  94648. readonly leftCamera: Nullable<FreeCamera>;
  94649. /**
  94650. * Gets the right camera of a rig setup in case of Rigged Camera
  94651. */
  94652. readonly rightCamera: Nullable<FreeCamera>;
  94653. /**
  94654. * Gets the left camera target of a rig setup in case of Rigged Camera
  94655. * @returns the target position
  94656. */
  94657. getLeftTarget(): Nullable<Vector3>;
  94658. /**
  94659. * Gets the right camera target of a rig setup in case of Rigged Camera
  94660. * @returns the target position
  94661. */
  94662. getRightTarget(): Nullable<Vector3>;
  94663. /**
  94664. * @hidden
  94665. */
  94666. setCameraRigMode(mode: number, rigParams: any): void;
  94667. /** @hidden */
  94668. static _setStereoscopicRigMode(camera: Camera): void;
  94669. /** @hidden */
  94670. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  94671. /** @hidden */
  94672. static _setVRRigMode(camera: Camera, rigParams: any): void;
  94673. /** @hidden */
  94674. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  94675. /** @hidden */
  94676. _getVRProjectionMatrix(): Matrix;
  94677. protected _updateCameraRotationMatrix(): void;
  94678. protected _updateWebVRCameraRotationMatrix(): void;
  94679. /**
  94680. * This function MUST be overwritten by the different WebVR cameras available.
  94681. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  94682. * @hidden
  94683. */
  94684. _getWebVRProjectionMatrix(): Matrix;
  94685. /**
  94686. * This function MUST be overwritten by the different WebVR cameras available.
  94687. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  94688. * @hidden
  94689. */
  94690. _getWebVRViewMatrix(): Matrix;
  94691. /** @hidden */
  94692. setCameraRigParameter(name: string, value: any): void;
  94693. /**
  94694. * needs to be overridden by children so sub has required properties to be copied
  94695. * @hidden
  94696. */
  94697. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  94698. /**
  94699. * May need to be overridden by children
  94700. * @hidden
  94701. */
  94702. _updateRigCameras(): void;
  94703. /** @hidden */
  94704. _setupInputs(): void;
  94705. /**
  94706. * Serialiaze the camera setup to a json represention
  94707. * @returns the JSON representation
  94708. */
  94709. serialize(): any;
  94710. /**
  94711. * Clones the current camera.
  94712. * @param name The cloned camera name
  94713. * @returns the cloned camera
  94714. */
  94715. clone(name: string): Camera;
  94716. /**
  94717. * Gets the direction of the camera relative to a given local axis.
  94718. * @param localAxis Defines the reference axis to provide a relative direction.
  94719. * @return the direction
  94720. */
  94721. getDirection(localAxis: Vector3): Vector3;
  94722. /**
  94723. * Returns the current camera absolute rotation
  94724. */
  94725. readonly absoluteRotation: Quaternion;
  94726. /**
  94727. * Gets the direction of the camera relative to a given local axis into a passed vector.
  94728. * @param localAxis Defines the reference axis to provide a relative direction.
  94729. * @param result Defines the vector to store the result in
  94730. */
  94731. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  94732. /**
  94733. * Gets a camera constructor for a given camera type
  94734. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  94735. * @param name The name of the camera the result will be able to instantiate
  94736. * @param scene The scene the result will construct the camera in
  94737. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  94738. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  94739. * @returns a factory method to construc the camera
  94740. */
  94741. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  94742. /**
  94743. * Compute the world matrix of the camera.
  94744. * @returns the camera world matrix
  94745. */
  94746. computeWorldMatrix(): Matrix;
  94747. /**
  94748. * Parse a JSON and creates the camera from the parsed information
  94749. * @param parsedCamera The JSON to parse
  94750. * @param scene The scene to instantiate the camera in
  94751. * @returns the newly constructed camera
  94752. */
  94753. static Parse(parsedCamera: any, scene: Scene): Camera;
  94754. }
  94755. }
  94756. declare module BABYLON {
  94757. /**
  94758. * Class containing static functions to help procedurally build meshes
  94759. */
  94760. export class DiscBuilder {
  94761. /**
  94762. * Creates a plane polygonal mesh. By default, this is a disc
  94763. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  94764. * * 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
  94765. * * 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
  94766. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  94767. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  94768. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  94769. * @param name defines the name of the mesh
  94770. * @param options defines the options used to create the mesh
  94771. * @param scene defines the hosting scene
  94772. * @returns the plane polygonal mesh
  94773. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  94774. */
  94775. static CreateDisc(name: string, options: {
  94776. radius?: number;
  94777. tessellation?: number;
  94778. arc?: number;
  94779. updatable?: boolean;
  94780. sideOrientation?: number;
  94781. frontUVs?: Vector4;
  94782. backUVs?: Vector4;
  94783. }, scene?: Nullable<Scene>): Mesh;
  94784. }
  94785. }
  94786. declare module BABYLON {
  94787. /**
  94788. * This represents all the required information to add a fresnel effect on a material:
  94789. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  94790. */
  94791. export class FresnelParameters {
  94792. private _isEnabled;
  94793. /**
  94794. * Define if the fresnel effect is enable or not.
  94795. */
  94796. isEnabled: boolean;
  94797. /**
  94798. * Define the color used on edges (grazing angle)
  94799. */
  94800. leftColor: Color3;
  94801. /**
  94802. * Define the color used on center
  94803. */
  94804. rightColor: Color3;
  94805. /**
  94806. * Define bias applied to computed fresnel term
  94807. */
  94808. bias: number;
  94809. /**
  94810. * Defined the power exponent applied to fresnel term
  94811. */
  94812. power: number;
  94813. /**
  94814. * Clones the current fresnel and its valuues
  94815. * @returns a clone fresnel configuration
  94816. */
  94817. clone(): FresnelParameters;
  94818. /**
  94819. * Serializes the current fresnel parameters to a JSON representation.
  94820. * @return the JSON serialization
  94821. */
  94822. serialize(): any;
  94823. /**
  94824. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  94825. * @param parsedFresnelParameters Define the JSON representation
  94826. * @returns the parsed parameters
  94827. */
  94828. static Parse(parsedFresnelParameters: any): FresnelParameters;
  94829. }
  94830. }
  94831. declare module BABYLON {
  94832. /**
  94833. * Base class of materials working in push mode in babylon JS
  94834. * @hidden
  94835. */
  94836. export class PushMaterial extends Material {
  94837. protected _activeEffect: Effect;
  94838. protected _normalMatrix: Matrix;
  94839. /**
  94840. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  94841. * This means that the material can keep using a previous shader while a new one is being compiled.
  94842. * This is mostly used when shader parallel compilation is supported (true by default)
  94843. */
  94844. allowShaderHotSwapping: boolean;
  94845. constructor(name: string, scene: Scene);
  94846. getEffect(): Effect;
  94847. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  94848. /**
  94849. * Binds the given world matrix to the active effect
  94850. *
  94851. * @param world the matrix to bind
  94852. */
  94853. bindOnlyWorldMatrix(world: Matrix): void;
  94854. /**
  94855. * Binds the given normal matrix to the active effect
  94856. *
  94857. * @param normalMatrix the matrix to bind
  94858. */
  94859. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  94860. bind(world: Matrix, mesh?: Mesh): void;
  94861. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  94862. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  94863. }
  94864. }
  94865. declare module BABYLON {
  94866. /**
  94867. * This groups all the flags used to control the materials channel.
  94868. */
  94869. export class MaterialFlags {
  94870. private static _DiffuseTextureEnabled;
  94871. /**
  94872. * Are diffuse textures enabled in the application.
  94873. */
  94874. static DiffuseTextureEnabled: boolean;
  94875. private static _AmbientTextureEnabled;
  94876. /**
  94877. * Are ambient textures enabled in the application.
  94878. */
  94879. static AmbientTextureEnabled: boolean;
  94880. private static _OpacityTextureEnabled;
  94881. /**
  94882. * Are opacity textures enabled in the application.
  94883. */
  94884. static OpacityTextureEnabled: boolean;
  94885. private static _ReflectionTextureEnabled;
  94886. /**
  94887. * Are reflection textures enabled in the application.
  94888. */
  94889. static ReflectionTextureEnabled: boolean;
  94890. private static _EmissiveTextureEnabled;
  94891. /**
  94892. * Are emissive textures enabled in the application.
  94893. */
  94894. static EmissiveTextureEnabled: boolean;
  94895. private static _SpecularTextureEnabled;
  94896. /**
  94897. * Are specular textures enabled in the application.
  94898. */
  94899. static SpecularTextureEnabled: boolean;
  94900. private static _BumpTextureEnabled;
  94901. /**
  94902. * Are bump textures enabled in the application.
  94903. */
  94904. static BumpTextureEnabled: boolean;
  94905. private static _LightmapTextureEnabled;
  94906. /**
  94907. * Are lightmap textures enabled in the application.
  94908. */
  94909. static LightmapTextureEnabled: boolean;
  94910. private static _RefractionTextureEnabled;
  94911. /**
  94912. * Are refraction textures enabled in the application.
  94913. */
  94914. static RefractionTextureEnabled: boolean;
  94915. private static _ColorGradingTextureEnabled;
  94916. /**
  94917. * Are color grading textures enabled in the application.
  94918. */
  94919. static ColorGradingTextureEnabled: boolean;
  94920. private static _FresnelEnabled;
  94921. /**
  94922. * Are fresnels enabled in the application.
  94923. */
  94924. static FresnelEnabled: boolean;
  94925. private static _ClearCoatTextureEnabled;
  94926. /**
  94927. * Are clear coat textures enabled in the application.
  94928. */
  94929. static ClearCoatTextureEnabled: boolean;
  94930. private static _ClearCoatBumpTextureEnabled;
  94931. /**
  94932. * Are clear coat bump textures enabled in the application.
  94933. */
  94934. static ClearCoatBumpTextureEnabled: boolean;
  94935. private static _ClearCoatTintTextureEnabled;
  94936. /**
  94937. * Are clear coat tint textures enabled in the application.
  94938. */
  94939. static ClearCoatTintTextureEnabled: boolean;
  94940. private static _SheenTextureEnabled;
  94941. /**
  94942. * Are sheen textures enabled in the application.
  94943. */
  94944. static SheenTextureEnabled: boolean;
  94945. private static _AnisotropicTextureEnabled;
  94946. /**
  94947. * Are anisotropic textures enabled in the application.
  94948. */
  94949. static AnisotropicTextureEnabled: boolean;
  94950. private static _ThicknessTextureEnabled;
  94951. /**
  94952. * Are thickness textures enabled in the application.
  94953. */
  94954. static ThicknessTextureEnabled: boolean;
  94955. }
  94956. }
  94957. declare module BABYLON {
  94958. /** @hidden */
  94959. export var defaultFragmentDeclaration: {
  94960. name: string;
  94961. shader: string;
  94962. };
  94963. }
  94964. declare module BABYLON {
  94965. /** @hidden */
  94966. export var defaultUboDeclaration: {
  94967. name: string;
  94968. shader: string;
  94969. };
  94970. }
  94971. declare module BABYLON {
  94972. /** @hidden */
  94973. export var lightFragmentDeclaration: {
  94974. name: string;
  94975. shader: string;
  94976. };
  94977. }
  94978. declare module BABYLON {
  94979. /** @hidden */
  94980. export var lightUboDeclaration: {
  94981. name: string;
  94982. shader: string;
  94983. };
  94984. }
  94985. declare module BABYLON {
  94986. /** @hidden */
  94987. export var lightsFragmentFunctions: {
  94988. name: string;
  94989. shader: string;
  94990. };
  94991. }
  94992. declare module BABYLON {
  94993. /** @hidden */
  94994. export var shadowsFragmentFunctions: {
  94995. name: string;
  94996. shader: string;
  94997. };
  94998. }
  94999. declare module BABYLON {
  95000. /** @hidden */
  95001. export var fresnelFunction: {
  95002. name: string;
  95003. shader: string;
  95004. };
  95005. }
  95006. declare module BABYLON {
  95007. /** @hidden */
  95008. export var reflectionFunction: {
  95009. name: string;
  95010. shader: string;
  95011. };
  95012. }
  95013. declare module BABYLON {
  95014. /** @hidden */
  95015. export var bumpFragmentFunctions: {
  95016. name: string;
  95017. shader: string;
  95018. };
  95019. }
  95020. declare module BABYLON {
  95021. /** @hidden */
  95022. export var logDepthDeclaration: {
  95023. name: string;
  95024. shader: string;
  95025. };
  95026. }
  95027. declare module BABYLON {
  95028. /** @hidden */
  95029. export var bumpFragment: {
  95030. name: string;
  95031. shader: string;
  95032. };
  95033. }
  95034. declare module BABYLON {
  95035. /** @hidden */
  95036. export var depthPrePass: {
  95037. name: string;
  95038. shader: string;
  95039. };
  95040. }
  95041. declare module BABYLON {
  95042. /** @hidden */
  95043. export var lightFragment: {
  95044. name: string;
  95045. shader: string;
  95046. };
  95047. }
  95048. declare module BABYLON {
  95049. /** @hidden */
  95050. export var logDepthFragment: {
  95051. name: string;
  95052. shader: string;
  95053. };
  95054. }
  95055. declare module BABYLON {
  95056. /** @hidden */
  95057. export var defaultPixelShader: {
  95058. name: string;
  95059. shader: string;
  95060. };
  95061. }
  95062. declare module BABYLON {
  95063. /** @hidden */
  95064. export var defaultVertexDeclaration: {
  95065. name: string;
  95066. shader: string;
  95067. };
  95068. }
  95069. declare module BABYLON {
  95070. /** @hidden */
  95071. export var bumpVertexDeclaration: {
  95072. name: string;
  95073. shader: string;
  95074. };
  95075. }
  95076. declare module BABYLON {
  95077. /** @hidden */
  95078. export var bumpVertex: {
  95079. name: string;
  95080. shader: string;
  95081. };
  95082. }
  95083. declare module BABYLON {
  95084. /** @hidden */
  95085. export var fogVertex: {
  95086. name: string;
  95087. shader: string;
  95088. };
  95089. }
  95090. declare module BABYLON {
  95091. /** @hidden */
  95092. export var shadowsVertex: {
  95093. name: string;
  95094. shader: string;
  95095. };
  95096. }
  95097. declare module BABYLON {
  95098. /** @hidden */
  95099. export var pointCloudVertex: {
  95100. name: string;
  95101. shader: string;
  95102. };
  95103. }
  95104. declare module BABYLON {
  95105. /** @hidden */
  95106. export var logDepthVertex: {
  95107. name: string;
  95108. shader: string;
  95109. };
  95110. }
  95111. declare module BABYLON {
  95112. /** @hidden */
  95113. export var defaultVertexShader: {
  95114. name: string;
  95115. shader: string;
  95116. };
  95117. }
  95118. declare module BABYLON {
  95119. /** @hidden */
  95120. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  95121. MAINUV1: boolean;
  95122. MAINUV2: boolean;
  95123. DIFFUSE: boolean;
  95124. DIFFUSEDIRECTUV: number;
  95125. AMBIENT: boolean;
  95126. AMBIENTDIRECTUV: number;
  95127. OPACITY: boolean;
  95128. OPACITYDIRECTUV: number;
  95129. OPACITYRGB: boolean;
  95130. REFLECTION: boolean;
  95131. EMISSIVE: boolean;
  95132. EMISSIVEDIRECTUV: number;
  95133. SPECULAR: boolean;
  95134. SPECULARDIRECTUV: number;
  95135. BUMP: boolean;
  95136. BUMPDIRECTUV: number;
  95137. PARALLAX: boolean;
  95138. PARALLAXOCCLUSION: boolean;
  95139. SPECULAROVERALPHA: boolean;
  95140. CLIPPLANE: boolean;
  95141. CLIPPLANE2: boolean;
  95142. CLIPPLANE3: boolean;
  95143. CLIPPLANE4: boolean;
  95144. ALPHATEST: boolean;
  95145. DEPTHPREPASS: boolean;
  95146. ALPHAFROMDIFFUSE: boolean;
  95147. POINTSIZE: boolean;
  95148. FOG: boolean;
  95149. SPECULARTERM: boolean;
  95150. DIFFUSEFRESNEL: boolean;
  95151. OPACITYFRESNEL: boolean;
  95152. REFLECTIONFRESNEL: boolean;
  95153. REFRACTIONFRESNEL: boolean;
  95154. EMISSIVEFRESNEL: boolean;
  95155. FRESNEL: boolean;
  95156. NORMAL: boolean;
  95157. UV1: boolean;
  95158. UV2: boolean;
  95159. VERTEXCOLOR: boolean;
  95160. VERTEXALPHA: boolean;
  95161. NUM_BONE_INFLUENCERS: number;
  95162. BonesPerMesh: number;
  95163. BONETEXTURE: boolean;
  95164. INSTANCES: boolean;
  95165. GLOSSINESS: boolean;
  95166. ROUGHNESS: boolean;
  95167. EMISSIVEASILLUMINATION: boolean;
  95168. LINKEMISSIVEWITHDIFFUSE: boolean;
  95169. REFLECTIONFRESNELFROMSPECULAR: boolean;
  95170. LIGHTMAP: boolean;
  95171. LIGHTMAPDIRECTUV: number;
  95172. OBJECTSPACE_NORMALMAP: boolean;
  95173. USELIGHTMAPASSHADOWMAP: boolean;
  95174. REFLECTIONMAP_3D: boolean;
  95175. REFLECTIONMAP_SPHERICAL: boolean;
  95176. REFLECTIONMAP_PLANAR: boolean;
  95177. REFLECTIONMAP_CUBIC: boolean;
  95178. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  95179. REFLECTIONMAP_PROJECTION: boolean;
  95180. REFLECTIONMAP_SKYBOX: boolean;
  95181. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  95182. REFLECTIONMAP_EXPLICIT: boolean;
  95183. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  95184. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  95185. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  95186. INVERTCUBICMAP: boolean;
  95187. LOGARITHMICDEPTH: boolean;
  95188. REFRACTION: boolean;
  95189. REFRACTIONMAP_3D: boolean;
  95190. REFLECTIONOVERALPHA: boolean;
  95191. TWOSIDEDLIGHTING: boolean;
  95192. SHADOWFLOAT: boolean;
  95193. MORPHTARGETS: boolean;
  95194. MORPHTARGETS_NORMAL: boolean;
  95195. MORPHTARGETS_TANGENT: boolean;
  95196. MORPHTARGETS_UV: boolean;
  95197. NUM_MORPH_INFLUENCERS: number;
  95198. NONUNIFORMSCALING: boolean;
  95199. PREMULTIPLYALPHA: boolean;
  95200. IMAGEPROCESSING: boolean;
  95201. VIGNETTE: boolean;
  95202. VIGNETTEBLENDMODEMULTIPLY: boolean;
  95203. VIGNETTEBLENDMODEOPAQUE: boolean;
  95204. TONEMAPPING: boolean;
  95205. TONEMAPPING_ACES: boolean;
  95206. CONTRAST: boolean;
  95207. COLORCURVES: boolean;
  95208. COLORGRADING: boolean;
  95209. COLORGRADING3D: boolean;
  95210. SAMPLER3DGREENDEPTH: boolean;
  95211. SAMPLER3DBGRMAP: boolean;
  95212. IMAGEPROCESSINGPOSTPROCESS: boolean;
  95213. MULTIVIEW: boolean;
  95214. /**
  95215. * If the reflection texture on this material is in linear color space
  95216. * @hidden
  95217. */
  95218. IS_REFLECTION_LINEAR: boolean;
  95219. /**
  95220. * If the refraction texture on this material is in linear color space
  95221. * @hidden
  95222. */
  95223. IS_REFRACTION_LINEAR: boolean;
  95224. EXPOSURE: boolean;
  95225. constructor();
  95226. setReflectionMode(modeToEnable: string): void;
  95227. }
  95228. /**
  95229. * This is the default material used in Babylon. It is the best trade off between quality
  95230. * and performances.
  95231. * @see http://doc.babylonjs.com/babylon101/materials
  95232. */
  95233. export class StandardMaterial extends PushMaterial {
  95234. private _diffuseTexture;
  95235. /**
  95236. * The basic texture of the material as viewed under a light.
  95237. */
  95238. diffuseTexture: Nullable<BaseTexture>;
  95239. private _ambientTexture;
  95240. /**
  95241. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  95242. */
  95243. ambientTexture: Nullable<BaseTexture>;
  95244. private _opacityTexture;
  95245. /**
  95246. * Define the transparency of the material from a texture.
  95247. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  95248. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  95249. */
  95250. opacityTexture: Nullable<BaseTexture>;
  95251. private _reflectionTexture;
  95252. /**
  95253. * Define the texture used to display the reflection.
  95254. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95255. */
  95256. reflectionTexture: Nullable<BaseTexture>;
  95257. private _emissiveTexture;
  95258. /**
  95259. * Define texture of the material as if self lit.
  95260. * This will be mixed in the final result even in the absence of light.
  95261. */
  95262. emissiveTexture: Nullable<BaseTexture>;
  95263. private _specularTexture;
  95264. /**
  95265. * Define how the color and intensity of the highlight given by the light in the material.
  95266. */
  95267. specularTexture: Nullable<BaseTexture>;
  95268. private _bumpTexture;
  95269. /**
  95270. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  95271. * 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.
  95272. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  95273. */
  95274. bumpTexture: Nullable<BaseTexture>;
  95275. private _lightmapTexture;
  95276. /**
  95277. * Complex lighting can be computationally expensive to compute at runtime.
  95278. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  95279. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  95280. */
  95281. lightmapTexture: Nullable<BaseTexture>;
  95282. private _refractionTexture;
  95283. /**
  95284. * Define the texture used to display the refraction.
  95285. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95286. */
  95287. refractionTexture: Nullable<BaseTexture>;
  95288. /**
  95289. * The color of the material lit by the environmental background lighting.
  95290. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  95291. */
  95292. ambientColor: Color3;
  95293. /**
  95294. * The basic color of the material as viewed under a light.
  95295. */
  95296. diffuseColor: Color3;
  95297. /**
  95298. * Define how the color and intensity of the highlight given by the light in the material.
  95299. */
  95300. specularColor: Color3;
  95301. /**
  95302. * Define the color of the material as if self lit.
  95303. * This will be mixed in the final result even in the absence of light.
  95304. */
  95305. emissiveColor: Color3;
  95306. /**
  95307. * Defines how sharp are the highlights in the material.
  95308. * The bigger the value the sharper giving a more glossy feeling to the result.
  95309. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  95310. */
  95311. specularPower: number;
  95312. private _useAlphaFromDiffuseTexture;
  95313. /**
  95314. * Does the transparency come from the diffuse texture alpha channel.
  95315. */
  95316. useAlphaFromDiffuseTexture: boolean;
  95317. private _useEmissiveAsIllumination;
  95318. /**
  95319. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  95320. */
  95321. useEmissiveAsIllumination: boolean;
  95322. private _linkEmissiveWithDiffuse;
  95323. /**
  95324. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  95325. * the emissive level when the final color is close to one.
  95326. */
  95327. linkEmissiveWithDiffuse: boolean;
  95328. private _useSpecularOverAlpha;
  95329. /**
  95330. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  95331. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  95332. */
  95333. useSpecularOverAlpha: boolean;
  95334. private _useReflectionOverAlpha;
  95335. /**
  95336. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  95337. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  95338. */
  95339. useReflectionOverAlpha: boolean;
  95340. private _disableLighting;
  95341. /**
  95342. * Does lights from the scene impacts this material.
  95343. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  95344. */
  95345. disableLighting: boolean;
  95346. private _useObjectSpaceNormalMap;
  95347. /**
  95348. * Allows using an object space normal map (instead of tangent space).
  95349. */
  95350. useObjectSpaceNormalMap: boolean;
  95351. private _useParallax;
  95352. /**
  95353. * Is parallax enabled or not.
  95354. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  95355. */
  95356. useParallax: boolean;
  95357. private _useParallaxOcclusion;
  95358. /**
  95359. * Is parallax occlusion enabled or not.
  95360. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  95361. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  95362. */
  95363. useParallaxOcclusion: boolean;
  95364. /**
  95365. * 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.
  95366. */
  95367. parallaxScaleBias: number;
  95368. private _roughness;
  95369. /**
  95370. * Helps to define how blurry the reflections should appears in the material.
  95371. */
  95372. roughness: number;
  95373. /**
  95374. * In case of refraction, define the value of the index of refraction.
  95375. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95376. */
  95377. indexOfRefraction: number;
  95378. /**
  95379. * Invert the refraction texture alongside the y axis.
  95380. * It can be useful with procedural textures or probe for instance.
  95381. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95382. */
  95383. invertRefractionY: boolean;
  95384. /**
  95385. * Defines the alpha limits in alpha test mode.
  95386. */
  95387. alphaCutOff: number;
  95388. private _useLightmapAsShadowmap;
  95389. /**
  95390. * In case of light mapping, define whether the map contains light or shadow informations.
  95391. */
  95392. useLightmapAsShadowmap: boolean;
  95393. private _diffuseFresnelParameters;
  95394. /**
  95395. * Define the diffuse fresnel parameters of the material.
  95396. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95397. */
  95398. diffuseFresnelParameters: FresnelParameters;
  95399. private _opacityFresnelParameters;
  95400. /**
  95401. * Define the opacity fresnel parameters of the material.
  95402. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95403. */
  95404. opacityFresnelParameters: FresnelParameters;
  95405. private _reflectionFresnelParameters;
  95406. /**
  95407. * Define the reflection fresnel parameters of the material.
  95408. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95409. */
  95410. reflectionFresnelParameters: FresnelParameters;
  95411. private _refractionFresnelParameters;
  95412. /**
  95413. * Define the refraction fresnel parameters of the material.
  95414. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95415. */
  95416. refractionFresnelParameters: FresnelParameters;
  95417. private _emissiveFresnelParameters;
  95418. /**
  95419. * Define the emissive fresnel parameters of the material.
  95420. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95421. */
  95422. emissiveFresnelParameters: FresnelParameters;
  95423. private _useReflectionFresnelFromSpecular;
  95424. /**
  95425. * If true automatically deducts the fresnels values from the material specularity.
  95426. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95427. */
  95428. useReflectionFresnelFromSpecular: boolean;
  95429. private _useGlossinessFromSpecularMapAlpha;
  95430. /**
  95431. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  95432. */
  95433. useGlossinessFromSpecularMapAlpha: boolean;
  95434. private _maxSimultaneousLights;
  95435. /**
  95436. * Defines the maximum number of lights that can be used in the material
  95437. */
  95438. maxSimultaneousLights: number;
  95439. private _invertNormalMapX;
  95440. /**
  95441. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  95442. */
  95443. invertNormalMapX: boolean;
  95444. private _invertNormalMapY;
  95445. /**
  95446. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  95447. */
  95448. invertNormalMapY: boolean;
  95449. private _twoSidedLighting;
  95450. /**
  95451. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  95452. */
  95453. twoSidedLighting: boolean;
  95454. /**
  95455. * Default configuration related to image processing available in the standard Material.
  95456. */
  95457. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  95458. /**
  95459. * Gets the image processing configuration used either in this material.
  95460. */
  95461. /**
  95462. * Sets the Default image processing configuration used either in the this material.
  95463. *
  95464. * If sets to null, the scene one is in use.
  95465. */
  95466. imageProcessingConfiguration: ImageProcessingConfiguration;
  95467. /**
  95468. * Keep track of the image processing observer to allow dispose and replace.
  95469. */
  95470. private _imageProcessingObserver;
  95471. /**
  95472. * Attaches a new image processing configuration to the Standard Material.
  95473. * @param configuration
  95474. */
  95475. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  95476. /**
  95477. * Gets wether the color curves effect is enabled.
  95478. */
  95479. /**
  95480. * Sets wether the color curves effect is enabled.
  95481. */
  95482. cameraColorCurvesEnabled: boolean;
  95483. /**
  95484. * Gets wether the color grading effect is enabled.
  95485. */
  95486. /**
  95487. * Gets wether the color grading effect is enabled.
  95488. */
  95489. cameraColorGradingEnabled: boolean;
  95490. /**
  95491. * Gets wether tonemapping is enabled or not.
  95492. */
  95493. /**
  95494. * Sets wether tonemapping is enabled or not
  95495. */
  95496. cameraToneMappingEnabled: boolean;
  95497. /**
  95498. * The camera exposure used on this material.
  95499. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  95500. * This corresponds to a photographic exposure.
  95501. */
  95502. /**
  95503. * The camera exposure used on this material.
  95504. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  95505. * This corresponds to a photographic exposure.
  95506. */
  95507. cameraExposure: number;
  95508. /**
  95509. * Gets The camera contrast used on this material.
  95510. */
  95511. /**
  95512. * Sets The camera contrast used on this material.
  95513. */
  95514. cameraContrast: number;
  95515. /**
  95516. * Gets the Color Grading 2D Lookup Texture.
  95517. */
  95518. /**
  95519. * Sets the Color Grading 2D Lookup Texture.
  95520. */
  95521. cameraColorGradingTexture: Nullable<BaseTexture>;
  95522. /**
  95523. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  95524. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  95525. * 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;
  95526. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  95527. */
  95528. /**
  95529. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  95530. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  95531. * 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;
  95532. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  95533. */
  95534. cameraColorCurves: Nullable<ColorCurves>;
  95535. /**
  95536. * Custom callback helping to override the default shader used in the material.
  95537. */
  95538. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  95539. protected _renderTargets: SmartArray<RenderTargetTexture>;
  95540. protected _worldViewProjectionMatrix: Matrix;
  95541. protected _globalAmbientColor: Color3;
  95542. protected _useLogarithmicDepth: boolean;
  95543. protected _rebuildInParallel: boolean;
  95544. /**
  95545. * Instantiates a new standard material.
  95546. * This is the default material used in Babylon. It is the best trade off between quality
  95547. * and performances.
  95548. * @see http://doc.babylonjs.com/babylon101/materials
  95549. * @param name Define the name of the material in the scene
  95550. * @param scene Define the scene the material belong to
  95551. */
  95552. constructor(name: string, scene: Scene);
  95553. /**
  95554. * Gets a boolean indicating that current material needs to register RTT
  95555. */
  95556. readonly hasRenderTargetTextures: boolean;
  95557. /**
  95558. * Gets the current class name of the material e.g. "StandardMaterial"
  95559. * Mainly use in serialization.
  95560. * @returns the class name
  95561. */
  95562. getClassName(): string;
  95563. /**
  95564. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  95565. * You can try switching to logarithmic depth.
  95566. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  95567. */
  95568. useLogarithmicDepth: boolean;
  95569. /**
  95570. * Specifies if the material will require alpha blending
  95571. * @returns a boolean specifying if alpha blending is needed
  95572. */
  95573. needAlphaBlending(): boolean;
  95574. /**
  95575. * Specifies if this material should be rendered in alpha test mode
  95576. * @returns a boolean specifying if an alpha test is needed.
  95577. */
  95578. needAlphaTesting(): boolean;
  95579. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  95580. /**
  95581. * Get the texture used for alpha test purpose.
  95582. * @returns the diffuse texture in case of the standard material.
  95583. */
  95584. getAlphaTestTexture(): Nullable<BaseTexture>;
  95585. /**
  95586. * Get if the submesh is ready to be used and all its information available.
  95587. * Child classes can use it to update shaders
  95588. * @param mesh defines the mesh to check
  95589. * @param subMesh defines which submesh to check
  95590. * @param useInstances specifies that instances should be used
  95591. * @returns a boolean indicating that the submesh is ready or not
  95592. */
  95593. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  95594. /**
  95595. * Builds the material UBO layouts.
  95596. * Used internally during the effect preparation.
  95597. */
  95598. buildUniformLayout(): void;
  95599. /**
  95600. * Unbinds the material from the mesh
  95601. */
  95602. unbind(): void;
  95603. /**
  95604. * Binds the submesh to this material by preparing the effect and shader to draw
  95605. * @param world defines the world transformation matrix
  95606. * @param mesh defines the mesh containing the submesh
  95607. * @param subMesh defines the submesh to bind the material to
  95608. */
  95609. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  95610. /**
  95611. * Get the list of animatables in the material.
  95612. * @returns the list of animatables object used in the material
  95613. */
  95614. getAnimatables(): IAnimatable[];
  95615. /**
  95616. * Gets the active textures from the material
  95617. * @returns an array of textures
  95618. */
  95619. getActiveTextures(): BaseTexture[];
  95620. /**
  95621. * Specifies if the material uses a texture
  95622. * @param texture defines the texture to check against the material
  95623. * @returns a boolean specifying if the material uses the texture
  95624. */
  95625. hasTexture(texture: BaseTexture): boolean;
  95626. /**
  95627. * Disposes the material
  95628. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  95629. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  95630. */
  95631. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  95632. /**
  95633. * Makes a duplicate of the material, and gives it a new name
  95634. * @param name defines the new name for the duplicated material
  95635. * @returns the cloned material
  95636. */
  95637. clone(name: string): StandardMaterial;
  95638. /**
  95639. * Serializes this material in a JSON representation
  95640. * @returns the serialized material object
  95641. */
  95642. serialize(): any;
  95643. /**
  95644. * Creates a standard material from parsed material data
  95645. * @param source defines the JSON representation of the material
  95646. * @param scene defines the hosting scene
  95647. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  95648. * @returns a new standard material
  95649. */
  95650. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  95651. /**
  95652. * Are diffuse textures enabled in the application.
  95653. */
  95654. static DiffuseTextureEnabled: boolean;
  95655. /**
  95656. * Are ambient textures enabled in the application.
  95657. */
  95658. static AmbientTextureEnabled: boolean;
  95659. /**
  95660. * Are opacity textures enabled in the application.
  95661. */
  95662. static OpacityTextureEnabled: boolean;
  95663. /**
  95664. * Are reflection textures enabled in the application.
  95665. */
  95666. static ReflectionTextureEnabled: boolean;
  95667. /**
  95668. * Are emissive textures enabled in the application.
  95669. */
  95670. static EmissiveTextureEnabled: boolean;
  95671. /**
  95672. * Are specular textures enabled in the application.
  95673. */
  95674. static SpecularTextureEnabled: boolean;
  95675. /**
  95676. * Are bump textures enabled in the application.
  95677. */
  95678. static BumpTextureEnabled: boolean;
  95679. /**
  95680. * Are lightmap textures enabled in the application.
  95681. */
  95682. static LightmapTextureEnabled: boolean;
  95683. /**
  95684. * Are refraction textures enabled in the application.
  95685. */
  95686. static RefractionTextureEnabled: boolean;
  95687. /**
  95688. * Are color grading textures enabled in the application.
  95689. */
  95690. static ColorGradingTextureEnabled: boolean;
  95691. /**
  95692. * Are fresnels enabled in the application.
  95693. */
  95694. static FresnelEnabled: boolean;
  95695. }
  95696. }
  95697. declare module BABYLON {
  95698. /**
  95699. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  95700. *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.
  95701. * The SPS is also a particle system. It provides some methods to manage the particles.
  95702. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  95703. *
  95704. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  95705. */
  95706. export class SolidParticleSystem implements IDisposable {
  95707. /**
  95708. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  95709. * Example : var p = SPS.particles[i];
  95710. */
  95711. particles: SolidParticle[];
  95712. /**
  95713. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  95714. */
  95715. nbParticles: number;
  95716. /**
  95717. * If the particles must ever face the camera (default false). Useful for planar particles.
  95718. */
  95719. billboard: boolean;
  95720. /**
  95721. * Recompute normals when adding a shape
  95722. */
  95723. recomputeNormals: boolean;
  95724. /**
  95725. * This a counter ofr your own usage. It's not set by any SPS functions.
  95726. */
  95727. counter: number;
  95728. /**
  95729. * The SPS name. This name is also given to the underlying mesh.
  95730. */
  95731. name: string;
  95732. /**
  95733. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  95734. */
  95735. mesh: Mesh;
  95736. /**
  95737. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  95738. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  95739. */
  95740. vars: any;
  95741. /**
  95742. * This array is populated when the SPS is set as 'pickable'.
  95743. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  95744. * Each element of this array is an object `{idx: int, faceId: int}`.
  95745. * `idx` is the picked particle index in the `SPS.particles` array
  95746. * `faceId` is the picked face index counted within this particle.
  95747. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  95748. */
  95749. pickedParticles: {
  95750. idx: number;
  95751. faceId: number;
  95752. }[];
  95753. /**
  95754. * This array is populated when `enableDepthSort` is set to true.
  95755. * Each element of this array is an instance of the class DepthSortedParticle.
  95756. */
  95757. depthSortedParticles: DepthSortedParticle[];
  95758. /**
  95759. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  95760. * @hidden
  95761. */
  95762. _bSphereOnly: boolean;
  95763. /**
  95764. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  95765. * @hidden
  95766. */
  95767. _bSphereRadiusFactor: number;
  95768. private _scene;
  95769. private _positions;
  95770. private _indices;
  95771. private _normals;
  95772. private _colors;
  95773. private _uvs;
  95774. private _indices32;
  95775. private _positions32;
  95776. private _normals32;
  95777. private _fixedNormal32;
  95778. private _colors32;
  95779. private _uvs32;
  95780. private _index;
  95781. private _updatable;
  95782. private _pickable;
  95783. private _isVisibilityBoxLocked;
  95784. private _alwaysVisible;
  95785. private _depthSort;
  95786. private _expandable;
  95787. private _shapeCounter;
  95788. private _copy;
  95789. private _color;
  95790. private _computeParticleColor;
  95791. private _computeParticleTexture;
  95792. private _computeParticleRotation;
  95793. private _computeParticleVertex;
  95794. private _computeBoundingBox;
  95795. private _depthSortParticles;
  95796. private _camera;
  95797. private _mustUnrotateFixedNormals;
  95798. private _particlesIntersect;
  95799. private _needs32Bits;
  95800. private _isNotBuilt;
  95801. private _lastParticleId;
  95802. private _idxOfId;
  95803. private _multimaterialEnabled;
  95804. private _useModelMaterial;
  95805. private _indicesByMaterial;
  95806. private _materialIndexes;
  95807. private _depthSortFunction;
  95808. private _materialSortFunction;
  95809. private _materials;
  95810. private _multimaterial;
  95811. private _materialIndexesById;
  95812. private _defaultMaterial;
  95813. private _autoUpdateSubMeshes;
  95814. /**
  95815. * Creates a SPS (Solid Particle System) object.
  95816. * @param name (String) is the SPS name, this will be the underlying mesh name.
  95817. * @param scene (Scene) is the scene in which the SPS is added.
  95818. * @param options defines the options of the sps e.g.
  95819. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  95820. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  95821. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  95822. * * useModelMaterial (optional boolean, defaut false) : if the model materials must be used to create the SPS multimaterial. This enables the multimaterial supports of the SPS.
  95823. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  95824. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  95825. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  95826. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  95827. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  95828. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  95829. */
  95830. constructor(name: string, scene: Scene, options?: {
  95831. updatable?: boolean;
  95832. isPickable?: boolean;
  95833. enableDepthSort?: boolean;
  95834. particleIntersection?: boolean;
  95835. boundingSphereOnly?: boolean;
  95836. bSphereRadiusFactor?: number;
  95837. expandable?: boolean;
  95838. useModelMaterial?: boolean;
  95839. enableMultiMaterial?: boolean;
  95840. });
  95841. /**
  95842. * Builds the SPS underlying mesh. Returns a standard Mesh.
  95843. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  95844. * @returns the created mesh
  95845. */
  95846. buildMesh(): Mesh;
  95847. /**
  95848. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  95849. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  95850. * Thus the particles generated from `digest()` have their property `position` set yet.
  95851. * @param mesh ( Mesh ) is the mesh to be digested
  95852. * @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
  95853. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  95854. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  95855. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  95856. * @returns the current SPS
  95857. */
  95858. digest(mesh: Mesh, options?: {
  95859. facetNb?: number;
  95860. number?: number;
  95861. delta?: number;
  95862. storage?: [];
  95863. }): SolidParticleSystem;
  95864. /**
  95865. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  95866. * @hidden
  95867. */
  95868. private _unrotateFixedNormals;
  95869. /**
  95870. * Resets the temporary working copy particle
  95871. * @hidden
  95872. */
  95873. private _resetCopy;
  95874. /**
  95875. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  95876. * @param p the current index in the positions array to be updated
  95877. * @param ind the current index in the indices array
  95878. * @param shape a Vector3 array, the shape geometry
  95879. * @param positions the positions array to be updated
  95880. * @param meshInd the shape indices array
  95881. * @param indices the indices array to be updated
  95882. * @param meshUV the shape uv array
  95883. * @param uvs the uv array to be updated
  95884. * @param meshCol the shape color array
  95885. * @param colors the color array to be updated
  95886. * @param meshNor the shape normals array
  95887. * @param normals the normals array to be updated
  95888. * @param idx the particle index
  95889. * @param idxInShape the particle index in its shape
  95890. * @param options the addShape() method passed options
  95891. * @model the particle model
  95892. * @hidden
  95893. */
  95894. private _meshBuilder;
  95895. /**
  95896. * Returns a shape Vector3 array from positions float array
  95897. * @param positions float array
  95898. * @returns a vector3 array
  95899. * @hidden
  95900. */
  95901. private _posToShape;
  95902. /**
  95903. * Returns a shapeUV array from a float uvs (array deep copy)
  95904. * @param uvs as a float array
  95905. * @returns a shapeUV array
  95906. * @hidden
  95907. */
  95908. private _uvsToShapeUV;
  95909. /**
  95910. * Adds a new particle object in the particles array
  95911. * @param idx particle index in particles array
  95912. * @param id particle id
  95913. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  95914. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  95915. * @param model particle ModelShape object
  95916. * @param shapeId model shape identifier
  95917. * @param idxInShape index of the particle in the current model
  95918. * @param bInfo model bounding info object
  95919. * @param storage target storage array, if any
  95920. * @hidden
  95921. */
  95922. private _addParticle;
  95923. /**
  95924. * Adds some particles to the SPS from the model shape. Returns the shape id.
  95925. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  95926. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  95927. * @param nb (positive integer) the number of particles to be created from this model
  95928. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  95929. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  95930. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  95931. * @returns the number of shapes in the system
  95932. */
  95933. addShape(mesh: Mesh, nb: number, options?: {
  95934. positionFunction?: any;
  95935. vertexFunction?: any;
  95936. storage?: [];
  95937. }): number;
  95938. /**
  95939. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  95940. * @hidden
  95941. */
  95942. private _rebuildParticle;
  95943. /**
  95944. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  95945. * @param reset boolean, default false : if the particles must be reset at position and rotation zero, scaling 1, color white, initial UVs and not parented.
  95946. * @returns the SPS.
  95947. */
  95948. rebuildMesh(reset?: boolean): SolidParticleSystem;
  95949. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  95950. * Returns an array with the removed particles.
  95951. * If the number of particles to remove is lower than zero or greater than the global remaining particle number, then an empty array is returned.
  95952. * The SPS can't be empty so at least one particle needs to remain in place.
  95953. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  95954. * @param start index of the first particle to remove
  95955. * @param end index of the last particle to remove (included)
  95956. * @returns an array populated with the removed particles
  95957. */
  95958. removeParticles(start: number, end: number): SolidParticle[];
  95959. /**
  95960. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  95961. * @param solidParticleArray an array populated with Solid Particles objects
  95962. * @returns the SPS
  95963. */
  95964. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  95965. /**
  95966. * Creates a new particle and modifies the SPS mesh geometry :
  95967. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  95968. * - calls _addParticle() to populate the particle array
  95969. * factorized code from addShape() and insertParticlesFromArray()
  95970. * @param idx particle index in the particles array
  95971. * @param i particle index in its shape
  95972. * @param modelShape particle ModelShape object
  95973. * @param shape shape vertex array
  95974. * @param meshInd shape indices array
  95975. * @param meshUV shape uv array
  95976. * @param meshCol shape color array
  95977. * @param meshNor shape normals array
  95978. * @param bbInfo shape bounding info
  95979. * @param storage target particle storage
  95980. * @options addShape() passed options
  95981. * @hidden
  95982. */
  95983. private _insertNewParticle;
  95984. /**
  95985. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  95986. * This method calls `updateParticle()` for each particle of the SPS.
  95987. * For an animated SPS, it is usually called within the render loop.
  95988. * This methods does nothing if called on a non updatable or not yet built SPS. Example : buildMesh() not called after having added or removed particles from an expandable SPS.
  95989. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  95990. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  95991. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  95992. * @returns the SPS.
  95993. */
  95994. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  95995. /**
  95996. * Disposes the SPS.
  95997. */
  95998. dispose(): void;
  95999. /**
  96000. * Returns a SolidParticle object from its identifier : particle.id
  96001. * @param id (integer) the particle Id
  96002. * @returns the searched particle or null if not found in the SPS.
  96003. */
  96004. getParticleById(id: number): Nullable<SolidParticle>;
  96005. /**
  96006. * Returns a new array populated with the particles having the passed shapeId.
  96007. * @param shapeId (integer) the shape identifier
  96008. * @returns a new solid particle array
  96009. */
  96010. getParticlesByShapeId(shapeId: number): SolidParticle[];
  96011. /**
  96012. * Populates the passed array "ref" with the particles having the passed shapeId.
  96013. * @param shapeId the shape identifier
  96014. * @returns the SPS
  96015. * @param ref
  96016. */
  96017. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  96018. /**
  96019. * Computes the required SubMeshes according the materials assigned to the particles.
  96020. * @returns the solid particle system.
  96021. * Does nothing if called before the SPS mesh is built.
  96022. */
  96023. computeSubMeshes(): SolidParticleSystem;
  96024. /**
  96025. * Sorts the solid particles by material when MultiMaterial is enabled.
  96026. * Updates the indices32 array.
  96027. * Updates the indicesByMaterial array.
  96028. * Updates the mesh indices array.
  96029. * @returns the SPS
  96030. * @hidden
  96031. */
  96032. private _sortParticlesByMaterial;
  96033. /**
  96034. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  96035. * @hidden
  96036. */
  96037. private _setMaterialIndexesById;
  96038. /**
  96039. * Returns an array with unique values of Materials from the passed array
  96040. * @param array the material array to be checked and filtered
  96041. * @hidden
  96042. */
  96043. private _filterUniqueMaterialId;
  96044. /**
  96045. * Sets a new Standard Material as _defaultMaterial if not already set.
  96046. * @hidden
  96047. */
  96048. private _setDefaultMaterial;
  96049. /**
  96050. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  96051. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  96052. * @returns the SPS.
  96053. */
  96054. refreshVisibleSize(): SolidParticleSystem;
  96055. /**
  96056. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  96057. * @param size the size (float) of the visibility box
  96058. * note : this doesn't lock the SPS mesh bounding box.
  96059. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  96060. */
  96061. setVisibilityBox(size: number): void;
  96062. /**
  96063. * Gets whether the SPS as always visible or not
  96064. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  96065. */
  96066. /**
  96067. * Sets the SPS as always visible or not
  96068. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  96069. */
  96070. isAlwaysVisible: boolean;
  96071. /**
  96072. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  96073. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  96074. */
  96075. /**
  96076. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  96077. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  96078. */
  96079. isVisibilityBoxLocked: boolean;
  96080. /**
  96081. * Tells to `setParticles()` to compute the particle rotations or not.
  96082. * Default value : true. The SPS is faster when it's set to false.
  96083. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  96084. */
  96085. /**
  96086. * Gets if `setParticles()` computes the particle rotations or not.
  96087. * Default value : true. The SPS is faster when it's set to false.
  96088. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  96089. */
  96090. computeParticleRotation: boolean;
  96091. /**
  96092. * Tells to `setParticles()` to compute the particle colors or not.
  96093. * Default value : true. The SPS is faster when it's set to false.
  96094. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  96095. */
  96096. /**
  96097. * Gets if `setParticles()` computes the particle colors or not.
  96098. * Default value : true. The SPS is faster when it's set to false.
  96099. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  96100. */
  96101. computeParticleColor: boolean;
  96102. /**
  96103. * Gets if `setParticles()` computes the particle textures or not.
  96104. * Default value : true. The SPS is faster when it's set to false.
  96105. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  96106. */
  96107. computeParticleTexture: boolean;
  96108. /**
  96109. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  96110. * Default value : false. The SPS is faster when it's set to false.
  96111. * Note : the particle custom vertex positions aren't stored values.
  96112. */
  96113. /**
  96114. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  96115. * Default value : false. The SPS is faster when it's set to false.
  96116. * Note : the particle custom vertex positions aren't stored values.
  96117. */
  96118. computeParticleVertex: boolean;
  96119. /**
  96120. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  96121. */
  96122. /**
  96123. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  96124. */
  96125. computeBoundingBox: boolean;
  96126. /**
  96127. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  96128. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  96129. * Default : `true`
  96130. */
  96131. /**
  96132. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  96133. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  96134. * Default : `true`
  96135. */
  96136. depthSortParticles: boolean;
  96137. /**
  96138. * Gets if the SPS is created as expandable at construction time.
  96139. * Default : `false`
  96140. */
  96141. readonly expandable: boolean;
  96142. /**
  96143. * Gets if the SPS supports the Multi Materials
  96144. */
  96145. readonly multimaterialEnabled: boolean;
  96146. /**
  96147. * Gets if the SPS uses the model materials for its own multimaterial.
  96148. */
  96149. readonly useModelMaterial: boolean;
  96150. /**
  96151. * The SPS used material array.
  96152. */
  96153. readonly materials: Material[];
  96154. /**
  96155. * Sets the SPS MultiMaterial from the passed materials.
  96156. * Note : the passed array is internally copied and not used then by reference.
  96157. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  96158. */
  96159. setMultiMaterial(materials: Material[]): void;
  96160. /**
  96161. * The SPS computed multimaterial object
  96162. */
  96163. multimaterial: MultiMaterial;
  96164. /**
  96165. * If the subMeshes must be updated on the next call to setParticles()
  96166. */
  96167. autoUpdateSubMeshes: boolean;
  96168. /**
  96169. * This function does nothing. It may be overwritten to set all the particle first values.
  96170. * The SPS doesn't call this function, you may have to call it by your own.
  96171. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  96172. */
  96173. initParticles(): void;
  96174. /**
  96175. * This function does nothing. It may be overwritten to recycle a particle.
  96176. * The SPS doesn't call this function, you may have to call it by your own.
  96177. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  96178. * @param particle The particle to recycle
  96179. * @returns the recycled particle
  96180. */
  96181. recycleParticle(particle: SolidParticle): SolidParticle;
  96182. /**
  96183. * Updates a particle : this function should be overwritten by the user.
  96184. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  96185. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  96186. * @example : just set a particle position or velocity and recycle conditions
  96187. * @param particle The particle to update
  96188. * @returns the updated particle
  96189. */
  96190. updateParticle(particle: SolidParticle): SolidParticle;
  96191. /**
  96192. * Updates a vertex of a particle : it can be overwritten by the user.
  96193. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  96194. * @param particle the current particle
  96195. * @param vertex the current index of the current particle
  96196. * @param pt the index of the current vertex in the particle shape
  96197. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  96198. * @example : just set a vertex particle position
  96199. * @returns the updated vertex
  96200. */
  96201. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  96202. /**
  96203. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  96204. * This does nothing and may be overwritten by the user.
  96205. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  96206. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  96207. * @param update the boolean update value actually passed to setParticles()
  96208. */
  96209. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  96210. /**
  96211. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  96212. * This will be passed three parameters.
  96213. * This does nothing and may be overwritten by the user.
  96214. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  96215. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  96216. * @param update the boolean update value actually passed to setParticles()
  96217. */
  96218. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  96219. }
  96220. }
  96221. declare module BABYLON {
  96222. /**
  96223. * Represents one particle of a solid particle system.
  96224. */
  96225. export class SolidParticle {
  96226. /**
  96227. * particle global index
  96228. */
  96229. idx: number;
  96230. /**
  96231. * particle identifier
  96232. */
  96233. id: number;
  96234. /**
  96235. * The color of the particle
  96236. */
  96237. color: Nullable<Color4>;
  96238. /**
  96239. * The world space position of the particle.
  96240. */
  96241. position: Vector3;
  96242. /**
  96243. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  96244. */
  96245. rotation: Vector3;
  96246. /**
  96247. * The world space rotation quaternion of the particle.
  96248. */
  96249. rotationQuaternion: Nullable<Quaternion>;
  96250. /**
  96251. * The scaling of the particle.
  96252. */
  96253. scaling: Vector3;
  96254. /**
  96255. * The uvs of the particle.
  96256. */
  96257. uvs: Vector4;
  96258. /**
  96259. * The current speed of the particle.
  96260. */
  96261. velocity: Vector3;
  96262. /**
  96263. * The pivot point in the particle local space.
  96264. */
  96265. pivot: Vector3;
  96266. /**
  96267. * Must the particle be translated from its pivot point in its local space ?
  96268. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  96269. * Default : false
  96270. */
  96271. translateFromPivot: boolean;
  96272. /**
  96273. * Is the particle active or not ?
  96274. */
  96275. alive: boolean;
  96276. /**
  96277. * Is the particle visible or not ?
  96278. */
  96279. isVisible: boolean;
  96280. /**
  96281. * Index of this particle in the global "positions" array (Internal use)
  96282. * @hidden
  96283. */
  96284. _pos: number;
  96285. /**
  96286. * @hidden Index of this particle in the global "indices" array (Internal use)
  96287. */
  96288. _ind: number;
  96289. /**
  96290. * @hidden ModelShape of this particle (Internal use)
  96291. */
  96292. _model: ModelShape;
  96293. /**
  96294. * ModelShape id of this particle
  96295. */
  96296. shapeId: number;
  96297. /**
  96298. * Index of the particle in its shape id
  96299. */
  96300. idxInShape: number;
  96301. /**
  96302. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  96303. */
  96304. _modelBoundingInfo: BoundingInfo;
  96305. /**
  96306. * @hidden Particle BoundingInfo object (Internal use)
  96307. */
  96308. _boundingInfo: BoundingInfo;
  96309. /**
  96310. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  96311. */
  96312. _sps: SolidParticleSystem;
  96313. /**
  96314. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  96315. */
  96316. _stillInvisible: boolean;
  96317. /**
  96318. * @hidden Last computed particle rotation matrix
  96319. */
  96320. _rotationMatrix: number[];
  96321. /**
  96322. * Parent particle Id, if any.
  96323. * Default null.
  96324. */
  96325. parentId: Nullable<number>;
  96326. /**
  96327. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  96328. */
  96329. materialIndex: Nullable<number>;
  96330. /**
  96331. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  96332. * The possible values are :
  96333. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  96334. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  96335. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  96336. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  96337. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  96338. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  96339. * */
  96340. cullingStrategy: number;
  96341. /**
  96342. * @hidden Internal global position in the SPS.
  96343. */
  96344. _globalPosition: Vector3;
  96345. /**
  96346. * Creates a Solid Particle object.
  96347. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  96348. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  96349. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  96350. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  96351. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  96352. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  96353. * @param shapeId (integer) is the model shape identifier in the SPS.
  96354. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  96355. * @param sps defines the sps it is associated to
  96356. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  96357. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  96358. */
  96359. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  96360. /**
  96361. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  96362. * @param target the particle target
  96363. * @returns the current particle
  96364. */
  96365. copyToRef(target: SolidParticle): SolidParticle;
  96366. /**
  96367. * Legacy support, changed scale to scaling
  96368. */
  96369. /**
  96370. * Legacy support, changed scale to scaling
  96371. */
  96372. scale: Vector3;
  96373. /**
  96374. * Legacy support, changed quaternion to rotationQuaternion
  96375. */
  96376. /**
  96377. * Legacy support, changed quaternion to rotationQuaternion
  96378. */
  96379. quaternion: Nullable<Quaternion>;
  96380. /**
  96381. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  96382. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  96383. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  96384. * @returns true if it intersects
  96385. */
  96386. intersectsMesh(target: Mesh | SolidParticle): boolean;
  96387. /**
  96388. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  96389. * A particle is in the frustum if its bounding box intersects the frustum
  96390. * @param frustumPlanes defines the frustum to test
  96391. * @returns true if the particle is in the frustum planes
  96392. */
  96393. isInFrustum(frustumPlanes: Plane[]): boolean;
  96394. /**
  96395. * get the rotation matrix of the particle
  96396. * @hidden
  96397. */
  96398. getRotationMatrix(m: Matrix): void;
  96399. }
  96400. /**
  96401. * Represents the shape of the model used by one particle of a solid particle system.
  96402. * SPS internal tool, don't use it manually.
  96403. */
  96404. export class ModelShape {
  96405. /**
  96406. * The shape id
  96407. * @hidden
  96408. */
  96409. shapeID: number;
  96410. /**
  96411. * flat array of model positions (internal use)
  96412. * @hidden
  96413. */
  96414. _shape: Vector3[];
  96415. /**
  96416. * flat array of model UVs (internal use)
  96417. * @hidden
  96418. */
  96419. _shapeUV: number[];
  96420. /**
  96421. * color array of the model
  96422. * @hidden
  96423. */
  96424. _shapeColors: number[];
  96425. /**
  96426. * indices array of the model
  96427. * @hidden
  96428. */
  96429. _indices: number[];
  96430. /**
  96431. * normals array of the model
  96432. * @hidden
  96433. */
  96434. _normals: number[];
  96435. /**
  96436. * length of the shape in the model indices array (internal use)
  96437. * @hidden
  96438. */
  96439. _indicesLength: number;
  96440. /**
  96441. * Custom position function (internal use)
  96442. * @hidden
  96443. */
  96444. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  96445. /**
  96446. * Custom vertex function (internal use)
  96447. * @hidden
  96448. */
  96449. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  96450. /**
  96451. * Model material (internal use)
  96452. * @hidden
  96453. */
  96454. _material: Nullable<Material>;
  96455. /**
  96456. * 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.
  96457. * SPS internal tool, don't use it manually.
  96458. * @hidden
  96459. */
  96460. constructor(id: number, shape: Vector3[], indices: number[], normals: number[], colors: number[], shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>, material: Nullable<Material>);
  96461. }
  96462. /**
  96463. * Represents a Depth Sorted Particle in the solid particle system.
  96464. * @hidden
  96465. */
  96466. export class DepthSortedParticle {
  96467. /**
  96468. * Index of the particle in the "indices" array
  96469. */
  96470. ind: number;
  96471. /**
  96472. * Length of the particle shape in the "indices" array
  96473. */
  96474. indicesLength: number;
  96475. /**
  96476. * Squared distance from the particle to the camera
  96477. */
  96478. sqDistance: number;
  96479. /**
  96480. * Material index when used with MultiMaterials
  96481. */
  96482. materialIndex: number;
  96483. /**
  96484. * Creates a new sorted particle
  96485. * @param materialIndex
  96486. */
  96487. constructor(ind: number, indLength: number, materialIndex: number);
  96488. }
  96489. }
  96490. declare module BABYLON {
  96491. /**
  96492. * @hidden
  96493. */
  96494. export class _MeshCollisionData {
  96495. _checkCollisions: boolean;
  96496. _collisionMask: number;
  96497. _collisionGroup: number;
  96498. _collider: Nullable<Collider>;
  96499. _oldPositionForCollisions: Vector3;
  96500. _diffPositionForCollisions: Vector3;
  96501. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  96502. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  96503. }
  96504. }
  96505. declare module BABYLON {
  96506. /** @hidden */
  96507. class _FacetDataStorage {
  96508. facetPositions: Vector3[];
  96509. facetNormals: Vector3[];
  96510. facetPartitioning: number[][];
  96511. facetNb: number;
  96512. partitioningSubdivisions: number;
  96513. partitioningBBoxRatio: number;
  96514. facetDataEnabled: boolean;
  96515. facetParameters: any;
  96516. bbSize: Vector3;
  96517. subDiv: {
  96518. max: number;
  96519. X: number;
  96520. Y: number;
  96521. Z: number;
  96522. };
  96523. facetDepthSort: boolean;
  96524. facetDepthSortEnabled: boolean;
  96525. depthSortedIndices: IndicesArray;
  96526. depthSortedFacets: {
  96527. ind: number;
  96528. sqDistance: number;
  96529. }[];
  96530. facetDepthSortFunction: (f1: {
  96531. ind: number;
  96532. sqDistance: number;
  96533. }, f2: {
  96534. ind: number;
  96535. sqDistance: number;
  96536. }) => number;
  96537. facetDepthSortFrom: Vector3;
  96538. facetDepthSortOrigin: Vector3;
  96539. invertedMatrix: Matrix;
  96540. }
  96541. /**
  96542. * @hidden
  96543. **/
  96544. class _InternalAbstractMeshDataInfo {
  96545. _hasVertexAlpha: boolean;
  96546. _useVertexColors: boolean;
  96547. _numBoneInfluencers: number;
  96548. _applyFog: boolean;
  96549. _receiveShadows: boolean;
  96550. _facetData: _FacetDataStorage;
  96551. _visibility: number;
  96552. _skeleton: Nullable<Skeleton>;
  96553. _layerMask: number;
  96554. _computeBonesUsingShaders: boolean;
  96555. _isActive: boolean;
  96556. _onlyForInstances: boolean;
  96557. _isActiveIntermediate: boolean;
  96558. _onlyForInstancesIntermediate: boolean;
  96559. _actAsRegularMesh: boolean;
  96560. }
  96561. /**
  96562. * Class used to store all common mesh properties
  96563. */
  96564. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  96565. /** No occlusion */
  96566. static OCCLUSION_TYPE_NONE: number;
  96567. /** Occlusion set to optimisitic */
  96568. static OCCLUSION_TYPE_OPTIMISTIC: number;
  96569. /** Occlusion set to strict */
  96570. static OCCLUSION_TYPE_STRICT: number;
  96571. /** Use an accurante occlusion algorithm */
  96572. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  96573. /** Use a conservative occlusion algorithm */
  96574. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  96575. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  96576. * Test order :
  96577. * Is the bounding sphere outside the frustum ?
  96578. * If not, are the bounding box vertices outside the frustum ?
  96579. * It not, then the cullable object is in the frustum.
  96580. */
  96581. static readonly CULLINGSTRATEGY_STANDARD: number;
  96582. /** Culling strategy : Bounding Sphere Only.
  96583. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  96584. * It's also less accurate than the standard because some not visible objects can still be selected.
  96585. * Test : is the bounding sphere outside the frustum ?
  96586. * If not, then the cullable object is in the frustum.
  96587. */
  96588. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  96589. /** Culling strategy : Optimistic Inclusion.
  96590. * This in an inclusion test first, then the standard exclusion test.
  96591. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  96592. * 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.
  96593. * Anyway, it's as accurate as the standard strategy.
  96594. * Test :
  96595. * Is the cullable object bounding sphere center in the frustum ?
  96596. * If not, apply the default culling strategy.
  96597. */
  96598. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  96599. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  96600. * This in an inclusion test first, then the bounding sphere only exclusion test.
  96601. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  96602. * 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.
  96603. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  96604. * Test :
  96605. * Is the cullable object bounding sphere center in the frustum ?
  96606. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  96607. */
  96608. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  96609. /**
  96610. * No billboard
  96611. */
  96612. static readonly BILLBOARDMODE_NONE: number;
  96613. /** Billboard on X axis */
  96614. static readonly BILLBOARDMODE_X: number;
  96615. /** Billboard on Y axis */
  96616. static readonly BILLBOARDMODE_Y: number;
  96617. /** Billboard on Z axis */
  96618. static readonly BILLBOARDMODE_Z: number;
  96619. /** Billboard on all axes */
  96620. static readonly BILLBOARDMODE_ALL: number;
  96621. /** Billboard on using position instead of orientation */
  96622. static readonly BILLBOARDMODE_USE_POSITION: number;
  96623. /** @hidden */
  96624. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  96625. /**
  96626. * The culling strategy to use to check whether the mesh must be rendered or not.
  96627. * This value can be changed at any time and will be used on the next render mesh selection.
  96628. * The possible values are :
  96629. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  96630. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  96631. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  96632. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  96633. * Please read each static variable documentation to get details about the culling process.
  96634. * */
  96635. cullingStrategy: number;
  96636. /**
  96637. * Gets the number of facets in the mesh
  96638. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  96639. */
  96640. readonly facetNb: number;
  96641. /**
  96642. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  96643. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  96644. */
  96645. partitioningSubdivisions: number;
  96646. /**
  96647. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  96648. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  96649. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  96650. */
  96651. partitioningBBoxRatio: number;
  96652. /**
  96653. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  96654. * Works only for updatable meshes.
  96655. * Doesn't work with multi-materials
  96656. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  96657. */
  96658. mustDepthSortFacets: boolean;
  96659. /**
  96660. * The location (Vector3) where the facet depth sort must be computed from.
  96661. * By default, the active camera position.
  96662. * Used only when facet depth sort is enabled
  96663. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  96664. */
  96665. facetDepthSortFrom: Vector3;
  96666. /**
  96667. * gets a boolean indicating if facetData is enabled
  96668. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  96669. */
  96670. readonly isFacetDataEnabled: boolean;
  96671. /** @hidden */
  96672. _updateNonUniformScalingState(value: boolean): boolean;
  96673. /**
  96674. * An event triggered when this mesh collides with another one
  96675. */
  96676. onCollideObservable: Observable<AbstractMesh>;
  96677. /** Set a function to call when this mesh collides with another one */
  96678. onCollide: () => void;
  96679. /**
  96680. * An event triggered when the collision's position changes
  96681. */
  96682. onCollisionPositionChangeObservable: Observable<Vector3>;
  96683. /** Set a function to call when the collision's position changes */
  96684. onCollisionPositionChange: () => void;
  96685. /**
  96686. * An event triggered when material is changed
  96687. */
  96688. onMaterialChangedObservable: Observable<AbstractMesh>;
  96689. /**
  96690. * Gets or sets the orientation for POV movement & rotation
  96691. */
  96692. definedFacingForward: boolean;
  96693. /** @hidden */
  96694. _occlusionQuery: Nullable<WebGLQuery>;
  96695. /** @hidden */
  96696. _renderingGroup: Nullable<RenderingGroup>;
  96697. /**
  96698. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  96699. */
  96700. /**
  96701. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  96702. */
  96703. visibility: number;
  96704. /** Gets or sets the alpha index used to sort transparent meshes
  96705. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  96706. */
  96707. alphaIndex: number;
  96708. /**
  96709. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  96710. */
  96711. isVisible: boolean;
  96712. /**
  96713. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  96714. */
  96715. isPickable: boolean;
  96716. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  96717. showSubMeshesBoundingBox: boolean;
  96718. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  96719. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  96720. */
  96721. isBlocker: boolean;
  96722. /**
  96723. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  96724. */
  96725. enablePointerMoveEvents: boolean;
  96726. /**
  96727. * Specifies the rendering group id for this mesh (0 by default)
  96728. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  96729. */
  96730. renderingGroupId: number;
  96731. private _material;
  96732. /** Gets or sets current material */
  96733. material: Nullable<Material>;
  96734. /**
  96735. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  96736. * @see http://doc.babylonjs.com/babylon101/shadows
  96737. */
  96738. receiveShadows: boolean;
  96739. /** Defines color to use when rendering outline */
  96740. outlineColor: Color3;
  96741. /** Define width to use when rendering outline */
  96742. outlineWidth: number;
  96743. /** Defines color to use when rendering overlay */
  96744. overlayColor: Color3;
  96745. /** Defines alpha to use when rendering overlay */
  96746. overlayAlpha: number;
  96747. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  96748. hasVertexAlpha: boolean;
  96749. /** 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) */
  96750. useVertexColors: boolean;
  96751. /**
  96752. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  96753. */
  96754. computeBonesUsingShaders: boolean;
  96755. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  96756. numBoneInfluencers: number;
  96757. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  96758. applyFog: boolean;
  96759. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  96760. useOctreeForRenderingSelection: boolean;
  96761. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  96762. useOctreeForPicking: boolean;
  96763. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  96764. useOctreeForCollisions: boolean;
  96765. /**
  96766. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  96767. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  96768. */
  96769. layerMask: number;
  96770. /**
  96771. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  96772. */
  96773. alwaysSelectAsActiveMesh: boolean;
  96774. /**
  96775. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  96776. */
  96777. doNotSyncBoundingInfo: boolean;
  96778. /**
  96779. * Gets or sets the current action manager
  96780. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  96781. */
  96782. actionManager: Nullable<AbstractActionManager>;
  96783. private _meshCollisionData;
  96784. /**
  96785. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  96786. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  96787. */
  96788. ellipsoid: Vector3;
  96789. /**
  96790. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  96791. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  96792. */
  96793. ellipsoidOffset: Vector3;
  96794. /**
  96795. * Gets or sets a collision mask used to mask collisions (default is -1).
  96796. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  96797. */
  96798. collisionMask: number;
  96799. /**
  96800. * Gets or sets the current collision group mask (-1 by default).
  96801. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  96802. */
  96803. collisionGroup: number;
  96804. /**
  96805. * Defines edge width used when edgesRenderer is enabled
  96806. * @see https://www.babylonjs-playground.com/#10OJSG#13
  96807. */
  96808. edgesWidth: number;
  96809. /**
  96810. * Defines edge color used when edgesRenderer is enabled
  96811. * @see https://www.babylonjs-playground.com/#10OJSG#13
  96812. */
  96813. edgesColor: Color4;
  96814. /** @hidden */
  96815. _edgesRenderer: Nullable<IEdgesRenderer>;
  96816. /** @hidden */
  96817. _masterMesh: Nullable<AbstractMesh>;
  96818. /** @hidden */
  96819. _boundingInfo: Nullable<BoundingInfo>;
  96820. /** @hidden */
  96821. _renderId: number;
  96822. /**
  96823. * Gets or sets the list of subMeshes
  96824. * @see http://doc.babylonjs.com/how_to/multi_materials
  96825. */
  96826. subMeshes: SubMesh[];
  96827. /** @hidden */
  96828. _intersectionsInProgress: AbstractMesh[];
  96829. /** @hidden */
  96830. _unIndexed: boolean;
  96831. /** @hidden */
  96832. _lightSources: Light[];
  96833. /** Gets the list of lights affecting that mesh */
  96834. readonly lightSources: Light[];
  96835. /** @hidden */
  96836. readonly _positions: Nullable<Vector3[]>;
  96837. /** @hidden */
  96838. _waitingData: {
  96839. lods: Nullable<any>;
  96840. actions: Nullable<any>;
  96841. freezeWorldMatrix: Nullable<boolean>;
  96842. };
  96843. /** @hidden */
  96844. _bonesTransformMatrices: Nullable<Float32Array>;
  96845. /** @hidden */
  96846. _transformMatrixTexture: Nullable<RawTexture>;
  96847. /**
  96848. * Gets or sets a skeleton to apply skining transformations
  96849. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  96850. */
  96851. skeleton: Nullable<Skeleton>;
  96852. /**
  96853. * An event triggered when the mesh is rebuilt.
  96854. */
  96855. onRebuildObservable: Observable<AbstractMesh>;
  96856. /**
  96857. * Creates a new AbstractMesh
  96858. * @param name defines the name of the mesh
  96859. * @param scene defines the hosting scene
  96860. */
  96861. constructor(name: string, scene?: Nullable<Scene>);
  96862. /**
  96863. * Returns the string "AbstractMesh"
  96864. * @returns "AbstractMesh"
  96865. */
  96866. getClassName(): string;
  96867. /**
  96868. * Gets a string representation of the current mesh
  96869. * @param fullDetails defines a boolean indicating if full details must be included
  96870. * @returns a string representation of the current mesh
  96871. */
  96872. toString(fullDetails?: boolean): string;
  96873. /**
  96874. * @hidden
  96875. */
  96876. protected _getEffectiveParent(): Nullable<Node>;
  96877. /** @hidden */
  96878. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  96879. /** @hidden */
  96880. _rebuild(): void;
  96881. /** @hidden */
  96882. _resyncLightSources(): void;
  96883. /** @hidden */
  96884. _resyncLightSource(light: Light): void;
  96885. /** @hidden */
  96886. _unBindEffect(): void;
  96887. /** @hidden */
  96888. _removeLightSource(light: Light, dispose: boolean): void;
  96889. private _markSubMeshesAsDirty;
  96890. /** @hidden */
  96891. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  96892. /** @hidden */
  96893. _markSubMeshesAsAttributesDirty(): void;
  96894. /** @hidden */
  96895. _markSubMeshesAsMiscDirty(): void;
  96896. /**
  96897. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  96898. */
  96899. scaling: Vector3;
  96900. /**
  96901. * Returns true if the mesh is blocked. Implemented by child classes
  96902. */
  96903. readonly isBlocked: boolean;
  96904. /**
  96905. * Returns the mesh itself by default. Implemented by child classes
  96906. * @param camera defines the camera to use to pick the right LOD level
  96907. * @returns the currentAbstractMesh
  96908. */
  96909. getLOD(camera: Camera): Nullable<AbstractMesh>;
  96910. /**
  96911. * Returns 0 by default. Implemented by child classes
  96912. * @returns an integer
  96913. */
  96914. getTotalVertices(): number;
  96915. /**
  96916. * Returns a positive integer : the total number of indices in this mesh geometry.
  96917. * @returns the numner of indices or zero if the mesh has no geometry.
  96918. */
  96919. getTotalIndices(): number;
  96920. /**
  96921. * Returns null by default. Implemented by child classes
  96922. * @returns null
  96923. */
  96924. getIndices(): Nullable<IndicesArray>;
  96925. /**
  96926. * Returns the array of the requested vertex data kind. Implemented by child classes
  96927. * @param kind defines the vertex data kind to use
  96928. * @returns null
  96929. */
  96930. getVerticesData(kind: string): Nullable<FloatArray>;
  96931. /**
  96932. * Sets the vertex data of the mesh geometry for the requested `kind`.
  96933. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  96934. * Note that a new underlying VertexBuffer object is created each call.
  96935. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  96936. * @param kind defines vertex data kind:
  96937. * * VertexBuffer.PositionKind
  96938. * * VertexBuffer.UVKind
  96939. * * VertexBuffer.UV2Kind
  96940. * * VertexBuffer.UV3Kind
  96941. * * VertexBuffer.UV4Kind
  96942. * * VertexBuffer.UV5Kind
  96943. * * VertexBuffer.UV6Kind
  96944. * * VertexBuffer.ColorKind
  96945. * * VertexBuffer.MatricesIndicesKind
  96946. * * VertexBuffer.MatricesIndicesExtraKind
  96947. * * VertexBuffer.MatricesWeightsKind
  96948. * * VertexBuffer.MatricesWeightsExtraKind
  96949. * @param data defines the data source
  96950. * @param updatable defines if the data must be flagged as updatable (or static)
  96951. * @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
  96952. * @returns the current mesh
  96953. */
  96954. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  96955. /**
  96956. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  96957. * If the mesh has no geometry, it is simply returned as it is.
  96958. * @param kind defines vertex data kind:
  96959. * * VertexBuffer.PositionKind
  96960. * * VertexBuffer.UVKind
  96961. * * VertexBuffer.UV2Kind
  96962. * * VertexBuffer.UV3Kind
  96963. * * VertexBuffer.UV4Kind
  96964. * * VertexBuffer.UV5Kind
  96965. * * VertexBuffer.UV6Kind
  96966. * * VertexBuffer.ColorKind
  96967. * * VertexBuffer.MatricesIndicesKind
  96968. * * VertexBuffer.MatricesIndicesExtraKind
  96969. * * VertexBuffer.MatricesWeightsKind
  96970. * * VertexBuffer.MatricesWeightsExtraKind
  96971. * @param data defines the data source
  96972. * @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
  96973. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  96974. * @returns the current mesh
  96975. */
  96976. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  96977. /**
  96978. * Sets the mesh indices,
  96979. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  96980. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  96981. * @param totalVertices Defines the total number of vertices
  96982. * @returns the current mesh
  96983. */
  96984. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  96985. /**
  96986. * Gets a boolean indicating if specific vertex data is present
  96987. * @param kind defines the vertex data kind to use
  96988. * @returns true is data kind is present
  96989. */
  96990. isVerticesDataPresent(kind: string): boolean;
  96991. /**
  96992. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  96993. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  96994. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  96995. * @returns a BoundingInfo
  96996. */
  96997. getBoundingInfo(): BoundingInfo;
  96998. /**
  96999. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  97000. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  97001. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  97002. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  97003. * @returns the current mesh
  97004. */
  97005. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  97006. /**
  97007. * Overwrite the current bounding info
  97008. * @param boundingInfo defines the new bounding info
  97009. * @returns the current mesh
  97010. */
  97011. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  97012. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  97013. readonly useBones: boolean;
  97014. /** @hidden */
  97015. _preActivate(): void;
  97016. /** @hidden */
  97017. _preActivateForIntermediateRendering(renderId: number): void;
  97018. /** @hidden */
  97019. _activate(renderId: number, intermediateRendering: boolean): boolean;
  97020. /** @hidden */
  97021. _postActivate(): void;
  97022. /** @hidden */
  97023. _freeze(): void;
  97024. /** @hidden */
  97025. _unFreeze(): void;
  97026. /**
  97027. * Gets the current world matrix
  97028. * @returns a Matrix
  97029. */
  97030. getWorldMatrix(): Matrix;
  97031. /** @hidden */
  97032. _getWorldMatrixDeterminant(): number;
  97033. /**
  97034. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  97035. */
  97036. readonly isAnInstance: boolean;
  97037. /**
  97038. * Gets a boolean indicating if this mesh has instances
  97039. */
  97040. readonly hasInstances: boolean;
  97041. /**
  97042. * Perform relative position change from the point of view of behind the front of the mesh.
  97043. * This is performed taking into account the meshes current rotation, so you do not have to care.
  97044. * Supports definition of mesh facing forward or backward
  97045. * @param amountRight defines the distance on the right axis
  97046. * @param amountUp defines the distance on the up axis
  97047. * @param amountForward defines the distance on the forward axis
  97048. * @returns the current mesh
  97049. */
  97050. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  97051. /**
  97052. * Calculate relative position change from the point of view of behind the front of the mesh.
  97053. * This is performed taking into account the meshes current rotation, so you do not have to care.
  97054. * Supports definition of mesh facing forward or backward
  97055. * @param amountRight defines the distance on the right axis
  97056. * @param amountUp defines the distance on the up axis
  97057. * @param amountForward defines the distance on the forward axis
  97058. * @returns the new displacement vector
  97059. */
  97060. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  97061. /**
  97062. * Perform relative rotation change from the point of view of behind the front of the mesh.
  97063. * Supports definition of mesh facing forward or backward
  97064. * @param flipBack defines the flip
  97065. * @param twirlClockwise defines the twirl
  97066. * @param tiltRight defines the tilt
  97067. * @returns the current mesh
  97068. */
  97069. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  97070. /**
  97071. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  97072. * Supports definition of mesh facing forward or backward.
  97073. * @param flipBack defines the flip
  97074. * @param twirlClockwise defines the twirl
  97075. * @param tiltRight defines the tilt
  97076. * @returns the new rotation vector
  97077. */
  97078. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  97079. /**
  97080. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  97081. * This means the mesh underlying bounding box and sphere are recomputed.
  97082. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  97083. * @returns the current mesh
  97084. */
  97085. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  97086. /** @hidden */
  97087. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  97088. /** @hidden */
  97089. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  97090. /** @hidden */
  97091. _updateBoundingInfo(): AbstractMesh;
  97092. /** @hidden */
  97093. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  97094. /** @hidden */
  97095. protected _afterComputeWorldMatrix(): void;
  97096. /** @hidden */
  97097. readonly _effectiveMesh: AbstractMesh;
  97098. /**
  97099. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  97100. * A mesh is in the frustum if its bounding box intersects the frustum
  97101. * @param frustumPlanes defines the frustum to test
  97102. * @returns true if the mesh is in the frustum planes
  97103. */
  97104. isInFrustum(frustumPlanes: Plane[]): boolean;
  97105. /**
  97106. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  97107. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  97108. * @param frustumPlanes defines the frustum to test
  97109. * @returns true if the mesh is completely in the frustum planes
  97110. */
  97111. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  97112. /**
  97113. * True if the mesh intersects another mesh or a SolidParticle object
  97114. * @param mesh defines a target mesh or SolidParticle to test
  97115. * @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)
  97116. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  97117. * @returns true if there is an intersection
  97118. */
  97119. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  97120. /**
  97121. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  97122. * @param point defines the point to test
  97123. * @returns true if there is an intersection
  97124. */
  97125. intersectsPoint(point: Vector3): boolean;
  97126. /**
  97127. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  97128. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  97129. */
  97130. checkCollisions: boolean;
  97131. /**
  97132. * Gets Collider object used to compute collisions (not physics)
  97133. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  97134. */
  97135. readonly collider: Nullable<Collider>;
  97136. /**
  97137. * Move the mesh using collision engine
  97138. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  97139. * @param displacement defines the requested displacement vector
  97140. * @returns the current mesh
  97141. */
  97142. moveWithCollisions(displacement: Vector3): AbstractMesh;
  97143. private _onCollisionPositionChange;
  97144. /** @hidden */
  97145. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  97146. /** @hidden */
  97147. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  97148. /** @hidden */
  97149. _checkCollision(collider: Collider): AbstractMesh;
  97150. /** @hidden */
  97151. _generatePointsArray(): boolean;
  97152. /**
  97153. * Checks if the passed Ray intersects with the mesh
  97154. * @param ray defines the ray to use
  97155. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  97156. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  97157. * @returns the picking info
  97158. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  97159. */
  97160. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  97161. /**
  97162. * Clones the current mesh
  97163. * @param name defines the mesh name
  97164. * @param newParent defines the new mesh parent
  97165. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  97166. * @returns the new mesh
  97167. */
  97168. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  97169. /**
  97170. * Disposes all the submeshes of the current meshnp
  97171. * @returns the current mesh
  97172. */
  97173. releaseSubMeshes(): AbstractMesh;
  97174. /**
  97175. * Releases resources associated with this abstract mesh.
  97176. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  97177. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  97178. */
  97179. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  97180. /**
  97181. * Adds the passed mesh as a child to the current mesh
  97182. * @param mesh defines the child mesh
  97183. * @returns the current mesh
  97184. */
  97185. addChild(mesh: AbstractMesh): AbstractMesh;
  97186. /**
  97187. * Removes the passed mesh from the current mesh children list
  97188. * @param mesh defines the child mesh
  97189. * @returns the current mesh
  97190. */
  97191. removeChild(mesh: AbstractMesh): AbstractMesh;
  97192. /** @hidden */
  97193. private _initFacetData;
  97194. /**
  97195. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  97196. * This method can be called within the render loop.
  97197. * 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
  97198. * @returns the current mesh
  97199. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  97200. */
  97201. updateFacetData(): AbstractMesh;
  97202. /**
  97203. * Returns the facetLocalNormals array.
  97204. * The normals are expressed in the mesh local spac
  97205. * @returns an array of Vector3
  97206. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  97207. */
  97208. getFacetLocalNormals(): Vector3[];
  97209. /**
  97210. * Returns the facetLocalPositions array.
  97211. * The facet positions are expressed in the mesh local space
  97212. * @returns an array of Vector3
  97213. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  97214. */
  97215. getFacetLocalPositions(): Vector3[];
  97216. /**
  97217. * Returns the facetLocalPartioning array
  97218. * @returns an array of array of numbers
  97219. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  97220. */
  97221. getFacetLocalPartitioning(): number[][];
  97222. /**
  97223. * Returns the i-th facet position in the world system.
  97224. * This method allocates a new Vector3 per call
  97225. * @param i defines the facet index
  97226. * @returns a new Vector3
  97227. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  97228. */
  97229. getFacetPosition(i: number): Vector3;
  97230. /**
  97231. * Sets the reference Vector3 with the i-th facet position in the world system
  97232. * @param i defines the facet index
  97233. * @param ref defines the target vector
  97234. * @returns the current mesh
  97235. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  97236. */
  97237. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  97238. /**
  97239. * Returns the i-th facet normal in the world system.
  97240. * This method allocates a new Vector3 per call
  97241. * @param i defines the facet index
  97242. * @returns a new Vector3
  97243. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  97244. */
  97245. getFacetNormal(i: number): Vector3;
  97246. /**
  97247. * Sets the reference Vector3 with the i-th facet normal in the world system
  97248. * @param i defines the facet index
  97249. * @param ref defines the target vector
  97250. * @returns the current mesh
  97251. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  97252. */
  97253. getFacetNormalToRef(i: number, ref: Vector3): this;
  97254. /**
  97255. * 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)
  97256. * @param x defines x coordinate
  97257. * @param y defines y coordinate
  97258. * @param z defines z coordinate
  97259. * @returns the array of facet indexes
  97260. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  97261. */
  97262. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  97263. /**
  97264. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  97265. * @param projected sets as the (x,y,z) world projection on the facet
  97266. * @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
  97267. * @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
  97268. * @param x defines x coordinate
  97269. * @param y defines y coordinate
  97270. * @param z defines z coordinate
  97271. * @returns the face index if found (or null instead)
  97272. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  97273. */
  97274. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  97275. /**
  97276. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  97277. * @param projected sets as the (x,y,z) local projection on the facet
  97278. * @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
  97279. * @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
  97280. * @param x defines x coordinate
  97281. * @param y defines y coordinate
  97282. * @param z defines z coordinate
  97283. * @returns the face index if found (or null instead)
  97284. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  97285. */
  97286. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  97287. /**
  97288. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  97289. * @returns the parameters
  97290. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  97291. */
  97292. getFacetDataParameters(): any;
  97293. /**
  97294. * Disables the feature FacetData and frees the related memory
  97295. * @returns the current mesh
  97296. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  97297. */
  97298. disableFacetData(): AbstractMesh;
  97299. /**
  97300. * Updates the AbstractMesh indices array
  97301. * @param indices defines the data source
  97302. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  97303. * @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)
  97304. * @returns the current mesh
  97305. */
  97306. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  97307. /**
  97308. * Creates new normals data for the mesh
  97309. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  97310. * @returns the current mesh
  97311. */
  97312. createNormals(updatable: boolean): AbstractMesh;
  97313. /**
  97314. * Align the mesh with a normal
  97315. * @param normal defines the normal to use
  97316. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  97317. * @returns the current mesh
  97318. */
  97319. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  97320. /** @hidden */
  97321. _checkOcclusionQuery(): boolean;
  97322. /**
  97323. * Disables the mesh edge rendering mode
  97324. * @returns the currentAbstractMesh
  97325. */
  97326. disableEdgesRendering(): AbstractMesh;
  97327. /**
  97328. * Enables the edge rendering mode on the mesh.
  97329. * This mode makes the mesh edges visible
  97330. * @param epsilon defines the maximal distance between two angles to detect a face
  97331. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  97332. * @returns the currentAbstractMesh
  97333. * @see https://www.babylonjs-playground.com/#19O9TU#0
  97334. */
  97335. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  97336. }
  97337. }
  97338. declare module BABYLON {
  97339. /**
  97340. * Interface used to define ActionEvent
  97341. */
  97342. export interface IActionEvent {
  97343. /** The mesh or sprite that triggered the action */
  97344. source: any;
  97345. /** The X mouse cursor position at the time of the event */
  97346. pointerX: number;
  97347. /** The Y mouse cursor position at the time of the event */
  97348. pointerY: number;
  97349. /** The mesh that is currently pointed at (can be null) */
  97350. meshUnderPointer: Nullable<AbstractMesh>;
  97351. /** the original (browser) event that triggered the ActionEvent */
  97352. sourceEvent?: any;
  97353. /** additional data for the event */
  97354. additionalData?: any;
  97355. }
  97356. /**
  97357. * ActionEvent is the event being sent when an action is triggered.
  97358. */
  97359. export class ActionEvent implements IActionEvent {
  97360. /** The mesh or sprite that triggered the action */
  97361. source: any;
  97362. /** The X mouse cursor position at the time of the event */
  97363. pointerX: number;
  97364. /** The Y mouse cursor position at the time of the event */
  97365. pointerY: number;
  97366. /** The mesh that is currently pointed at (can be null) */
  97367. meshUnderPointer: Nullable<AbstractMesh>;
  97368. /** the original (browser) event that triggered the ActionEvent */
  97369. sourceEvent?: any;
  97370. /** additional data for the event */
  97371. additionalData?: any;
  97372. /**
  97373. * Creates a new ActionEvent
  97374. * @param source The mesh or sprite that triggered the action
  97375. * @param pointerX The X mouse cursor position at the time of the event
  97376. * @param pointerY The Y mouse cursor position at the time of the event
  97377. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  97378. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  97379. * @param additionalData additional data for the event
  97380. */
  97381. constructor(
  97382. /** The mesh or sprite that triggered the action */
  97383. source: any,
  97384. /** The X mouse cursor position at the time of the event */
  97385. pointerX: number,
  97386. /** The Y mouse cursor position at the time of the event */
  97387. pointerY: number,
  97388. /** The mesh that is currently pointed at (can be null) */
  97389. meshUnderPointer: Nullable<AbstractMesh>,
  97390. /** the original (browser) event that triggered the ActionEvent */
  97391. sourceEvent?: any,
  97392. /** additional data for the event */
  97393. additionalData?: any);
  97394. /**
  97395. * Helper function to auto-create an ActionEvent from a source mesh.
  97396. * @param source The source mesh that triggered the event
  97397. * @param evt The original (browser) event
  97398. * @param additionalData additional data for the event
  97399. * @returns the new ActionEvent
  97400. */
  97401. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  97402. /**
  97403. * Helper function to auto-create an ActionEvent from a source sprite
  97404. * @param source The source sprite that triggered the event
  97405. * @param scene Scene associated with the sprite
  97406. * @param evt The original (browser) event
  97407. * @param additionalData additional data for the event
  97408. * @returns the new ActionEvent
  97409. */
  97410. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  97411. /**
  97412. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  97413. * @param scene the scene where the event occurred
  97414. * @param evt The original (browser) event
  97415. * @returns the new ActionEvent
  97416. */
  97417. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  97418. /**
  97419. * Helper function to auto-create an ActionEvent from a primitive
  97420. * @param prim defines the target primitive
  97421. * @param pointerPos defines the pointer position
  97422. * @param evt The original (browser) event
  97423. * @param additionalData additional data for the event
  97424. * @returns the new ActionEvent
  97425. */
  97426. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  97427. }
  97428. }
  97429. declare module BABYLON {
  97430. /**
  97431. * Abstract class used to decouple action Manager from scene and meshes.
  97432. * Do not instantiate.
  97433. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  97434. */
  97435. export abstract class AbstractActionManager implements IDisposable {
  97436. /** Gets the list of active triggers */
  97437. static Triggers: {
  97438. [key: string]: number;
  97439. };
  97440. /** Gets the cursor to use when hovering items */
  97441. hoverCursor: string;
  97442. /** Gets the list of actions */
  97443. actions: IAction[];
  97444. /**
  97445. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  97446. */
  97447. isRecursive: boolean;
  97448. /**
  97449. * Releases all associated resources
  97450. */
  97451. abstract dispose(): void;
  97452. /**
  97453. * Does this action manager has pointer triggers
  97454. */
  97455. abstract readonly hasPointerTriggers: boolean;
  97456. /**
  97457. * Does this action manager has pick triggers
  97458. */
  97459. abstract readonly hasPickTriggers: boolean;
  97460. /**
  97461. * Process a specific trigger
  97462. * @param trigger defines the trigger to process
  97463. * @param evt defines the event details to be processed
  97464. */
  97465. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  97466. /**
  97467. * Does this action manager handles actions of any of the given triggers
  97468. * @param triggers defines the triggers to be tested
  97469. * @return a boolean indicating whether one (or more) of the triggers is handled
  97470. */
  97471. abstract hasSpecificTriggers(triggers: number[]): boolean;
  97472. /**
  97473. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  97474. * speed.
  97475. * @param triggerA defines the trigger to be tested
  97476. * @param triggerB defines the trigger to be tested
  97477. * @return a boolean indicating whether one (or more) of the triggers is handled
  97478. */
  97479. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  97480. /**
  97481. * Does this action manager handles actions of a given trigger
  97482. * @param trigger defines the trigger to be tested
  97483. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  97484. * @return whether the trigger is handled
  97485. */
  97486. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  97487. /**
  97488. * Serialize this manager to a JSON object
  97489. * @param name defines the property name to store this manager
  97490. * @returns a JSON representation of this manager
  97491. */
  97492. abstract serialize(name: string): any;
  97493. /**
  97494. * Registers an action to this action manager
  97495. * @param action defines the action to be registered
  97496. * @return the action amended (prepared) after registration
  97497. */
  97498. abstract registerAction(action: IAction): Nullable<IAction>;
  97499. /**
  97500. * Unregisters an action to this action manager
  97501. * @param action defines the action to be unregistered
  97502. * @return a boolean indicating whether the action has been unregistered
  97503. */
  97504. abstract unregisterAction(action: IAction): Boolean;
  97505. /**
  97506. * Does exist one action manager with at least one trigger
  97507. **/
  97508. static readonly HasTriggers: boolean;
  97509. /**
  97510. * Does exist one action manager with at least one pick trigger
  97511. **/
  97512. static readonly HasPickTriggers: boolean;
  97513. /**
  97514. * Does exist one action manager that handles actions of a given trigger
  97515. * @param trigger defines the trigger to be tested
  97516. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  97517. **/
  97518. static HasSpecificTrigger(trigger: number): boolean;
  97519. }
  97520. }
  97521. declare module BABYLON {
  97522. /**
  97523. * Defines how a node can be built from a string name.
  97524. */
  97525. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  97526. /**
  97527. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  97528. */
  97529. export class Node implements IBehaviorAware<Node> {
  97530. /** @hidden */
  97531. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  97532. private static _NodeConstructors;
  97533. /**
  97534. * Add a new node constructor
  97535. * @param type defines the type name of the node to construct
  97536. * @param constructorFunc defines the constructor function
  97537. */
  97538. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  97539. /**
  97540. * Returns a node constructor based on type name
  97541. * @param type defines the type name
  97542. * @param name defines the new node name
  97543. * @param scene defines the hosting scene
  97544. * @param options defines optional options to transmit to constructors
  97545. * @returns the new constructor or null
  97546. */
  97547. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  97548. /**
  97549. * Gets or sets the name of the node
  97550. */
  97551. name: string;
  97552. /**
  97553. * Gets or sets the id of the node
  97554. */
  97555. id: string;
  97556. /**
  97557. * Gets or sets the unique id of the node
  97558. */
  97559. uniqueId: number;
  97560. /**
  97561. * Gets or sets a string used to store user defined state for the node
  97562. */
  97563. state: string;
  97564. /**
  97565. * Gets or sets an object used to store user defined information for the node
  97566. */
  97567. metadata: any;
  97568. /**
  97569. * For internal use only. Please do not use.
  97570. */
  97571. reservedDataStore: any;
  97572. /**
  97573. * List of inspectable custom properties (used by the Inspector)
  97574. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  97575. */
  97576. inspectableCustomProperties: IInspectable[];
  97577. private _doNotSerialize;
  97578. /**
  97579. * Gets or sets a boolean used to define if the node must be serialized
  97580. */
  97581. doNotSerialize: boolean;
  97582. /** @hidden */
  97583. _isDisposed: boolean;
  97584. /**
  97585. * Gets a list of Animations associated with the node
  97586. */
  97587. animations: Animation[];
  97588. protected _ranges: {
  97589. [name: string]: Nullable<AnimationRange>;
  97590. };
  97591. /**
  97592. * Callback raised when the node is ready to be used
  97593. */
  97594. onReady: Nullable<(node: Node) => void>;
  97595. private _isEnabled;
  97596. private _isParentEnabled;
  97597. private _isReady;
  97598. /** @hidden */
  97599. _currentRenderId: number;
  97600. private _parentUpdateId;
  97601. /** @hidden */
  97602. _childUpdateId: number;
  97603. /** @hidden */
  97604. _waitingParentId: Nullable<string>;
  97605. /** @hidden */
  97606. _scene: Scene;
  97607. /** @hidden */
  97608. _cache: any;
  97609. private _parentNode;
  97610. private _children;
  97611. /** @hidden */
  97612. _worldMatrix: Matrix;
  97613. /** @hidden */
  97614. _worldMatrixDeterminant: number;
  97615. /** @hidden */
  97616. _worldMatrixDeterminantIsDirty: boolean;
  97617. /** @hidden */
  97618. private _sceneRootNodesIndex;
  97619. /**
  97620. * Gets a boolean indicating if the node has been disposed
  97621. * @returns true if the node was disposed
  97622. */
  97623. isDisposed(): boolean;
  97624. /**
  97625. * Gets or sets the parent of the node (without keeping the current position in the scene)
  97626. * @see https://doc.babylonjs.com/how_to/parenting
  97627. */
  97628. parent: Nullable<Node>;
  97629. /** @hidden */
  97630. _addToSceneRootNodes(): void;
  97631. /** @hidden */
  97632. _removeFromSceneRootNodes(): void;
  97633. private _animationPropertiesOverride;
  97634. /**
  97635. * Gets or sets the animation properties override
  97636. */
  97637. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  97638. /**
  97639. * Gets a string idenfifying the name of the class
  97640. * @returns "Node" string
  97641. */
  97642. getClassName(): string;
  97643. /** @hidden */
  97644. readonly _isNode: boolean;
  97645. /**
  97646. * An event triggered when the mesh is disposed
  97647. */
  97648. onDisposeObservable: Observable<Node>;
  97649. private _onDisposeObserver;
  97650. /**
  97651. * Sets a callback that will be raised when the node will be disposed
  97652. */
  97653. onDispose: () => void;
  97654. /**
  97655. * Creates a new Node
  97656. * @param name the name and id to be given to this node
  97657. * @param scene the scene this node will be added to
  97658. */
  97659. constructor(name: string, scene?: Nullable<Scene>);
  97660. /**
  97661. * Gets the scene of the node
  97662. * @returns a scene
  97663. */
  97664. getScene(): Scene;
  97665. /**
  97666. * Gets the engine of the node
  97667. * @returns a Engine
  97668. */
  97669. getEngine(): Engine;
  97670. private _behaviors;
  97671. /**
  97672. * Attach a behavior to the node
  97673. * @see http://doc.babylonjs.com/features/behaviour
  97674. * @param behavior defines the behavior to attach
  97675. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  97676. * @returns the current Node
  97677. */
  97678. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  97679. /**
  97680. * Remove an attached behavior
  97681. * @see http://doc.babylonjs.com/features/behaviour
  97682. * @param behavior defines the behavior to attach
  97683. * @returns the current Node
  97684. */
  97685. removeBehavior(behavior: Behavior<Node>): Node;
  97686. /**
  97687. * Gets the list of attached behaviors
  97688. * @see http://doc.babylonjs.com/features/behaviour
  97689. */
  97690. readonly behaviors: Behavior<Node>[];
  97691. /**
  97692. * Gets an attached behavior by name
  97693. * @param name defines the name of the behavior to look for
  97694. * @see http://doc.babylonjs.com/features/behaviour
  97695. * @returns null if behavior was not found else the requested behavior
  97696. */
  97697. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  97698. /**
  97699. * Returns the latest update of the World matrix
  97700. * @returns a Matrix
  97701. */
  97702. getWorldMatrix(): Matrix;
  97703. /** @hidden */
  97704. _getWorldMatrixDeterminant(): number;
  97705. /**
  97706. * Returns directly the latest state of the mesh World matrix.
  97707. * A Matrix is returned.
  97708. */
  97709. readonly worldMatrixFromCache: Matrix;
  97710. /** @hidden */
  97711. _initCache(): void;
  97712. /** @hidden */
  97713. updateCache(force?: boolean): void;
  97714. /** @hidden */
  97715. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  97716. /** @hidden */
  97717. _updateCache(ignoreParentClass?: boolean): void;
  97718. /** @hidden */
  97719. _isSynchronized(): boolean;
  97720. /** @hidden */
  97721. _markSyncedWithParent(): void;
  97722. /** @hidden */
  97723. isSynchronizedWithParent(): boolean;
  97724. /** @hidden */
  97725. isSynchronized(): boolean;
  97726. /**
  97727. * Is this node ready to be used/rendered
  97728. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  97729. * @return true if the node is ready
  97730. */
  97731. isReady(completeCheck?: boolean): boolean;
  97732. /**
  97733. * Is this node enabled?
  97734. * 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
  97735. * @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
  97736. * @return whether this node (and its parent) is enabled
  97737. */
  97738. isEnabled(checkAncestors?: boolean): boolean;
  97739. /** @hidden */
  97740. protected _syncParentEnabledState(): void;
  97741. /**
  97742. * Set the enabled state of this node
  97743. * @param value defines the new enabled state
  97744. */
  97745. setEnabled(value: boolean): void;
  97746. /**
  97747. * Is this node a descendant of the given node?
  97748. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  97749. * @param ancestor defines the parent node to inspect
  97750. * @returns a boolean indicating if this node is a descendant of the given node
  97751. */
  97752. isDescendantOf(ancestor: Node): boolean;
  97753. /** @hidden */
  97754. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  97755. /**
  97756. * Will return all nodes that have this node as ascendant
  97757. * @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
  97758. * @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
  97759. * @return all children nodes of all types
  97760. */
  97761. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  97762. /**
  97763. * Get all child-meshes of this node
  97764. * @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)
  97765. * @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
  97766. * @returns an array of AbstractMesh
  97767. */
  97768. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  97769. /**
  97770. * Get all direct children of this node
  97771. * @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
  97772. * @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)
  97773. * @returns an array of Node
  97774. */
  97775. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  97776. /** @hidden */
  97777. _setReady(state: boolean): void;
  97778. /**
  97779. * Get an animation by name
  97780. * @param name defines the name of the animation to look for
  97781. * @returns null if not found else the requested animation
  97782. */
  97783. getAnimationByName(name: string): Nullable<Animation>;
  97784. /**
  97785. * Creates an animation range for this node
  97786. * @param name defines the name of the range
  97787. * @param from defines the starting key
  97788. * @param to defines the end key
  97789. */
  97790. createAnimationRange(name: string, from: number, to: number): void;
  97791. /**
  97792. * Delete a specific animation range
  97793. * @param name defines the name of the range to delete
  97794. * @param deleteFrames defines if animation frames from the range must be deleted as well
  97795. */
  97796. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  97797. /**
  97798. * Get an animation range by name
  97799. * @param name defines the name of the animation range to look for
  97800. * @returns null if not found else the requested animation range
  97801. */
  97802. getAnimationRange(name: string): Nullable<AnimationRange>;
  97803. /**
  97804. * Gets the list of all animation ranges defined on this node
  97805. * @returns an array
  97806. */
  97807. getAnimationRanges(): Nullable<AnimationRange>[];
  97808. /**
  97809. * Will start the animation sequence
  97810. * @param name defines the range frames for animation sequence
  97811. * @param loop defines if the animation should loop (false by default)
  97812. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  97813. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  97814. * @returns the object created for this animation. If range does not exist, it will return null
  97815. */
  97816. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  97817. /**
  97818. * Serialize animation ranges into a JSON compatible object
  97819. * @returns serialization object
  97820. */
  97821. serializeAnimationRanges(): any;
  97822. /**
  97823. * Computes the world matrix of the node
  97824. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  97825. * @returns the world matrix
  97826. */
  97827. computeWorldMatrix(force?: boolean): Matrix;
  97828. /**
  97829. * Releases resources associated with this node.
  97830. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  97831. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  97832. */
  97833. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  97834. /**
  97835. * Parse animation range data from a serialization object and store them into a given node
  97836. * @param node defines where to store the animation ranges
  97837. * @param parsedNode defines the serialization object to read data from
  97838. * @param scene defines the hosting scene
  97839. */
  97840. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  97841. /**
  97842. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  97843. * @param includeDescendants Include bounding info from descendants as well (true by default)
  97844. * @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
  97845. * @returns the new bounding vectors
  97846. */
  97847. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  97848. min: Vector3;
  97849. max: Vector3;
  97850. };
  97851. }
  97852. }
  97853. declare module BABYLON {
  97854. /**
  97855. * @hidden
  97856. */
  97857. export class _IAnimationState {
  97858. key: number;
  97859. repeatCount: number;
  97860. workValue?: any;
  97861. loopMode?: number;
  97862. offsetValue?: any;
  97863. highLimitValue?: any;
  97864. }
  97865. /**
  97866. * Class used to store any kind of animation
  97867. */
  97868. export class Animation {
  97869. /**Name of the animation */
  97870. name: string;
  97871. /**Property to animate */
  97872. targetProperty: string;
  97873. /**The frames per second of the animation */
  97874. framePerSecond: number;
  97875. /**The data type of the animation */
  97876. dataType: number;
  97877. /**The loop mode of the animation */
  97878. loopMode?: number | undefined;
  97879. /**Specifies if blending should be enabled */
  97880. enableBlending?: boolean | undefined;
  97881. /**
  97882. * Use matrix interpolation instead of using direct key value when animating matrices
  97883. */
  97884. static AllowMatricesInterpolation: boolean;
  97885. /**
  97886. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  97887. */
  97888. static AllowMatrixDecomposeForInterpolation: boolean;
  97889. /**
  97890. * Stores the key frames of the animation
  97891. */
  97892. private _keys;
  97893. /**
  97894. * Stores the easing function of the animation
  97895. */
  97896. private _easingFunction;
  97897. /**
  97898. * @hidden Internal use only
  97899. */
  97900. _runtimeAnimations: RuntimeAnimation[];
  97901. /**
  97902. * The set of event that will be linked to this animation
  97903. */
  97904. private _events;
  97905. /**
  97906. * Stores an array of target property paths
  97907. */
  97908. targetPropertyPath: string[];
  97909. /**
  97910. * Stores the blending speed of the animation
  97911. */
  97912. blendingSpeed: number;
  97913. /**
  97914. * Stores the animation ranges for the animation
  97915. */
  97916. private _ranges;
  97917. /**
  97918. * @hidden Internal use
  97919. */
  97920. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  97921. /**
  97922. * Sets up an animation
  97923. * @param property The property to animate
  97924. * @param animationType The animation type to apply
  97925. * @param framePerSecond The frames per second of the animation
  97926. * @param easingFunction The easing function used in the animation
  97927. * @returns The created animation
  97928. */
  97929. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  97930. /**
  97931. * Create and start an animation on a node
  97932. * @param name defines the name of the global animation that will be run on all nodes
  97933. * @param node defines the root node where the animation will take place
  97934. * @param targetProperty defines property to animate
  97935. * @param framePerSecond defines the number of frame per second yo use
  97936. * @param totalFrame defines the number of frames in total
  97937. * @param from defines the initial value
  97938. * @param to defines the final value
  97939. * @param loopMode defines which loop mode you want to use (off by default)
  97940. * @param easingFunction defines the easing function to use (linear by default)
  97941. * @param onAnimationEnd defines the callback to call when animation end
  97942. * @returns the animatable created for this animation
  97943. */
  97944. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  97945. /**
  97946. * Create and start an animation on a node and its descendants
  97947. * @param name defines the name of the global animation that will be run on all nodes
  97948. * @param node defines the root node where the animation will take place
  97949. * @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
  97950. * @param targetProperty defines property to animate
  97951. * @param framePerSecond defines the number of frame per second to use
  97952. * @param totalFrame defines the number of frames in total
  97953. * @param from defines the initial value
  97954. * @param to defines the final value
  97955. * @param loopMode defines which loop mode you want to use (off by default)
  97956. * @param easingFunction defines the easing function to use (linear by default)
  97957. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  97958. * @returns the list of animatables created for all nodes
  97959. * @example https://www.babylonjs-playground.com/#MH0VLI
  97960. */
  97961. 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[]>;
  97962. /**
  97963. * Creates a new animation, merges it with the existing animations and starts it
  97964. * @param name Name of the animation
  97965. * @param node Node which contains the scene that begins the animations
  97966. * @param targetProperty Specifies which property to animate
  97967. * @param framePerSecond The frames per second of the animation
  97968. * @param totalFrame The total number of frames
  97969. * @param from The frame at the beginning of the animation
  97970. * @param to The frame at the end of the animation
  97971. * @param loopMode Specifies the loop mode of the animation
  97972. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  97973. * @param onAnimationEnd Callback to run once the animation is complete
  97974. * @returns Nullable animation
  97975. */
  97976. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  97977. /**
  97978. * Transition property of an host to the target Value
  97979. * @param property The property to transition
  97980. * @param targetValue The target Value of the property
  97981. * @param host The object where the property to animate belongs
  97982. * @param scene Scene used to run the animation
  97983. * @param frameRate Framerate (in frame/s) to use
  97984. * @param transition The transition type we want to use
  97985. * @param duration The duration of the animation, in milliseconds
  97986. * @param onAnimationEnd Callback trigger at the end of the animation
  97987. * @returns Nullable animation
  97988. */
  97989. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  97990. /**
  97991. * Return the array of runtime animations currently using this animation
  97992. */
  97993. readonly runtimeAnimations: RuntimeAnimation[];
  97994. /**
  97995. * Specifies if any of the runtime animations are currently running
  97996. */
  97997. readonly hasRunningRuntimeAnimations: boolean;
  97998. /**
  97999. * Initializes the animation
  98000. * @param name Name of the animation
  98001. * @param targetProperty Property to animate
  98002. * @param framePerSecond The frames per second of the animation
  98003. * @param dataType The data type of the animation
  98004. * @param loopMode The loop mode of the animation
  98005. * @param enableBlending Specifies if blending should be enabled
  98006. */
  98007. constructor(
  98008. /**Name of the animation */
  98009. name: string,
  98010. /**Property to animate */
  98011. targetProperty: string,
  98012. /**The frames per second of the animation */
  98013. framePerSecond: number,
  98014. /**The data type of the animation */
  98015. dataType: number,
  98016. /**The loop mode of the animation */
  98017. loopMode?: number | undefined,
  98018. /**Specifies if blending should be enabled */
  98019. enableBlending?: boolean | undefined);
  98020. /**
  98021. * Converts the animation to a string
  98022. * @param fullDetails support for multiple levels of logging within scene loading
  98023. * @returns String form of the animation
  98024. */
  98025. toString(fullDetails?: boolean): string;
  98026. /**
  98027. * Add an event to this animation
  98028. * @param event Event to add
  98029. */
  98030. addEvent(event: AnimationEvent): void;
  98031. /**
  98032. * Remove all events found at the given frame
  98033. * @param frame The frame to remove events from
  98034. */
  98035. removeEvents(frame: number): void;
  98036. /**
  98037. * Retrieves all the events from the animation
  98038. * @returns Events from the animation
  98039. */
  98040. getEvents(): AnimationEvent[];
  98041. /**
  98042. * Creates an animation range
  98043. * @param name Name of the animation range
  98044. * @param from Starting frame of the animation range
  98045. * @param to Ending frame of the animation
  98046. */
  98047. createRange(name: string, from: number, to: number): void;
  98048. /**
  98049. * Deletes an animation range by name
  98050. * @param name Name of the animation range to delete
  98051. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  98052. */
  98053. deleteRange(name: string, deleteFrames?: boolean): void;
  98054. /**
  98055. * Gets the animation range by name, or null if not defined
  98056. * @param name Name of the animation range
  98057. * @returns Nullable animation range
  98058. */
  98059. getRange(name: string): Nullable<AnimationRange>;
  98060. /**
  98061. * Gets the key frames from the animation
  98062. * @returns The key frames of the animation
  98063. */
  98064. getKeys(): Array<IAnimationKey>;
  98065. /**
  98066. * Gets the highest frame rate of the animation
  98067. * @returns Highest frame rate of the animation
  98068. */
  98069. getHighestFrame(): number;
  98070. /**
  98071. * Gets the easing function of the animation
  98072. * @returns Easing function of the animation
  98073. */
  98074. getEasingFunction(): IEasingFunction;
  98075. /**
  98076. * Sets the easing function of the animation
  98077. * @param easingFunction A custom mathematical formula for animation
  98078. */
  98079. setEasingFunction(easingFunction: EasingFunction): void;
  98080. /**
  98081. * Interpolates a scalar linearly
  98082. * @param startValue Start value of the animation curve
  98083. * @param endValue End value of the animation curve
  98084. * @param gradient Scalar amount to interpolate
  98085. * @returns Interpolated scalar value
  98086. */
  98087. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  98088. /**
  98089. * Interpolates a scalar cubically
  98090. * @param startValue Start value of the animation curve
  98091. * @param outTangent End tangent of the animation
  98092. * @param endValue End value of the animation curve
  98093. * @param inTangent Start tangent of the animation curve
  98094. * @param gradient Scalar amount to interpolate
  98095. * @returns Interpolated scalar value
  98096. */
  98097. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  98098. /**
  98099. * Interpolates a quaternion using a spherical linear interpolation
  98100. * @param startValue Start value of the animation curve
  98101. * @param endValue End value of the animation curve
  98102. * @param gradient Scalar amount to interpolate
  98103. * @returns Interpolated quaternion value
  98104. */
  98105. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  98106. /**
  98107. * Interpolates a quaternion cubically
  98108. * @param startValue Start value of the animation curve
  98109. * @param outTangent End tangent of the animation curve
  98110. * @param endValue End value of the animation curve
  98111. * @param inTangent Start tangent of the animation curve
  98112. * @param gradient Scalar amount to interpolate
  98113. * @returns Interpolated quaternion value
  98114. */
  98115. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  98116. /**
  98117. * Interpolates a Vector3 linearl
  98118. * @param startValue Start value of the animation curve
  98119. * @param endValue End value of the animation curve
  98120. * @param gradient Scalar amount to interpolate
  98121. * @returns Interpolated scalar value
  98122. */
  98123. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  98124. /**
  98125. * Interpolates a Vector3 cubically
  98126. * @param startValue Start value of the animation curve
  98127. * @param outTangent End tangent of the animation
  98128. * @param endValue End value of the animation curve
  98129. * @param inTangent Start tangent of the animation curve
  98130. * @param gradient Scalar amount to interpolate
  98131. * @returns InterpolatedVector3 value
  98132. */
  98133. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  98134. /**
  98135. * Interpolates a Vector2 linearly
  98136. * @param startValue Start value of the animation curve
  98137. * @param endValue End value of the animation curve
  98138. * @param gradient Scalar amount to interpolate
  98139. * @returns Interpolated Vector2 value
  98140. */
  98141. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  98142. /**
  98143. * Interpolates a Vector2 cubically
  98144. * @param startValue Start value of the animation curve
  98145. * @param outTangent End tangent of the animation
  98146. * @param endValue End value of the animation curve
  98147. * @param inTangent Start tangent of the animation curve
  98148. * @param gradient Scalar amount to interpolate
  98149. * @returns Interpolated Vector2 value
  98150. */
  98151. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  98152. /**
  98153. * Interpolates a size linearly
  98154. * @param startValue Start value of the animation curve
  98155. * @param endValue End value of the animation curve
  98156. * @param gradient Scalar amount to interpolate
  98157. * @returns Interpolated Size value
  98158. */
  98159. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  98160. /**
  98161. * Interpolates a Color3 linearly
  98162. * @param startValue Start value of the animation curve
  98163. * @param endValue End value of the animation curve
  98164. * @param gradient Scalar amount to interpolate
  98165. * @returns Interpolated Color3 value
  98166. */
  98167. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  98168. /**
  98169. * Interpolates a Color4 linearly
  98170. * @param startValue Start value of the animation curve
  98171. * @param endValue End value of the animation curve
  98172. * @param gradient Scalar amount to interpolate
  98173. * @returns Interpolated Color3 value
  98174. */
  98175. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  98176. /**
  98177. * @hidden Internal use only
  98178. */
  98179. _getKeyValue(value: any): any;
  98180. /**
  98181. * @hidden Internal use only
  98182. */
  98183. _interpolate(currentFrame: number, state: _IAnimationState): any;
  98184. /**
  98185. * Defines the function to use to interpolate matrices
  98186. * @param startValue defines the start matrix
  98187. * @param endValue defines the end matrix
  98188. * @param gradient defines the gradient between both matrices
  98189. * @param result defines an optional target matrix where to store the interpolation
  98190. * @returns the interpolated matrix
  98191. */
  98192. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  98193. /**
  98194. * Makes a copy of the animation
  98195. * @returns Cloned animation
  98196. */
  98197. clone(): Animation;
  98198. /**
  98199. * Sets the key frames of the animation
  98200. * @param values The animation key frames to set
  98201. */
  98202. setKeys(values: Array<IAnimationKey>): void;
  98203. /**
  98204. * Serializes the animation to an object
  98205. * @returns Serialized object
  98206. */
  98207. serialize(): any;
  98208. /**
  98209. * Float animation type
  98210. */
  98211. static readonly ANIMATIONTYPE_FLOAT: number;
  98212. /**
  98213. * Vector3 animation type
  98214. */
  98215. static readonly ANIMATIONTYPE_VECTOR3: number;
  98216. /**
  98217. * Quaternion animation type
  98218. */
  98219. static readonly ANIMATIONTYPE_QUATERNION: number;
  98220. /**
  98221. * Matrix animation type
  98222. */
  98223. static readonly ANIMATIONTYPE_MATRIX: number;
  98224. /**
  98225. * Color3 animation type
  98226. */
  98227. static readonly ANIMATIONTYPE_COLOR3: number;
  98228. /**
  98229. * Color3 animation type
  98230. */
  98231. static readonly ANIMATIONTYPE_COLOR4: number;
  98232. /**
  98233. * Vector2 animation type
  98234. */
  98235. static readonly ANIMATIONTYPE_VECTOR2: number;
  98236. /**
  98237. * Size animation type
  98238. */
  98239. static readonly ANIMATIONTYPE_SIZE: number;
  98240. /**
  98241. * Relative Loop Mode
  98242. */
  98243. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  98244. /**
  98245. * Cycle Loop Mode
  98246. */
  98247. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  98248. /**
  98249. * Constant Loop Mode
  98250. */
  98251. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  98252. /** @hidden */
  98253. static _UniversalLerp(left: any, right: any, amount: number): any;
  98254. /**
  98255. * Parses an animation object and creates an animation
  98256. * @param parsedAnimation Parsed animation object
  98257. * @returns Animation object
  98258. */
  98259. static Parse(parsedAnimation: any): Animation;
  98260. /**
  98261. * Appends the serialized animations from the source animations
  98262. * @param source Source containing the animations
  98263. * @param destination Target to store the animations
  98264. */
  98265. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  98266. }
  98267. }
  98268. declare module BABYLON {
  98269. /**
  98270. * Interface containing an array of animations
  98271. */
  98272. export interface IAnimatable {
  98273. /**
  98274. * Array of animations
  98275. */
  98276. animations: Nullable<Array<Animation>>;
  98277. }
  98278. }
  98279. declare module BABYLON {
  98280. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  98281. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  98282. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  98283. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  98284. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  98285. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  98286. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  98287. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  98288. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  98289. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  98290. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  98291. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  98292. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  98293. /**
  98294. * Decorator used to define property that can be serialized as reference to a camera
  98295. * @param sourceName defines the name of the property to decorate
  98296. */
  98297. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  98298. /**
  98299. * Class used to help serialization objects
  98300. */
  98301. export class SerializationHelper {
  98302. /** @hidden */
  98303. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  98304. /** @hidden */
  98305. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  98306. /** @hidden */
  98307. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  98308. /** @hidden */
  98309. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  98310. /**
  98311. * Appends the serialized animations from the source animations
  98312. * @param source Source containing the animations
  98313. * @param destination Target to store the animations
  98314. */
  98315. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  98316. /**
  98317. * Static function used to serialized a specific entity
  98318. * @param entity defines the entity to serialize
  98319. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  98320. * @returns a JSON compatible object representing the serialization of the entity
  98321. */
  98322. static Serialize<T>(entity: T, serializationObject?: any): any;
  98323. /**
  98324. * Creates a new entity from a serialization data object
  98325. * @param creationFunction defines a function used to instanciated the new entity
  98326. * @param source defines the source serialization data
  98327. * @param scene defines the hosting scene
  98328. * @param rootUrl defines the root url for resources
  98329. * @returns a new entity
  98330. */
  98331. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  98332. /**
  98333. * Clones an object
  98334. * @param creationFunction defines the function used to instanciate the new object
  98335. * @param source defines the source object
  98336. * @returns the cloned object
  98337. */
  98338. static Clone<T>(creationFunction: () => T, source: T): T;
  98339. /**
  98340. * Instanciates a new object based on a source one (some data will be shared between both object)
  98341. * @param creationFunction defines the function used to instanciate the new object
  98342. * @param source defines the source object
  98343. * @returns the new object
  98344. */
  98345. static Instanciate<T>(creationFunction: () => T, source: T): T;
  98346. }
  98347. }
  98348. declare module BABYLON {
  98349. /**
  98350. * Class used to manipulate GUIDs
  98351. */
  98352. export class GUID {
  98353. /**
  98354. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  98355. * Be aware Math.random() could cause collisions, but:
  98356. * "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"
  98357. * @returns a pseudo random id
  98358. */
  98359. static RandomId(): string;
  98360. }
  98361. }
  98362. declare module BABYLON {
  98363. /**
  98364. * Base class of all the textures in babylon.
  98365. * It groups all the common properties the materials, post process, lights... might need
  98366. * in order to make a correct use of the texture.
  98367. */
  98368. export class BaseTexture implements IAnimatable {
  98369. /**
  98370. * Default anisotropic filtering level for the application.
  98371. * It is set to 4 as a good tradeoff between perf and quality.
  98372. */
  98373. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  98374. /**
  98375. * Gets or sets the unique id of the texture
  98376. */
  98377. uniqueId: number;
  98378. /**
  98379. * Define the name of the texture.
  98380. */
  98381. name: string;
  98382. /**
  98383. * Gets or sets an object used to store user defined information.
  98384. */
  98385. metadata: any;
  98386. /**
  98387. * For internal use only. Please do not use.
  98388. */
  98389. reservedDataStore: any;
  98390. private _hasAlpha;
  98391. /**
  98392. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  98393. */
  98394. hasAlpha: boolean;
  98395. /**
  98396. * Defines if the alpha value should be determined via the rgb values.
  98397. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  98398. */
  98399. getAlphaFromRGB: boolean;
  98400. /**
  98401. * Intensity or strength of the texture.
  98402. * It is commonly used by materials to fine tune the intensity of the texture
  98403. */
  98404. level: number;
  98405. /**
  98406. * Define the UV chanel to use starting from 0 and defaulting to 0.
  98407. * This is part of the texture as textures usually maps to one uv set.
  98408. */
  98409. coordinatesIndex: number;
  98410. private _coordinatesMode;
  98411. /**
  98412. * How a texture is mapped.
  98413. *
  98414. * | Value | Type | Description |
  98415. * | ----- | ----------------------------------- | ----------- |
  98416. * | 0 | EXPLICIT_MODE | |
  98417. * | 1 | SPHERICAL_MODE | |
  98418. * | 2 | PLANAR_MODE | |
  98419. * | 3 | CUBIC_MODE | |
  98420. * | 4 | PROJECTION_MODE | |
  98421. * | 5 | SKYBOX_MODE | |
  98422. * | 6 | INVCUBIC_MODE | |
  98423. * | 7 | EQUIRECTANGULAR_MODE | |
  98424. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  98425. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  98426. */
  98427. coordinatesMode: number;
  98428. /**
  98429. * | Value | Type | Description |
  98430. * | ----- | ------------------ | ----------- |
  98431. * | 0 | CLAMP_ADDRESSMODE | |
  98432. * | 1 | WRAP_ADDRESSMODE | |
  98433. * | 2 | MIRROR_ADDRESSMODE | |
  98434. */
  98435. wrapU: number;
  98436. /**
  98437. * | Value | Type | Description |
  98438. * | ----- | ------------------ | ----------- |
  98439. * | 0 | CLAMP_ADDRESSMODE | |
  98440. * | 1 | WRAP_ADDRESSMODE | |
  98441. * | 2 | MIRROR_ADDRESSMODE | |
  98442. */
  98443. wrapV: number;
  98444. /**
  98445. * | Value | Type | Description |
  98446. * | ----- | ------------------ | ----------- |
  98447. * | 0 | CLAMP_ADDRESSMODE | |
  98448. * | 1 | WRAP_ADDRESSMODE | |
  98449. * | 2 | MIRROR_ADDRESSMODE | |
  98450. */
  98451. wrapR: number;
  98452. /**
  98453. * With compliant hardware and browser (supporting anisotropic filtering)
  98454. * this defines the level of anisotropic filtering in the texture.
  98455. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  98456. */
  98457. anisotropicFilteringLevel: number;
  98458. /**
  98459. * Define if the texture is a cube texture or if false a 2d texture.
  98460. */
  98461. isCube: boolean;
  98462. /**
  98463. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  98464. */
  98465. is3D: boolean;
  98466. /**
  98467. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  98468. */
  98469. is2DArray: boolean;
  98470. /**
  98471. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  98472. * HDR texture are usually stored in linear space.
  98473. * This only impacts the PBR and Background materials
  98474. */
  98475. gammaSpace: boolean;
  98476. /**
  98477. * Gets or sets whether or not the texture contains RGBD data.
  98478. */
  98479. isRGBD: boolean;
  98480. /**
  98481. * Is Z inverted in the texture (useful in a cube texture).
  98482. */
  98483. invertZ: boolean;
  98484. /**
  98485. * Are mip maps generated for this texture or not.
  98486. */
  98487. readonly noMipmap: boolean;
  98488. /**
  98489. * @hidden
  98490. */
  98491. lodLevelInAlpha: boolean;
  98492. /**
  98493. * With prefiltered texture, defined the offset used during the prefiltering steps.
  98494. */
  98495. lodGenerationOffset: number;
  98496. /**
  98497. * With prefiltered texture, defined the scale used during the prefiltering steps.
  98498. */
  98499. lodGenerationScale: number;
  98500. /**
  98501. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  98502. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  98503. * average roughness values.
  98504. */
  98505. linearSpecularLOD: boolean;
  98506. /**
  98507. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  98508. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  98509. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  98510. */
  98511. irradianceTexture: Nullable<BaseTexture>;
  98512. /**
  98513. * Define if the texture is a render target.
  98514. */
  98515. isRenderTarget: boolean;
  98516. /**
  98517. * Define the unique id of the texture in the scene.
  98518. */
  98519. readonly uid: string;
  98520. /**
  98521. * Return a string representation of the texture.
  98522. * @returns the texture as a string
  98523. */
  98524. toString(): string;
  98525. /**
  98526. * Get the class name of the texture.
  98527. * @returns "BaseTexture"
  98528. */
  98529. getClassName(): string;
  98530. /**
  98531. * Define the list of animation attached to the texture.
  98532. */
  98533. animations: Animation[];
  98534. /**
  98535. * An event triggered when the texture is disposed.
  98536. */
  98537. onDisposeObservable: Observable<BaseTexture>;
  98538. private _onDisposeObserver;
  98539. /**
  98540. * Callback triggered when the texture has been disposed.
  98541. * Kept for back compatibility, you can use the onDisposeObservable instead.
  98542. */
  98543. onDispose: () => void;
  98544. /**
  98545. * Define the current state of the loading sequence when in delayed load mode.
  98546. */
  98547. delayLoadState: number;
  98548. private _scene;
  98549. /** @hidden */
  98550. _texture: Nullable<InternalTexture>;
  98551. private _uid;
  98552. /**
  98553. * Define if the texture is preventinga material to render or not.
  98554. * If not and the texture is not ready, the engine will use a default black texture instead.
  98555. */
  98556. readonly isBlocking: boolean;
  98557. /**
  98558. * Instantiates a new BaseTexture.
  98559. * Base class of all the textures in babylon.
  98560. * It groups all the common properties the materials, post process, lights... might need
  98561. * in order to make a correct use of the texture.
  98562. * @param scene Define the scene the texture blongs to
  98563. */
  98564. constructor(scene: Nullable<Scene>);
  98565. /**
  98566. * Get the scene the texture belongs to.
  98567. * @returns the scene or null if undefined
  98568. */
  98569. getScene(): Nullable<Scene>;
  98570. /**
  98571. * Get the texture transform matrix used to offset tile the texture for istance.
  98572. * @returns the transformation matrix
  98573. */
  98574. getTextureMatrix(): Matrix;
  98575. /**
  98576. * Get the texture reflection matrix used to rotate/transform the reflection.
  98577. * @returns the reflection matrix
  98578. */
  98579. getReflectionTextureMatrix(): Matrix;
  98580. /**
  98581. * Get the underlying lower level texture from Babylon.
  98582. * @returns the insternal texture
  98583. */
  98584. getInternalTexture(): Nullable<InternalTexture>;
  98585. /**
  98586. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  98587. * @returns true if ready or not blocking
  98588. */
  98589. isReadyOrNotBlocking(): boolean;
  98590. /**
  98591. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  98592. * @returns true if fully ready
  98593. */
  98594. isReady(): boolean;
  98595. private _cachedSize;
  98596. /**
  98597. * Get the size of the texture.
  98598. * @returns the texture size.
  98599. */
  98600. getSize(): ISize;
  98601. /**
  98602. * Get the base size of the texture.
  98603. * It can be different from the size if the texture has been resized for POT for instance
  98604. * @returns the base size
  98605. */
  98606. getBaseSize(): ISize;
  98607. /**
  98608. * Update the sampling mode of the texture.
  98609. * Default is Trilinear mode.
  98610. *
  98611. * | Value | Type | Description |
  98612. * | ----- | ------------------ | ----------- |
  98613. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  98614. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  98615. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  98616. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  98617. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  98618. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  98619. * | 7 | NEAREST_LINEAR | |
  98620. * | 8 | NEAREST_NEAREST | |
  98621. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  98622. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  98623. * | 11 | LINEAR_LINEAR | |
  98624. * | 12 | LINEAR_NEAREST | |
  98625. *
  98626. * > _mag_: magnification filter (close to the viewer)
  98627. * > _min_: minification filter (far from the viewer)
  98628. * > _mip_: filter used between mip map levels
  98629. *@param samplingMode Define the new sampling mode of the texture
  98630. */
  98631. updateSamplingMode(samplingMode: number): void;
  98632. /**
  98633. * Scales the texture if is `canRescale()`
  98634. * @param ratio the resize factor we want to use to rescale
  98635. */
  98636. scale(ratio: number): void;
  98637. /**
  98638. * Get if the texture can rescale.
  98639. */
  98640. readonly canRescale: boolean;
  98641. /** @hidden */
  98642. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  98643. /** @hidden */
  98644. _rebuild(): void;
  98645. /**
  98646. * Triggers the load sequence in delayed load mode.
  98647. */
  98648. delayLoad(): void;
  98649. /**
  98650. * Clones the texture.
  98651. * @returns the cloned texture
  98652. */
  98653. clone(): Nullable<BaseTexture>;
  98654. /**
  98655. * Get the texture underlying type (INT, FLOAT...)
  98656. */
  98657. readonly textureType: number;
  98658. /**
  98659. * Get the texture underlying format (RGB, RGBA...)
  98660. */
  98661. readonly textureFormat: number;
  98662. /**
  98663. * Indicates that textures need to be re-calculated for all materials
  98664. */
  98665. protected _markAllSubMeshesAsTexturesDirty(): void;
  98666. /**
  98667. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  98668. * This will returns an RGBA array buffer containing either in values (0-255) or
  98669. * float values (0-1) depending of the underlying buffer type.
  98670. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  98671. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  98672. * @param buffer defines a user defined buffer to fill with data (can be null)
  98673. * @returns The Array buffer containing the pixels data.
  98674. */
  98675. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  98676. /**
  98677. * Release and destroy the underlying lower level texture aka internalTexture.
  98678. */
  98679. releaseInternalTexture(): void;
  98680. /** @hidden */
  98681. readonly _lodTextureHigh: Nullable<BaseTexture>;
  98682. /** @hidden */
  98683. readonly _lodTextureMid: Nullable<BaseTexture>;
  98684. /** @hidden */
  98685. readonly _lodTextureLow: Nullable<BaseTexture>;
  98686. /**
  98687. * Dispose the texture and release its associated resources.
  98688. */
  98689. dispose(): void;
  98690. /**
  98691. * Serialize the texture into a JSON representation that can be parsed later on.
  98692. * @returns the JSON representation of the texture
  98693. */
  98694. serialize(): any;
  98695. /**
  98696. * Helper function to be called back once a list of texture contains only ready textures.
  98697. * @param textures Define the list of textures to wait for
  98698. * @param callback Define the callback triggered once the entire list will be ready
  98699. */
  98700. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  98701. }
  98702. }
  98703. declare module BABYLON {
  98704. /**
  98705. * Options to be used when creating an effect.
  98706. */
  98707. export interface IEffectCreationOptions {
  98708. /**
  98709. * Atrributes that will be used in the shader.
  98710. */
  98711. attributes: string[];
  98712. /**
  98713. * Uniform varible names that will be set in the shader.
  98714. */
  98715. uniformsNames: string[];
  98716. /**
  98717. * Uniform buffer variable names that will be set in the shader.
  98718. */
  98719. uniformBuffersNames: string[];
  98720. /**
  98721. * Sampler texture variable names that will be set in the shader.
  98722. */
  98723. samplers: string[];
  98724. /**
  98725. * Define statements that will be set in the shader.
  98726. */
  98727. defines: any;
  98728. /**
  98729. * Possible fallbacks for this effect to improve performance when needed.
  98730. */
  98731. fallbacks: Nullable<IEffectFallbacks>;
  98732. /**
  98733. * Callback that will be called when the shader is compiled.
  98734. */
  98735. onCompiled: Nullable<(effect: Effect) => void>;
  98736. /**
  98737. * Callback that will be called if an error occurs during shader compilation.
  98738. */
  98739. onError: Nullable<(effect: Effect, errors: string) => void>;
  98740. /**
  98741. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  98742. */
  98743. indexParameters?: any;
  98744. /**
  98745. * Max number of lights that can be used in the shader.
  98746. */
  98747. maxSimultaneousLights?: number;
  98748. /**
  98749. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  98750. */
  98751. transformFeedbackVaryings?: Nullable<string[]>;
  98752. }
  98753. /**
  98754. * Effect containing vertex and fragment shader that can be executed on an object.
  98755. */
  98756. export class Effect implements IDisposable {
  98757. /**
  98758. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  98759. */
  98760. static ShadersRepository: string;
  98761. /**
  98762. * Name of the effect.
  98763. */
  98764. name: any;
  98765. /**
  98766. * String container all the define statements that should be set on the shader.
  98767. */
  98768. defines: string;
  98769. /**
  98770. * Callback that will be called when the shader is compiled.
  98771. */
  98772. onCompiled: Nullable<(effect: Effect) => void>;
  98773. /**
  98774. * Callback that will be called if an error occurs during shader compilation.
  98775. */
  98776. onError: Nullable<(effect: Effect, errors: string) => void>;
  98777. /**
  98778. * Callback that will be called when effect is bound.
  98779. */
  98780. onBind: Nullable<(effect: Effect) => void>;
  98781. /**
  98782. * Unique ID of the effect.
  98783. */
  98784. uniqueId: number;
  98785. /**
  98786. * Observable that will be called when the shader is compiled.
  98787. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  98788. */
  98789. onCompileObservable: Observable<Effect>;
  98790. /**
  98791. * Observable that will be called if an error occurs during shader compilation.
  98792. */
  98793. onErrorObservable: Observable<Effect>;
  98794. /** @hidden */
  98795. _onBindObservable: Nullable<Observable<Effect>>;
  98796. /**
  98797. * Observable that will be called when effect is bound.
  98798. */
  98799. readonly onBindObservable: Observable<Effect>;
  98800. /** @hidden */
  98801. _bonesComputationForcedToCPU: boolean;
  98802. private static _uniqueIdSeed;
  98803. private _engine;
  98804. private _uniformBuffersNames;
  98805. private _uniformsNames;
  98806. private _samplerList;
  98807. private _samplers;
  98808. private _isReady;
  98809. private _compilationError;
  98810. private _allFallbacksProcessed;
  98811. private _attributesNames;
  98812. private _attributes;
  98813. private _uniforms;
  98814. /**
  98815. * Key for the effect.
  98816. * @hidden
  98817. */
  98818. _key: string;
  98819. private _indexParameters;
  98820. private _fallbacks;
  98821. private _vertexSourceCode;
  98822. private _fragmentSourceCode;
  98823. private _vertexSourceCodeOverride;
  98824. private _fragmentSourceCodeOverride;
  98825. private _transformFeedbackVaryings;
  98826. /**
  98827. * Compiled shader to webGL program.
  98828. * @hidden
  98829. */
  98830. _pipelineContext: Nullable<IPipelineContext>;
  98831. private _valueCache;
  98832. private static _baseCache;
  98833. /**
  98834. * Instantiates an effect.
  98835. * An effect can be used to create/manage/execute vertex and fragment shaders.
  98836. * @param baseName Name of the effect.
  98837. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  98838. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  98839. * @param samplers List of sampler variables that will be passed to the shader.
  98840. * @param engine Engine to be used to render the effect
  98841. * @param defines Define statements to be added to the shader.
  98842. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  98843. * @param onCompiled Callback that will be called when the shader is compiled.
  98844. * @param onError Callback that will be called if an error occurs during shader compilation.
  98845. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  98846. */
  98847. constructor(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  98848. private _useFinalCode;
  98849. /**
  98850. * Unique key for this effect
  98851. */
  98852. readonly key: string;
  98853. /**
  98854. * If the effect has been compiled and prepared.
  98855. * @returns if the effect is compiled and prepared.
  98856. */
  98857. isReady(): boolean;
  98858. private _isReadyInternal;
  98859. /**
  98860. * The engine the effect was initialized with.
  98861. * @returns the engine.
  98862. */
  98863. getEngine(): Engine;
  98864. /**
  98865. * The pipeline context for this effect
  98866. * @returns the associated pipeline context
  98867. */
  98868. getPipelineContext(): Nullable<IPipelineContext>;
  98869. /**
  98870. * The set of names of attribute variables for the shader.
  98871. * @returns An array of attribute names.
  98872. */
  98873. getAttributesNames(): string[];
  98874. /**
  98875. * Returns the attribute at the given index.
  98876. * @param index The index of the attribute.
  98877. * @returns The location of the attribute.
  98878. */
  98879. getAttributeLocation(index: number): number;
  98880. /**
  98881. * Returns the attribute based on the name of the variable.
  98882. * @param name of the attribute to look up.
  98883. * @returns the attribute location.
  98884. */
  98885. getAttributeLocationByName(name: string): number;
  98886. /**
  98887. * The number of attributes.
  98888. * @returns the numnber of attributes.
  98889. */
  98890. getAttributesCount(): number;
  98891. /**
  98892. * Gets the index of a uniform variable.
  98893. * @param uniformName of the uniform to look up.
  98894. * @returns the index.
  98895. */
  98896. getUniformIndex(uniformName: string): number;
  98897. /**
  98898. * Returns the attribute based on the name of the variable.
  98899. * @param uniformName of the uniform to look up.
  98900. * @returns the location of the uniform.
  98901. */
  98902. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  98903. /**
  98904. * Returns an array of sampler variable names
  98905. * @returns The array of sampler variable neames.
  98906. */
  98907. getSamplers(): string[];
  98908. /**
  98909. * The error from the last compilation.
  98910. * @returns the error string.
  98911. */
  98912. getCompilationError(): string;
  98913. /**
  98914. * Gets a boolean indicating that all fallbacks were used during compilation
  98915. * @returns true if all fallbacks were used
  98916. */
  98917. allFallbacksProcessed(): boolean;
  98918. /**
  98919. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  98920. * @param func The callback to be used.
  98921. */
  98922. executeWhenCompiled(func: (effect: Effect) => void): void;
  98923. private _checkIsReady;
  98924. private _loadShader;
  98925. /**
  98926. * Recompiles the webGL program
  98927. * @param vertexSourceCode The source code for the vertex shader.
  98928. * @param fragmentSourceCode The source code for the fragment shader.
  98929. * @param onCompiled Callback called when completed.
  98930. * @param onError Callback called on error.
  98931. * @hidden
  98932. */
  98933. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  98934. /**
  98935. * Prepares the effect
  98936. * @hidden
  98937. */
  98938. _prepareEffect(): void;
  98939. private _processCompilationErrors;
  98940. /**
  98941. * Checks if the effect is supported. (Must be called after compilation)
  98942. */
  98943. readonly isSupported: boolean;
  98944. /**
  98945. * Binds a texture to the engine to be used as output of the shader.
  98946. * @param channel Name of the output variable.
  98947. * @param texture Texture to bind.
  98948. * @hidden
  98949. */
  98950. _bindTexture(channel: string, texture: InternalTexture): void;
  98951. /**
  98952. * Sets a texture on the engine to be used in the shader.
  98953. * @param channel Name of the sampler variable.
  98954. * @param texture Texture to set.
  98955. */
  98956. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  98957. /**
  98958. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  98959. * @param channel Name of the sampler variable.
  98960. * @param texture Texture to set.
  98961. */
  98962. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  98963. /**
  98964. * Sets an array of textures on the engine to be used in the shader.
  98965. * @param channel Name of the variable.
  98966. * @param textures Textures to set.
  98967. */
  98968. setTextureArray(channel: string, textures: BaseTexture[]): void;
  98969. /**
  98970. * 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)
  98971. * @param channel Name of the sampler variable.
  98972. * @param postProcess Post process to get the input texture from.
  98973. */
  98974. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  98975. /**
  98976. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  98977. * 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)
  98978. * @param channel Name of the sampler variable.
  98979. * @param postProcess Post process to get the output texture from.
  98980. */
  98981. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  98982. /** @hidden */
  98983. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  98984. /** @hidden */
  98985. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  98986. /** @hidden */
  98987. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  98988. /** @hidden */
  98989. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  98990. /**
  98991. * Binds a buffer to a uniform.
  98992. * @param buffer Buffer to bind.
  98993. * @param name Name of the uniform variable to bind to.
  98994. */
  98995. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  98996. /**
  98997. * Binds block to a uniform.
  98998. * @param blockName Name of the block to bind.
  98999. * @param index Index to bind.
  99000. */
  99001. bindUniformBlock(blockName: string, index: number): void;
  99002. /**
  99003. * Sets an interger value on a uniform variable.
  99004. * @param uniformName Name of the variable.
  99005. * @param value Value to be set.
  99006. * @returns this effect.
  99007. */
  99008. setInt(uniformName: string, value: number): Effect;
  99009. /**
  99010. * Sets an int array on a uniform variable.
  99011. * @param uniformName Name of the variable.
  99012. * @param array array to be set.
  99013. * @returns this effect.
  99014. */
  99015. setIntArray(uniformName: string, array: Int32Array): Effect;
  99016. /**
  99017. * 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)
  99018. * @param uniformName Name of the variable.
  99019. * @param array array to be set.
  99020. * @returns this effect.
  99021. */
  99022. setIntArray2(uniformName: string, array: Int32Array): Effect;
  99023. /**
  99024. * 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)
  99025. * @param uniformName Name of the variable.
  99026. * @param array array to be set.
  99027. * @returns this effect.
  99028. */
  99029. setIntArray3(uniformName: string, array: Int32Array): Effect;
  99030. /**
  99031. * 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)
  99032. * @param uniformName Name of the variable.
  99033. * @param array array to be set.
  99034. * @returns this effect.
  99035. */
  99036. setIntArray4(uniformName: string, array: Int32Array): Effect;
  99037. /**
  99038. * Sets an float array on a uniform variable.
  99039. * @param uniformName Name of the variable.
  99040. * @param array array to be set.
  99041. * @returns this effect.
  99042. */
  99043. setFloatArray(uniformName: string, array: Float32Array): Effect;
  99044. /**
  99045. * 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)
  99046. * @param uniformName Name of the variable.
  99047. * @param array array to be set.
  99048. * @returns this effect.
  99049. */
  99050. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  99051. /**
  99052. * 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)
  99053. * @param uniformName Name of the variable.
  99054. * @param array array to be set.
  99055. * @returns this effect.
  99056. */
  99057. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  99058. /**
  99059. * 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)
  99060. * @param uniformName Name of the variable.
  99061. * @param array array to be set.
  99062. * @returns this effect.
  99063. */
  99064. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  99065. /**
  99066. * Sets an array on a uniform variable.
  99067. * @param uniformName Name of the variable.
  99068. * @param array array to be set.
  99069. * @returns this effect.
  99070. */
  99071. setArray(uniformName: string, array: number[]): Effect;
  99072. /**
  99073. * 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)
  99074. * @param uniformName Name of the variable.
  99075. * @param array array to be set.
  99076. * @returns this effect.
  99077. */
  99078. setArray2(uniformName: string, array: number[]): Effect;
  99079. /**
  99080. * 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)
  99081. * @param uniformName Name of the variable.
  99082. * @param array array to be set.
  99083. * @returns this effect.
  99084. */
  99085. setArray3(uniformName: string, array: number[]): Effect;
  99086. /**
  99087. * 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)
  99088. * @param uniformName Name of the variable.
  99089. * @param array array to be set.
  99090. * @returns this effect.
  99091. */
  99092. setArray4(uniformName: string, array: number[]): Effect;
  99093. /**
  99094. * Sets matrices on a uniform variable.
  99095. * @param uniformName Name of the variable.
  99096. * @param matrices matrices to be set.
  99097. * @returns this effect.
  99098. */
  99099. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  99100. /**
  99101. * Sets matrix on a uniform variable.
  99102. * @param uniformName Name of the variable.
  99103. * @param matrix matrix to be set.
  99104. * @returns this effect.
  99105. */
  99106. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  99107. /**
  99108. * 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)
  99109. * @param uniformName Name of the variable.
  99110. * @param matrix matrix to be set.
  99111. * @returns this effect.
  99112. */
  99113. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  99114. /**
  99115. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  99116. * @param uniformName Name of the variable.
  99117. * @param matrix matrix to be set.
  99118. * @returns this effect.
  99119. */
  99120. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  99121. /**
  99122. * Sets a float on a uniform variable.
  99123. * @param uniformName Name of the variable.
  99124. * @param value value to be set.
  99125. * @returns this effect.
  99126. */
  99127. setFloat(uniformName: string, value: number): Effect;
  99128. /**
  99129. * Sets a boolean on a uniform variable.
  99130. * @param uniformName Name of the variable.
  99131. * @param bool value to be set.
  99132. * @returns this effect.
  99133. */
  99134. setBool(uniformName: string, bool: boolean): Effect;
  99135. /**
  99136. * Sets a Vector2 on a uniform variable.
  99137. * @param uniformName Name of the variable.
  99138. * @param vector2 vector2 to be set.
  99139. * @returns this effect.
  99140. */
  99141. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  99142. /**
  99143. * Sets a float2 on a uniform variable.
  99144. * @param uniformName Name of the variable.
  99145. * @param x First float in float2.
  99146. * @param y Second float in float2.
  99147. * @returns this effect.
  99148. */
  99149. setFloat2(uniformName: string, x: number, y: number): Effect;
  99150. /**
  99151. * Sets a Vector3 on a uniform variable.
  99152. * @param uniformName Name of the variable.
  99153. * @param vector3 Value to be set.
  99154. * @returns this effect.
  99155. */
  99156. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  99157. /**
  99158. * Sets a float3 on a uniform variable.
  99159. * @param uniformName Name of the variable.
  99160. * @param x First float in float3.
  99161. * @param y Second float in float3.
  99162. * @param z Third float in float3.
  99163. * @returns this effect.
  99164. */
  99165. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  99166. /**
  99167. * Sets a Vector4 on a uniform variable.
  99168. * @param uniformName Name of the variable.
  99169. * @param vector4 Value to be set.
  99170. * @returns this effect.
  99171. */
  99172. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  99173. /**
  99174. * Sets a float4 on a uniform variable.
  99175. * @param uniformName Name of the variable.
  99176. * @param x First float in float4.
  99177. * @param y Second float in float4.
  99178. * @param z Third float in float4.
  99179. * @param w Fourth float in float4.
  99180. * @returns this effect.
  99181. */
  99182. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  99183. /**
  99184. * Sets a Color3 on a uniform variable.
  99185. * @param uniformName Name of the variable.
  99186. * @param color3 Value to be set.
  99187. * @returns this effect.
  99188. */
  99189. setColor3(uniformName: string, color3: IColor3Like): Effect;
  99190. /**
  99191. * Sets a Color4 on a uniform variable.
  99192. * @param uniformName Name of the variable.
  99193. * @param color3 Value to be set.
  99194. * @param alpha Alpha value to be set.
  99195. * @returns this effect.
  99196. */
  99197. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  99198. /**
  99199. * Sets a Color4 on a uniform variable
  99200. * @param uniformName defines the name of the variable
  99201. * @param color4 defines the value to be set
  99202. * @returns this effect.
  99203. */
  99204. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  99205. /** Release all associated resources */
  99206. dispose(): void;
  99207. /**
  99208. * This function will add a new shader to the shader store
  99209. * @param name the name of the shader
  99210. * @param pixelShader optional pixel shader content
  99211. * @param vertexShader optional vertex shader content
  99212. */
  99213. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  99214. /**
  99215. * Store of each shader (The can be looked up using effect.key)
  99216. */
  99217. static ShadersStore: {
  99218. [key: string]: string;
  99219. };
  99220. /**
  99221. * Store of each included file for a shader (The can be looked up using effect.key)
  99222. */
  99223. static IncludesShadersStore: {
  99224. [key: string]: string;
  99225. };
  99226. /**
  99227. * Resets the cache of effects.
  99228. */
  99229. static ResetCache(): void;
  99230. }
  99231. }
  99232. declare module BABYLON {
  99233. /**
  99234. * Interface used to describe the capabilities of the engine relatively to the current browser
  99235. */
  99236. export interface EngineCapabilities {
  99237. /** Maximum textures units per fragment shader */
  99238. maxTexturesImageUnits: number;
  99239. /** Maximum texture units per vertex shader */
  99240. maxVertexTextureImageUnits: number;
  99241. /** Maximum textures units in the entire pipeline */
  99242. maxCombinedTexturesImageUnits: number;
  99243. /** Maximum texture size */
  99244. maxTextureSize: number;
  99245. /** Maximum texture samples */
  99246. maxSamples?: number;
  99247. /** Maximum cube texture size */
  99248. maxCubemapTextureSize: number;
  99249. /** Maximum render texture size */
  99250. maxRenderTextureSize: number;
  99251. /** Maximum number of vertex attributes */
  99252. maxVertexAttribs: number;
  99253. /** Maximum number of varyings */
  99254. maxVaryingVectors: number;
  99255. /** Maximum number of uniforms per vertex shader */
  99256. maxVertexUniformVectors: number;
  99257. /** Maximum number of uniforms per fragment shader */
  99258. maxFragmentUniformVectors: number;
  99259. /** Defines if standard derivates (dx/dy) are supported */
  99260. standardDerivatives: boolean;
  99261. /** Defines if s3tc texture compression is supported */
  99262. s3tc?: WEBGL_compressed_texture_s3tc;
  99263. /** Defines if pvrtc texture compression is supported */
  99264. pvrtc: any;
  99265. /** Defines if etc1 texture compression is supported */
  99266. etc1: any;
  99267. /** Defines if etc2 texture compression is supported */
  99268. etc2: any;
  99269. /** Defines if astc texture compression is supported */
  99270. astc: any;
  99271. /** Defines if float textures are supported */
  99272. textureFloat: boolean;
  99273. /** Defines if vertex array objects are supported */
  99274. vertexArrayObject: boolean;
  99275. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  99276. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  99277. /** Gets the maximum level of anisotropy supported */
  99278. maxAnisotropy: number;
  99279. /** Defines if instancing is supported */
  99280. instancedArrays: boolean;
  99281. /** Defines if 32 bits indices are supported */
  99282. uintIndices: boolean;
  99283. /** Defines if high precision shaders are supported */
  99284. highPrecisionShaderSupported: boolean;
  99285. /** Defines if depth reading in the fragment shader is supported */
  99286. fragmentDepthSupported: boolean;
  99287. /** Defines if float texture linear filtering is supported*/
  99288. textureFloatLinearFiltering: boolean;
  99289. /** Defines if rendering to float textures is supported */
  99290. textureFloatRender: boolean;
  99291. /** Defines if half float textures are supported*/
  99292. textureHalfFloat: boolean;
  99293. /** Defines if half float texture linear filtering is supported*/
  99294. textureHalfFloatLinearFiltering: boolean;
  99295. /** Defines if rendering to half float textures is supported */
  99296. textureHalfFloatRender: boolean;
  99297. /** Defines if textureLOD shader command is supported */
  99298. textureLOD: boolean;
  99299. /** Defines if draw buffers extension is supported */
  99300. drawBuffersExtension: boolean;
  99301. /** Defines if depth textures are supported */
  99302. depthTextureExtension: boolean;
  99303. /** Defines if float color buffer are supported */
  99304. colorBufferFloat: boolean;
  99305. /** Gets disjoint timer query extension (null if not supported) */
  99306. timerQuery?: EXT_disjoint_timer_query;
  99307. /** Defines if timestamp can be used with timer query */
  99308. canUseTimestampForTimerQuery: boolean;
  99309. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  99310. multiview?: any;
  99311. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  99312. oculusMultiview?: any;
  99313. /** Function used to let the system compiles shaders in background */
  99314. parallelShaderCompile?: {
  99315. COMPLETION_STATUS_KHR: number;
  99316. };
  99317. /** Max number of texture samples for MSAA */
  99318. maxMSAASamples: number;
  99319. /** Defines if the blend min max extension is supported */
  99320. blendMinMax: boolean;
  99321. }
  99322. }
  99323. declare module BABYLON {
  99324. /**
  99325. * @hidden
  99326. **/
  99327. export class DepthCullingState {
  99328. private _isDepthTestDirty;
  99329. private _isDepthMaskDirty;
  99330. private _isDepthFuncDirty;
  99331. private _isCullFaceDirty;
  99332. private _isCullDirty;
  99333. private _isZOffsetDirty;
  99334. private _isFrontFaceDirty;
  99335. private _depthTest;
  99336. private _depthMask;
  99337. private _depthFunc;
  99338. private _cull;
  99339. private _cullFace;
  99340. private _zOffset;
  99341. private _frontFace;
  99342. /**
  99343. * Initializes the state.
  99344. */
  99345. constructor();
  99346. readonly isDirty: boolean;
  99347. zOffset: number;
  99348. cullFace: Nullable<number>;
  99349. cull: Nullable<boolean>;
  99350. depthFunc: Nullable<number>;
  99351. depthMask: boolean;
  99352. depthTest: boolean;
  99353. frontFace: Nullable<number>;
  99354. reset(): void;
  99355. apply(gl: WebGLRenderingContext): void;
  99356. }
  99357. }
  99358. declare module BABYLON {
  99359. /**
  99360. * @hidden
  99361. **/
  99362. export class StencilState {
  99363. /** 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 */
  99364. static readonly ALWAYS: number;
  99365. /** Passed to stencilOperation to specify that stencil value must be kept */
  99366. static readonly KEEP: number;
  99367. /** Passed to stencilOperation to specify that stencil value must be replaced */
  99368. static readonly REPLACE: number;
  99369. private _isStencilTestDirty;
  99370. private _isStencilMaskDirty;
  99371. private _isStencilFuncDirty;
  99372. private _isStencilOpDirty;
  99373. private _stencilTest;
  99374. private _stencilMask;
  99375. private _stencilFunc;
  99376. private _stencilFuncRef;
  99377. private _stencilFuncMask;
  99378. private _stencilOpStencilFail;
  99379. private _stencilOpDepthFail;
  99380. private _stencilOpStencilDepthPass;
  99381. readonly isDirty: boolean;
  99382. stencilFunc: number;
  99383. stencilFuncRef: number;
  99384. stencilFuncMask: number;
  99385. stencilOpStencilFail: number;
  99386. stencilOpDepthFail: number;
  99387. stencilOpStencilDepthPass: number;
  99388. stencilMask: number;
  99389. stencilTest: boolean;
  99390. constructor();
  99391. reset(): void;
  99392. apply(gl: WebGLRenderingContext): void;
  99393. }
  99394. }
  99395. declare module BABYLON {
  99396. /**
  99397. * @hidden
  99398. **/
  99399. export class AlphaState {
  99400. private _isAlphaBlendDirty;
  99401. private _isBlendFunctionParametersDirty;
  99402. private _isBlendEquationParametersDirty;
  99403. private _isBlendConstantsDirty;
  99404. private _alphaBlend;
  99405. private _blendFunctionParameters;
  99406. private _blendEquationParameters;
  99407. private _blendConstants;
  99408. /**
  99409. * Initializes the state.
  99410. */
  99411. constructor();
  99412. readonly isDirty: boolean;
  99413. alphaBlend: boolean;
  99414. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  99415. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  99416. setAlphaEquationParameters(rgb: number, alpha: number): void;
  99417. reset(): void;
  99418. apply(gl: WebGLRenderingContext): void;
  99419. }
  99420. }
  99421. declare module BABYLON {
  99422. /** @hidden */
  99423. export class WebGL2ShaderProcessor implements IShaderProcessor {
  99424. attributeProcessor(attribute: string): string;
  99425. varyingProcessor(varying: string, isFragment: boolean): string;
  99426. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  99427. }
  99428. }
  99429. declare module BABYLON {
  99430. /**
  99431. * Interface for attribute information associated with buffer instanciation
  99432. */
  99433. export interface InstancingAttributeInfo {
  99434. /**
  99435. * Index/offset of the attribute in the vertex shader
  99436. */
  99437. index: number;
  99438. /**
  99439. * size of the attribute, 1, 2, 3 or 4
  99440. */
  99441. attributeSize: number;
  99442. /**
  99443. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  99444. * default is FLOAT
  99445. */
  99446. attributeType: number;
  99447. /**
  99448. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  99449. */
  99450. normalized: boolean;
  99451. /**
  99452. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  99453. */
  99454. offset: number;
  99455. /**
  99456. * Name of the GLSL attribute, for debugging purpose only
  99457. */
  99458. attributeName: string;
  99459. }
  99460. }
  99461. declare module BABYLON {
  99462. interface ThinEngine {
  99463. /**
  99464. * Update a video texture
  99465. * @param texture defines the texture to update
  99466. * @param video defines the video element to use
  99467. * @param invertY defines if data must be stored with Y axis inverted
  99468. */
  99469. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  99470. }
  99471. }
  99472. declare module BABYLON {
  99473. /**
  99474. * Settings for finer control over video usage
  99475. */
  99476. export interface VideoTextureSettings {
  99477. /**
  99478. * Applies `autoplay` to video, if specified
  99479. */
  99480. autoPlay?: boolean;
  99481. /**
  99482. * Applies `loop` to video, if specified
  99483. */
  99484. loop?: boolean;
  99485. /**
  99486. * Automatically updates internal texture from video at every frame in the render loop
  99487. */
  99488. autoUpdateTexture: boolean;
  99489. /**
  99490. * Image src displayed during the video loading or until the user interacts with the video.
  99491. */
  99492. poster?: string;
  99493. }
  99494. /**
  99495. * If you want to display a video in your scene, this is the special texture for that.
  99496. * This special texture works similar to other textures, with the exception of a few parameters.
  99497. * @see https://doc.babylonjs.com/how_to/video_texture
  99498. */
  99499. export class VideoTexture extends Texture {
  99500. /**
  99501. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  99502. */
  99503. readonly autoUpdateTexture: boolean;
  99504. /**
  99505. * The video instance used by the texture internally
  99506. */
  99507. readonly video: HTMLVideoElement;
  99508. private _onUserActionRequestedObservable;
  99509. /**
  99510. * Event triggerd when a dom action is required by the user to play the video.
  99511. * This happens due to recent changes in browser policies preventing video to auto start.
  99512. */
  99513. readonly onUserActionRequestedObservable: Observable<Texture>;
  99514. private _generateMipMaps;
  99515. private _engine;
  99516. private _stillImageCaptured;
  99517. private _displayingPosterTexture;
  99518. private _settings;
  99519. private _createInternalTextureOnEvent;
  99520. private _frameId;
  99521. /**
  99522. * Creates a video texture.
  99523. * If you want to display a video in your scene, this is the special texture for that.
  99524. * This special texture works similar to other textures, with the exception of a few parameters.
  99525. * @see https://doc.babylonjs.com/how_to/video_texture
  99526. * @param name optional name, will detect from video source, if not defined
  99527. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  99528. * @param scene is obviously the current scene.
  99529. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  99530. * @param invertY is false by default but can be used to invert video on Y axis
  99531. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  99532. * @param settings allows finer control over video usage
  99533. */
  99534. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  99535. private _getName;
  99536. private _getVideo;
  99537. private _createInternalTexture;
  99538. private reset;
  99539. /**
  99540. * @hidden Internal method to initiate `update`.
  99541. */
  99542. _rebuild(): void;
  99543. /**
  99544. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  99545. */
  99546. update(): void;
  99547. /**
  99548. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  99549. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  99550. */
  99551. updateTexture(isVisible: boolean): void;
  99552. protected _updateInternalTexture: () => void;
  99553. /**
  99554. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  99555. * @param url New url.
  99556. */
  99557. updateURL(url: string): void;
  99558. /**
  99559. * Dispose the texture and release its associated resources.
  99560. */
  99561. dispose(): void;
  99562. /**
  99563. * Creates a video texture straight from a stream.
  99564. * @param scene Define the scene the texture should be created in
  99565. * @param stream Define the stream the texture should be created from
  99566. * @returns The created video texture as a promise
  99567. */
  99568. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  99569. /**
  99570. * Creates a video texture straight from your WebCam video feed.
  99571. * @param scene Define the scene the texture should be created in
  99572. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  99573. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  99574. * @returns The created video texture as a promise
  99575. */
  99576. static CreateFromWebCamAsync(scene: Scene, constraints: {
  99577. minWidth: number;
  99578. maxWidth: number;
  99579. minHeight: number;
  99580. maxHeight: number;
  99581. deviceId: string;
  99582. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  99583. /**
  99584. * Creates a video texture straight from your WebCam video feed.
  99585. * @param scene Define the scene the texture should be created in
  99586. * @param onReady Define a callback to triggered once the texture will be ready
  99587. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  99588. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  99589. */
  99590. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  99591. minWidth: number;
  99592. maxWidth: number;
  99593. minHeight: number;
  99594. maxHeight: number;
  99595. deviceId: string;
  99596. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  99597. }
  99598. }
  99599. declare module BABYLON {
  99600. /**
  99601. * Defines the interface used by objects working like Scene
  99602. * @hidden
  99603. */
  99604. interface ISceneLike {
  99605. _addPendingData(data: any): void;
  99606. _removePendingData(data: any): void;
  99607. offlineProvider: IOfflineProvider;
  99608. }
  99609. /** Interface defining initialization parameters for Engine class */
  99610. export interface EngineOptions extends WebGLContextAttributes {
  99611. /**
  99612. * Defines if the engine should no exceed a specified device ratio
  99613. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  99614. */
  99615. limitDeviceRatio?: number;
  99616. /**
  99617. * Defines if webvr should be enabled automatically
  99618. * @see http://doc.babylonjs.com/how_to/webvr_camera
  99619. */
  99620. autoEnableWebVR?: boolean;
  99621. /**
  99622. * Defines if webgl2 should be turned off even if supported
  99623. * @see http://doc.babylonjs.com/features/webgl2
  99624. */
  99625. disableWebGL2Support?: boolean;
  99626. /**
  99627. * Defines if webaudio should be initialized as well
  99628. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99629. */
  99630. audioEngine?: boolean;
  99631. /**
  99632. * Defines if animations should run using a deterministic lock step
  99633. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99634. */
  99635. deterministicLockstep?: boolean;
  99636. /** Defines the maximum steps to use with deterministic lock step mode */
  99637. lockstepMaxSteps?: number;
  99638. /** Defines the seconds between each deterministic lock step */
  99639. timeStep?: number;
  99640. /**
  99641. * Defines that engine should ignore context lost events
  99642. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  99643. */
  99644. doNotHandleContextLost?: boolean;
  99645. /**
  99646. * Defines that engine should ignore modifying touch action attribute and style
  99647. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  99648. */
  99649. doNotHandleTouchAction?: boolean;
  99650. /**
  99651. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  99652. */
  99653. useHighPrecisionFloats?: boolean;
  99654. }
  99655. /**
  99656. * The base engine class (root of all engines)
  99657. */
  99658. export class ThinEngine {
  99659. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  99660. static ExceptionList: ({
  99661. key: string;
  99662. capture: string;
  99663. captureConstraint: number;
  99664. targets: string[];
  99665. } | {
  99666. key: string;
  99667. capture: null;
  99668. captureConstraint: null;
  99669. targets: string[];
  99670. })[];
  99671. /** @hidden */
  99672. static _TextureLoaders: IInternalTextureLoader[];
  99673. /**
  99674. * Returns the current npm package of the sdk
  99675. */
  99676. static readonly NpmPackage: string;
  99677. /**
  99678. * Returns the current version of the framework
  99679. */
  99680. static readonly Version: string;
  99681. /**
  99682. * Returns a string describing the current engine
  99683. */
  99684. readonly description: string;
  99685. /**
  99686. * Gets or sets the epsilon value used by collision engine
  99687. */
  99688. static CollisionsEpsilon: number;
  99689. /**
  99690. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  99691. */
  99692. static ShadersRepository: string;
  99693. /**
  99694. * Gets or sets the textures that the engine should not attempt to load as compressed
  99695. */
  99696. protected _excludedCompressedTextures: string[];
  99697. /**
  99698. * Filters the compressed texture formats to only include
  99699. * files that are not included in the skippable list
  99700. *
  99701. * @param url the current extension
  99702. * @param textureFormatInUse the current compressed texture format
  99703. * @returns "format" string
  99704. */
  99705. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  99706. /** @hidden */
  99707. _shaderProcessor: IShaderProcessor;
  99708. /**
  99709. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  99710. */
  99711. forcePOTTextures: boolean;
  99712. /**
  99713. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  99714. */
  99715. isFullscreen: boolean;
  99716. /**
  99717. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  99718. */
  99719. cullBackFaces: boolean;
  99720. /**
  99721. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  99722. */
  99723. renderEvenInBackground: boolean;
  99724. /**
  99725. * Gets or sets a boolean indicating that cache can be kept between frames
  99726. */
  99727. preventCacheWipeBetweenFrames: boolean;
  99728. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  99729. validateShaderPrograms: boolean;
  99730. /**
  99731. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  99732. * This can provide greater z depth for distant objects.
  99733. */
  99734. useReverseDepthBuffer: boolean;
  99735. /**
  99736. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  99737. */
  99738. disableUniformBuffers: boolean;
  99739. /** @hidden */
  99740. _uniformBuffers: UniformBuffer[];
  99741. /**
  99742. * Gets a boolean indicating that the engine supports uniform buffers
  99743. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  99744. */
  99745. readonly supportsUniformBuffers: boolean;
  99746. /** @hidden */
  99747. _gl: WebGLRenderingContext;
  99748. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  99749. protected _windowIsBackground: boolean;
  99750. protected _webGLVersion: number;
  99751. protected _creationOptions: EngineOptions;
  99752. protected _highPrecisionShadersAllowed: boolean;
  99753. /** @hidden */
  99754. readonly _shouldUseHighPrecisionShader: boolean;
  99755. /**
  99756. * Gets a boolean indicating that only power of 2 textures are supported
  99757. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  99758. */
  99759. readonly needPOTTextures: boolean;
  99760. /** @hidden */
  99761. _badOS: boolean;
  99762. /** @hidden */
  99763. _badDesktopOS: boolean;
  99764. private _hardwareScalingLevel;
  99765. /** @hidden */
  99766. _caps: EngineCapabilities;
  99767. private _isStencilEnable;
  99768. protected _colorWrite: boolean;
  99769. private _glVersion;
  99770. private _glRenderer;
  99771. private _glVendor;
  99772. /** @hidden */
  99773. _videoTextureSupported: boolean;
  99774. protected _renderingQueueLaunched: boolean;
  99775. protected _activeRenderLoops: (() => void)[];
  99776. /**
  99777. * Observable signaled when a context lost event is raised
  99778. */
  99779. onContextLostObservable: Observable<ThinEngine>;
  99780. /**
  99781. * Observable signaled when a context restored event is raised
  99782. */
  99783. onContextRestoredObservable: Observable<ThinEngine>;
  99784. private _onContextLost;
  99785. private _onContextRestored;
  99786. protected _contextWasLost: boolean;
  99787. /** @hidden */
  99788. _doNotHandleContextLost: boolean;
  99789. /**
  99790. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  99791. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  99792. */
  99793. doNotHandleContextLost: boolean;
  99794. /**
  99795. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  99796. */
  99797. disableVertexArrayObjects: boolean;
  99798. /** @hidden */
  99799. protected _depthCullingState: DepthCullingState;
  99800. /** @hidden */
  99801. protected _stencilState: StencilState;
  99802. /** @hidden */
  99803. protected _alphaState: AlphaState;
  99804. /** @hidden */
  99805. _internalTexturesCache: InternalTexture[];
  99806. /** @hidden */
  99807. protected _activeChannel: number;
  99808. private _currentTextureChannel;
  99809. /** @hidden */
  99810. protected _boundTexturesCache: {
  99811. [key: string]: Nullable<InternalTexture>;
  99812. };
  99813. /** @hidden */
  99814. protected _currentEffect: Nullable<Effect>;
  99815. /** @hidden */
  99816. protected _currentProgram: Nullable<WebGLProgram>;
  99817. private _compiledEffects;
  99818. private _vertexAttribArraysEnabled;
  99819. /** @hidden */
  99820. protected _cachedViewport: Nullable<IViewportLike>;
  99821. private _cachedVertexArrayObject;
  99822. /** @hidden */
  99823. protected _cachedVertexBuffers: any;
  99824. /** @hidden */
  99825. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  99826. /** @hidden */
  99827. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  99828. /** @hidden */
  99829. _currentRenderTarget: Nullable<InternalTexture>;
  99830. private _uintIndicesCurrentlySet;
  99831. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  99832. /** @hidden */
  99833. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  99834. private _currentBufferPointers;
  99835. private _currentInstanceLocations;
  99836. private _currentInstanceBuffers;
  99837. private _textureUnits;
  99838. /** @hidden */
  99839. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  99840. /** @hidden */
  99841. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  99842. /** @hidden */
  99843. _boundRenderFunction: any;
  99844. private _vaoRecordInProgress;
  99845. private _mustWipeVertexAttributes;
  99846. private _emptyTexture;
  99847. private _emptyCubeTexture;
  99848. private _emptyTexture3D;
  99849. private _emptyTexture2DArray;
  99850. /** @hidden */
  99851. _frameHandler: number;
  99852. private _nextFreeTextureSlots;
  99853. private _maxSimultaneousTextures;
  99854. private _activeRequests;
  99855. protected _texturesSupported: string[];
  99856. /** @hidden */
  99857. _textureFormatInUse: Nullable<string>;
  99858. protected readonly _supportsHardwareTextureRescaling: boolean;
  99859. /**
  99860. * Gets the list of texture formats supported
  99861. */
  99862. readonly texturesSupported: Array<string>;
  99863. /**
  99864. * Gets the list of texture formats in use
  99865. */
  99866. readonly textureFormatInUse: Nullable<string>;
  99867. /**
  99868. * Gets the current viewport
  99869. */
  99870. readonly currentViewport: Nullable<IViewportLike>;
  99871. /**
  99872. * Gets the default empty texture
  99873. */
  99874. readonly emptyTexture: InternalTexture;
  99875. /**
  99876. * Gets the default empty 3D texture
  99877. */
  99878. readonly emptyTexture3D: InternalTexture;
  99879. /**
  99880. * Gets the default empty 2D array texture
  99881. */
  99882. readonly emptyTexture2DArray: InternalTexture;
  99883. /**
  99884. * Gets the default empty cube texture
  99885. */
  99886. readonly emptyCubeTexture: InternalTexture;
  99887. /**
  99888. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  99889. */
  99890. readonly premultipliedAlpha: boolean;
  99891. /**
  99892. * Observable event triggered before each texture is initialized
  99893. */
  99894. onBeforeTextureInitObservable: Observable<Texture>;
  99895. /**
  99896. * Creates a new engine
  99897. * @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
  99898. * @param antialias defines enable antialiasing (default: false)
  99899. * @param options defines further options to be sent to the getContext() function
  99900. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  99901. */
  99902. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  99903. private _rebuildInternalTextures;
  99904. private _rebuildEffects;
  99905. /**
  99906. * Gets a boolean indicating if all created effects are ready
  99907. * @returns true if all effects are ready
  99908. */
  99909. areAllEffectsReady(): boolean;
  99910. protected _rebuildBuffers(): void;
  99911. private _initGLContext;
  99912. /**
  99913. * Gets version of the current webGL context
  99914. */
  99915. readonly webGLVersion: number;
  99916. /**
  99917. * Gets a string idenfifying the name of the class
  99918. * @returns "Engine" string
  99919. */
  99920. getClassName(): string;
  99921. /**
  99922. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  99923. */
  99924. readonly isStencilEnable: boolean;
  99925. /** @hidden */
  99926. _prepareWorkingCanvas(): void;
  99927. /**
  99928. * Reset the texture cache to empty state
  99929. */
  99930. resetTextureCache(): void;
  99931. /**
  99932. * Gets an object containing information about the current webGL context
  99933. * @returns an object containing the vender, the renderer and the version of the current webGL context
  99934. */
  99935. getGlInfo(): {
  99936. vendor: string;
  99937. renderer: string;
  99938. version: string;
  99939. };
  99940. /**
  99941. * Defines the hardware scaling level.
  99942. * By default the hardware scaling level is computed from the window device ratio.
  99943. * 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.
  99944. * @param level defines the level to use
  99945. */
  99946. setHardwareScalingLevel(level: number): void;
  99947. /**
  99948. * Gets the current hardware scaling level.
  99949. * By default the hardware scaling level is computed from the window device ratio.
  99950. * 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.
  99951. * @returns a number indicating the current hardware scaling level
  99952. */
  99953. getHardwareScalingLevel(): number;
  99954. /**
  99955. * Gets the list of loaded textures
  99956. * @returns an array containing all loaded textures
  99957. */
  99958. getLoadedTexturesCache(): InternalTexture[];
  99959. /**
  99960. * Gets the object containing all engine capabilities
  99961. * @returns the EngineCapabilities object
  99962. */
  99963. getCaps(): EngineCapabilities;
  99964. /**
  99965. * stop executing a render loop function and remove it from the execution array
  99966. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  99967. */
  99968. stopRenderLoop(renderFunction?: () => void): void;
  99969. /** @hidden */
  99970. _renderLoop(): void;
  99971. /**
  99972. * Gets the HTML canvas attached with the current webGL context
  99973. * @returns a HTML canvas
  99974. */
  99975. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  99976. /**
  99977. * Gets host window
  99978. * @returns the host window object
  99979. */
  99980. getHostWindow(): Nullable<Window>;
  99981. /**
  99982. * Gets the current render width
  99983. * @param useScreen defines if screen size must be used (or the current render target if any)
  99984. * @returns a number defining the current render width
  99985. */
  99986. getRenderWidth(useScreen?: boolean): number;
  99987. /**
  99988. * Gets the current render height
  99989. * @param useScreen defines if screen size must be used (or the current render target if any)
  99990. * @returns a number defining the current render height
  99991. */
  99992. getRenderHeight(useScreen?: boolean): number;
  99993. /**
  99994. * Can be used to override the current requestAnimationFrame requester.
  99995. * @hidden
  99996. */
  99997. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  99998. /**
  99999. * Register and execute a render loop. The engine can have more than one render function
  100000. * @param renderFunction defines the function to continuously execute
  100001. */
  100002. runRenderLoop(renderFunction: () => void): void;
  100003. /**
  100004. * Clear the current render buffer or the current render target (if any is set up)
  100005. * @param color defines the color to use
  100006. * @param backBuffer defines if the back buffer must be cleared
  100007. * @param depth defines if the depth buffer must be cleared
  100008. * @param stencil defines if the stencil buffer must be cleared
  100009. */
  100010. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  100011. private _viewportCached;
  100012. /** @hidden */
  100013. _viewport(x: number, y: number, width: number, height: number): void;
  100014. /**
  100015. * Set the WebGL's viewport
  100016. * @param viewport defines the viewport element to be used
  100017. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  100018. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  100019. */
  100020. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  100021. /**
  100022. * Begin a new frame
  100023. */
  100024. beginFrame(): void;
  100025. /**
  100026. * Enf the current frame
  100027. */
  100028. endFrame(): void;
  100029. /**
  100030. * Resize the view according to the canvas' size
  100031. */
  100032. resize(): void;
  100033. /**
  100034. * Force a specific size of the canvas
  100035. * @param width defines the new canvas' width
  100036. * @param height defines the new canvas' height
  100037. */
  100038. setSize(width: number, height: number): void;
  100039. /**
  100040. * Binds the frame buffer to the specified texture.
  100041. * @param texture The texture to render to or null for the default canvas
  100042. * @param faceIndex The face of the texture to render to in case of cube texture
  100043. * @param requiredWidth The width of the target to render to
  100044. * @param requiredHeight The height of the target to render to
  100045. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  100046. * @param depthStencilTexture The depth stencil texture to use to render
  100047. * @param lodLevel defines le lod level to bind to the frame buffer
  100048. */
  100049. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  100050. /** @hidden */
  100051. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  100052. /**
  100053. * Unbind the current render target texture from the webGL context
  100054. * @param texture defines the render target texture to unbind
  100055. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  100056. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  100057. */
  100058. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  100059. /**
  100060. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  100061. */
  100062. flushFramebuffer(): void;
  100063. /**
  100064. * Unbind the current render target and bind the default framebuffer
  100065. */
  100066. restoreDefaultFramebuffer(): void;
  100067. /** @hidden */
  100068. protected _resetVertexBufferBinding(): void;
  100069. /**
  100070. * Creates a vertex buffer
  100071. * @param data the data for the vertex buffer
  100072. * @returns the new WebGL static buffer
  100073. */
  100074. createVertexBuffer(data: DataArray): DataBuffer;
  100075. private _createVertexBuffer;
  100076. /**
  100077. * Creates a dynamic vertex buffer
  100078. * @param data the data for the dynamic vertex buffer
  100079. * @returns the new WebGL dynamic buffer
  100080. */
  100081. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  100082. protected _resetIndexBufferBinding(): void;
  100083. /**
  100084. * Creates a new index buffer
  100085. * @param indices defines the content of the index buffer
  100086. * @param updatable defines if the index buffer must be updatable
  100087. * @returns a new webGL buffer
  100088. */
  100089. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  100090. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  100091. /**
  100092. * Bind a webGL buffer to the webGL context
  100093. * @param buffer defines the buffer to bind
  100094. */
  100095. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  100096. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  100097. private bindBuffer;
  100098. /**
  100099. * update the bound buffer with the given data
  100100. * @param data defines the data to update
  100101. */
  100102. updateArrayBuffer(data: Float32Array): void;
  100103. private _vertexAttribPointer;
  100104. private _bindIndexBufferWithCache;
  100105. private _bindVertexBuffersAttributes;
  100106. /**
  100107. * Records a vertex array object
  100108. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  100109. * @param vertexBuffers defines the list of vertex buffers to store
  100110. * @param indexBuffer defines the index buffer to store
  100111. * @param effect defines the effect to store
  100112. * @returns the new vertex array object
  100113. */
  100114. recordVertexArrayObject(vertexBuffers: {
  100115. [key: string]: VertexBuffer;
  100116. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  100117. /**
  100118. * Bind a specific vertex array object
  100119. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  100120. * @param vertexArrayObject defines the vertex array object to bind
  100121. * @param indexBuffer defines the index buffer to bind
  100122. */
  100123. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  100124. /**
  100125. * Bind webGl buffers directly to the webGL context
  100126. * @param vertexBuffer defines the vertex buffer to bind
  100127. * @param indexBuffer defines the index buffer to bind
  100128. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  100129. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  100130. * @param effect defines the effect associated with the vertex buffer
  100131. */
  100132. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  100133. private _unbindVertexArrayObject;
  100134. /**
  100135. * Bind a list of vertex buffers to the webGL context
  100136. * @param vertexBuffers defines the list of vertex buffers to bind
  100137. * @param indexBuffer defines the index buffer to bind
  100138. * @param effect defines the effect associated with the vertex buffers
  100139. */
  100140. bindBuffers(vertexBuffers: {
  100141. [key: string]: Nullable<VertexBuffer>;
  100142. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  100143. /**
  100144. * Unbind all instance attributes
  100145. */
  100146. unbindInstanceAttributes(): void;
  100147. /**
  100148. * Release and free the memory of a vertex array object
  100149. * @param vao defines the vertex array object to delete
  100150. */
  100151. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  100152. /** @hidden */
  100153. _releaseBuffer(buffer: DataBuffer): boolean;
  100154. protected _deleteBuffer(buffer: DataBuffer): void;
  100155. /**
  100156. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  100157. * @param instancesBuffer defines the webGL buffer to update and bind
  100158. * @param data defines the data to store in the buffer
  100159. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  100160. */
  100161. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  100162. /**
  100163. * Apply all cached states (depth, culling, stencil and alpha)
  100164. */
  100165. applyStates(): void;
  100166. /**
  100167. * Send a draw order
  100168. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  100169. * @param indexStart defines the starting index
  100170. * @param indexCount defines the number of index to draw
  100171. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  100172. */
  100173. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  100174. /**
  100175. * Draw a list of points
  100176. * @param verticesStart defines the index of first vertex to draw
  100177. * @param verticesCount defines the count of vertices to draw
  100178. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  100179. */
  100180. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  100181. /**
  100182. * Draw a list of unindexed primitives
  100183. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  100184. * @param verticesStart defines the index of first vertex to draw
  100185. * @param verticesCount defines the count of vertices to draw
  100186. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  100187. */
  100188. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  100189. /**
  100190. * Draw a list of indexed primitives
  100191. * @param fillMode defines the primitive to use
  100192. * @param indexStart defines the starting index
  100193. * @param indexCount defines the number of index to draw
  100194. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  100195. */
  100196. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  100197. /**
  100198. * Draw a list of unindexed primitives
  100199. * @param fillMode defines the primitive to use
  100200. * @param verticesStart defines the index of first vertex to draw
  100201. * @param verticesCount defines the count of vertices to draw
  100202. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  100203. */
  100204. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  100205. private _drawMode;
  100206. /** @hidden */
  100207. protected _reportDrawCall(): void;
  100208. /** @hidden */
  100209. _releaseEffect(effect: Effect): void;
  100210. /** @hidden */
  100211. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  100212. /**
  100213. * Create a new effect (used to store vertex/fragment shaders)
  100214. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  100215. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  100216. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  100217. * @param samplers defines an array of string used to represent textures
  100218. * @param defines defines the string containing the defines to use to compile the shaders
  100219. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  100220. * @param onCompiled defines a function to call when the effect creation is successful
  100221. * @param onError defines a function to call when the effect creation has failed
  100222. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  100223. * @returns the new Effect
  100224. */
  100225. createEffect(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  100226. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  100227. private _compileShader;
  100228. private _compileRawShader;
  100229. /**
  100230. * Directly creates a webGL program
  100231. * @param pipelineContext defines the pipeline context to attach to
  100232. * @param vertexCode defines the vertex shader code to use
  100233. * @param fragmentCode defines the fragment shader code to use
  100234. * @param context defines the webGL context to use (if not set, the current one will be used)
  100235. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  100236. * @returns the new webGL program
  100237. */
  100238. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  100239. /**
  100240. * Creates a webGL program
  100241. * @param pipelineContext defines the pipeline context to attach to
  100242. * @param vertexCode defines the vertex shader code to use
  100243. * @param fragmentCode defines the fragment shader code to use
  100244. * @param defines defines the string containing the defines to use to compile the shaders
  100245. * @param context defines the webGL context to use (if not set, the current one will be used)
  100246. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  100247. * @returns the new webGL program
  100248. */
  100249. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  100250. /**
  100251. * Creates a new pipeline context
  100252. * @returns the new pipeline
  100253. */
  100254. createPipelineContext(): IPipelineContext;
  100255. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  100256. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  100257. /** @hidden */
  100258. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  100259. /** @hidden */
  100260. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  100261. /** @hidden */
  100262. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  100263. /**
  100264. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  100265. * @param pipelineContext defines the pipeline context to use
  100266. * @param uniformsNames defines the list of uniform names
  100267. * @returns an array of webGL uniform locations
  100268. */
  100269. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  100270. /**
  100271. * Gets the lsit of active attributes for a given webGL program
  100272. * @param pipelineContext defines the pipeline context to use
  100273. * @param attributesNames defines the list of attribute names to get
  100274. * @returns an array of indices indicating the offset of each attribute
  100275. */
  100276. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  100277. /**
  100278. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  100279. * @param effect defines the effect to activate
  100280. */
  100281. enableEffect(effect: Nullable<Effect>): void;
  100282. /**
  100283. * Set the value of an uniform to a number (int)
  100284. * @param uniform defines the webGL uniform location where to store the value
  100285. * @param value defines the int number to store
  100286. */
  100287. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  100288. /**
  100289. * Set the value of an uniform to an array of int32
  100290. * @param uniform defines the webGL uniform location where to store the value
  100291. * @param array defines the array of int32 to store
  100292. */
  100293. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  100294. /**
  100295. * Set the value of an uniform to an array of int32 (stored as vec2)
  100296. * @param uniform defines the webGL uniform location where to store the value
  100297. * @param array defines the array of int32 to store
  100298. */
  100299. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  100300. /**
  100301. * Set the value of an uniform to an array of int32 (stored as vec3)
  100302. * @param uniform defines the webGL uniform location where to store the value
  100303. * @param array defines the array of int32 to store
  100304. */
  100305. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  100306. /**
  100307. * Set the value of an uniform to an array of int32 (stored as vec4)
  100308. * @param uniform defines the webGL uniform location where to store the value
  100309. * @param array defines the array of int32 to store
  100310. */
  100311. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  100312. /**
  100313. * Set the value of an uniform to an array of number
  100314. * @param uniform defines the webGL uniform location where to store the value
  100315. * @param array defines the array of number to store
  100316. */
  100317. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  100318. /**
  100319. * Set the value of an uniform to an array of number (stored as vec2)
  100320. * @param uniform defines the webGL uniform location where to store the value
  100321. * @param array defines the array of number to store
  100322. */
  100323. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  100324. /**
  100325. * Set the value of an uniform to an array of number (stored as vec3)
  100326. * @param uniform defines the webGL uniform location where to store the value
  100327. * @param array defines the array of number to store
  100328. */
  100329. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  100330. /**
  100331. * Set the value of an uniform to an array of number (stored as vec4)
  100332. * @param uniform defines the webGL uniform location where to store the value
  100333. * @param array defines the array of number to store
  100334. */
  100335. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  100336. /**
  100337. * Set the value of an uniform to an array of float32 (stored as matrices)
  100338. * @param uniform defines the webGL uniform location where to store the value
  100339. * @param matrices defines the array of float32 to store
  100340. */
  100341. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  100342. /**
  100343. * Set the value of an uniform to a matrix (3x3)
  100344. * @param uniform defines the webGL uniform location where to store the value
  100345. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  100346. */
  100347. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  100348. /**
  100349. * Set the value of an uniform to a matrix (2x2)
  100350. * @param uniform defines the webGL uniform location where to store the value
  100351. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  100352. */
  100353. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  100354. /**
  100355. * Set the value of an uniform to a number (float)
  100356. * @param uniform defines the webGL uniform location where to store the value
  100357. * @param value defines the float number to store
  100358. */
  100359. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  100360. /**
  100361. * Set the value of an uniform to a vec2
  100362. * @param uniform defines the webGL uniform location where to store the value
  100363. * @param x defines the 1st component of the value
  100364. * @param y defines the 2nd component of the value
  100365. */
  100366. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  100367. /**
  100368. * Set the value of an uniform to a vec3
  100369. * @param uniform defines the webGL uniform location where to store the value
  100370. * @param x defines the 1st component of the value
  100371. * @param y defines the 2nd component of the value
  100372. * @param z defines the 3rd component of the value
  100373. */
  100374. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  100375. /**
  100376. * Set the value of an uniform to a vec4
  100377. * @param uniform defines the webGL uniform location where to store the value
  100378. * @param x defines the 1st component of the value
  100379. * @param y defines the 2nd component of the value
  100380. * @param z defines the 3rd component of the value
  100381. * @param w defines the 4th component of the value
  100382. */
  100383. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  100384. /**
  100385. * Gets the depth culling state manager
  100386. */
  100387. readonly depthCullingState: DepthCullingState;
  100388. /**
  100389. * Gets the alpha state manager
  100390. */
  100391. readonly alphaState: AlphaState;
  100392. /**
  100393. * Gets the stencil state manager
  100394. */
  100395. readonly stencilState: StencilState;
  100396. /**
  100397. * Clears the list of texture accessible through engine.
  100398. * This can help preventing texture load conflict due to name collision.
  100399. */
  100400. clearInternalTexturesCache(): void;
  100401. /**
  100402. * Force the entire cache to be cleared
  100403. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  100404. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  100405. */
  100406. wipeCaches(bruteForce?: boolean): void;
  100407. /** @hidden */
  100408. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  100409. min: number;
  100410. mag: number;
  100411. };
  100412. /** @hidden */
  100413. _createTexture(): WebGLTexture;
  100414. /**
  100415. * Usually called from Texture.ts.
  100416. * Passed information to create a WebGLTexture
  100417. * @param urlArg defines a value which contains one of the following:
  100418. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  100419. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  100420. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  100421. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  100422. * @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)
  100423. * @param scene needed for loading to the correct scene
  100424. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  100425. * @param onLoad optional callback to be called upon successful completion
  100426. * @param onError optional callback to be called upon failure
  100427. * @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
  100428. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  100429. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  100430. * @param forcedExtension defines the extension to use to pick the right loader
  100431. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  100432. * @param mimeType defines an optional mime type
  100433. * @returns a InternalTexture for assignment back into BABYLON.Texture
  100434. */
  100435. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>, mimeType?: string): InternalTexture;
  100436. /**
  100437. * @hidden
  100438. */
  100439. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  100440. /**
  100441. * Creates a raw texture
  100442. * @param data defines the data to store in the texture
  100443. * @param width defines the width of the texture
  100444. * @param height defines the height of the texture
  100445. * @param format defines the format of the data
  100446. * @param generateMipMaps defines if the engine should generate the mip levels
  100447. * @param invertY defines if data must be stored with Y axis inverted
  100448. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  100449. * @param compression defines the compression used (null by default)
  100450. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  100451. * @returns the raw texture inside an InternalTexture
  100452. */
  100453. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  100454. /**
  100455. * Creates a new raw cube texture
  100456. * @param data defines the array of data to use to create each face
  100457. * @param size defines the size of the textures
  100458. * @param format defines the format of the data
  100459. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  100460. * @param generateMipMaps defines if the engine should generate the mip levels
  100461. * @param invertY defines if data must be stored with Y axis inverted
  100462. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  100463. * @param compression defines the compression used (null by default)
  100464. * @returns the cube texture as an InternalTexture
  100465. */
  100466. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  100467. /**
  100468. * Creates a new raw 3D texture
  100469. * @param data defines the data used to create the texture
  100470. * @param width defines the width of the texture
  100471. * @param height defines the height of the texture
  100472. * @param depth defines the depth of the texture
  100473. * @param format defines the format of the texture
  100474. * @param generateMipMaps defines if the engine must generate mip levels
  100475. * @param invertY defines if data must be stored with Y axis inverted
  100476. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  100477. * @param compression defines the compressed used (can be null)
  100478. * @param textureType defines the compressed used (can be null)
  100479. * @returns a new raw 3D texture (stored in an InternalTexture)
  100480. */
  100481. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  100482. /**
  100483. * Creates a new raw 2D array texture
  100484. * @param data defines the data used to create the texture
  100485. * @param width defines the width of the texture
  100486. * @param height defines the height of the texture
  100487. * @param depth defines the number of layers of the texture
  100488. * @param format defines the format of the texture
  100489. * @param generateMipMaps defines if the engine must generate mip levels
  100490. * @param invertY defines if data must be stored with Y axis inverted
  100491. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  100492. * @param compression defines the compressed used (can be null)
  100493. * @param textureType defines the compressed used (can be null)
  100494. * @returns a new raw 2D array texture (stored in an InternalTexture)
  100495. */
  100496. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  100497. private _unpackFlipYCached;
  100498. /**
  100499. * In case you are sharing the context with other applications, it might
  100500. * be interested to not cache the unpack flip y state to ensure a consistent
  100501. * value would be set.
  100502. */
  100503. enableUnpackFlipYCached: boolean;
  100504. /** @hidden */
  100505. _unpackFlipY(value: boolean): void;
  100506. /** @hidden */
  100507. _getUnpackAlignement(): number;
  100508. /**
  100509. * Update the sampling mode of a given texture
  100510. * @param samplingMode defines the required sampling mode
  100511. * @param texture defines the texture to update
  100512. */
  100513. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  100514. /** @hidden */
  100515. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  100516. width: number;
  100517. height: number;
  100518. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  100519. /** @hidden */
  100520. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  100521. /** @hidden */
  100522. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  100523. /** @hidden */
  100524. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  100525. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  100526. private _prepareWebGLTexture;
  100527. /** @hidden */
  100528. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  100529. /** @hidden */
  100530. _releaseFramebufferObjects(texture: InternalTexture): void;
  100531. /** @hidden */
  100532. _releaseTexture(texture: InternalTexture): void;
  100533. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  100534. protected _setProgram(program: WebGLProgram): void;
  100535. protected _boundUniforms: {
  100536. [key: number]: WebGLUniformLocation;
  100537. };
  100538. /**
  100539. * Binds an effect to the webGL context
  100540. * @param effect defines the effect to bind
  100541. */
  100542. bindSamplers(effect: Effect): void;
  100543. private _activateCurrentTexture;
  100544. /** @hidden */
  100545. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  100546. /** @hidden */
  100547. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  100548. /**
  100549. * Unbind all textures from the webGL context
  100550. */
  100551. unbindAllTextures(): void;
  100552. /**
  100553. * Sets a texture to the according uniform.
  100554. * @param channel The texture channel
  100555. * @param uniform The uniform to set
  100556. * @param texture The texture to apply
  100557. */
  100558. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  100559. private _bindSamplerUniformToChannel;
  100560. private _getTextureWrapMode;
  100561. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  100562. /**
  100563. * Sets an array of texture to the webGL context
  100564. * @param channel defines the channel where the texture array must be set
  100565. * @param uniform defines the associated uniform location
  100566. * @param textures defines the array of textures to bind
  100567. */
  100568. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  100569. /** @hidden */
  100570. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  100571. private _setTextureParameterFloat;
  100572. private _setTextureParameterInteger;
  100573. /**
  100574. * Unbind all vertex attributes from the webGL context
  100575. */
  100576. unbindAllAttributes(): void;
  100577. /**
  100578. * 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
  100579. */
  100580. releaseEffects(): void;
  100581. /**
  100582. * Dispose and release all associated resources
  100583. */
  100584. dispose(): void;
  100585. /**
  100586. * Attach a new callback raised when context lost event is fired
  100587. * @param callback defines the callback to call
  100588. */
  100589. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  100590. /**
  100591. * Attach a new callback raised when context restored event is fired
  100592. * @param callback defines the callback to call
  100593. */
  100594. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  100595. /**
  100596. * Get the current error code of the webGL context
  100597. * @returns the error code
  100598. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  100599. */
  100600. getError(): number;
  100601. private _canRenderToFloatFramebuffer;
  100602. private _canRenderToHalfFloatFramebuffer;
  100603. private _canRenderToFramebuffer;
  100604. /** @hidden */
  100605. _getWebGLTextureType(type: number): number;
  100606. /** @hidden */
  100607. _getInternalFormat(format: number): number;
  100608. /** @hidden */
  100609. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  100610. /** @hidden */
  100611. _getRGBAMultiSampleBufferFormat(type: number): number;
  100612. /** @hidden */
  100613. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: IWebRequest, exception?: any) => void): IFileRequest;
  100614. /**
  100615. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  100616. * @returns true if the engine can be created
  100617. * @ignorenaming
  100618. */
  100619. static isSupported(): boolean;
  100620. /**
  100621. * Find the next highest power of two.
  100622. * @param x Number to start search from.
  100623. * @return Next highest power of two.
  100624. */
  100625. static CeilingPOT(x: number): number;
  100626. /**
  100627. * Find the next lowest power of two.
  100628. * @param x Number to start search from.
  100629. * @return Next lowest power of two.
  100630. */
  100631. static FloorPOT(x: number): number;
  100632. /**
  100633. * Find the nearest power of two.
  100634. * @param x Number to start search from.
  100635. * @return Next nearest power of two.
  100636. */
  100637. static NearestPOT(x: number): number;
  100638. /**
  100639. * Get the closest exponent of two
  100640. * @param value defines the value to approximate
  100641. * @param max defines the maximum value to return
  100642. * @param mode defines how to define the closest value
  100643. * @returns closest exponent of two of the given value
  100644. */
  100645. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  100646. /**
  100647. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  100648. * @param func - the function to be called
  100649. * @param requester - the object that will request the next frame. Falls back to window.
  100650. * @returns frame number
  100651. */
  100652. static QueueNewFrame(func: () => void, requester?: any): number;
  100653. /**
  100654. * Gets host document
  100655. * @returns the host document object
  100656. */
  100657. getHostDocument(): Document;
  100658. }
  100659. }
  100660. declare module BABYLON {
  100661. /**
  100662. * Class representing spherical harmonics coefficients to the 3rd degree
  100663. */
  100664. export class SphericalHarmonics {
  100665. /**
  100666. * Defines whether or not the harmonics have been prescaled for rendering.
  100667. */
  100668. preScaled: boolean;
  100669. /**
  100670. * The l0,0 coefficients of the spherical harmonics
  100671. */
  100672. l00: Vector3;
  100673. /**
  100674. * The l1,-1 coefficients of the spherical harmonics
  100675. */
  100676. l1_1: Vector3;
  100677. /**
  100678. * The l1,0 coefficients of the spherical harmonics
  100679. */
  100680. l10: Vector3;
  100681. /**
  100682. * The l1,1 coefficients of the spherical harmonics
  100683. */
  100684. l11: Vector3;
  100685. /**
  100686. * The l2,-2 coefficients of the spherical harmonics
  100687. */
  100688. l2_2: Vector3;
  100689. /**
  100690. * The l2,-1 coefficients of the spherical harmonics
  100691. */
  100692. l2_1: Vector3;
  100693. /**
  100694. * The l2,0 coefficients of the spherical harmonics
  100695. */
  100696. l20: Vector3;
  100697. /**
  100698. * The l2,1 coefficients of the spherical harmonics
  100699. */
  100700. l21: Vector3;
  100701. /**
  100702. * The l2,2 coefficients of the spherical harmonics
  100703. */
  100704. l22: Vector3;
  100705. /**
  100706. * Adds a light to the spherical harmonics
  100707. * @param direction the direction of the light
  100708. * @param color the color of the light
  100709. * @param deltaSolidAngle the delta solid angle of the light
  100710. */
  100711. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  100712. /**
  100713. * Scales the spherical harmonics by the given amount
  100714. * @param scale the amount to scale
  100715. */
  100716. scaleInPlace(scale: number): void;
  100717. /**
  100718. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  100719. *
  100720. * ```
  100721. * E_lm = A_l * L_lm
  100722. * ```
  100723. *
  100724. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  100725. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  100726. * the scaling factors are given in equation 9.
  100727. */
  100728. convertIncidentRadianceToIrradiance(): void;
  100729. /**
  100730. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  100731. *
  100732. * ```
  100733. * L = (1/pi) * E * rho
  100734. * ```
  100735. *
  100736. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  100737. */
  100738. convertIrradianceToLambertianRadiance(): void;
  100739. /**
  100740. * Integrates the reconstruction coefficients directly in to the SH preventing further
  100741. * required operations at run time.
  100742. *
  100743. * This is simply done by scaling back the SH with Ylm constants parameter.
  100744. * The trigonometric part being applied by the shader at run time.
  100745. */
  100746. preScaleForRendering(): void;
  100747. /**
  100748. * Constructs a spherical harmonics from an array.
  100749. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  100750. * @returns the spherical harmonics
  100751. */
  100752. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  100753. /**
  100754. * Gets the spherical harmonics from polynomial
  100755. * @param polynomial the spherical polynomial
  100756. * @returns the spherical harmonics
  100757. */
  100758. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  100759. }
  100760. /**
  100761. * Class representing spherical polynomial coefficients to the 3rd degree
  100762. */
  100763. export class SphericalPolynomial {
  100764. private _harmonics;
  100765. /**
  100766. * The spherical harmonics used to create the polynomials.
  100767. */
  100768. readonly preScaledHarmonics: SphericalHarmonics;
  100769. /**
  100770. * The x coefficients of the spherical polynomial
  100771. */
  100772. x: Vector3;
  100773. /**
  100774. * The y coefficients of the spherical polynomial
  100775. */
  100776. y: Vector3;
  100777. /**
  100778. * The z coefficients of the spherical polynomial
  100779. */
  100780. z: Vector3;
  100781. /**
  100782. * The xx coefficients of the spherical polynomial
  100783. */
  100784. xx: Vector3;
  100785. /**
  100786. * The yy coefficients of the spherical polynomial
  100787. */
  100788. yy: Vector3;
  100789. /**
  100790. * The zz coefficients of the spherical polynomial
  100791. */
  100792. zz: Vector3;
  100793. /**
  100794. * The xy coefficients of the spherical polynomial
  100795. */
  100796. xy: Vector3;
  100797. /**
  100798. * The yz coefficients of the spherical polynomial
  100799. */
  100800. yz: Vector3;
  100801. /**
  100802. * The zx coefficients of the spherical polynomial
  100803. */
  100804. zx: Vector3;
  100805. /**
  100806. * Adds an ambient color to the spherical polynomial
  100807. * @param color the color to add
  100808. */
  100809. addAmbient(color: Color3): void;
  100810. /**
  100811. * Scales the spherical polynomial by the given amount
  100812. * @param scale the amount to scale
  100813. */
  100814. scaleInPlace(scale: number): void;
  100815. /**
  100816. * Gets the spherical polynomial from harmonics
  100817. * @param harmonics the spherical harmonics
  100818. * @returns the spherical polynomial
  100819. */
  100820. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  100821. /**
  100822. * Constructs a spherical polynomial from an array.
  100823. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  100824. * @returns the spherical polynomial
  100825. */
  100826. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  100827. }
  100828. }
  100829. declare module BABYLON {
  100830. /**
  100831. * Defines the source of the internal texture
  100832. */
  100833. export enum InternalTextureSource {
  100834. /**
  100835. * The source of the texture data is unknown
  100836. */
  100837. Unknown = 0,
  100838. /**
  100839. * Texture data comes from an URL
  100840. */
  100841. Url = 1,
  100842. /**
  100843. * Texture data is only used for temporary storage
  100844. */
  100845. Temp = 2,
  100846. /**
  100847. * Texture data comes from raw data (ArrayBuffer)
  100848. */
  100849. Raw = 3,
  100850. /**
  100851. * Texture content is dynamic (video or dynamic texture)
  100852. */
  100853. Dynamic = 4,
  100854. /**
  100855. * Texture content is generated by rendering to it
  100856. */
  100857. RenderTarget = 5,
  100858. /**
  100859. * Texture content is part of a multi render target process
  100860. */
  100861. MultiRenderTarget = 6,
  100862. /**
  100863. * Texture data comes from a cube data file
  100864. */
  100865. Cube = 7,
  100866. /**
  100867. * Texture data comes from a raw cube data
  100868. */
  100869. CubeRaw = 8,
  100870. /**
  100871. * Texture data come from a prefiltered cube data file
  100872. */
  100873. CubePrefiltered = 9,
  100874. /**
  100875. * Texture content is raw 3D data
  100876. */
  100877. Raw3D = 10,
  100878. /**
  100879. * Texture content is raw 2D array data
  100880. */
  100881. Raw2DArray = 11,
  100882. /**
  100883. * Texture content is a depth texture
  100884. */
  100885. Depth = 12,
  100886. /**
  100887. * Texture data comes from a raw cube data encoded with RGBD
  100888. */
  100889. CubeRawRGBD = 13
  100890. }
  100891. /**
  100892. * Class used to store data associated with WebGL texture data for the engine
  100893. * This class should not be used directly
  100894. */
  100895. export class InternalTexture {
  100896. /** @hidden */
  100897. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  100898. /**
  100899. * Defines if the texture is ready
  100900. */
  100901. isReady: boolean;
  100902. /**
  100903. * Defines if the texture is a cube texture
  100904. */
  100905. isCube: boolean;
  100906. /**
  100907. * Defines if the texture contains 3D data
  100908. */
  100909. is3D: boolean;
  100910. /**
  100911. * Defines if the texture contains 2D array data
  100912. */
  100913. is2DArray: boolean;
  100914. /**
  100915. * Defines if the texture contains multiview data
  100916. */
  100917. isMultiview: boolean;
  100918. /**
  100919. * Gets the URL used to load this texture
  100920. */
  100921. url: string;
  100922. /**
  100923. * Gets the sampling mode of the texture
  100924. */
  100925. samplingMode: number;
  100926. /**
  100927. * Gets a boolean indicating if the texture needs mipmaps generation
  100928. */
  100929. generateMipMaps: boolean;
  100930. /**
  100931. * Gets the number of samples used by the texture (WebGL2+ only)
  100932. */
  100933. samples: number;
  100934. /**
  100935. * Gets the type of the texture (int, float...)
  100936. */
  100937. type: number;
  100938. /**
  100939. * Gets the format of the texture (RGB, RGBA...)
  100940. */
  100941. format: number;
  100942. /**
  100943. * Observable called when the texture is loaded
  100944. */
  100945. onLoadedObservable: Observable<InternalTexture>;
  100946. /**
  100947. * Gets the width of the texture
  100948. */
  100949. width: number;
  100950. /**
  100951. * Gets the height of the texture
  100952. */
  100953. height: number;
  100954. /**
  100955. * Gets the depth of the texture
  100956. */
  100957. depth: number;
  100958. /**
  100959. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  100960. */
  100961. baseWidth: number;
  100962. /**
  100963. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  100964. */
  100965. baseHeight: number;
  100966. /**
  100967. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  100968. */
  100969. baseDepth: number;
  100970. /**
  100971. * Gets a boolean indicating if the texture is inverted on Y axis
  100972. */
  100973. invertY: boolean;
  100974. /** @hidden */
  100975. _invertVScale: boolean;
  100976. /** @hidden */
  100977. _associatedChannel: number;
  100978. /** @hidden */
  100979. _source: InternalTextureSource;
  100980. /** @hidden */
  100981. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  100982. /** @hidden */
  100983. _bufferView: Nullable<ArrayBufferView>;
  100984. /** @hidden */
  100985. _bufferViewArray: Nullable<ArrayBufferView[]>;
  100986. /** @hidden */
  100987. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  100988. /** @hidden */
  100989. _size: number;
  100990. /** @hidden */
  100991. _extension: string;
  100992. /** @hidden */
  100993. _files: Nullable<string[]>;
  100994. /** @hidden */
  100995. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  100996. /** @hidden */
  100997. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  100998. /** @hidden */
  100999. _framebuffer: Nullable<WebGLFramebuffer>;
  101000. /** @hidden */
  101001. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  101002. /** @hidden */
  101003. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  101004. /** @hidden */
  101005. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  101006. /** @hidden */
  101007. _attachments: Nullable<number[]>;
  101008. /** @hidden */
  101009. _cachedCoordinatesMode: Nullable<number>;
  101010. /** @hidden */
  101011. _cachedWrapU: Nullable<number>;
  101012. /** @hidden */
  101013. _cachedWrapV: Nullable<number>;
  101014. /** @hidden */
  101015. _cachedWrapR: Nullable<number>;
  101016. /** @hidden */
  101017. _cachedAnisotropicFilteringLevel: Nullable<number>;
  101018. /** @hidden */
  101019. _isDisabled: boolean;
  101020. /** @hidden */
  101021. _compression: Nullable<string>;
  101022. /** @hidden */
  101023. _generateStencilBuffer: boolean;
  101024. /** @hidden */
  101025. _generateDepthBuffer: boolean;
  101026. /** @hidden */
  101027. _comparisonFunction: number;
  101028. /** @hidden */
  101029. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  101030. /** @hidden */
  101031. _lodGenerationScale: number;
  101032. /** @hidden */
  101033. _lodGenerationOffset: number;
  101034. /** @hidden */
  101035. _colorTextureArray: Nullable<WebGLTexture>;
  101036. /** @hidden */
  101037. _depthStencilTextureArray: Nullable<WebGLTexture>;
  101038. /** @hidden */
  101039. _lodTextureHigh: Nullable<BaseTexture>;
  101040. /** @hidden */
  101041. _lodTextureMid: Nullable<BaseTexture>;
  101042. /** @hidden */
  101043. _lodTextureLow: Nullable<BaseTexture>;
  101044. /** @hidden */
  101045. _isRGBD: boolean;
  101046. /** @hidden */
  101047. _linearSpecularLOD: boolean;
  101048. /** @hidden */
  101049. _irradianceTexture: Nullable<BaseTexture>;
  101050. /** @hidden */
  101051. _webGLTexture: Nullable<WebGLTexture>;
  101052. /** @hidden */
  101053. _references: number;
  101054. private _engine;
  101055. /**
  101056. * Gets the Engine the texture belongs to.
  101057. * @returns The babylon engine
  101058. */
  101059. getEngine(): ThinEngine;
  101060. /**
  101061. * Gets the data source type of the texture
  101062. */
  101063. readonly source: InternalTextureSource;
  101064. /**
  101065. * Creates a new InternalTexture
  101066. * @param engine defines the engine to use
  101067. * @param source defines the type of data that will be used
  101068. * @param delayAllocation if the texture allocation should be delayed (default: false)
  101069. */
  101070. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  101071. /**
  101072. * Increments the number of references (ie. the number of Texture that point to it)
  101073. */
  101074. incrementReferences(): void;
  101075. /**
  101076. * Change the size of the texture (not the size of the content)
  101077. * @param width defines the new width
  101078. * @param height defines the new height
  101079. * @param depth defines the new depth (1 by default)
  101080. */
  101081. updateSize(width: int, height: int, depth?: int): void;
  101082. /** @hidden */
  101083. _rebuild(): void;
  101084. /** @hidden */
  101085. _swapAndDie(target: InternalTexture): void;
  101086. /**
  101087. * Dispose the current allocated resources
  101088. */
  101089. dispose(): void;
  101090. }
  101091. }
  101092. declare module BABYLON {
  101093. /**
  101094. * Class used to work with sound analyzer using fast fourier transform (FFT)
  101095. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101096. */
  101097. export class Analyser {
  101098. /**
  101099. * Gets or sets the smoothing
  101100. * @ignorenaming
  101101. */
  101102. SMOOTHING: number;
  101103. /**
  101104. * Gets or sets the FFT table size
  101105. * @ignorenaming
  101106. */
  101107. FFT_SIZE: number;
  101108. /**
  101109. * Gets or sets the bar graph amplitude
  101110. * @ignorenaming
  101111. */
  101112. BARGRAPHAMPLITUDE: number;
  101113. /**
  101114. * Gets or sets the position of the debug canvas
  101115. * @ignorenaming
  101116. */
  101117. DEBUGCANVASPOS: {
  101118. x: number;
  101119. y: number;
  101120. };
  101121. /**
  101122. * Gets or sets the debug canvas size
  101123. * @ignorenaming
  101124. */
  101125. DEBUGCANVASSIZE: {
  101126. width: number;
  101127. height: number;
  101128. };
  101129. private _byteFreqs;
  101130. private _byteTime;
  101131. private _floatFreqs;
  101132. private _webAudioAnalyser;
  101133. private _debugCanvas;
  101134. private _debugCanvasContext;
  101135. private _scene;
  101136. private _registerFunc;
  101137. private _audioEngine;
  101138. /**
  101139. * Creates a new analyser
  101140. * @param scene defines hosting scene
  101141. */
  101142. constructor(scene: Scene);
  101143. /**
  101144. * Get the number of data values you will have to play with for the visualization
  101145. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  101146. * @returns a number
  101147. */
  101148. getFrequencyBinCount(): number;
  101149. /**
  101150. * Gets the current frequency data as a byte array
  101151. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  101152. * @returns a Uint8Array
  101153. */
  101154. getByteFrequencyData(): Uint8Array;
  101155. /**
  101156. * Gets the current waveform as a byte array
  101157. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  101158. * @returns a Uint8Array
  101159. */
  101160. getByteTimeDomainData(): Uint8Array;
  101161. /**
  101162. * Gets the current frequency data as a float array
  101163. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  101164. * @returns a Float32Array
  101165. */
  101166. getFloatFrequencyData(): Float32Array;
  101167. /**
  101168. * Renders the debug canvas
  101169. */
  101170. drawDebugCanvas(): void;
  101171. /**
  101172. * Stops rendering the debug canvas and removes it
  101173. */
  101174. stopDebugCanvas(): void;
  101175. /**
  101176. * Connects two audio nodes
  101177. * @param inputAudioNode defines first node to connect
  101178. * @param outputAudioNode defines second node to connect
  101179. */
  101180. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  101181. /**
  101182. * Releases all associated resources
  101183. */
  101184. dispose(): void;
  101185. }
  101186. }
  101187. declare module BABYLON {
  101188. /**
  101189. * This represents an audio engine and it is responsible
  101190. * to play, synchronize and analyse sounds throughout the application.
  101191. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101192. */
  101193. export interface IAudioEngine extends IDisposable {
  101194. /**
  101195. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  101196. */
  101197. readonly canUseWebAudio: boolean;
  101198. /**
  101199. * Gets the current AudioContext if available.
  101200. */
  101201. readonly audioContext: Nullable<AudioContext>;
  101202. /**
  101203. * The master gain node defines the global audio volume of your audio engine.
  101204. */
  101205. readonly masterGain: GainNode;
  101206. /**
  101207. * Gets whether or not mp3 are supported by your browser.
  101208. */
  101209. readonly isMP3supported: boolean;
  101210. /**
  101211. * Gets whether or not ogg are supported by your browser.
  101212. */
  101213. readonly isOGGsupported: boolean;
  101214. /**
  101215. * Defines if Babylon should emit a warning if WebAudio is not supported.
  101216. * @ignoreNaming
  101217. */
  101218. WarnedWebAudioUnsupported: boolean;
  101219. /**
  101220. * Defines if the audio engine relies on a custom unlocked button.
  101221. * In this case, the embedded button will not be displayed.
  101222. */
  101223. useCustomUnlockedButton: boolean;
  101224. /**
  101225. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  101226. */
  101227. readonly unlocked: boolean;
  101228. /**
  101229. * Event raised when audio has been unlocked on the browser.
  101230. */
  101231. onAudioUnlockedObservable: Observable<AudioEngine>;
  101232. /**
  101233. * Event raised when audio has been locked on the browser.
  101234. */
  101235. onAudioLockedObservable: Observable<AudioEngine>;
  101236. /**
  101237. * Flags the audio engine in Locked state.
  101238. * This happens due to new browser policies preventing audio to autoplay.
  101239. */
  101240. lock(): void;
  101241. /**
  101242. * Unlocks the audio engine once a user action has been done on the dom.
  101243. * This is helpful to resume play once browser policies have been satisfied.
  101244. */
  101245. unlock(): void;
  101246. }
  101247. /**
  101248. * This represents the default audio engine used in babylon.
  101249. * It is responsible to play, synchronize and analyse sounds throughout the application.
  101250. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101251. */
  101252. export class AudioEngine implements IAudioEngine {
  101253. private _audioContext;
  101254. private _audioContextInitialized;
  101255. private _muteButton;
  101256. private _hostElement;
  101257. /**
  101258. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  101259. */
  101260. canUseWebAudio: boolean;
  101261. /**
  101262. * The master gain node defines the global audio volume of your audio engine.
  101263. */
  101264. masterGain: GainNode;
  101265. /**
  101266. * Defines if Babylon should emit a warning if WebAudio is not supported.
  101267. * @ignoreNaming
  101268. */
  101269. WarnedWebAudioUnsupported: boolean;
  101270. /**
  101271. * Gets whether or not mp3 are supported by your browser.
  101272. */
  101273. isMP3supported: boolean;
  101274. /**
  101275. * Gets whether or not ogg are supported by your browser.
  101276. */
  101277. isOGGsupported: boolean;
  101278. /**
  101279. * Gets whether audio has been unlocked on the device.
  101280. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  101281. * a user interaction has happened.
  101282. */
  101283. unlocked: boolean;
  101284. /**
  101285. * Defines if the audio engine relies on a custom unlocked button.
  101286. * In this case, the embedded button will not be displayed.
  101287. */
  101288. useCustomUnlockedButton: boolean;
  101289. /**
  101290. * Event raised when audio has been unlocked on the browser.
  101291. */
  101292. onAudioUnlockedObservable: Observable<AudioEngine>;
  101293. /**
  101294. * Event raised when audio has been locked on the browser.
  101295. */
  101296. onAudioLockedObservable: Observable<AudioEngine>;
  101297. /**
  101298. * Gets the current AudioContext if available.
  101299. */
  101300. readonly audioContext: Nullable<AudioContext>;
  101301. private _connectedAnalyser;
  101302. /**
  101303. * Instantiates a new audio engine.
  101304. *
  101305. * There should be only one per page as some browsers restrict the number
  101306. * of audio contexts you can create.
  101307. * @param hostElement defines the host element where to display the mute icon if necessary
  101308. */
  101309. constructor(hostElement?: Nullable<HTMLElement>);
  101310. /**
  101311. * Flags the audio engine in Locked state.
  101312. * This happens due to new browser policies preventing audio to autoplay.
  101313. */
  101314. lock(): void;
  101315. /**
  101316. * Unlocks the audio engine once a user action has been done on the dom.
  101317. * This is helpful to resume play once browser policies have been satisfied.
  101318. */
  101319. unlock(): void;
  101320. private _resumeAudioContext;
  101321. private _initializeAudioContext;
  101322. private _tryToRun;
  101323. private _triggerRunningState;
  101324. private _triggerSuspendedState;
  101325. private _displayMuteButton;
  101326. private _moveButtonToTopLeft;
  101327. private _onResize;
  101328. private _hideMuteButton;
  101329. /**
  101330. * Destroy and release the resources associated with the audio ccontext.
  101331. */
  101332. dispose(): void;
  101333. /**
  101334. * Gets the global volume sets on the master gain.
  101335. * @returns the global volume if set or -1 otherwise
  101336. */
  101337. getGlobalVolume(): number;
  101338. /**
  101339. * Sets the global volume of your experience (sets on the master gain).
  101340. * @param newVolume Defines the new global volume of the application
  101341. */
  101342. setGlobalVolume(newVolume: number): void;
  101343. /**
  101344. * Connect the audio engine to an audio analyser allowing some amazing
  101345. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  101346. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  101347. * @param analyser The analyser to connect to the engine
  101348. */
  101349. connectToAnalyser(analyser: Analyser): void;
  101350. }
  101351. }
  101352. declare module BABYLON {
  101353. /**
  101354. * Interface used to present a loading screen while loading a scene
  101355. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  101356. */
  101357. export interface ILoadingScreen {
  101358. /**
  101359. * Function called to display the loading screen
  101360. */
  101361. displayLoadingUI: () => void;
  101362. /**
  101363. * Function called to hide the loading screen
  101364. */
  101365. hideLoadingUI: () => void;
  101366. /**
  101367. * Gets or sets the color to use for the background
  101368. */
  101369. loadingUIBackgroundColor: string;
  101370. /**
  101371. * Gets or sets the text to display while loading
  101372. */
  101373. loadingUIText: string;
  101374. }
  101375. /**
  101376. * Class used for the default loading screen
  101377. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  101378. */
  101379. export class DefaultLoadingScreen implements ILoadingScreen {
  101380. private _renderingCanvas;
  101381. private _loadingText;
  101382. private _loadingDivBackgroundColor;
  101383. private _loadingDiv;
  101384. private _loadingTextDiv;
  101385. /** Gets or sets the logo url to use for the default loading screen */
  101386. static DefaultLogoUrl: string;
  101387. /** Gets or sets the spinner url to use for the default loading screen */
  101388. static DefaultSpinnerUrl: string;
  101389. /**
  101390. * Creates a new default loading screen
  101391. * @param _renderingCanvas defines the canvas used to render the scene
  101392. * @param _loadingText defines the default text to display
  101393. * @param _loadingDivBackgroundColor defines the default background color
  101394. */
  101395. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  101396. /**
  101397. * Function called to display the loading screen
  101398. */
  101399. displayLoadingUI(): void;
  101400. /**
  101401. * Function called to hide the loading screen
  101402. */
  101403. hideLoadingUI(): void;
  101404. /**
  101405. * Gets or sets the text to display while loading
  101406. */
  101407. loadingUIText: string;
  101408. /**
  101409. * Gets or sets the color to use for the background
  101410. */
  101411. loadingUIBackgroundColor: string;
  101412. private _resizeLoadingUI;
  101413. }
  101414. }
  101415. declare module BABYLON {
  101416. /**
  101417. * Interface for any object that can request an animation frame
  101418. */
  101419. export interface ICustomAnimationFrameRequester {
  101420. /**
  101421. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  101422. */
  101423. renderFunction?: Function;
  101424. /**
  101425. * Called to request the next frame to render to
  101426. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  101427. */
  101428. requestAnimationFrame: Function;
  101429. /**
  101430. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  101431. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  101432. */
  101433. requestID?: number;
  101434. }
  101435. }
  101436. declare module BABYLON {
  101437. /**
  101438. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  101439. */
  101440. export class PerformanceMonitor {
  101441. private _enabled;
  101442. private _rollingFrameTime;
  101443. private _lastFrameTimeMs;
  101444. /**
  101445. * constructor
  101446. * @param frameSampleSize The number of samples required to saturate the sliding window
  101447. */
  101448. constructor(frameSampleSize?: number);
  101449. /**
  101450. * Samples current frame
  101451. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  101452. */
  101453. sampleFrame(timeMs?: number): void;
  101454. /**
  101455. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  101456. */
  101457. readonly averageFrameTime: number;
  101458. /**
  101459. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  101460. */
  101461. readonly averageFrameTimeVariance: number;
  101462. /**
  101463. * Returns the frame time of the most recent frame
  101464. */
  101465. readonly instantaneousFrameTime: number;
  101466. /**
  101467. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  101468. */
  101469. readonly averageFPS: number;
  101470. /**
  101471. * Returns the average framerate in frames per second using the most recent frame time
  101472. */
  101473. readonly instantaneousFPS: number;
  101474. /**
  101475. * Returns true if enough samples have been taken to completely fill the sliding window
  101476. */
  101477. readonly isSaturated: boolean;
  101478. /**
  101479. * Enables contributions to the sliding window sample set
  101480. */
  101481. enable(): void;
  101482. /**
  101483. * Disables contributions to the sliding window sample set
  101484. * Samples will not be interpolated over the disabled period
  101485. */
  101486. disable(): void;
  101487. /**
  101488. * Returns true if sampling is enabled
  101489. */
  101490. readonly isEnabled: boolean;
  101491. /**
  101492. * Resets performance monitor
  101493. */
  101494. reset(): void;
  101495. }
  101496. /**
  101497. * RollingAverage
  101498. *
  101499. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  101500. */
  101501. export class RollingAverage {
  101502. /**
  101503. * Current average
  101504. */
  101505. average: number;
  101506. /**
  101507. * Current variance
  101508. */
  101509. variance: number;
  101510. protected _samples: Array<number>;
  101511. protected _sampleCount: number;
  101512. protected _pos: number;
  101513. protected _m2: number;
  101514. /**
  101515. * constructor
  101516. * @param length The number of samples required to saturate the sliding window
  101517. */
  101518. constructor(length: number);
  101519. /**
  101520. * Adds a sample to the sample set
  101521. * @param v The sample value
  101522. */
  101523. add(v: number): void;
  101524. /**
  101525. * Returns previously added values or null if outside of history or outside the sliding window domain
  101526. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  101527. * @return Value previously recorded with add() or null if outside of range
  101528. */
  101529. history(i: number): number;
  101530. /**
  101531. * Returns true if enough samples have been taken to completely fill the sliding window
  101532. * @return true if sample-set saturated
  101533. */
  101534. isSaturated(): boolean;
  101535. /**
  101536. * Resets the rolling average (equivalent to 0 samples taken so far)
  101537. */
  101538. reset(): void;
  101539. /**
  101540. * Wraps a value around the sample range boundaries
  101541. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  101542. * @return Wrapped position in sample range
  101543. */
  101544. protected _wrapPosition(i: number): number;
  101545. }
  101546. }
  101547. declare module BABYLON {
  101548. /**
  101549. * This class is used to track a performance counter which is number based.
  101550. * The user has access to many properties which give statistics of different nature.
  101551. *
  101552. * The implementer can track two kinds of Performance Counter: time and count.
  101553. * 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.
  101554. * 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.
  101555. */
  101556. export class PerfCounter {
  101557. /**
  101558. * Gets or sets a global boolean to turn on and off all the counters
  101559. */
  101560. static Enabled: boolean;
  101561. /**
  101562. * Returns the smallest value ever
  101563. */
  101564. readonly min: number;
  101565. /**
  101566. * Returns the biggest value ever
  101567. */
  101568. readonly max: number;
  101569. /**
  101570. * Returns the average value since the performance counter is running
  101571. */
  101572. readonly average: number;
  101573. /**
  101574. * Returns the average value of the last second the counter was monitored
  101575. */
  101576. readonly lastSecAverage: number;
  101577. /**
  101578. * Returns the current value
  101579. */
  101580. readonly current: number;
  101581. /**
  101582. * Gets the accumulated total
  101583. */
  101584. readonly total: number;
  101585. /**
  101586. * Gets the total value count
  101587. */
  101588. readonly count: number;
  101589. /**
  101590. * Creates a new counter
  101591. */
  101592. constructor();
  101593. /**
  101594. * Call this method to start monitoring a new frame.
  101595. * 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.
  101596. */
  101597. fetchNewFrame(): void;
  101598. /**
  101599. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  101600. * @param newCount the count value to add to the monitored count
  101601. * @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.
  101602. */
  101603. addCount(newCount: number, fetchResult: boolean): void;
  101604. /**
  101605. * Start monitoring this performance counter
  101606. */
  101607. beginMonitoring(): void;
  101608. /**
  101609. * Compute the time lapsed since the previous beginMonitoring() call.
  101610. * @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
  101611. */
  101612. endMonitoring(newFrame?: boolean): void;
  101613. private _fetchResult;
  101614. private _startMonitoringTime;
  101615. private _min;
  101616. private _max;
  101617. private _average;
  101618. private _current;
  101619. private _totalValueCount;
  101620. private _totalAccumulated;
  101621. private _lastSecAverage;
  101622. private _lastSecAccumulated;
  101623. private _lastSecTime;
  101624. private _lastSecValueCount;
  101625. }
  101626. }
  101627. declare module BABYLON {
  101628. /**
  101629. * Defines the interface used by display changed events
  101630. */
  101631. export interface IDisplayChangedEventArgs {
  101632. /** Gets the vrDisplay object (if any) */
  101633. vrDisplay: Nullable<any>;
  101634. /** Gets a boolean indicating if webVR is supported */
  101635. vrSupported: boolean;
  101636. }
  101637. /**
  101638. * Defines the interface used by objects containing a viewport (like a camera)
  101639. */
  101640. interface IViewportOwnerLike {
  101641. /**
  101642. * Gets or sets the viewport
  101643. */
  101644. viewport: IViewportLike;
  101645. }
  101646. /**
  101647. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  101648. */
  101649. export class Engine extends ThinEngine {
  101650. /** Defines that alpha blending is disabled */
  101651. static readonly ALPHA_DISABLE: number;
  101652. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  101653. static readonly ALPHA_ADD: number;
  101654. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  101655. static readonly ALPHA_COMBINE: number;
  101656. /** Defines that alpha blending to DEST - SRC * DEST */
  101657. static readonly ALPHA_SUBTRACT: number;
  101658. /** Defines that alpha blending to SRC * DEST */
  101659. static readonly ALPHA_MULTIPLY: number;
  101660. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  101661. static readonly ALPHA_MAXIMIZED: number;
  101662. /** Defines that alpha blending to SRC + DEST */
  101663. static readonly ALPHA_ONEONE: number;
  101664. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  101665. static readonly ALPHA_PREMULTIPLIED: number;
  101666. /**
  101667. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  101668. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  101669. */
  101670. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  101671. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  101672. static readonly ALPHA_INTERPOLATE: number;
  101673. /**
  101674. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  101675. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  101676. */
  101677. static readonly ALPHA_SCREENMODE: number;
  101678. /** Defines that the ressource is not delayed*/
  101679. static readonly DELAYLOADSTATE_NONE: number;
  101680. /** Defines that the ressource was successfully delay loaded */
  101681. static readonly DELAYLOADSTATE_LOADED: number;
  101682. /** Defines that the ressource is currently delay loading */
  101683. static readonly DELAYLOADSTATE_LOADING: number;
  101684. /** Defines that the ressource is delayed and has not started loading */
  101685. static readonly DELAYLOADSTATE_NOTLOADED: number;
  101686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  101687. static readonly NEVER: number;
  101688. /** 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 */
  101689. static readonly ALWAYS: number;
  101690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  101691. static readonly LESS: number;
  101692. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  101693. static readonly EQUAL: number;
  101694. /** 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 */
  101695. static readonly LEQUAL: number;
  101696. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  101697. static readonly GREATER: number;
  101698. /** 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 */
  101699. static readonly GEQUAL: number;
  101700. /** 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 */
  101701. static readonly NOTEQUAL: number;
  101702. /** Passed to stencilOperation to specify that stencil value must be kept */
  101703. static readonly KEEP: number;
  101704. /** Passed to stencilOperation to specify that stencil value must be replaced */
  101705. static readonly REPLACE: number;
  101706. /** Passed to stencilOperation to specify that stencil value must be incremented */
  101707. static readonly INCR: number;
  101708. /** Passed to stencilOperation to specify that stencil value must be decremented */
  101709. static readonly DECR: number;
  101710. /** Passed to stencilOperation to specify that stencil value must be inverted */
  101711. static readonly INVERT: number;
  101712. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  101713. static readonly INCR_WRAP: number;
  101714. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  101715. static readonly DECR_WRAP: number;
  101716. /** Texture is not repeating outside of 0..1 UVs */
  101717. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  101718. /** Texture is repeating outside of 0..1 UVs */
  101719. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  101720. /** Texture is repeating and mirrored */
  101721. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  101722. /** ALPHA */
  101723. static readonly TEXTUREFORMAT_ALPHA: number;
  101724. /** LUMINANCE */
  101725. static readonly TEXTUREFORMAT_LUMINANCE: number;
  101726. /** LUMINANCE_ALPHA */
  101727. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  101728. /** RGB */
  101729. static readonly TEXTUREFORMAT_RGB: number;
  101730. /** RGBA */
  101731. static readonly TEXTUREFORMAT_RGBA: number;
  101732. /** RED */
  101733. static readonly TEXTUREFORMAT_RED: number;
  101734. /** RED (2nd reference) */
  101735. static readonly TEXTUREFORMAT_R: number;
  101736. /** RG */
  101737. static readonly TEXTUREFORMAT_RG: number;
  101738. /** RED_INTEGER */
  101739. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  101740. /** RED_INTEGER (2nd reference) */
  101741. static readonly TEXTUREFORMAT_R_INTEGER: number;
  101742. /** RG_INTEGER */
  101743. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  101744. /** RGB_INTEGER */
  101745. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  101746. /** RGBA_INTEGER */
  101747. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  101748. /** UNSIGNED_BYTE */
  101749. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  101750. /** UNSIGNED_BYTE (2nd reference) */
  101751. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  101752. /** FLOAT */
  101753. static readonly TEXTURETYPE_FLOAT: number;
  101754. /** HALF_FLOAT */
  101755. static readonly TEXTURETYPE_HALF_FLOAT: number;
  101756. /** BYTE */
  101757. static readonly TEXTURETYPE_BYTE: number;
  101758. /** SHORT */
  101759. static readonly TEXTURETYPE_SHORT: number;
  101760. /** UNSIGNED_SHORT */
  101761. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  101762. /** INT */
  101763. static readonly TEXTURETYPE_INT: number;
  101764. /** UNSIGNED_INT */
  101765. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  101766. /** UNSIGNED_SHORT_4_4_4_4 */
  101767. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  101768. /** UNSIGNED_SHORT_5_5_5_1 */
  101769. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  101770. /** UNSIGNED_SHORT_5_6_5 */
  101771. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  101772. /** UNSIGNED_INT_2_10_10_10_REV */
  101773. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  101774. /** UNSIGNED_INT_24_8 */
  101775. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  101776. /** UNSIGNED_INT_10F_11F_11F_REV */
  101777. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  101778. /** UNSIGNED_INT_5_9_9_9_REV */
  101779. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  101780. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  101781. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  101782. /** nearest is mag = nearest and min = nearest and mip = linear */
  101783. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  101784. /** Bilinear is mag = linear and min = linear and mip = nearest */
  101785. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  101786. /** Trilinear is mag = linear and min = linear and mip = linear */
  101787. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  101788. /** nearest is mag = nearest and min = nearest and mip = linear */
  101789. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  101790. /** Bilinear is mag = linear and min = linear and mip = nearest */
  101791. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  101792. /** Trilinear is mag = linear and min = linear and mip = linear */
  101793. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  101794. /** mag = nearest and min = nearest and mip = nearest */
  101795. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  101796. /** mag = nearest and min = linear and mip = nearest */
  101797. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  101798. /** mag = nearest and min = linear and mip = linear */
  101799. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  101800. /** mag = nearest and min = linear and mip = none */
  101801. static readonly TEXTURE_NEAREST_LINEAR: number;
  101802. /** mag = nearest and min = nearest and mip = none */
  101803. static readonly TEXTURE_NEAREST_NEAREST: number;
  101804. /** mag = linear and min = nearest and mip = nearest */
  101805. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  101806. /** mag = linear and min = nearest and mip = linear */
  101807. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  101808. /** mag = linear and min = linear and mip = none */
  101809. static readonly TEXTURE_LINEAR_LINEAR: number;
  101810. /** mag = linear and min = nearest and mip = none */
  101811. static readonly TEXTURE_LINEAR_NEAREST: number;
  101812. /** Explicit coordinates mode */
  101813. static readonly TEXTURE_EXPLICIT_MODE: number;
  101814. /** Spherical coordinates mode */
  101815. static readonly TEXTURE_SPHERICAL_MODE: number;
  101816. /** Planar coordinates mode */
  101817. static readonly TEXTURE_PLANAR_MODE: number;
  101818. /** Cubic coordinates mode */
  101819. static readonly TEXTURE_CUBIC_MODE: number;
  101820. /** Projection coordinates mode */
  101821. static readonly TEXTURE_PROJECTION_MODE: number;
  101822. /** Skybox coordinates mode */
  101823. static readonly TEXTURE_SKYBOX_MODE: number;
  101824. /** Inverse Cubic coordinates mode */
  101825. static readonly TEXTURE_INVCUBIC_MODE: number;
  101826. /** Equirectangular coordinates mode */
  101827. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  101828. /** Equirectangular Fixed coordinates mode */
  101829. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  101830. /** Equirectangular Fixed Mirrored coordinates mode */
  101831. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  101832. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  101833. static readonly SCALEMODE_FLOOR: number;
  101834. /** Defines that texture rescaling will look for the nearest power of 2 size */
  101835. static readonly SCALEMODE_NEAREST: number;
  101836. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  101837. static readonly SCALEMODE_CEILING: number;
  101838. /**
  101839. * Returns the current npm package of the sdk
  101840. */
  101841. static readonly NpmPackage: string;
  101842. /**
  101843. * Returns the current version of the framework
  101844. */
  101845. static readonly Version: string;
  101846. /** Gets the list of created engines */
  101847. static readonly Instances: Engine[];
  101848. /**
  101849. * Gets the latest created engine
  101850. */
  101851. static readonly LastCreatedEngine: Nullable<Engine>;
  101852. /**
  101853. * Gets the latest created scene
  101854. */
  101855. static readonly LastCreatedScene: Nullable<Scene>;
  101856. /**
  101857. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  101858. * @param flag defines which part of the materials must be marked as dirty
  101859. * @param predicate defines a predicate used to filter which materials should be affected
  101860. */
  101861. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  101862. /**
  101863. * Method called to create the default loading screen.
  101864. * This can be overriden in your own app.
  101865. * @param canvas The rendering canvas element
  101866. * @returns The loading screen
  101867. */
  101868. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  101869. /**
  101870. * Method called to create the default rescale post process on each engine.
  101871. */
  101872. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  101873. /**
  101874. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  101875. **/
  101876. enableOfflineSupport: boolean;
  101877. /**
  101878. * 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)
  101879. **/
  101880. disableManifestCheck: boolean;
  101881. /**
  101882. * Gets the list of created scenes
  101883. */
  101884. scenes: Scene[];
  101885. /**
  101886. * Event raised when a new scene is created
  101887. */
  101888. onNewSceneAddedObservable: Observable<Scene>;
  101889. /**
  101890. * Gets the list of created postprocesses
  101891. */
  101892. postProcesses: PostProcess[];
  101893. /**
  101894. * Gets a boolean indicating if the pointer is currently locked
  101895. */
  101896. isPointerLock: boolean;
  101897. /**
  101898. * Observable event triggered each time the rendering canvas is resized
  101899. */
  101900. onResizeObservable: Observable<Engine>;
  101901. /**
  101902. * Observable event triggered each time the canvas loses focus
  101903. */
  101904. onCanvasBlurObservable: Observable<Engine>;
  101905. /**
  101906. * Observable event triggered each time the canvas gains focus
  101907. */
  101908. onCanvasFocusObservable: Observable<Engine>;
  101909. /**
  101910. * Observable event triggered each time the canvas receives pointerout event
  101911. */
  101912. onCanvasPointerOutObservable: Observable<PointerEvent>;
  101913. /**
  101914. * Observable raised when the engine begins a new frame
  101915. */
  101916. onBeginFrameObservable: Observable<Engine>;
  101917. /**
  101918. * If set, will be used to request the next animation frame for the render loop
  101919. */
  101920. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  101921. /**
  101922. * Observable raised when the engine ends the current frame
  101923. */
  101924. onEndFrameObservable: Observable<Engine>;
  101925. /**
  101926. * Observable raised when the engine is about to compile a shader
  101927. */
  101928. onBeforeShaderCompilationObservable: Observable<Engine>;
  101929. /**
  101930. * Observable raised when the engine has jsut compiled a shader
  101931. */
  101932. onAfterShaderCompilationObservable: Observable<Engine>;
  101933. /**
  101934. * Gets the audio engine
  101935. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101936. * @ignorenaming
  101937. */
  101938. static audioEngine: IAudioEngine;
  101939. /**
  101940. * Default AudioEngine factory responsible of creating the Audio Engine.
  101941. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  101942. */
  101943. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  101944. /**
  101945. * Default offline support factory responsible of creating a tool used to store data locally.
  101946. * By default, this will create a Database object if the workload has been embedded.
  101947. */
  101948. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  101949. private _loadingScreen;
  101950. private _pointerLockRequested;
  101951. private _dummyFramebuffer;
  101952. private _rescalePostProcess;
  101953. /** @hidden */
  101954. protected _alphaMode: number;
  101955. /** @hidden */
  101956. protected _alphaEquation: number;
  101957. private _deterministicLockstep;
  101958. private _lockstepMaxSteps;
  101959. private _timeStep;
  101960. protected readonly _supportsHardwareTextureRescaling: boolean;
  101961. private _fps;
  101962. private _deltaTime;
  101963. /** @hidden */
  101964. _drawCalls: PerfCounter;
  101965. /**
  101966. * Turn this value on if you want to pause FPS computation when in background
  101967. */
  101968. disablePerformanceMonitorInBackground: boolean;
  101969. private _performanceMonitor;
  101970. /**
  101971. * Gets the performance monitor attached to this engine
  101972. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  101973. */
  101974. readonly performanceMonitor: PerformanceMonitor;
  101975. private _onFocus;
  101976. private _onBlur;
  101977. private _onCanvasPointerOut;
  101978. private _onCanvasBlur;
  101979. private _onCanvasFocus;
  101980. private _onFullscreenChange;
  101981. private _onPointerLockChange;
  101982. /**
  101983. * Gets the HTML element used to attach event listeners
  101984. * @returns a HTML element
  101985. */
  101986. getInputElement(): Nullable<HTMLElement>;
  101987. /**
  101988. * Creates a new engine
  101989. * @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
  101990. * @param antialias defines enable antialiasing (default: false)
  101991. * @param options defines further options to be sent to the getContext() function
  101992. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  101993. */
  101994. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  101995. /**
  101996. * Gets current aspect ratio
  101997. * @param viewportOwner defines the camera to use to get the aspect ratio
  101998. * @param useScreen defines if screen size must be used (or the current render target if any)
  101999. * @returns a number defining the aspect ratio
  102000. */
  102001. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  102002. /**
  102003. * Gets current screen aspect ratio
  102004. * @returns a number defining the aspect ratio
  102005. */
  102006. getScreenAspectRatio(): number;
  102007. /**
  102008. * Gets the client rect of the HTML canvas attached with the current webGL context
  102009. * @returns a client rectanglee
  102010. */
  102011. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  102012. /**
  102013. * Gets the client rect of the HTML element used for events
  102014. * @returns a client rectanglee
  102015. */
  102016. getInputElementClientRect(): Nullable<ClientRect>;
  102017. /**
  102018. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  102019. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  102020. * @returns true if engine is in deterministic lock step mode
  102021. */
  102022. isDeterministicLockStep(): boolean;
  102023. /**
  102024. * Gets the max steps when engine is running in deterministic lock step
  102025. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  102026. * @returns the max steps
  102027. */
  102028. getLockstepMaxSteps(): number;
  102029. /**
  102030. * Returns the time in ms between steps when using deterministic lock step.
  102031. * @returns time step in (ms)
  102032. */
  102033. getTimeStep(): number;
  102034. /**
  102035. * Force the mipmap generation for the given render target texture
  102036. * @param texture defines the render target texture to use
  102037. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  102038. */
  102039. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  102040. /** States */
  102041. /**
  102042. * Set various states to the webGL context
  102043. * @param culling defines backface culling state
  102044. * @param zOffset defines the value to apply to zOffset (0 by default)
  102045. * @param force defines if states must be applied even if cache is up to date
  102046. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  102047. */
  102048. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  102049. /**
  102050. * Set the z offset to apply to current rendering
  102051. * @param value defines the offset to apply
  102052. */
  102053. setZOffset(value: number): void;
  102054. /**
  102055. * Gets the current value of the zOffset
  102056. * @returns the current zOffset state
  102057. */
  102058. getZOffset(): number;
  102059. /**
  102060. * Enable or disable depth buffering
  102061. * @param enable defines the state to set
  102062. */
  102063. setDepthBuffer(enable: boolean): void;
  102064. /**
  102065. * Gets a boolean indicating if depth writing is enabled
  102066. * @returns the current depth writing state
  102067. */
  102068. getDepthWrite(): boolean;
  102069. /**
  102070. * Enable or disable depth writing
  102071. * @param enable defines the state to set
  102072. */
  102073. setDepthWrite(enable: boolean): void;
  102074. /**
  102075. * Enable or disable color writing
  102076. * @param enable defines the state to set
  102077. */
  102078. setColorWrite(enable: boolean): void;
  102079. /**
  102080. * Gets a boolean indicating if color writing is enabled
  102081. * @returns the current color writing state
  102082. */
  102083. getColorWrite(): boolean;
  102084. /**
  102085. * Sets alpha constants used by some alpha blending modes
  102086. * @param r defines the red component
  102087. * @param g defines the green component
  102088. * @param b defines the blue component
  102089. * @param a defines the alpha component
  102090. */
  102091. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  102092. /**
  102093. * Sets the current alpha mode
  102094. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  102095. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  102096. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  102097. */
  102098. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  102099. /**
  102100. * Gets the current alpha mode
  102101. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  102102. * @returns the current alpha mode
  102103. */
  102104. getAlphaMode(): number;
  102105. /**
  102106. * Sets the current alpha equation
  102107. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  102108. */
  102109. setAlphaEquation(equation: number): void;
  102110. /**
  102111. * Gets the current alpha equation.
  102112. * @returns the current alpha equation
  102113. */
  102114. getAlphaEquation(): number;
  102115. /**
  102116. * Gets a boolean indicating if stencil buffer is enabled
  102117. * @returns the current stencil buffer state
  102118. */
  102119. getStencilBuffer(): boolean;
  102120. /**
  102121. * Enable or disable the stencil buffer
  102122. * @param enable defines if the stencil buffer must be enabled or disabled
  102123. */
  102124. setStencilBuffer(enable: boolean): void;
  102125. /**
  102126. * Gets the current stencil mask
  102127. * @returns a number defining the new stencil mask to use
  102128. */
  102129. getStencilMask(): number;
  102130. /**
  102131. * Sets the current stencil mask
  102132. * @param mask defines the new stencil mask to use
  102133. */
  102134. setStencilMask(mask: number): void;
  102135. /**
  102136. * Gets the current stencil function
  102137. * @returns a number defining the stencil function to use
  102138. */
  102139. getStencilFunction(): number;
  102140. /**
  102141. * Gets the current stencil reference value
  102142. * @returns a number defining the stencil reference value to use
  102143. */
  102144. getStencilFunctionReference(): number;
  102145. /**
  102146. * Gets the current stencil mask
  102147. * @returns a number defining the stencil mask to use
  102148. */
  102149. getStencilFunctionMask(): number;
  102150. /**
  102151. * Sets the current stencil function
  102152. * @param stencilFunc defines the new stencil function to use
  102153. */
  102154. setStencilFunction(stencilFunc: number): void;
  102155. /**
  102156. * Sets the current stencil reference
  102157. * @param reference defines the new stencil reference to use
  102158. */
  102159. setStencilFunctionReference(reference: number): void;
  102160. /**
  102161. * Sets the current stencil mask
  102162. * @param mask defines the new stencil mask to use
  102163. */
  102164. setStencilFunctionMask(mask: number): void;
  102165. /**
  102166. * Gets the current stencil operation when stencil fails
  102167. * @returns a number defining stencil operation to use when stencil fails
  102168. */
  102169. getStencilOperationFail(): number;
  102170. /**
  102171. * Gets the current stencil operation when depth fails
  102172. * @returns a number defining stencil operation to use when depth fails
  102173. */
  102174. getStencilOperationDepthFail(): number;
  102175. /**
  102176. * Gets the current stencil operation when stencil passes
  102177. * @returns a number defining stencil operation to use when stencil passes
  102178. */
  102179. getStencilOperationPass(): number;
  102180. /**
  102181. * Sets the stencil operation to use when stencil fails
  102182. * @param operation defines the stencil operation to use when stencil fails
  102183. */
  102184. setStencilOperationFail(operation: number): void;
  102185. /**
  102186. * Sets the stencil operation to use when depth fails
  102187. * @param operation defines the stencil operation to use when depth fails
  102188. */
  102189. setStencilOperationDepthFail(operation: number): void;
  102190. /**
  102191. * Sets the stencil operation to use when stencil passes
  102192. * @param operation defines the stencil operation to use when stencil passes
  102193. */
  102194. setStencilOperationPass(operation: number): void;
  102195. /**
  102196. * Sets a boolean indicating if the dithering state is enabled or disabled
  102197. * @param value defines the dithering state
  102198. */
  102199. setDitheringState(value: boolean): void;
  102200. /**
  102201. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  102202. * @param value defines the rasterizer state
  102203. */
  102204. setRasterizerState(value: boolean): void;
  102205. /**
  102206. * Gets the current depth function
  102207. * @returns a number defining the depth function
  102208. */
  102209. getDepthFunction(): Nullable<number>;
  102210. /**
  102211. * Sets the current depth function
  102212. * @param depthFunc defines the function to use
  102213. */
  102214. setDepthFunction(depthFunc: number): void;
  102215. /**
  102216. * Sets the current depth function to GREATER
  102217. */
  102218. setDepthFunctionToGreater(): void;
  102219. /**
  102220. * Sets the current depth function to GEQUAL
  102221. */
  102222. setDepthFunctionToGreaterOrEqual(): void;
  102223. /**
  102224. * Sets the current depth function to LESS
  102225. */
  102226. setDepthFunctionToLess(): void;
  102227. /**
  102228. * Sets the current depth function to LEQUAL
  102229. */
  102230. setDepthFunctionToLessOrEqual(): void;
  102231. private _cachedStencilBuffer;
  102232. private _cachedStencilFunction;
  102233. private _cachedStencilMask;
  102234. private _cachedStencilOperationPass;
  102235. private _cachedStencilOperationFail;
  102236. private _cachedStencilOperationDepthFail;
  102237. private _cachedStencilReference;
  102238. /**
  102239. * Caches the the state of the stencil buffer
  102240. */
  102241. cacheStencilState(): void;
  102242. /**
  102243. * Restores the state of the stencil buffer
  102244. */
  102245. restoreStencilState(): void;
  102246. /**
  102247. * Directly set the WebGL Viewport
  102248. * @param x defines the x coordinate of the viewport (in screen space)
  102249. * @param y defines the y coordinate of the viewport (in screen space)
  102250. * @param width defines the width of the viewport (in screen space)
  102251. * @param height defines the height of the viewport (in screen space)
  102252. * @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
  102253. */
  102254. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  102255. /**
  102256. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  102257. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  102258. * @param y defines the y-coordinate of the corner of the clear rectangle
  102259. * @param width defines the width of the clear rectangle
  102260. * @param height defines the height of the clear rectangle
  102261. * @param clearColor defines the clear color
  102262. */
  102263. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  102264. /**
  102265. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  102266. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  102267. * @param y defines the y-coordinate of the corner of the clear rectangle
  102268. * @param width defines the width of the clear rectangle
  102269. * @param height defines the height of the clear rectangle
  102270. */
  102271. enableScissor(x: number, y: number, width: number, height: number): void;
  102272. /**
  102273. * Disable previously set scissor test rectangle
  102274. */
  102275. disableScissor(): void;
  102276. protected _reportDrawCall(): void;
  102277. /**
  102278. * Initializes a webVR display and starts listening to display change events
  102279. * The onVRDisplayChangedObservable will be notified upon these changes
  102280. * @returns The onVRDisplayChangedObservable
  102281. */
  102282. initWebVR(): Observable<IDisplayChangedEventArgs>;
  102283. /** @hidden */
  102284. _prepareVRComponent(): void;
  102285. /** @hidden */
  102286. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  102287. /** @hidden */
  102288. _submitVRFrame(): void;
  102289. /**
  102290. * Call this function to leave webVR mode
  102291. * Will do nothing if webVR is not supported or if there is no webVR device
  102292. * @see http://doc.babylonjs.com/how_to/webvr_camera
  102293. */
  102294. disableVR(): void;
  102295. /**
  102296. * Gets a boolean indicating that the system is in VR mode and is presenting
  102297. * @returns true if VR mode is engaged
  102298. */
  102299. isVRPresenting(): boolean;
  102300. /** @hidden */
  102301. _requestVRFrame(): void;
  102302. /** @hidden */
  102303. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  102304. /**
  102305. * Gets the source code of the vertex shader associated with a specific webGL program
  102306. * @param program defines the program to use
  102307. * @returns a string containing the source code of the vertex shader associated with the program
  102308. */
  102309. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  102310. /**
  102311. * Gets the source code of the fragment shader associated with a specific webGL program
  102312. * @param program defines the program to use
  102313. * @returns a string containing the source code of the fragment shader associated with the program
  102314. */
  102315. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  102316. /**
  102317. * Reads pixels from the current frame buffer. Please note that this function can be slow
  102318. * @param x defines the x coordinate of the rectangle where pixels must be read
  102319. * @param y defines the y coordinate of the rectangle where pixels must be read
  102320. * @param width defines the width of the rectangle where pixels must be read
  102321. * @param height defines the height of the rectangle where pixels must be read
  102322. * @returns a Uint8Array containing RGBA colors
  102323. */
  102324. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  102325. /**
  102326. * Sets a depth stencil texture from a render target to the according uniform.
  102327. * @param channel The texture channel
  102328. * @param uniform The uniform to set
  102329. * @param texture The render target texture containing the depth stencil texture to apply
  102330. */
  102331. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  102332. /**
  102333. * Sets a texture to the webGL context from a postprocess
  102334. * @param channel defines the channel to use
  102335. * @param postProcess defines the source postprocess
  102336. */
  102337. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  102338. /**
  102339. * Binds the output of the passed in post process to the texture channel specified
  102340. * @param channel The channel the texture should be bound to
  102341. * @param postProcess The post process which's output should be bound
  102342. */
  102343. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  102344. /** @hidden */
  102345. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  102346. protected _rebuildBuffers(): void;
  102347. /** @hidden */
  102348. _renderFrame(): void;
  102349. _renderLoop(): void;
  102350. /** @hidden */
  102351. _renderViews(): boolean;
  102352. /**
  102353. * Toggle full screen mode
  102354. * @param requestPointerLock defines if a pointer lock should be requested from the user
  102355. */
  102356. switchFullscreen(requestPointerLock: boolean): void;
  102357. /**
  102358. * Enters full screen mode
  102359. * @param requestPointerLock defines if a pointer lock should be requested from the user
  102360. */
  102361. enterFullscreen(requestPointerLock: boolean): void;
  102362. /**
  102363. * Exits full screen mode
  102364. */
  102365. exitFullscreen(): void;
  102366. /**
  102367. * Enters Pointerlock mode
  102368. */
  102369. enterPointerlock(): void;
  102370. /**
  102371. * Exits Pointerlock mode
  102372. */
  102373. exitPointerlock(): void;
  102374. /**
  102375. * Begin a new frame
  102376. */
  102377. beginFrame(): void;
  102378. /**
  102379. * Enf the current frame
  102380. */
  102381. endFrame(): void;
  102382. resize(): void;
  102383. /**
  102384. * Set the compressed texture format to use, based on the formats you have, and the formats
  102385. * supported by the hardware / browser.
  102386. *
  102387. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  102388. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  102389. * to API arguments needed to compressed textures. This puts the burden on the container
  102390. * generator to house the arcane code for determining these for current & future formats.
  102391. *
  102392. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  102393. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  102394. *
  102395. * Note: The result of this call is not taken into account when a texture is base64.
  102396. *
  102397. * @param formatsAvailable defines the list of those format families you have created
  102398. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  102399. *
  102400. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  102401. * @returns The extension selected.
  102402. */
  102403. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  102404. /**
  102405. * Set the compressed texture extensions or file names to skip.
  102406. *
  102407. * @param skippedFiles defines the list of those texture files you want to skip
  102408. * Example: [".dds", ".env", "myfile.png"]
  102409. */
  102410. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  102411. /**
  102412. * Force a specific size of the canvas
  102413. * @param width defines the new canvas' width
  102414. * @param height defines the new canvas' height
  102415. */
  102416. setSize(width: number, height: number): void;
  102417. /**
  102418. * Updates a dynamic vertex buffer.
  102419. * @param vertexBuffer the vertex buffer to update
  102420. * @param data the data used to update the vertex buffer
  102421. * @param byteOffset the byte offset of the data
  102422. * @param byteLength the byte length of the data
  102423. */
  102424. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  102425. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  102426. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  102427. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  102428. _releaseTexture(texture: InternalTexture): void;
  102429. /**
  102430. * @hidden
  102431. * Rescales a texture
  102432. * @param source input texutre
  102433. * @param destination destination texture
  102434. * @param scene scene to use to render the resize
  102435. * @param internalFormat format to use when resizing
  102436. * @param onComplete callback to be called when resize has completed
  102437. */
  102438. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  102439. /**
  102440. * Gets the current framerate
  102441. * @returns a number representing the framerate
  102442. */
  102443. getFps(): number;
  102444. /**
  102445. * Gets the time spent between current and previous frame
  102446. * @returns a number representing the delta time in ms
  102447. */
  102448. getDeltaTime(): number;
  102449. private _measureFps;
  102450. /** @hidden */
  102451. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  102452. /**
  102453. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  102454. * @param renderTarget The render target to set the frame buffer for
  102455. */
  102456. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  102457. /**
  102458. * Update a dynamic index buffer
  102459. * @param indexBuffer defines the target index buffer
  102460. * @param indices defines the data to update
  102461. * @param offset defines the offset in the target index buffer where update should start
  102462. */
  102463. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  102464. /**
  102465. * Updates the sample count of a render target texture
  102466. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  102467. * @param texture defines the texture to update
  102468. * @param samples defines the sample count to set
  102469. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  102470. */
  102471. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  102472. /**
  102473. * Updates a depth texture Comparison Mode and Function.
  102474. * If the comparison Function is equal to 0, the mode will be set to none.
  102475. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  102476. * @param texture The texture to set the comparison function for
  102477. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  102478. */
  102479. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  102480. /**
  102481. * Creates a webGL buffer to use with instanciation
  102482. * @param capacity defines the size of the buffer
  102483. * @returns the webGL buffer
  102484. */
  102485. createInstancesBuffer(capacity: number): DataBuffer;
  102486. /**
  102487. * Delete a webGL buffer used with instanciation
  102488. * @param buffer defines the webGL buffer to delete
  102489. */
  102490. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  102491. /** @hidden */
  102492. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  102493. dispose(): void;
  102494. private _disableTouchAction;
  102495. /**
  102496. * Display the loading screen
  102497. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  102498. */
  102499. displayLoadingUI(): void;
  102500. /**
  102501. * Hide the loading screen
  102502. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  102503. */
  102504. hideLoadingUI(): void;
  102505. /**
  102506. * Gets the current loading screen object
  102507. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  102508. */
  102509. /**
  102510. * Sets the current loading screen object
  102511. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  102512. */
  102513. loadingScreen: ILoadingScreen;
  102514. /**
  102515. * Sets the current loading screen text
  102516. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  102517. */
  102518. loadingUIText: string;
  102519. /**
  102520. * Sets the current loading screen background color
  102521. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  102522. */
  102523. loadingUIBackgroundColor: string;
  102524. /** Pointerlock and fullscreen */
  102525. /**
  102526. * Ask the browser to promote the current element to pointerlock mode
  102527. * @param element defines the DOM element to promote
  102528. */
  102529. static _RequestPointerlock(element: HTMLElement): void;
  102530. /**
  102531. * Asks the browser to exit pointerlock mode
  102532. */
  102533. static _ExitPointerlock(): void;
  102534. /**
  102535. * Ask the browser to promote the current element to fullscreen rendering mode
  102536. * @param element defines the DOM element to promote
  102537. */
  102538. static _RequestFullscreen(element: HTMLElement): void;
  102539. /**
  102540. * Asks the browser to exit fullscreen mode
  102541. */
  102542. static _ExitFullscreen(): void;
  102543. }
  102544. }
  102545. declare module BABYLON {
  102546. /**
  102547. * The engine store class is responsible to hold all the instances of Engine and Scene created
  102548. * during the life time of the application.
  102549. */
  102550. export class EngineStore {
  102551. /** Gets the list of created engines */
  102552. static Instances: Engine[];
  102553. /** @hidden */
  102554. static _LastCreatedScene: Nullable<Scene>;
  102555. /**
  102556. * Gets the latest created engine
  102557. */
  102558. static readonly LastCreatedEngine: Nullable<Engine>;
  102559. /**
  102560. * Gets the latest created scene
  102561. */
  102562. static readonly LastCreatedScene: Nullable<Scene>;
  102563. /**
  102564. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  102565. * @ignorenaming
  102566. */
  102567. static UseFallbackTexture: boolean;
  102568. /**
  102569. * Texture content used if a texture cannot loaded
  102570. * @ignorenaming
  102571. */
  102572. static FallbackTexture: string;
  102573. }
  102574. }
  102575. declare module BABYLON {
  102576. /**
  102577. * Helper class that provides a small promise polyfill
  102578. */
  102579. export class PromisePolyfill {
  102580. /**
  102581. * Static function used to check if the polyfill is required
  102582. * If this is the case then the function will inject the polyfill to window.Promise
  102583. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  102584. */
  102585. static Apply(force?: boolean): void;
  102586. }
  102587. }
  102588. declare module BABYLON {
  102589. /**
  102590. * Interface for screenshot methods with describe argument called `size` as object with options
  102591. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  102592. */
  102593. export interface IScreenshotSize {
  102594. /**
  102595. * number in pixels for canvas height
  102596. */
  102597. height?: number;
  102598. /**
  102599. * multiplier allowing render at a higher or lower resolution
  102600. * If value is defined then height and width will be ignored and taken from camera
  102601. */
  102602. precision?: number;
  102603. /**
  102604. * number in pixels for canvas width
  102605. */
  102606. width?: number;
  102607. }
  102608. }
  102609. declare module BABYLON {
  102610. interface IColor4Like {
  102611. r: float;
  102612. g: float;
  102613. b: float;
  102614. a: float;
  102615. }
  102616. /**
  102617. * Class containing a set of static utilities functions
  102618. */
  102619. export class Tools {
  102620. /**
  102621. * Gets or sets the base URL to use to load assets
  102622. */
  102623. static BaseUrl: string;
  102624. /**
  102625. * Enable/Disable Custom HTTP Request Headers globally.
  102626. * default = false
  102627. * @see CustomRequestHeaders
  102628. */
  102629. static UseCustomRequestHeaders: boolean;
  102630. /**
  102631. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  102632. * i.e. when loading files, where the server/service expects an Authorization header
  102633. */
  102634. static CustomRequestHeaders: {
  102635. [key: string]: string;
  102636. };
  102637. /**
  102638. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  102639. */
  102640. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  102641. /**
  102642. * Default behaviour for cors in the application.
  102643. * It can be a string if the expected behavior is identical in the entire app.
  102644. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  102645. */
  102646. static CorsBehavior: string | ((url: string | string[]) => string);
  102647. /**
  102648. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  102649. * @ignorenaming
  102650. */
  102651. static UseFallbackTexture: boolean;
  102652. /**
  102653. * Use this object to register external classes like custom textures or material
  102654. * to allow the laoders to instantiate them
  102655. */
  102656. static RegisteredExternalClasses: {
  102657. [key: string]: Object;
  102658. };
  102659. /**
  102660. * Texture content used if a texture cannot loaded
  102661. * @ignorenaming
  102662. */
  102663. static fallbackTexture: string;
  102664. /**
  102665. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  102666. * @param u defines the coordinate on X axis
  102667. * @param v defines the coordinate on Y axis
  102668. * @param width defines the width of the source data
  102669. * @param height defines the height of the source data
  102670. * @param pixels defines the source byte array
  102671. * @param color defines the output color
  102672. */
  102673. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  102674. /**
  102675. * Interpolates between a and b via alpha
  102676. * @param a The lower value (returned when alpha = 0)
  102677. * @param b The upper value (returned when alpha = 1)
  102678. * @param alpha The interpolation-factor
  102679. * @return The mixed value
  102680. */
  102681. static Mix(a: number, b: number, alpha: number): number;
  102682. /**
  102683. * Tries to instantiate a new object from a given class name
  102684. * @param className defines the class name to instantiate
  102685. * @returns the new object or null if the system was not able to do the instantiation
  102686. */
  102687. static Instantiate(className: string): any;
  102688. /**
  102689. * Provides a slice function that will work even on IE
  102690. * @param data defines the array to slice
  102691. * @param start defines the start of the data (optional)
  102692. * @param end defines the end of the data (optional)
  102693. * @returns the new sliced array
  102694. */
  102695. static Slice<T>(data: T, start?: number, end?: number): T;
  102696. /**
  102697. * Polyfill for setImmediate
  102698. * @param action defines the action to execute after the current execution block
  102699. */
  102700. static SetImmediate(action: () => void): void;
  102701. /**
  102702. * Function indicating if a number is an exponent of 2
  102703. * @param value defines the value to test
  102704. * @returns true if the value is an exponent of 2
  102705. */
  102706. static IsExponentOfTwo(value: number): boolean;
  102707. private static _tmpFloatArray;
  102708. /**
  102709. * Returns the nearest 32-bit single precision float representation of a Number
  102710. * @param value A Number. If the parameter is of a different type, it will get converted
  102711. * to a number or to NaN if it cannot be converted
  102712. * @returns number
  102713. */
  102714. static FloatRound(value: number): number;
  102715. /**
  102716. * Extracts the filename from a path
  102717. * @param path defines the path to use
  102718. * @returns the filename
  102719. */
  102720. static GetFilename(path: string): string;
  102721. /**
  102722. * Extracts the "folder" part of a path (everything before the filename).
  102723. * @param uri The URI to extract the info from
  102724. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  102725. * @returns The "folder" part of the path
  102726. */
  102727. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  102728. /**
  102729. * Extracts text content from a DOM element hierarchy
  102730. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  102731. */
  102732. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  102733. /**
  102734. * Convert an angle in radians to degrees
  102735. * @param angle defines the angle to convert
  102736. * @returns the angle in degrees
  102737. */
  102738. static ToDegrees(angle: number): number;
  102739. /**
  102740. * Convert an angle in degrees to radians
  102741. * @param angle defines the angle to convert
  102742. * @returns the angle in radians
  102743. */
  102744. static ToRadians(angle: number): number;
  102745. /**
  102746. * Returns an array if obj is not an array
  102747. * @param obj defines the object to evaluate as an array
  102748. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  102749. * @returns either obj directly if obj is an array or a new array containing obj
  102750. */
  102751. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  102752. /**
  102753. * Gets the pointer prefix to use
  102754. * @returns "pointer" if touch is enabled. Else returns "mouse"
  102755. */
  102756. static GetPointerPrefix(): string;
  102757. /**
  102758. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  102759. * @param url define the url we are trying
  102760. * @param element define the dom element where to configure the cors policy
  102761. */
  102762. static SetCorsBehavior(url: string | string[], element: {
  102763. crossOrigin: string | null;
  102764. }): void;
  102765. /**
  102766. * Removes unwanted characters from an url
  102767. * @param url defines the url to clean
  102768. * @returns the cleaned url
  102769. */
  102770. static CleanUrl(url: string): string;
  102771. /**
  102772. * Gets or sets a function used to pre-process url before using them to load assets
  102773. */
  102774. static PreprocessUrl: (url: string) => string;
  102775. /**
  102776. * Loads an image as an HTMLImageElement.
  102777. * @param input url string, ArrayBuffer, or Blob to load
  102778. * @param onLoad callback called when the image successfully loads
  102779. * @param onError callback called when the image fails to load
  102780. * @param offlineProvider offline provider for caching
  102781. * @param mimeType optional mime type
  102782. * @returns the HTMLImageElement of the loaded image
  102783. */
  102784. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  102785. /**
  102786. * Loads a file from a url
  102787. * @param url url string, ArrayBuffer, or Blob to load
  102788. * @param onSuccess callback called when the file successfully loads
  102789. * @param onProgress callback called while file is loading (if the server supports this mode)
  102790. * @param offlineProvider defines the offline provider for caching
  102791. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  102792. * @param onError callback called when the file fails to load
  102793. * @returns a file request object
  102794. */
  102795. 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;
  102796. /**
  102797. * Loads a file from a url
  102798. * @param url the file url to load
  102799. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  102800. */
  102801. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  102802. /**
  102803. * Load a script (identified by an url). When the url returns, the
  102804. * content of this file is added into a new script element, attached to the DOM (body element)
  102805. * @param scriptUrl defines the url of the script to laod
  102806. * @param onSuccess defines the callback called when the script is loaded
  102807. * @param onError defines the callback to call if an error occurs
  102808. * @param scriptId defines the id of the script element
  102809. */
  102810. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  102811. /**
  102812. * Load an asynchronous script (identified by an url). When the url returns, the
  102813. * content of this file is added into a new script element, attached to the DOM (body element)
  102814. * @param scriptUrl defines the url of the script to laod
  102815. * @param scriptId defines the id of the script element
  102816. * @returns a promise request object
  102817. */
  102818. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  102819. /**
  102820. * Loads a file from a blob
  102821. * @param fileToLoad defines the blob to use
  102822. * @param callback defines the callback to call when data is loaded
  102823. * @param progressCallback defines the callback to call during loading process
  102824. * @returns a file request object
  102825. */
  102826. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  102827. /**
  102828. * Reads a file from a File object
  102829. * @param file defines the file to load
  102830. * @param onSuccess defines the callback to call when data is loaded
  102831. * @param onProgress defines the callback to call during loading process
  102832. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  102833. * @param onError defines the callback to call when an error occurs
  102834. * @returns a file request object
  102835. */
  102836. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  102837. /**
  102838. * Creates a data url from a given string content
  102839. * @param content defines the content to convert
  102840. * @returns the new data url link
  102841. */
  102842. static FileAsURL(content: string): string;
  102843. /**
  102844. * Format the given number to a specific decimal format
  102845. * @param value defines the number to format
  102846. * @param decimals defines the number of decimals to use
  102847. * @returns the formatted string
  102848. */
  102849. static Format(value: number, decimals?: number): string;
  102850. /**
  102851. * Tries to copy an object by duplicating every property
  102852. * @param source defines the source object
  102853. * @param destination defines the target object
  102854. * @param doNotCopyList defines a list of properties to avoid
  102855. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  102856. */
  102857. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  102858. /**
  102859. * Gets a boolean indicating if the given object has no own property
  102860. * @param obj defines the object to test
  102861. * @returns true if object has no own property
  102862. */
  102863. static IsEmpty(obj: any): boolean;
  102864. /**
  102865. * Function used to register events at window level
  102866. * @param windowElement defines the Window object to use
  102867. * @param events defines the events to register
  102868. */
  102869. static RegisterTopRootEvents(windowElement: Window, events: {
  102870. name: string;
  102871. handler: Nullable<(e: FocusEvent) => any>;
  102872. }[]): void;
  102873. /**
  102874. * Function used to unregister events from window level
  102875. * @param windowElement defines the Window object to use
  102876. * @param events defines the events to unregister
  102877. */
  102878. static UnregisterTopRootEvents(windowElement: Window, events: {
  102879. name: string;
  102880. handler: Nullable<(e: FocusEvent) => any>;
  102881. }[]): void;
  102882. /**
  102883. * @ignore
  102884. */
  102885. static _ScreenshotCanvas: HTMLCanvasElement;
  102886. /**
  102887. * Dumps the current bound framebuffer
  102888. * @param width defines the rendering width
  102889. * @param height defines the rendering height
  102890. * @param engine defines the hosting engine
  102891. * @param successCallback defines the callback triggered once the data are available
  102892. * @param mimeType defines the mime type of the result
  102893. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  102894. */
  102895. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  102896. /**
  102897. * Converts the canvas data to blob.
  102898. * This acts as a polyfill for browsers not supporting the to blob function.
  102899. * @param canvas Defines the canvas to extract the data from
  102900. * @param successCallback Defines the callback triggered once the data are available
  102901. * @param mimeType Defines the mime type of the result
  102902. */
  102903. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  102904. /**
  102905. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  102906. * @param successCallback defines the callback triggered once the data are available
  102907. * @param mimeType defines the mime type of the result
  102908. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  102909. */
  102910. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  102911. /**
  102912. * Downloads a blob in the browser
  102913. * @param blob defines the blob to download
  102914. * @param fileName defines the name of the downloaded file
  102915. */
  102916. static Download(blob: Blob, fileName: string): void;
  102917. /**
  102918. * Captures a screenshot of the current rendering
  102919. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  102920. * @param engine defines the rendering engine
  102921. * @param camera defines the source camera
  102922. * @param size This parameter can be set to a single number or to an object with the
  102923. * following (optional) properties: precision, width, height. If a single number is passed,
  102924. * it will be used for both width and height. If an object is passed, the screenshot size
  102925. * will be derived from the parameters. The precision property is a multiplier allowing
  102926. * rendering at a higher or lower resolution
  102927. * @param successCallback defines the callback receives a single parameter which contains the
  102928. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  102929. * src parameter of an <img> to display it
  102930. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  102931. * Check your browser for supported MIME types
  102932. */
  102933. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  102934. /**
  102935. * Captures a screenshot of the current rendering
  102936. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  102937. * @param engine defines the rendering engine
  102938. * @param camera defines the source camera
  102939. * @param size This parameter can be set to a single number or to an object with the
  102940. * following (optional) properties: precision, width, height. If a single number is passed,
  102941. * it will be used for both width and height. If an object is passed, the screenshot size
  102942. * will be derived from the parameters. The precision property is a multiplier allowing
  102943. * rendering at a higher or lower resolution
  102944. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  102945. * Check your browser for supported MIME types
  102946. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  102947. * to the src parameter of an <img> to display it
  102948. */
  102949. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  102950. /**
  102951. * Generates an image screenshot from the specified camera.
  102952. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  102953. * @param engine The engine to use for rendering
  102954. * @param camera The camera to use for rendering
  102955. * @param size This parameter can be set to a single number or to an object with the
  102956. * following (optional) properties: precision, width, height. If a single number is passed,
  102957. * it will be used for both width and height. If an object is passed, the screenshot size
  102958. * will be derived from the parameters. The precision property is a multiplier allowing
  102959. * rendering at a higher or lower resolution
  102960. * @param successCallback The callback receives a single parameter which contains the
  102961. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  102962. * src parameter of an <img> to display it
  102963. * @param mimeType The MIME type of the screenshot image (default: image/png).
  102964. * Check your browser for supported MIME types
  102965. * @param samples Texture samples (default: 1)
  102966. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  102967. * @param fileName A name for for the downloaded file.
  102968. */
  102969. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  102970. /**
  102971. * Generates an image screenshot from the specified camera.
  102972. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  102973. * @param engine The engine to use for rendering
  102974. * @param camera The camera to use for rendering
  102975. * @param size This parameter can be set to a single number or to an object with the
  102976. * following (optional) properties: precision, width, height. If a single number is passed,
  102977. * it will be used for both width and height. If an object is passed, the screenshot size
  102978. * will be derived from the parameters. The precision property is a multiplier allowing
  102979. * rendering at a higher or lower resolution
  102980. * @param mimeType The MIME type of the screenshot image (default: image/png).
  102981. * Check your browser for supported MIME types
  102982. * @param samples Texture samples (default: 1)
  102983. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  102984. * @param fileName A name for for the downloaded file.
  102985. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  102986. * to the src parameter of an <img> to display it
  102987. */
  102988. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  102989. /**
  102990. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  102991. * Be aware Math.random() could cause collisions, but:
  102992. * "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"
  102993. * @returns a pseudo random id
  102994. */
  102995. static RandomId(): string;
  102996. /**
  102997. * Test if the given uri is a base64 string
  102998. * @param uri The uri to test
  102999. * @return True if the uri is a base64 string or false otherwise
  103000. */
  103001. static IsBase64(uri: string): boolean;
  103002. /**
  103003. * Decode the given base64 uri.
  103004. * @param uri The uri to decode
  103005. * @return The decoded base64 data.
  103006. */
  103007. static DecodeBase64(uri: string): ArrayBuffer;
  103008. /**
  103009. * Gets the absolute url.
  103010. * @param url the input url
  103011. * @return the absolute url
  103012. */
  103013. static GetAbsoluteUrl(url: string): string;
  103014. /**
  103015. * No log
  103016. */
  103017. static readonly NoneLogLevel: number;
  103018. /**
  103019. * Only message logs
  103020. */
  103021. static readonly MessageLogLevel: number;
  103022. /**
  103023. * Only warning logs
  103024. */
  103025. static readonly WarningLogLevel: number;
  103026. /**
  103027. * Only error logs
  103028. */
  103029. static readonly ErrorLogLevel: number;
  103030. /**
  103031. * All logs
  103032. */
  103033. static readonly AllLogLevel: number;
  103034. /**
  103035. * Gets a value indicating the number of loading errors
  103036. * @ignorenaming
  103037. */
  103038. static readonly errorsCount: number;
  103039. /**
  103040. * Callback called when a new log is added
  103041. */
  103042. static OnNewCacheEntry: (entry: string) => void;
  103043. /**
  103044. * Log a message to the console
  103045. * @param message defines the message to log
  103046. */
  103047. static Log(message: string): void;
  103048. /**
  103049. * Write a warning message to the console
  103050. * @param message defines the message to log
  103051. */
  103052. static Warn(message: string): void;
  103053. /**
  103054. * Write an error message to the console
  103055. * @param message defines the message to log
  103056. */
  103057. static Error(message: string): void;
  103058. /**
  103059. * Gets current log cache (list of logs)
  103060. */
  103061. static readonly LogCache: string;
  103062. /**
  103063. * Clears the log cache
  103064. */
  103065. static ClearLogCache(): void;
  103066. /**
  103067. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  103068. */
  103069. static LogLevels: number;
  103070. /**
  103071. * Checks if the window object exists
  103072. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  103073. */
  103074. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  103075. /**
  103076. * No performance log
  103077. */
  103078. static readonly PerformanceNoneLogLevel: number;
  103079. /**
  103080. * Use user marks to log performance
  103081. */
  103082. static readonly PerformanceUserMarkLogLevel: number;
  103083. /**
  103084. * Log performance to the console
  103085. */
  103086. static readonly PerformanceConsoleLogLevel: number;
  103087. private static _performance;
  103088. /**
  103089. * Sets the current performance log level
  103090. */
  103091. static PerformanceLogLevel: number;
  103092. private static _StartPerformanceCounterDisabled;
  103093. private static _EndPerformanceCounterDisabled;
  103094. private static _StartUserMark;
  103095. private static _EndUserMark;
  103096. private static _StartPerformanceConsole;
  103097. private static _EndPerformanceConsole;
  103098. /**
  103099. * Starts a performance counter
  103100. */
  103101. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  103102. /**
  103103. * Ends a specific performance coutner
  103104. */
  103105. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  103106. /**
  103107. * Gets either window.performance.now() if supported or Date.now() else
  103108. */
  103109. static readonly Now: number;
  103110. /**
  103111. * This method will return the name of the class used to create the instance of the given object.
  103112. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  103113. * @param object the object to get the class name from
  103114. * @param isType defines if the object is actually a type
  103115. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  103116. */
  103117. static GetClassName(object: any, isType?: boolean): string;
  103118. /**
  103119. * Gets the first element of an array satisfying a given predicate
  103120. * @param array defines the array to browse
  103121. * @param predicate defines the predicate to use
  103122. * @returns null if not found or the element
  103123. */
  103124. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  103125. /**
  103126. * This method will return the name of the full name of the class, including its owning module (if any).
  103127. * 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).
  103128. * @param object the object to get the class name from
  103129. * @param isType defines if the object is actually a type
  103130. * @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.
  103131. * @ignorenaming
  103132. */
  103133. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  103134. /**
  103135. * Returns a promise that resolves after the given amount of time.
  103136. * @param delay Number of milliseconds to delay
  103137. * @returns Promise that resolves after the given amount of time
  103138. */
  103139. static DelayAsync(delay: number): Promise<void>;
  103140. }
  103141. /**
  103142. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  103143. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  103144. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  103145. * @param name The name of the class, case should be preserved
  103146. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  103147. */
  103148. export function className(name: string, module?: string): (target: Object) => void;
  103149. /**
  103150. * An implementation of a loop for asynchronous functions.
  103151. */
  103152. export class AsyncLoop {
  103153. /**
  103154. * Defines the number of iterations for the loop
  103155. */
  103156. iterations: number;
  103157. /**
  103158. * Defines the current index of the loop.
  103159. */
  103160. index: number;
  103161. private _done;
  103162. private _fn;
  103163. private _successCallback;
  103164. /**
  103165. * Constructor.
  103166. * @param iterations the number of iterations.
  103167. * @param func the function to run each iteration
  103168. * @param successCallback the callback that will be called upon succesful execution
  103169. * @param offset starting offset.
  103170. */
  103171. constructor(
  103172. /**
  103173. * Defines the number of iterations for the loop
  103174. */
  103175. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  103176. /**
  103177. * Execute the next iteration. Must be called after the last iteration was finished.
  103178. */
  103179. executeNext(): void;
  103180. /**
  103181. * Break the loop and run the success callback.
  103182. */
  103183. breakLoop(): void;
  103184. /**
  103185. * Create and run an async loop.
  103186. * @param iterations the number of iterations.
  103187. * @param fn the function to run each iteration
  103188. * @param successCallback the callback that will be called upon succesful execution
  103189. * @param offset starting offset.
  103190. * @returns the created async loop object
  103191. */
  103192. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  103193. /**
  103194. * A for-loop that will run a given number of iterations synchronous and the rest async.
  103195. * @param iterations total number of iterations
  103196. * @param syncedIterations number of synchronous iterations in each async iteration.
  103197. * @param fn the function to call each iteration.
  103198. * @param callback a success call back that will be called when iterating stops.
  103199. * @param breakFunction a break condition (optional)
  103200. * @param timeout timeout settings for the setTimeout function. default - 0.
  103201. * @returns the created async loop object
  103202. */
  103203. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  103204. }
  103205. }
  103206. declare module BABYLON {
  103207. /**
  103208. * This class implement a typical dictionary using a string as key and the generic type T as value.
  103209. * The underlying implementation relies on an associative array to ensure the best performances.
  103210. * The value can be anything including 'null' but except 'undefined'
  103211. */
  103212. export class StringDictionary<T> {
  103213. /**
  103214. * This will clear this dictionary and copy the content from the 'source' one.
  103215. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  103216. * @param source the dictionary to take the content from and copy to this dictionary
  103217. */
  103218. copyFrom(source: StringDictionary<T>): void;
  103219. /**
  103220. * Get a value based from its key
  103221. * @param key the given key to get the matching value from
  103222. * @return the value if found, otherwise undefined is returned
  103223. */
  103224. get(key: string): T | undefined;
  103225. /**
  103226. * Get a value from its key or add it if it doesn't exist.
  103227. * This method will ensure you that a given key/data will be present in the dictionary.
  103228. * @param key the given key to get the matching value from
  103229. * @param factory the factory that will create the value if the key is not present in the dictionary.
  103230. * The factory will only be invoked if there's no data for the given key.
  103231. * @return the value corresponding to the key.
  103232. */
  103233. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  103234. /**
  103235. * Get a value from its key if present in the dictionary otherwise add it
  103236. * @param key the key to get the value from
  103237. * @param val if there's no such key/value pair in the dictionary add it with this value
  103238. * @return the value corresponding to the key
  103239. */
  103240. getOrAdd(key: string, val: T): T;
  103241. /**
  103242. * Check if there's a given key in the dictionary
  103243. * @param key the key to check for
  103244. * @return true if the key is present, false otherwise
  103245. */
  103246. contains(key: string): boolean;
  103247. /**
  103248. * Add a new key and its corresponding value
  103249. * @param key the key to add
  103250. * @param value the value corresponding to the key
  103251. * @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
  103252. */
  103253. add(key: string, value: T): boolean;
  103254. /**
  103255. * Update a specific value associated to a key
  103256. * @param key defines the key to use
  103257. * @param value defines the value to store
  103258. * @returns true if the value was updated (or false if the key was not found)
  103259. */
  103260. set(key: string, value: T): boolean;
  103261. /**
  103262. * Get the element of the given key and remove it from the dictionary
  103263. * @param key defines the key to search
  103264. * @returns the value associated with the key or null if not found
  103265. */
  103266. getAndRemove(key: string): Nullable<T>;
  103267. /**
  103268. * Remove a key/value from the dictionary.
  103269. * @param key the key to remove
  103270. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  103271. */
  103272. remove(key: string): boolean;
  103273. /**
  103274. * Clear the whole content of the dictionary
  103275. */
  103276. clear(): void;
  103277. /**
  103278. * Gets the current count
  103279. */
  103280. readonly count: number;
  103281. /**
  103282. * Execute a callback on each key/val of the dictionary.
  103283. * Note that you can remove any element in this dictionary in the callback implementation
  103284. * @param callback the callback to execute on a given key/value pair
  103285. */
  103286. forEach(callback: (key: string, val: T) => void): void;
  103287. /**
  103288. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  103289. * If the callback returns null or undefined the method will iterate to the next key/value pair
  103290. * Note that you can remove any element in this dictionary in the callback implementation
  103291. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  103292. * @returns the first item
  103293. */
  103294. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  103295. private _count;
  103296. private _data;
  103297. }
  103298. }
  103299. declare module BABYLON {
  103300. /** @hidden */
  103301. export interface ICollisionCoordinator {
  103302. createCollider(): Collider;
  103303. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  103304. init(scene: Scene): void;
  103305. }
  103306. /** @hidden */
  103307. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  103308. private _scene;
  103309. private _scaledPosition;
  103310. private _scaledVelocity;
  103311. private _finalPosition;
  103312. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  103313. createCollider(): Collider;
  103314. init(scene: Scene): void;
  103315. private _collideWithWorld;
  103316. }
  103317. }
  103318. declare module BABYLON {
  103319. /**
  103320. * Class used to manage all inputs for the scene.
  103321. */
  103322. export class InputManager {
  103323. /** The distance in pixel that you have to move to prevent some events */
  103324. static DragMovementThreshold: number;
  103325. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  103326. static LongPressDelay: number;
  103327. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  103328. static DoubleClickDelay: number;
  103329. /** If you need to check double click without raising a single click at first click, enable this flag */
  103330. static ExclusiveDoubleClickMode: boolean;
  103331. private _wheelEventName;
  103332. private _onPointerMove;
  103333. private _onPointerDown;
  103334. private _onPointerUp;
  103335. private _initClickEvent;
  103336. private _initActionManager;
  103337. private _delayedSimpleClick;
  103338. private _delayedSimpleClickTimeout;
  103339. private _previousDelayedSimpleClickTimeout;
  103340. private _meshPickProceed;
  103341. private _previousButtonPressed;
  103342. private _currentPickResult;
  103343. private _previousPickResult;
  103344. private _totalPointersPressed;
  103345. private _doubleClickOccured;
  103346. private _pointerOverMesh;
  103347. private _pickedDownMesh;
  103348. private _pickedUpMesh;
  103349. private _pointerX;
  103350. private _pointerY;
  103351. private _unTranslatedPointerX;
  103352. private _unTranslatedPointerY;
  103353. private _startingPointerPosition;
  103354. private _previousStartingPointerPosition;
  103355. private _startingPointerTime;
  103356. private _previousStartingPointerTime;
  103357. private _pointerCaptures;
  103358. private _onKeyDown;
  103359. private _onKeyUp;
  103360. private _onCanvasFocusObserver;
  103361. private _onCanvasBlurObserver;
  103362. private _scene;
  103363. /**
  103364. * Creates a new InputManager
  103365. * @param scene defines the hosting scene
  103366. */
  103367. constructor(scene: Scene);
  103368. /**
  103369. * Gets the mesh that is currently under the pointer
  103370. */
  103371. readonly meshUnderPointer: Nullable<AbstractMesh>;
  103372. /**
  103373. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  103374. */
  103375. readonly unTranslatedPointer: Vector2;
  103376. /**
  103377. * Gets or sets the current on-screen X position of the pointer
  103378. */
  103379. pointerX: number;
  103380. /**
  103381. * Gets or sets the current on-screen Y position of the pointer
  103382. */
  103383. pointerY: number;
  103384. private _updatePointerPosition;
  103385. private _processPointerMove;
  103386. private _setRayOnPointerInfo;
  103387. private _checkPrePointerObservable;
  103388. /**
  103389. * Use this method to simulate a pointer move on a mesh
  103390. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  103391. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  103392. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  103393. */
  103394. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  103395. /**
  103396. * Use this method to simulate a pointer down on a mesh
  103397. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  103398. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  103399. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  103400. */
  103401. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  103402. private _processPointerDown;
  103403. /** @hidden */
  103404. _isPointerSwiping(): boolean;
  103405. /**
  103406. * Use this method to simulate a pointer up on a mesh
  103407. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  103408. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  103409. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  103410. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  103411. */
  103412. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  103413. private _processPointerUp;
  103414. /**
  103415. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  103416. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  103417. * @returns true if the pointer was captured
  103418. */
  103419. isPointerCaptured(pointerId?: number): boolean;
  103420. /**
  103421. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  103422. * @param attachUp defines if you want to attach events to pointerup
  103423. * @param attachDown defines if you want to attach events to pointerdown
  103424. * @param attachMove defines if you want to attach events to pointermove
  103425. */
  103426. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  103427. /**
  103428. * Detaches all event handlers
  103429. */
  103430. detachControl(): void;
  103431. /**
  103432. * Force the value of meshUnderPointer
  103433. * @param mesh defines the mesh to use
  103434. */
  103435. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  103436. /**
  103437. * Gets the mesh under the pointer
  103438. * @returns a Mesh or null if no mesh is under the pointer
  103439. */
  103440. getPointerOverMesh(): Nullable<AbstractMesh>;
  103441. }
  103442. }
  103443. declare module BABYLON {
  103444. /**
  103445. * Helper class used to generate session unique ID
  103446. */
  103447. export class UniqueIdGenerator {
  103448. private static _UniqueIdCounter;
  103449. /**
  103450. * Gets an unique (relatively to the current scene) Id
  103451. */
  103452. static readonly UniqueId: number;
  103453. }
  103454. }
  103455. declare module BABYLON {
  103456. /**
  103457. * This class defines the direct association between an animation and a target
  103458. */
  103459. export class TargetedAnimation {
  103460. /**
  103461. * Animation to perform
  103462. */
  103463. animation: Animation;
  103464. /**
  103465. * Target to animate
  103466. */
  103467. target: any;
  103468. /**
  103469. * Serialize the object
  103470. * @returns the JSON object representing the current entity
  103471. */
  103472. serialize(): any;
  103473. }
  103474. /**
  103475. * Use this class to create coordinated animations on multiple targets
  103476. */
  103477. export class AnimationGroup implements IDisposable {
  103478. /** The name of the animation group */
  103479. name: string;
  103480. private _scene;
  103481. private _targetedAnimations;
  103482. private _animatables;
  103483. private _from;
  103484. private _to;
  103485. private _isStarted;
  103486. private _isPaused;
  103487. private _speedRatio;
  103488. private _loopAnimation;
  103489. /**
  103490. * Gets or sets the unique id of the node
  103491. */
  103492. uniqueId: number;
  103493. /**
  103494. * This observable will notify when one animation have ended
  103495. */
  103496. onAnimationEndObservable: Observable<TargetedAnimation>;
  103497. /**
  103498. * Observer raised when one animation loops
  103499. */
  103500. onAnimationLoopObservable: Observable<TargetedAnimation>;
  103501. /**
  103502. * Observer raised when all animations have looped
  103503. */
  103504. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  103505. /**
  103506. * This observable will notify when all animations have ended.
  103507. */
  103508. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  103509. /**
  103510. * This observable will notify when all animations have paused.
  103511. */
  103512. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  103513. /**
  103514. * This observable will notify when all animations are playing.
  103515. */
  103516. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  103517. /**
  103518. * Gets the first frame
  103519. */
  103520. readonly from: number;
  103521. /**
  103522. * Gets the last frame
  103523. */
  103524. readonly to: number;
  103525. /**
  103526. * Define if the animations are started
  103527. */
  103528. readonly isStarted: boolean;
  103529. /**
  103530. * Gets a value indicating that the current group is playing
  103531. */
  103532. readonly isPlaying: boolean;
  103533. /**
  103534. * Gets or sets the speed ratio to use for all animations
  103535. */
  103536. /**
  103537. * Gets or sets the speed ratio to use for all animations
  103538. */
  103539. speedRatio: number;
  103540. /**
  103541. * Gets or sets if all animations should loop or not
  103542. */
  103543. loopAnimation: boolean;
  103544. /**
  103545. * Gets the targeted animations for this animation group
  103546. */
  103547. readonly targetedAnimations: Array<TargetedAnimation>;
  103548. /**
  103549. * returning the list of animatables controlled by this animation group.
  103550. */
  103551. readonly animatables: Array<Animatable>;
  103552. /**
  103553. * Instantiates a new Animation Group.
  103554. * This helps managing several animations at once.
  103555. * @see http://doc.babylonjs.com/how_to/group
  103556. * @param name Defines the name of the group
  103557. * @param scene Defines the scene the group belongs to
  103558. */
  103559. constructor(
  103560. /** The name of the animation group */
  103561. name: string, scene?: Nullable<Scene>);
  103562. /**
  103563. * Add an animation (with its target) in the group
  103564. * @param animation defines the animation we want to add
  103565. * @param target defines the target of the animation
  103566. * @returns the TargetedAnimation object
  103567. */
  103568. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  103569. /**
  103570. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  103571. * It can add constant keys at begin or end
  103572. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  103573. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  103574. * @returns the animation group
  103575. */
  103576. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  103577. private _animationLoopCount;
  103578. private _animationLoopFlags;
  103579. private _processLoop;
  103580. /**
  103581. * Start all animations on given targets
  103582. * @param loop defines if animations must loop
  103583. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  103584. * @param from defines the from key (optional)
  103585. * @param to defines the to key (optional)
  103586. * @returns the current animation group
  103587. */
  103588. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  103589. /**
  103590. * Pause all animations
  103591. * @returns the animation group
  103592. */
  103593. pause(): AnimationGroup;
  103594. /**
  103595. * Play all animations to initial state
  103596. * This function will start() the animations if they were not started or will restart() them if they were paused
  103597. * @param loop defines if animations must loop
  103598. * @returns the animation group
  103599. */
  103600. play(loop?: boolean): AnimationGroup;
  103601. /**
  103602. * Reset all animations to initial state
  103603. * @returns the animation group
  103604. */
  103605. reset(): AnimationGroup;
  103606. /**
  103607. * Restart animations from key 0
  103608. * @returns the animation group
  103609. */
  103610. restart(): AnimationGroup;
  103611. /**
  103612. * Stop all animations
  103613. * @returns the animation group
  103614. */
  103615. stop(): AnimationGroup;
  103616. /**
  103617. * Set animation weight for all animatables
  103618. * @param weight defines the weight to use
  103619. * @return the animationGroup
  103620. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  103621. */
  103622. setWeightForAllAnimatables(weight: number): AnimationGroup;
  103623. /**
  103624. * Synchronize and normalize all animatables with a source animatable
  103625. * @param root defines the root animatable to synchronize with
  103626. * @return the animationGroup
  103627. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  103628. */
  103629. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  103630. /**
  103631. * Goes to a specific frame in this animation group
  103632. * @param frame the frame number to go to
  103633. * @return the animationGroup
  103634. */
  103635. goToFrame(frame: number): AnimationGroup;
  103636. /**
  103637. * Dispose all associated resources
  103638. */
  103639. dispose(): void;
  103640. private _checkAnimationGroupEnded;
  103641. /**
  103642. * Clone the current animation group and returns a copy
  103643. * @param newName defines the name of the new group
  103644. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  103645. * @returns the new aniamtion group
  103646. */
  103647. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  103648. /**
  103649. * Serializes the animationGroup to an object
  103650. * @returns Serialized object
  103651. */
  103652. serialize(): any;
  103653. /**
  103654. * Returns a new AnimationGroup object parsed from the source provided.
  103655. * @param parsedAnimationGroup defines the source
  103656. * @param scene defines the scene that will receive the animationGroup
  103657. * @returns a new AnimationGroup
  103658. */
  103659. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  103660. /**
  103661. * Returns the string "AnimationGroup"
  103662. * @returns "AnimationGroup"
  103663. */
  103664. getClassName(): string;
  103665. /**
  103666. * Creates a detailled string about the object
  103667. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  103668. * @returns a string representing the object
  103669. */
  103670. toString(fullDetails?: boolean): string;
  103671. }
  103672. }
  103673. declare module BABYLON {
  103674. /**
  103675. * Define an interface for all classes that will hold resources
  103676. */
  103677. export interface IDisposable {
  103678. /**
  103679. * Releases all held resources
  103680. */
  103681. dispose(): void;
  103682. }
  103683. /** Interface defining initialization parameters for Scene class */
  103684. export interface SceneOptions {
  103685. /**
  103686. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  103687. * It will improve performance when the number of geometries becomes important.
  103688. */
  103689. useGeometryUniqueIdsMap?: boolean;
  103690. /**
  103691. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  103692. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  103693. */
  103694. useMaterialMeshMap?: boolean;
  103695. /**
  103696. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  103697. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  103698. */
  103699. useClonedMeshhMap?: boolean;
  103700. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  103701. virtual?: boolean;
  103702. }
  103703. /**
  103704. * Represents a scene to be rendered by the engine.
  103705. * @see http://doc.babylonjs.com/features/scene
  103706. */
  103707. export class Scene extends AbstractScene implements IAnimatable {
  103708. /** The fog is deactivated */
  103709. static readonly FOGMODE_NONE: number;
  103710. /** The fog density is following an exponential function */
  103711. static readonly FOGMODE_EXP: number;
  103712. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  103713. static readonly FOGMODE_EXP2: number;
  103714. /** The fog density is following a linear function. */
  103715. static readonly FOGMODE_LINEAR: number;
  103716. /**
  103717. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  103718. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  103719. */
  103720. static MinDeltaTime: number;
  103721. /**
  103722. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  103723. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  103724. */
  103725. static MaxDeltaTime: number;
  103726. /**
  103727. * Factory used to create the default material.
  103728. * @param name The name of the material to create
  103729. * @param scene The scene to create the material for
  103730. * @returns The default material
  103731. */
  103732. static DefaultMaterialFactory(scene: Scene): Material;
  103733. /**
  103734. * Factory used to create the a collision coordinator.
  103735. * @returns The collision coordinator
  103736. */
  103737. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  103738. /** @hidden */
  103739. _inputManager: InputManager;
  103740. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  103741. cameraToUseForPointers: Nullable<Camera>;
  103742. /** @hidden */
  103743. readonly _isScene: boolean;
  103744. /**
  103745. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  103746. */
  103747. autoClear: boolean;
  103748. /**
  103749. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  103750. */
  103751. autoClearDepthAndStencil: boolean;
  103752. /**
  103753. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  103754. */
  103755. clearColor: Color4;
  103756. /**
  103757. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  103758. */
  103759. ambientColor: Color3;
  103760. /**
  103761. * This is use to store the default BRDF lookup for PBR materials in your scene.
  103762. * It should only be one of the following (if not the default embedded one):
  103763. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  103764. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  103765. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  103766. * The material properties need to be setup according to the type of texture in use.
  103767. */
  103768. environmentBRDFTexture: BaseTexture;
  103769. /** @hidden */
  103770. protected _environmentTexture: Nullable<BaseTexture>;
  103771. /**
  103772. * Texture used in all pbr material as the reflection texture.
  103773. * As in the majority of the scene they are the same (exception for multi room and so on),
  103774. * this is easier to reference from here than from all the materials.
  103775. */
  103776. /**
  103777. * Texture used in all pbr material as the reflection texture.
  103778. * As in the majority of the scene they are the same (exception for multi room and so on),
  103779. * this is easier to set here than in all the materials.
  103780. */
  103781. environmentTexture: Nullable<BaseTexture>;
  103782. /** @hidden */
  103783. protected _environmentIntensity: number;
  103784. /**
  103785. * Intensity of the environment in all pbr material.
  103786. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  103787. * As in the majority of the scene they are the same (exception for multi room and so on),
  103788. * this is easier to reference from here than from all the materials.
  103789. */
  103790. /**
  103791. * Intensity of the environment in all pbr material.
  103792. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  103793. * As in the majority of the scene they are the same (exception for multi room and so on),
  103794. * this is easier to set here than in all the materials.
  103795. */
  103796. environmentIntensity: number;
  103797. /** @hidden */
  103798. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103799. /**
  103800. * Default image processing configuration used either in the rendering
  103801. * Forward main pass or through the imageProcessingPostProcess if present.
  103802. * As in the majority of the scene they are the same (exception for multi camera),
  103803. * this is easier to reference from here than from all the materials and post process.
  103804. *
  103805. * No setter as we it is a shared configuration, you can set the values instead.
  103806. */
  103807. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  103808. private _forceWireframe;
  103809. /**
  103810. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  103811. */
  103812. forceWireframe: boolean;
  103813. private _forcePointsCloud;
  103814. /**
  103815. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  103816. */
  103817. forcePointsCloud: boolean;
  103818. /**
  103819. * Gets or sets the active clipplane 1
  103820. */
  103821. clipPlane: Nullable<Plane>;
  103822. /**
  103823. * Gets or sets the active clipplane 2
  103824. */
  103825. clipPlane2: Nullable<Plane>;
  103826. /**
  103827. * Gets or sets the active clipplane 3
  103828. */
  103829. clipPlane3: Nullable<Plane>;
  103830. /**
  103831. * Gets or sets the active clipplane 4
  103832. */
  103833. clipPlane4: Nullable<Plane>;
  103834. /**
  103835. * Gets or sets a boolean indicating if animations are enabled
  103836. */
  103837. animationsEnabled: boolean;
  103838. private _animationPropertiesOverride;
  103839. /**
  103840. * Gets or sets the animation properties override
  103841. */
  103842. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  103843. /**
  103844. * Gets or sets a boolean indicating if a constant deltatime has to be used
  103845. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  103846. */
  103847. useConstantAnimationDeltaTime: boolean;
  103848. /**
  103849. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  103850. * Please note that it requires to run a ray cast through the scene on every frame
  103851. */
  103852. constantlyUpdateMeshUnderPointer: boolean;
  103853. /**
  103854. * Defines the HTML cursor to use when hovering over interactive elements
  103855. */
  103856. hoverCursor: string;
  103857. /**
  103858. * Defines the HTML default cursor to use (empty by default)
  103859. */
  103860. defaultCursor: string;
  103861. /**
  103862. * Defines wether cursors are handled by the scene.
  103863. */
  103864. doNotHandleCursors: boolean;
  103865. /**
  103866. * This is used to call preventDefault() on pointer down
  103867. * in order to block unwanted artifacts like system double clicks
  103868. */
  103869. preventDefaultOnPointerDown: boolean;
  103870. /**
  103871. * This is used to call preventDefault() on pointer up
  103872. * in order to block unwanted artifacts like system double clicks
  103873. */
  103874. preventDefaultOnPointerUp: boolean;
  103875. /**
  103876. * Gets or sets user defined metadata
  103877. */
  103878. metadata: any;
  103879. /**
  103880. * For internal use only. Please do not use.
  103881. */
  103882. reservedDataStore: any;
  103883. /**
  103884. * Gets the name of the plugin used to load this scene (null by default)
  103885. */
  103886. loadingPluginName: string;
  103887. /**
  103888. * Use this array to add regular expressions used to disable offline support for specific urls
  103889. */
  103890. disableOfflineSupportExceptionRules: RegExp[];
  103891. /**
  103892. * An event triggered when the scene is disposed.
  103893. */
  103894. onDisposeObservable: Observable<Scene>;
  103895. private _onDisposeObserver;
  103896. /** Sets a function to be executed when this scene is disposed. */
  103897. onDispose: () => void;
  103898. /**
  103899. * An event triggered before rendering the scene (right after animations and physics)
  103900. */
  103901. onBeforeRenderObservable: Observable<Scene>;
  103902. private _onBeforeRenderObserver;
  103903. /** Sets a function to be executed before rendering this scene */
  103904. beforeRender: Nullable<() => void>;
  103905. /**
  103906. * An event triggered after rendering the scene
  103907. */
  103908. onAfterRenderObservable: Observable<Scene>;
  103909. /**
  103910. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  103911. */
  103912. onAfterRenderCameraObservable: Observable<Camera>;
  103913. private _onAfterRenderObserver;
  103914. /** Sets a function to be executed after rendering this scene */
  103915. afterRender: Nullable<() => void>;
  103916. /**
  103917. * An event triggered before animating the scene
  103918. */
  103919. onBeforeAnimationsObservable: Observable<Scene>;
  103920. /**
  103921. * An event triggered after animations processing
  103922. */
  103923. onAfterAnimationsObservable: Observable<Scene>;
  103924. /**
  103925. * An event triggered before draw calls are ready to be sent
  103926. */
  103927. onBeforeDrawPhaseObservable: Observable<Scene>;
  103928. /**
  103929. * An event triggered after draw calls have been sent
  103930. */
  103931. onAfterDrawPhaseObservable: Observable<Scene>;
  103932. /**
  103933. * An event triggered when the scene is ready
  103934. */
  103935. onReadyObservable: Observable<Scene>;
  103936. /**
  103937. * An event triggered before rendering a camera
  103938. */
  103939. onBeforeCameraRenderObservable: Observable<Camera>;
  103940. private _onBeforeCameraRenderObserver;
  103941. /** Sets a function to be executed before rendering a camera*/
  103942. beforeCameraRender: () => void;
  103943. /**
  103944. * An event triggered after rendering a camera
  103945. */
  103946. onAfterCameraRenderObservable: Observable<Camera>;
  103947. private _onAfterCameraRenderObserver;
  103948. /** Sets a function to be executed after rendering a camera*/
  103949. afterCameraRender: () => void;
  103950. /**
  103951. * An event triggered when active meshes evaluation is about to start
  103952. */
  103953. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  103954. /**
  103955. * An event triggered when active meshes evaluation is done
  103956. */
  103957. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  103958. /**
  103959. * An event triggered when particles rendering is about to start
  103960. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  103961. */
  103962. onBeforeParticlesRenderingObservable: Observable<Scene>;
  103963. /**
  103964. * An event triggered when particles rendering is done
  103965. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  103966. */
  103967. onAfterParticlesRenderingObservable: Observable<Scene>;
  103968. /**
  103969. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  103970. */
  103971. onDataLoadedObservable: Observable<Scene>;
  103972. /**
  103973. * An event triggered when a camera is created
  103974. */
  103975. onNewCameraAddedObservable: Observable<Camera>;
  103976. /**
  103977. * An event triggered when a camera is removed
  103978. */
  103979. onCameraRemovedObservable: Observable<Camera>;
  103980. /**
  103981. * An event triggered when a light is created
  103982. */
  103983. onNewLightAddedObservable: Observable<Light>;
  103984. /**
  103985. * An event triggered when a light is removed
  103986. */
  103987. onLightRemovedObservable: Observable<Light>;
  103988. /**
  103989. * An event triggered when a geometry is created
  103990. */
  103991. onNewGeometryAddedObservable: Observable<Geometry>;
  103992. /**
  103993. * An event triggered when a geometry is removed
  103994. */
  103995. onGeometryRemovedObservable: Observable<Geometry>;
  103996. /**
  103997. * An event triggered when a transform node is created
  103998. */
  103999. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  104000. /**
  104001. * An event triggered when a transform node is removed
  104002. */
  104003. onTransformNodeRemovedObservable: Observable<TransformNode>;
  104004. /**
  104005. * An event triggered when a mesh is created
  104006. */
  104007. onNewMeshAddedObservable: Observable<AbstractMesh>;
  104008. /**
  104009. * An event triggered when a mesh is removed
  104010. */
  104011. onMeshRemovedObservable: Observable<AbstractMesh>;
  104012. /**
  104013. * An event triggered when a skeleton is created
  104014. */
  104015. onNewSkeletonAddedObservable: Observable<Skeleton>;
  104016. /**
  104017. * An event triggered when a skeleton is removed
  104018. */
  104019. onSkeletonRemovedObservable: Observable<Skeleton>;
  104020. /**
  104021. * An event triggered when a material is created
  104022. */
  104023. onNewMaterialAddedObservable: Observable<Material>;
  104024. /**
  104025. * An event triggered when a material is removed
  104026. */
  104027. onMaterialRemovedObservable: Observable<Material>;
  104028. /**
  104029. * An event triggered when a texture is created
  104030. */
  104031. onNewTextureAddedObservable: Observable<BaseTexture>;
  104032. /**
  104033. * An event triggered when a texture is removed
  104034. */
  104035. onTextureRemovedObservable: Observable<BaseTexture>;
  104036. /**
  104037. * An event triggered when render targets are about to be rendered
  104038. * Can happen multiple times per frame.
  104039. */
  104040. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  104041. /**
  104042. * An event triggered when render targets were rendered.
  104043. * Can happen multiple times per frame.
  104044. */
  104045. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  104046. /**
  104047. * An event triggered before calculating deterministic simulation step
  104048. */
  104049. onBeforeStepObservable: Observable<Scene>;
  104050. /**
  104051. * An event triggered after calculating deterministic simulation step
  104052. */
  104053. onAfterStepObservable: Observable<Scene>;
  104054. /**
  104055. * An event triggered when the activeCamera property is updated
  104056. */
  104057. onActiveCameraChanged: Observable<Scene>;
  104058. /**
  104059. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  104060. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  104061. * 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)
  104062. */
  104063. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  104064. /**
  104065. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  104066. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  104067. * 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)
  104068. */
  104069. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  104070. /**
  104071. * This Observable will when a mesh has been imported into the scene.
  104072. */
  104073. onMeshImportedObservable: Observable<AbstractMesh>;
  104074. /**
  104075. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  104076. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  104077. */
  104078. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  104079. /** @hidden */
  104080. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  104081. /**
  104082. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  104083. */
  104084. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  104085. /**
  104086. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  104087. */
  104088. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  104089. /**
  104090. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  104091. */
  104092. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  104093. /** Callback called when a pointer move is detected */
  104094. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  104095. /** Callback called when a pointer down is detected */
  104096. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  104097. /** Callback called when a pointer up is detected */
  104098. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  104099. /** Callback called when a pointer pick is detected */
  104100. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  104101. /**
  104102. * 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).
  104103. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  104104. */
  104105. onPrePointerObservable: Observable<PointerInfoPre>;
  104106. /**
  104107. * Observable event triggered each time an input event is received from the rendering canvas
  104108. */
  104109. onPointerObservable: Observable<PointerInfo>;
  104110. /**
  104111. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  104112. */
  104113. readonly unTranslatedPointer: Vector2;
  104114. /**
  104115. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  104116. */
  104117. static DragMovementThreshold: number;
  104118. /**
  104119. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  104120. */
  104121. static LongPressDelay: number;
  104122. /**
  104123. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  104124. */
  104125. static DoubleClickDelay: number;
  104126. /** If you need to check double click without raising a single click at first click, enable this flag */
  104127. static ExclusiveDoubleClickMode: boolean;
  104128. /** @hidden */
  104129. _mirroredCameraPosition: Nullable<Vector3>;
  104130. /**
  104131. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  104132. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  104133. */
  104134. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  104135. /**
  104136. * Observable event triggered each time an keyboard event is received from the hosting window
  104137. */
  104138. onKeyboardObservable: Observable<KeyboardInfo>;
  104139. private _useRightHandedSystem;
  104140. /**
  104141. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  104142. */
  104143. useRightHandedSystem: boolean;
  104144. private _timeAccumulator;
  104145. private _currentStepId;
  104146. private _currentInternalStep;
  104147. /**
  104148. * Sets the step Id used by deterministic lock step
  104149. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104150. * @param newStepId defines the step Id
  104151. */
  104152. setStepId(newStepId: number): void;
  104153. /**
  104154. * Gets the step Id used by deterministic lock step
  104155. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104156. * @returns the step Id
  104157. */
  104158. getStepId(): number;
  104159. /**
  104160. * Gets the internal step used by deterministic lock step
  104161. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104162. * @returns the internal step
  104163. */
  104164. getInternalStep(): number;
  104165. private _fogEnabled;
  104166. /**
  104167. * Gets or sets a boolean indicating if fog is enabled on this scene
  104168. * @see http://doc.babylonjs.com/babylon101/environment#fog
  104169. * (Default is true)
  104170. */
  104171. fogEnabled: boolean;
  104172. private _fogMode;
  104173. /**
  104174. * Gets or sets the fog mode to use
  104175. * @see http://doc.babylonjs.com/babylon101/environment#fog
  104176. * | mode | value |
  104177. * | --- | --- |
  104178. * | FOGMODE_NONE | 0 |
  104179. * | FOGMODE_EXP | 1 |
  104180. * | FOGMODE_EXP2 | 2 |
  104181. * | FOGMODE_LINEAR | 3 |
  104182. */
  104183. fogMode: number;
  104184. /**
  104185. * Gets or sets the fog color to use
  104186. * @see http://doc.babylonjs.com/babylon101/environment#fog
  104187. * (Default is Color3(0.2, 0.2, 0.3))
  104188. */
  104189. fogColor: Color3;
  104190. /**
  104191. * Gets or sets the fog density to use
  104192. * @see http://doc.babylonjs.com/babylon101/environment#fog
  104193. * (Default is 0.1)
  104194. */
  104195. fogDensity: number;
  104196. /**
  104197. * Gets or sets the fog start distance to use
  104198. * @see http://doc.babylonjs.com/babylon101/environment#fog
  104199. * (Default is 0)
  104200. */
  104201. fogStart: number;
  104202. /**
  104203. * Gets or sets the fog end distance to use
  104204. * @see http://doc.babylonjs.com/babylon101/environment#fog
  104205. * (Default is 1000)
  104206. */
  104207. fogEnd: number;
  104208. private _shadowsEnabled;
  104209. /**
  104210. * Gets or sets a boolean indicating if shadows are enabled on this scene
  104211. */
  104212. shadowsEnabled: boolean;
  104213. private _lightsEnabled;
  104214. /**
  104215. * Gets or sets a boolean indicating if lights are enabled on this scene
  104216. */
  104217. lightsEnabled: boolean;
  104218. /** All of the active cameras added to this scene. */
  104219. activeCameras: Camera[];
  104220. /** @hidden */
  104221. _activeCamera: Nullable<Camera>;
  104222. /** Gets or sets the current active camera */
  104223. activeCamera: Nullable<Camera>;
  104224. private _defaultMaterial;
  104225. /** The default material used on meshes when no material is affected */
  104226. /** The default material used on meshes when no material is affected */
  104227. defaultMaterial: Material;
  104228. private _texturesEnabled;
  104229. /**
  104230. * Gets or sets a boolean indicating if textures are enabled on this scene
  104231. */
  104232. texturesEnabled: boolean;
  104233. /**
  104234. * Gets or sets a boolean indicating if particles are enabled on this scene
  104235. */
  104236. particlesEnabled: boolean;
  104237. /**
  104238. * Gets or sets a boolean indicating if sprites are enabled on this scene
  104239. */
  104240. spritesEnabled: boolean;
  104241. private _skeletonsEnabled;
  104242. /**
  104243. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  104244. */
  104245. skeletonsEnabled: boolean;
  104246. /**
  104247. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  104248. */
  104249. lensFlaresEnabled: boolean;
  104250. /**
  104251. * Gets or sets a boolean indicating if collisions are enabled on this scene
  104252. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  104253. */
  104254. collisionsEnabled: boolean;
  104255. private _collisionCoordinator;
  104256. /** @hidden */
  104257. readonly collisionCoordinator: ICollisionCoordinator;
  104258. /**
  104259. * Defines the gravity applied to this scene (used only for collisions)
  104260. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  104261. */
  104262. gravity: Vector3;
  104263. /**
  104264. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  104265. */
  104266. postProcessesEnabled: boolean;
  104267. /**
  104268. * The list of postprocesses added to the scene
  104269. */
  104270. postProcesses: PostProcess[];
  104271. /**
  104272. * Gets the current postprocess manager
  104273. */
  104274. postProcessManager: PostProcessManager;
  104275. /**
  104276. * Gets or sets a boolean indicating if render targets are enabled on this scene
  104277. */
  104278. renderTargetsEnabled: boolean;
  104279. /**
  104280. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  104281. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  104282. */
  104283. dumpNextRenderTargets: boolean;
  104284. /**
  104285. * The list of user defined render targets added to the scene
  104286. */
  104287. customRenderTargets: RenderTargetTexture[];
  104288. /**
  104289. * Defines if texture loading must be delayed
  104290. * If true, textures will only be loaded when they need to be rendered
  104291. */
  104292. useDelayedTextureLoading: boolean;
  104293. /**
  104294. * Gets the list of meshes imported to the scene through SceneLoader
  104295. */
  104296. importedMeshesFiles: String[];
  104297. /**
  104298. * Gets or sets a boolean indicating if probes are enabled on this scene
  104299. */
  104300. probesEnabled: boolean;
  104301. /**
  104302. * Gets or sets the current offline provider to use to store scene data
  104303. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  104304. */
  104305. offlineProvider: IOfflineProvider;
  104306. /**
  104307. * Gets or sets the action manager associated with the scene
  104308. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  104309. */
  104310. actionManager: AbstractActionManager;
  104311. private _meshesForIntersections;
  104312. /**
  104313. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  104314. */
  104315. proceduralTexturesEnabled: boolean;
  104316. private _engine;
  104317. private _totalVertices;
  104318. /** @hidden */
  104319. _activeIndices: PerfCounter;
  104320. /** @hidden */
  104321. _activeParticles: PerfCounter;
  104322. /** @hidden */
  104323. _activeBones: PerfCounter;
  104324. private _animationRatio;
  104325. /** @hidden */
  104326. _animationTimeLast: number;
  104327. /** @hidden */
  104328. _animationTime: number;
  104329. /**
  104330. * Gets or sets a general scale for animation speed
  104331. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  104332. */
  104333. animationTimeScale: number;
  104334. /** @hidden */
  104335. _cachedMaterial: Nullable<Material>;
  104336. /** @hidden */
  104337. _cachedEffect: Nullable<Effect>;
  104338. /** @hidden */
  104339. _cachedVisibility: Nullable<number>;
  104340. private _renderId;
  104341. private _frameId;
  104342. private _executeWhenReadyTimeoutId;
  104343. private _intermediateRendering;
  104344. private _viewUpdateFlag;
  104345. private _projectionUpdateFlag;
  104346. /** @hidden */
  104347. _toBeDisposed: Nullable<IDisposable>[];
  104348. private _activeRequests;
  104349. /** @hidden */
  104350. _pendingData: any[];
  104351. private _isDisposed;
  104352. /**
  104353. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  104354. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  104355. */
  104356. dispatchAllSubMeshesOfActiveMeshes: boolean;
  104357. private _activeMeshes;
  104358. private _processedMaterials;
  104359. private _renderTargets;
  104360. /** @hidden */
  104361. _activeParticleSystems: SmartArray<IParticleSystem>;
  104362. private _activeSkeletons;
  104363. private _softwareSkinnedMeshes;
  104364. private _renderingManager;
  104365. /** @hidden */
  104366. _activeAnimatables: Animatable[];
  104367. private _transformMatrix;
  104368. private _sceneUbo;
  104369. /** @hidden */
  104370. _viewMatrix: Matrix;
  104371. private _projectionMatrix;
  104372. /** @hidden */
  104373. _forcedViewPosition: Nullable<Vector3>;
  104374. /** @hidden */
  104375. _frustumPlanes: Plane[];
  104376. /**
  104377. * Gets the list of frustum planes (built from the active camera)
  104378. */
  104379. readonly frustumPlanes: Plane[];
  104380. /**
  104381. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  104382. * This is useful if there are more lights that the maximum simulteanous authorized
  104383. */
  104384. requireLightSorting: boolean;
  104385. /** @hidden */
  104386. readonly useMaterialMeshMap: boolean;
  104387. /** @hidden */
  104388. readonly useClonedMeshhMap: boolean;
  104389. private _externalData;
  104390. private _uid;
  104391. /**
  104392. * @hidden
  104393. * Backing store of defined scene components.
  104394. */
  104395. _components: ISceneComponent[];
  104396. /**
  104397. * @hidden
  104398. * Backing store of defined scene components.
  104399. */
  104400. _serializableComponents: ISceneSerializableComponent[];
  104401. /**
  104402. * List of components to register on the next registration step.
  104403. */
  104404. private _transientComponents;
  104405. /**
  104406. * Registers the transient components if needed.
  104407. */
  104408. private _registerTransientComponents;
  104409. /**
  104410. * @hidden
  104411. * Add a component to the scene.
  104412. * Note that the ccomponent could be registered on th next frame if this is called after
  104413. * the register component stage.
  104414. * @param component Defines the component to add to the scene
  104415. */
  104416. _addComponent(component: ISceneComponent): void;
  104417. /**
  104418. * @hidden
  104419. * Gets a component from the scene.
  104420. * @param name defines the name of the component to retrieve
  104421. * @returns the component or null if not present
  104422. */
  104423. _getComponent(name: string): Nullable<ISceneComponent>;
  104424. /**
  104425. * @hidden
  104426. * Defines the actions happening before camera updates.
  104427. */
  104428. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  104429. /**
  104430. * @hidden
  104431. * Defines the actions happening before clear the canvas.
  104432. */
  104433. _beforeClearStage: Stage<SimpleStageAction>;
  104434. /**
  104435. * @hidden
  104436. * Defines the actions when collecting render targets for the frame.
  104437. */
  104438. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  104439. /**
  104440. * @hidden
  104441. * Defines the actions happening for one camera in the frame.
  104442. */
  104443. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  104444. /**
  104445. * @hidden
  104446. * Defines the actions happening during the per mesh ready checks.
  104447. */
  104448. _isReadyForMeshStage: Stage<MeshStageAction>;
  104449. /**
  104450. * @hidden
  104451. * Defines the actions happening before evaluate active mesh checks.
  104452. */
  104453. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  104454. /**
  104455. * @hidden
  104456. * Defines the actions happening during the evaluate sub mesh checks.
  104457. */
  104458. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  104459. /**
  104460. * @hidden
  104461. * Defines the actions happening during the active mesh stage.
  104462. */
  104463. _activeMeshStage: Stage<ActiveMeshStageAction>;
  104464. /**
  104465. * @hidden
  104466. * Defines the actions happening during the per camera render target step.
  104467. */
  104468. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  104469. /**
  104470. * @hidden
  104471. * Defines the actions happening just before the active camera is drawing.
  104472. */
  104473. _beforeCameraDrawStage: Stage<CameraStageAction>;
  104474. /**
  104475. * @hidden
  104476. * Defines the actions happening just before a render target is drawing.
  104477. */
  104478. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  104479. /**
  104480. * @hidden
  104481. * Defines the actions happening just before a rendering group is drawing.
  104482. */
  104483. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  104484. /**
  104485. * @hidden
  104486. * Defines the actions happening just before a mesh is drawing.
  104487. */
  104488. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  104489. /**
  104490. * @hidden
  104491. * Defines the actions happening just after a mesh has been drawn.
  104492. */
  104493. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  104494. /**
  104495. * @hidden
  104496. * Defines the actions happening just after a rendering group has been drawn.
  104497. */
  104498. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  104499. /**
  104500. * @hidden
  104501. * Defines the actions happening just after the active camera has been drawn.
  104502. */
  104503. _afterCameraDrawStage: Stage<CameraStageAction>;
  104504. /**
  104505. * @hidden
  104506. * Defines the actions happening just after a render target has been drawn.
  104507. */
  104508. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  104509. /**
  104510. * @hidden
  104511. * Defines the actions happening just after rendering all cameras and computing intersections.
  104512. */
  104513. _afterRenderStage: Stage<SimpleStageAction>;
  104514. /**
  104515. * @hidden
  104516. * Defines the actions happening when a pointer move event happens.
  104517. */
  104518. _pointerMoveStage: Stage<PointerMoveStageAction>;
  104519. /**
  104520. * @hidden
  104521. * Defines the actions happening when a pointer down event happens.
  104522. */
  104523. _pointerDownStage: Stage<PointerUpDownStageAction>;
  104524. /**
  104525. * @hidden
  104526. * Defines the actions happening when a pointer up event happens.
  104527. */
  104528. _pointerUpStage: Stage<PointerUpDownStageAction>;
  104529. /**
  104530. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  104531. */
  104532. private geometriesByUniqueId;
  104533. /**
  104534. * Creates a new Scene
  104535. * @param engine defines the engine to use to render this scene
  104536. * @param options defines the scene options
  104537. */
  104538. constructor(engine: Engine, options?: SceneOptions);
  104539. /**
  104540. * Gets a string idenfifying the name of the class
  104541. * @returns "Scene" string
  104542. */
  104543. getClassName(): string;
  104544. private _defaultMeshCandidates;
  104545. /**
  104546. * @hidden
  104547. */
  104548. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  104549. private _defaultSubMeshCandidates;
  104550. /**
  104551. * @hidden
  104552. */
  104553. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  104554. /**
  104555. * Sets the default candidate providers for the scene.
  104556. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  104557. * and getCollidingSubMeshCandidates to their default function
  104558. */
  104559. setDefaultCandidateProviders(): void;
  104560. /**
  104561. * Gets the mesh that is currently under the pointer
  104562. */
  104563. readonly meshUnderPointer: Nullable<AbstractMesh>;
  104564. /**
  104565. * Gets or sets the current on-screen X position of the pointer
  104566. */
  104567. pointerX: number;
  104568. /**
  104569. * Gets or sets the current on-screen Y position of the pointer
  104570. */
  104571. pointerY: number;
  104572. /**
  104573. * Gets the cached material (ie. the latest rendered one)
  104574. * @returns the cached material
  104575. */
  104576. getCachedMaterial(): Nullable<Material>;
  104577. /**
  104578. * Gets the cached effect (ie. the latest rendered one)
  104579. * @returns the cached effect
  104580. */
  104581. getCachedEffect(): Nullable<Effect>;
  104582. /**
  104583. * Gets the cached visibility state (ie. the latest rendered one)
  104584. * @returns the cached visibility state
  104585. */
  104586. getCachedVisibility(): Nullable<number>;
  104587. /**
  104588. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  104589. * @param material defines the current material
  104590. * @param effect defines the current effect
  104591. * @param visibility defines the current visibility state
  104592. * @returns true if one parameter is not cached
  104593. */
  104594. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  104595. /**
  104596. * Gets the engine associated with the scene
  104597. * @returns an Engine
  104598. */
  104599. getEngine(): Engine;
  104600. /**
  104601. * Gets the total number of vertices rendered per frame
  104602. * @returns the total number of vertices rendered per frame
  104603. */
  104604. getTotalVertices(): number;
  104605. /**
  104606. * Gets the performance counter for total vertices
  104607. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  104608. */
  104609. readonly totalVerticesPerfCounter: PerfCounter;
  104610. /**
  104611. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  104612. * @returns the total number of active indices rendered per frame
  104613. */
  104614. getActiveIndices(): number;
  104615. /**
  104616. * Gets the performance counter for active indices
  104617. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  104618. */
  104619. readonly totalActiveIndicesPerfCounter: PerfCounter;
  104620. /**
  104621. * Gets the total number of active particles rendered per frame
  104622. * @returns the total number of active particles rendered per frame
  104623. */
  104624. getActiveParticles(): number;
  104625. /**
  104626. * Gets the performance counter for active particles
  104627. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  104628. */
  104629. readonly activeParticlesPerfCounter: PerfCounter;
  104630. /**
  104631. * Gets the total number of active bones rendered per frame
  104632. * @returns the total number of active bones rendered per frame
  104633. */
  104634. getActiveBones(): number;
  104635. /**
  104636. * Gets the performance counter for active bones
  104637. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  104638. */
  104639. readonly activeBonesPerfCounter: PerfCounter;
  104640. /**
  104641. * Gets the array of active meshes
  104642. * @returns an array of AbstractMesh
  104643. */
  104644. getActiveMeshes(): SmartArray<AbstractMesh>;
  104645. /**
  104646. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  104647. * @returns a number
  104648. */
  104649. getAnimationRatio(): number;
  104650. /**
  104651. * Gets an unique Id for the current render phase
  104652. * @returns a number
  104653. */
  104654. getRenderId(): number;
  104655. /**
  104656. * Gets an unique Id for the current frame
  104657. * @returns a number
  104658. */
  104659. getFrameId(): number;
  104660. /** Call this function if you want to manually increment the render Id*/
  104661. incrementRenderId(): void;
  104662. private _createUbo;
  104663. /**
  104664. * Use this method to simulate a pointer move on a mesh
  104665. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  104666. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  104667. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  104668. * @returns the current scene
  104669. */
  104670. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  104671. /**
  104672. * Use this method to simulate a pointer down on a mesh
  104673. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  104674. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  104675. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  104676. * @returns the current scene
  104677. */
  104678. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  104679. /**
  104680. * Use this method to simulate a pointer up on a mesh
  104681. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  104682. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  104683. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  104684. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  104685. * @returns the current scene
  104686. */
  104687. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  104688. /**
  104689. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  104690. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  104691. * @returns true if the pointer was captured
  104692. */
  104693. isPointerCaptured(pointerId?: number): boolean;
  104694. /**
  104695. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  104696. * @param attachUp defines if you want to attach events to pointerup
  104697. * @param attachDown defines if you want to attach events to pointerdown
  104698. * @param attachMove defines if you want to attach events to pointermove
  104699. */
  104700. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  104701. /** Detaches all event handlers*/
  104702. detachControl(): void;
  104703. /**
  104704. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  104705. * Delay loaded resources are not taking in account
  104706. * @return true if all required resources are ready
  104707. */
  104708. isReady(): boolean;
  104709. /** Resets all cached information relative to material (including effect and visibility) */
  104710. resetCachedMaterial(): void;
  104711. /**
  104712. * Registers a function to be called before every frame render
  104713. * @param func defines the function to register
  104714. */
  104715. registerBeforeRender(func: () => void): void;
  104716. /**
  104717. * Unregisters a function called before every frame render
  104718. * @param func defines the function to unregister
  104719. */
  104720. unregisterBeforeRender(func: () => void): void;
  104721. /**
  104722. * Registers a function to be called after every frame render
  104723. * @param func defines the function to register
  104724. */
  104725. registerAfterRender(func: () => void): void;
  104726. /**
  104727. * Unregisters a function called after every frame render
  104728. * @param func defines the function to unregister
  104729. */
  104730. unregisterAfterRender(func: () => void): void;
  104731. private _executeOnceBeforeRender;
  104732. /**
  104733. * The provided function will run before render once and will be disposed afterwards.
  104734. * A timeout delay can be provided so that the function will be executed in N ms.
  104735. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  104736. * @param func The function to be executed.
  104737. * @param timeout optional delay in ms
  104738. */
  104739. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  104740. /** @hidden */
  104741. _addPendingData(data: any): void;
  104742. /** @hidden */
  104743. _removePendingData(data: any): void;
  104744. /**
  104745. * Returns the number of items waiting to be loaded
  104746. * @returns the number of items waiting to be loaded
  104747. */
  104748. getWaitingItemsCount(): number;
  104749. /**
  104750. * Returns a boolean indicating if the scene is still loading data
  104751. */
  104752. readonly isLoading: boolean;
  104753. /**
  104754. * Registers a function to be executed when the scene is ready
  104755. * @param {Function} func - the function to be executed
  104756. */
  104757. executeWhenReady(func: () => void): void;
  104758. /**
  104759. * Returns a promise that resolves when the scene is ready
  104760. * @returns A promise that resolves when the scene is ready
  104761. */
  104762. whenReadyAsync(): Promise<void>;
  104763. /** @hidden */
  104764. _checkIsReady(): void;
  104765. /**
  104766. * Gets all animatable attached to the scene
  104767. */
  104768. readonly animatables: Animatable[];
  104769. /**
  104770. * Resets the last animation time frame.
  104771. * Useful to override when animations start running when loading a scene for the first time.
  104772. */
  104773. resetLastAnimationTimeFrame(): void;
  104774. /**
  104775. * Gets the current view matrix
  104776. * @returns a Matrix
  104777. */
  104778. getViewMatrix(): Matrix;
  104779. /**
  104780. * Gets the current projection matrix
  104781. * @returns a Matrix
  104782. */
  104783. getProjectionMatrix(): Matrix;
  104784. /**
  104785. * Gets the current transform matrix
  104786. * @returns a Matrix made of View * Projection
  104787. */
  104788. getTransformMatrix(): Matrix;
  104789. /**
  104790. * Sets the current transform matrix
  104791. * @param viewL defines the View matrix to use
  104792. * @param projectionL defines the Projection matrix to use
  104793. * @param viewR defines the right View matrix to use (if provided)
  104794. * @param projectionR defines the right Projection matrix to use (if provided)
  104795. */
  104796. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  104797. /**
  104798. * Gets the uniform buffer used to store scene data
  104799. * @returns a UniformBuffer
  104800. */
  104801. getSceneUniformBuffer(): UniformBuffer;
  104802. /**
  104803. * Gets an unique (relatively to the current scene) Id
  104804. * @returns an unique number for the scene
  104805. */
  104806. getUniqueId(): number;
  104807. /**
  104808. * Add a mesh to the list of scene's meshes
  104809. * @param newMesh defines the mesh to add
  104810. * @param recursive if all child meshes should also be added to the scene
  104811. */
  104812. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  104813. /**
  104814. * Remove a mesh for the list of scene's meshes
  104815. * @param toRemove defines the mesh to remove
  104816. * @param recursive if all child meshes should also be removed from the scene
  104817. * @returns the index where the mesh was in the mesh list
  104818. */
  104819. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  104820. /**
  104821. * Add a transform node to the list of scene's transform nodes
  104822. * @param newTransformNode defines the transform node to add
  104823. */
  104824. addTransformNode(newTransformNode: TransformNode): void;
  104825. /**
  104826. * Remove a transform node for the list of scene's transform nodes
  104827. * @param toRemove defines the transform node to remove
  104828. * @returns the index where the transform node was in the transform node list
  104829. */
  104830. removeTransformNode(toRemove: TransformNode): number;
  104831. /**
  104832. * Remove a skeleton for the list of scene's skeletons
  104833. * @param toRemove defines the skeleton to remove
  104834. * @returns the index where the skeleton was in the skeleton list
  104835. */
  104836. removeSkeleton(toRemove: Skeleton): number;
  104837. /**
  104838. * Remove a morph target for the list of scene's morph targets
  104839. * @param toRemove defines the morph target to remove
  104840. * @returns the index where the morph target was in the morph target list
  104841. */
  104842. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  104843. /**
  104844. * Remove a light for the list of scene's lights
  104845. * @param toRemove defines the light to remove
  104846. * @returns the index where the light was in the light list
  104847. */
  104848. removeLight(toRemove: Light): number;
  104849. /**
  104850. * Remove a camera for the list of scene's cameras
  104851. * @param toRemove defines the camera to remove
  104852. * @returns the index where the camera was in the camera list
  104853. */
  104854. removeCamera(toRemove: Camera): number;
  104855. /**
  104856. * Remove a particle system for the list of scene's particle systems
  104857. * @param toRemove defines the particle system to remove
  104858. * @returns the index where the particle system was in the particle system list
  104859. */
  104860. removeParticleSystem(toRemove: IParticleSystem): number;
  104861. /**
  104862. * Remove a animation for the list of scene's animations
  104863. * @param toRemove defines the animation to remove
  104864. * @returns the index where the animation was in the animation list
  104865. */
  104866. removeAnimation(toRemove: Animation): number;
  104867. /**
  104868. * Will stop the animation of the given target
  104869. * @param target - the target
  104870. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  104871. * @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)
  104872. */
  104873. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  104874. /**
  104875. * Removes the given animation group from this scene.
  104876. * @param toRemove The animation group to remove
  104877. * @returns The index of the removed animation group
  104878. */
  104879. removeAnimationGroup(toRemove: AnimationGroup): number;
  104880. /**
  104881. * Removes the given multi-material from this scene.
  104882. * @param toRemove The multi-material to remove
  104883. * @returns The index of the removed multi-material
  104884. */
  104885. removeMultiMaterial(toRemove: MultiMaterial): number;
  104886. /**
  104887. * Removes the given material from this scene.
  104888. * @param toRemove The material to remove
  104889. * @returns The index of the removed material
  104890. */
  104891. removeMaterial(toRemove: Material): number;
  104892. /**
  104893. * Removes the given action manager from this scene.
  104894. * @param toRemove The action manager to remove
  104895. * @returns The index of the removed action manager
  104896. */
  104897. removeActionManager(toRemove: AbstractActionManager): number;
  104898. /**
  104899. * Removes the given texture from this scene.
  104900. * @param toRemove The texture to remove
  104901. * @returns The index of the removed texture
  104902. */
  104903. removeTexture(toRemove: BaseTexture): number;
  104904. /**
  104905. * Adds the given light to this scene
  104906. * @param newLight The light to add
  104907. */
  104908. addLight(newLight: Light): void;
  104909. /**
  104910. * Sorts the list list based on light priorities
  104911. */
  104912. sortLightsByPriority(): void;
  104913. /**
  104914. * Adds the given camera to this scene
  104915. * @param newCamera The camera to add
  104916. */
  104917. addCamera(newCamera: Camera): void;
  104918. /**
  104919. * Adds the given skeleton to this scene
  104920. * @param newSkeleton The skeleton to add
  104921. */
  104922. addSkeleton(newSkeleton: Skeleton): void;
  104923. /**
  104924. * Adds the given particle system to this scene
  104925. * @param newParticleSystem The particle system to add
  104926. */
  104927. addParticleSystem(newParticleSystem: IParticleSystem): void;
  104928. /**
  104929. * Adds the given animation to this scene
  104930. * @param newAnimation The animation to add
  104931. */
  104932. addAnimation(newAnimation: Animation): void;
  104933. /**
  104934. * Adds the given animation group to this scene.
  104935. * @param newAnimationGroup The animation group to add
  104936. */
  104937. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  104938. /**
  104939. * Adds the given multi-material to this scene
  104940. * @param newMultiMaterial The multi-material to add
  104941. */
  104942. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  104943. /**
  104944. * Adds the given material to this scene
  104945. * @param newMaterial The material to add
  104946. */
  104947. addMaterial(newMaterial: Material): void;
  104948. /**
  104949. * Adds the given morph target to this scene
  104950. * @param newMorphTargetManager The morph target to add
  104951. */
  104952. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  104953. /**
  104954. * Adds the given geometry to this scene
  104955. * @param newGeometry The geometry to add
  104956. */
  104957. addGeometry(newGeometry: Geometry): void;
  104958. /**
  104959. * Adds the given action manager to this scene
  104960. * @param newActionManager The action manager to add
  104961. */
  104962. addActionManager(newActionManager: AbstractActionManager): void;
  104963. /**
  104964. * Adds the given texture to this scene.
  104965. * @param newTexture The texture to add
  104966. */
  104967. addTexture(newTexture: BaseTexture): void;
  104968. /**
  104969. * Switch active camera
  104970. * @param newCamera defines the new active camera
  104971. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  104972. */
  104973. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  104974. /**
  104975. * sets the active camera of the scene using its ID
  104976. * @param id defines the camera's ID
  104977. * @return the new active camera or null if none found.
  104978. */
  104979. setActiveCameraByID(id: string): Nullable<Camera>;
  104980. /**
  104981. * sets the active camera of the scene using its name
  104982. * @param name defines the camera's name
  104983. * @returns the new active camera or null if none found.
  104984. */
  104985. setActiveCameraByName(name: string): Nullable<Camera>;
  104986. /**
  104987. * get an animation group using its name
  104988. * @param name defines the material's name
  104989. * @return the animation group or null if none found.
  104990. */
  104991. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  104992. /**
  104993. * Get a material using its unique id
  104994. * @param uniqueId defines the material's unique id
  104995. * @return the material or null if none found.
  104996. */
  104997. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  104998. /**
  104999. * get a material using its id
  105000. * @param id defines the material's ID
  105001. * @return the material or null if none found.
  105002. */
  105003. getMaterialByID(id: string): Nullable<Material>;
  105004. /**
  105005. * Gets a the last added material using a given id
  105006. * @param id defines the material's ID
  105007. * @return the last material with the given id or null if none found.
  105008. */
  105009. getLastMaterialByID(id: string): Nullable<Material>;
  105010. /**
  105011. * Gets a material using its name
  105012. * @param name defines the material's name
  105013. * @return the material or null if none found.
  105014. */
  105015. getMaterialByName(name: string): Nullable<Material>;
  105016. /**
  105017. * Get a texture using its unique id
  105018. * @param uniqueId defines the texture's unique id
  105019. * @return the texture or null if none found.
  105020. */
  105021. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  105022. /**
  105023. * Gets a camera using its id
  105024. * @param id defines the id to look for
  105025. * @returns the camera or null if not found
  105026. */
  105027. getCameraByID(id: string): Nullable<Camera>;
  105028. /**
  105029. * Gets a camera using its unique id
  105030. * @param uniqueId defines the unique id to look for
  105031. * @returns the camera or null if not found
  105032. */
  105033. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  105034. /**
  105035. * Gets a camera using its name
  105036. * @param name defines the camera's name
  105037. * @return the camera or null if none found.
  105038. */
  105039. getCameraByName(name: string): Nullable<Camera>;
  105040. /**
  105041. * Gets a bone using its id
  105042. * @param id defines the bone's id
  105043. * @return the bone or null if not found
  105044. */
  105045. getBoneByID(id: string): Nullable<Bone>;
  105046. /**
  105047. * Gets a bone using its id
  105048. * @param name defines the bone's name
  105049. * @return the bone or null if not found
  105050. */
  105051. getBoneByName(name: string): Nullable<Bone>;
  105052. /**
  105053. * Gets a light node using its name
  105054. * @param name defines the the light's name
  105055. * @return the light or null if none found.
  105056. */
  105057. getLightByName(name: string): Nullable<Light>;
  105058. /**
  105059. * Gets a light node using its id
  105060. * @param id defines the light's id
  105061. * @return the light or null if none found.
  105062. */
  105063. getLightByID(id: string): Nullable<Light>;
  105064. /**
  105065. * Gets a light node using its scene-generated unique ID
  105066. * @param uniqueId defines the light's unique id
  105067. * @return the light or null if none found.
  105068. */
  105069. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  105070. /**
  105071. * Gets a particle system by id
  105072. * @param id defines the particle system id
  105073. * @return the corresponding system or null if none found
  105074. */
  105075. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  105076. /**
  105077. * Gets a geometry using its ID
  105078. * @param id defines the geometry's id
  105079. * @return the geometry or null if none found.
  105080. */
  105081. getGeometryByID(id: string): Nullable<Geometry>;
  105082. private _getGeometryByUniqueID;
  105083. /**
  105084. * Add a new geometry to this scene
  105085. * @param geometry defines the geometry to be added to the scene.
  105086. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  105087. * @return a boolean defining if the geometry was added or not
  105088. */
  105089. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  105090. /**
  105091. * Removes an existing geometry
  105092. * @param geometry defines the geometry to be removed from the scene
  105093. * @return a boolean defining if the geometry was removed or not
  105094. */
  105095. removeGeometry(geometry: Geometry): boolean;
  105096. /**
  105097. * Gets the list of geometries attached to the scene
  105098. * @returns an array of Geometry
  105099. */
  105100. getGeometries(): Geometry[];
  105101. /**
  105102. * Gets the first added mesh found of a given ID
  105103. * @param id defines the id to search for
  105104. * @return the mesh found or null if not found at all
  105105. */
  105106. getMeshByID(id: string): Nullable<AbstractMesh>;
  105107. /**
  105108. * Gets a list of meshes using their id
  105109. * @param id defines the id to search for
  105110. * @returns a list of meshes
  105111. */
  105112. getMeshesByID(id: string): Array<AbstractMesh>;
  105113. /**
  105114. * Gets the first added transform node found of a given ID
  105115. * @param id defines the id to search for
  105116. * @return the found transform node or null if not found at all.
  105117. */
  105118. getTransformNodeByID(id: string): Nullable<TransformNode>;
  105119. /**
  105120. * Gets a transform node with its auto-generated unique id
  105121. * @param uniqueId efines the unique id to search for
  105122. * @return the found transform node or null if not found at all.
  105123. */
  105124. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  105125. /**
  105126. * Gets a list of transform nodes using their id
  105127. * @param id defines the id to search for
  105128. * @returns a list of transform nodes
  105129. */
  105130. getTransformNodesByID(id: string): Array<TransformNode>;
  105131. /**
  105132. * Gets a mesh with its auto-generated unique id
  105133. * @param uniqueId defines the unique id to search for
  105134. * @return the found mesh or null if not found at all.
  105135. */
  105136. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  105137. /**
  105138. * Gets a the last added mesh using a given id
  105139. * @param id defines the id to search for
  105140. * @return the found mesh or null if not found at all.
  105141. */
  105142. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  105143. /**
  105144. * Gets a the last added node (Mesh, Camera, Light) using a given id
  105145. * @param id defines the id to search for
  105146. * @return the found node or null if not found at all
  105147. */
  105148. getLastEntryByID(id: string): Nullable<Node>;
  105149. /**
  105150. * Gets a node (Mesh, Camera, Light) using a given id
  105151. * @param id defines the id to search for
  105152. * @return the found node or null if not found at all
  105153. */
  105154. getNodeByID(id: string): Nullable<Node>;
  105155. /**
  105156. * Gets a node (Mesh, Camera, Light) using a given name
  105157. * @param name defines the name to search for
  105158. * @return the found node or null if not found at all.
  105159. */
  105160. getNodeByName(name: string): Nullable<Node>;
  105161. /**
  105162. * Gets a mesh using a given name
  105163. * @param name defines the name to search for
  105164. * @return the found mesh or null if not found at all.
  105165. */
  105166. getMeshByName(name: string): Nullable<AbstractMesh>;
  105167. /**
  105168. * Gets a transform node using a given name
  105169. * @param name defines the name to search for
  105170. * @return the found transform node or null if not found at all.
  105171. */
  105172. getTransformNodeByName(name: string): Nullable<TransformNode>;
  105173. /**
  105174. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  105175. * @param id defines the id to search for
  105176. * @return the found skeleton or null if not found at all.
  105177. */
  105178. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  105179. /**
  105180. * Gets a skeleton using a given auto generated unique id
  105181. * @param uniqueId defines the unique id to search for
  105182. * @return the found skeleton or null if not found at all.
  105183. */
  105184. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  105185. /**
  105186. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  105187. * @param id defines the id to search for
  105188. * @return the found skeleton or null if not found at all.
  105189. */
  105190. getSkeletonById(id: string): Nullable<Skeleton>;
  105191. /**
  105192. * Gets a skeleton using a given name
  105193. * @param name defines the name to search for
  105194. * @return the found skeleton or null if not found at all.
  105195. */
  105196. getSkeletonByName(name: string): Nullable<Skeleton>;
  105197. /**
  105198. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  105199. * @param id defines the id to search for
  105200. * @return the found morph target manager or null if not found at all.
  105201. */
  105202. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  105203. /**
  105204. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  105205. * @param id defines the id to search for
  105206. * @return the found morph target or null if not found at all.
  105207. */
  105208. getMorphTargetById(id: string): Nullable<MorphTarget>;
  105209. /**
  105210. * Gets a boolean indicating if the given mesh is active
  105211. * @param mesh defines the mesh to look for
  105212. * @returns true if the mesh is in the active list
  105213. */
  105214. isActiveMesh(mesh: AbstractMesh): boolean;
  105215. /**
  105216. * Return a unique id as a string which can serve as an identifier for the scene
  105217. */
  105218. readonly uid: string;
  105219. /**
  105220. * Add an externaly attached data from its key.
  105221. * This method call will fail and return false, if such key already exists.
  105222. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  105223. * @param key the unique key that identifies the data
  105224. * @param data the data object to associate to the key for this Engine instance
  105225. * @return true if no such key were already present and the data was added successfully, false otherwise
  105226. */
  105227. addExternalData<T>(key: string, data: T): boolean;
  105228. /**
  105229. * Get an externaly attached data from its key
  105230. * @param key the unique key that identifies the data
  105231. * @return the associated data, if present (can be null), or undefined if not present
  105232. */
  105233. getExternalData<T>(key: string): Nullable<T>;
  105234. /**
  105235. * Get an externaly attached data from its key, create it using a factory if it's not already present
  105236. * @param key the unique key that identifies the data
  105237. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  105238. * @return the associated data, can be null if the factory returned null.
  105239. */
  105240. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  105241. /**
  105242. * Remove an externaly attached data from the Engine instance
  105243. * @param key the unique key that identifies the data
  105244. * @return true if the data was successfully removed, false if it doesn't exist
  105245. */
  105246. removeExternalData(key: string): boolean;
  105247. private _evaluateSubMesh;
  105248. /**
  105249. * Clear the processed materials smart array preventing retention point in material dispose.
  105250. */
  105251. freeProcessedMaterials(): void;
  105252. private _preventFreeActiveMeshesAndRenderingGroups;
  105253. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  105254. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  105255. * when disposing several meshes in a row or a hierarchy of meshes.
  105256. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  105257. */
  105258. blockfreeActiveMeshesAndRenderingGroups: boolean;
  105259. /**
  105260. * Clear the active meshes smart array preventing retention point in mesh dispose.
  105261. */
  105262. freeActiveMeshes(): void;
  105263. /**
  105264. * Clear the info related to rendering groups preventing retention points during dispose.
  105265. */
  105266. freeRenderingGroups(): void;
  105267. /** @hidden */
  105268. _isInIntermediateRendering(): boolean;
  105269. /**
  105270. * Lambda returning the list of potentially active meshes.
  105271. */
  105272. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  105273. /**
  105274. * Lambda returning the list of potentially active sub meshes.
  105275. */
  105276. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  105277. /**
  105278. * Lambda returning the list of potentially intersecting sub meshes.
  105279. */
  105280. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  105281. /**
  105282. * Lambda returning the list of potentially colliding sub meshes.
  105283. */
  105284. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  105285. private _activeMeshesFrozen;
  105286. private _skipEvaluateActiveMeshesCompletely;
  105287. /**
  105288. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  105289. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  105290. * @returns the current scene
  105291. */
  105292. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  105293. /**
  105294. * Use this function to restart evaluating active meshes on every frame
  105295. * @returns the current scene
  105296. */
  105297. unfreezeActiveMeshes(): Scene;
  105298. private _evaluateActiveMeshes;
  105299. private _activeMesh;
  105300. /**
  105301. * Update the transform matrix to update from the current active camera
  105302. * @param force defines a boolean used to force the update even if cache is up to date
  105303. */
  105304. updateTransformMatrix(force?: boolean): void;
  105305. private _bindFrameBuffer;
  105306. /** @hidden */
  105307. _allowPostProcessClearColor: boolean;
  105308. /** @hidden */
  105309. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  105310. private _processSubCameras;
  105311. private _checkIntersections;
  105312. /** @hidden */
  105313. _advancePhysicsEngineStep(step: number): void;
  105314. /**
  105315. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  105316. */
  105317. getDeterministicFrameTime: () => number;
  105318. /** @hidden */
  105319. _animate(): void;
  105320. /** Execute all animations (for a frame) */
  105321. animate(): void;
  105322. /**
  105323. * Render the scene
  105324. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  105325. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  105326. */
  105327. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  105328. /**
  105329. * Freeze all materials
  105330. * A frozen material will not be updatable but should be faster to render
  105331. */
  105332. freezeMaterials(): void;
  105333. /**
  105334. * Unfreeze all materials
  105335. * A frozen material will not be updatable but should be faster to render
  105336. */
  105337. unfreezeMaterials(): void;
  105338. /**
  105339. * Releases all held ressources
  105340. */
  105341. dispose(): void;
  105342. /**
  105343. * Gets if the scene is already disposed
  105344. */
  105345. readonly isDisposed: boolean;
  105346. /**
  105347. * Call this function to reduce memory footprint of the scene.
  105348. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  105349. */
  105350. clearCachedVertexData(): void;
  105351. /**
  105352. * This function will remove the local cached buffer data from texture.
  105353. * It will save memory but will prevent the texture from being rebuilt
  105354. */
  105355. cleanCachedTextureBuffer(): void;
  105356. /**
  105357. * Get the world extend vectors with an optional filter
  105358. *
  105359. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  105360. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  105361. */
  105362. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  105363. min: Vector3;
  105364. max: Vector3;
  105365. };
  105366. /**
  105367. * Creates a ray that can be used to pick in the scene
  105368. * @param x defines the x coordinate of the origin (on-screen)
  105369. * @param y defines the y coordinate of the origin (on-screen)
  105370. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  105371. * @param camera defines the camera to use for the picking
  105372. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  105373. * @returns a Ray
  105374. */
  105375. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  105376. /**
  105377. * Creates a ray that can be used to pick in the scene
  105378. * @param x defines the x coordinate of the origin (on-screen)
  105379. * @param y defines the y coordinate of the origin (on-screen)
  105380. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  105381. * @param result defines the ray where to store the picking ray
  105382. * @param camera defines the camera to use for the picking
  105383. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  105384. * @returns the current scene
  105385. */
  105386. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  105387. /**
  105388. * Creates a ray that can be used to pick in the scene
  105389. * @param x defines the x coordinate of the origin (on-screen)
  105390. * @param y defines the y coordinate of the origin (on-screen)
  105391. * @param camera defines the camera to use for the picking
  105392. * @returns a Ray
  105393. */
  105394. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  105395. /**
  105396. * Creates a ray that can be used to pick in the scene
  105397. * @param x defines the x coordinate of the origin (on-screen)
  105398. * @param y defines the y coordinate of the origin (on-screen)
  105399. * @param result defines the ray where to store the picking ray
  105400. * @param camera defines the camera to use for the picking
  105401. * @returns the current scene
  105402. */
  105403. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  105404. /** Launch a ray to try to pick a mesh in the scene
  105405. * @param x position on screen
  105406. * @param y position on screen
  105407. * @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
  105408. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  105409. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  105410. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  105411. * @returns a PickingInfo
  105412. */
  105413. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  105414. /** Use the given ray to pick a mesh in the scene
  105415. * @param ray The ray to use to pick meshes
  105416. * @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
  105417. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  105418. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  105419. * @returns a PickingInfo
  105420. */
  105421. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  105422. /**
  105423. * Launch a ray to try to pick a mesh in the scene
  105424. * @param x X position on screen
  105425. * @param y Y position on screen
  105426. * @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
  105427. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  105428. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  105429. * @returns an array of PickingInfo
  105430. */
  105431. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  105432. /**
  105433. * Launch a ray to try to pick a mesh in the scene
  105434. * @param ray Ray to use
  105435. * @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
  105436. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  105437. * @returns an array of PickingInfo
  105438. */
  105439. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  105440. /**
  105441. * Force the value of meshUnderPointer
  105442. * @param mesh defines the mesh to use
  105443. */
  105444. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  105445. /**
  105446. * Gets the mesh under the pointer
  105447. * @returns a Mesh or null if no mesh is under the pointer
  105448. */
  105449. getPointerOverMesh(): Nullable<AbstractMesh>;
  105450. /** @hidden */
  105451. _rebuildGeometries(): void;
  105452. /** @hidden */
  105453. _rebuildTextures(): void;
  105454. private _getByTags;
  105455. /**
  105456. * Get a list of meshes by tags
  105457. * @param tagsQuery defines the tags query to use
  105458. * @param forEach defines a predicate used to filter results
  105459. * @returns an array of Mesh
  105460. */
  105461. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  105462. /**
  105463. * Get a list of cameras by tags
  105464. * @param tagsQuery defines the tags query to use
  105465. * @param forEach defines a predicate used to filter results
  105466. * @returns an array of Camera
  105467. */
  105468. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  105469. /**
  105470. * Get a list of lights by tags
  105471. * @param tagsQuery defines the tags query to use
  105472. * @param forEach defines a predicate used to filter results
  105473. * @returns an array of Light
  105474. */
  105475. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  105476. /**
  105477. * Get a list of materials by tags
  105478. * @param tagsQuery defines the tags query to use
  105479. * @param forEach defines a predicate used to filter results
  105480. * @returns an array of Material
  105481. */
  105482. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  105483. /**
  105484. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  105485. * This allowed control for front to back rendering or reversly depending of the special needs.
  105486. *
  105487. * @param renderingGroupId The rendering group id corresponding to its index
  105488. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  105489. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  105490. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  105491. */
  105492. 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;
  105493. /**
  105494. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  105495. *
  105496. * @param renderingGroupId The rendering group id corresponding to its index
  105497. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  105498. * @param depth Automatically clears depth between groups if true and autoClear is true.
  105499. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  105500. */
  105501. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  105502. /**
  105503. * Gets the current auto clear configuration for one rendering group of the rendering
  105504. * manager.
  105505. * @param index the rendering group index to get the information for
  105506. * @returns The auto clear setup for the requested rendering group
  105507. */
  105508. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  105509. private _blockMaterialDirtyMechanism;
  105510. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  105511. blockMaterialDirtyMechanism: boolean;
  105512. /**
  105513. * Will flag all materials as dirty to trigger new shader compilation
  105514. * @param flag defines the flag used to specify which material part must be marked as dirty
  105515. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  105516. */
  105517. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  105518. /** @hidden */
  105519. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  105520. /** @hidden */
  105521. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  105522. /** @hidden */
  105523. _requestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  105524. /** @hidden */
  105525. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  105526. /** @hidden */
  105527. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  105528. /** @hidden */
  105529. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  105530. }
  105531. }
  105532. declare module BABYLON {
  105533. /**
  105534. * Set of assets to keep when moving a scene into an asset container.
  105535. */
  105536. export class KeepAssets extends AbstractScene {
  105537. }
  105538. /**
  105539. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  105540. */
  105541. export class InstantiatedEntries {
  105542. /**
  105543. * List of new root nodes (eg. nodes with no parent)
  105544. */
  105545. rootNodes: TransformNode[];
  105546. /**
  105547. * List of new skeletons
  105548. */
  105549. skeletons: Skeleton[];
  105550. /**
  105551. * List of new animation groups
  105552. */
  105553. animationGroups: AnimationGroup[];
  105554. }
  105555. /**
  105556. * Container with a set of assets that can be added or removed from a scene.
  105557. */
  105558. export class AssetContainer extends AbstractScene {
  105559. /**
  105560. * The scene the AssetContainer belongs to.
  105561. */
  105562. scene: Scene;
  105563. /**
  105564. * Instantiates an AssetContainer.
  105565. * @param scene The scene the AssetContainer belongs to.
  105566. */
  105567. constructor(scene: Scene);
  105568. /**
  105569. * Instantiate or clone all meshes and add the new ones to the scene.
  105570. * Skeletons and animation groups will all be cloned
  105571. * @param nameFunction defines an optional function used to get new names for clones
  105572. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  105573. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  105574. */
  105575. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  105576. /**
  105577. * Adds all the assets from the container to the scene.
  105578. */
  105579. addAllToScene(): void;
  105580. /**
  105581. * Removes all the assets in the container from the scene
  105582. */
  105583. removeAllFromScene(): void;
  105584. /**
  105585. * Disposes all the assets in the container
  105586. */
  105587. dispose(): void;
  105588. private _moveAssets;
  105589. /**
  105590. * Removes all the assets contained in the scene and adds them to the container.
  105591. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  105592. */
  105593. moveAllFromScene(keepAssets?: KeepAssets): void;
  105594. /**
  105595. * 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.
  105596. * @returns the root mesh
  105597. */
  105598. createRootMesh(): Mesh;
  105599. }
  105600. }
  105601. declare module BABYLON {
  105602. /**
  105603. * Defines how the parser contract is defined.
  105604. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  105605. */
  105606. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  105607. /**
  105608. * Defines how the individual parser contract is defined.
  105609. * These parser can parse an individual asset
  105610. */
  105611. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  105612. /**
  105613. * Base class of the scene acting as a container for the different elements composing a scene.
  105614. * This class is dynamically extended by the different components of the scene increasing
  105615. * flexibility and reducing coupling
  105616. */
  105617. export abstract class AbstractScene {
  105618. /**
  105619. * Stores the list of available parsers in the application.
  105620. */
  105621. private static _BabylonFileParsers;
  105622. /**
  105623. * Stores the list of available individual parsers in the application.
  105624. */
  105625. private static _IndividualBabylonFileParsers;
  105626. /**
  105627. * Adds a parser in the list of available ones
  105628. * @param name Defines the name of the parser
  105629. * @param parser Defines the parser to add
  105630. */
  105631. static AddParser(name: string, parser: BabylonFileParser): void;
  105632. /**
  105633. * Gets a general parser from the list of avaialble ones
  105634. * @param name Defines the name of the parser
  105635. * @returns the requested parser or null
  105636. */
  105637. static GetParser(name: string): Nullable<BabylonFileParser>;
  105638. /**
  105639. * Adds n individual parser in the list of available ones
  105640. * @param name Defines the name of the parser
  105641. * @param parser Defines the parser to add
  105642. */
  105643. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  105644. /**
  105645. * Gets an individual parser from the list of avaialble ones
  105646. * @param name Defines the name of the parser
  105647. * @returns the requested parser or null
  105648. */
  105649. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  105650. /**
  105651. * Parser json data and populate both a scene and its associated container object
  105652. * @param jsonData Defines the data to parse
  105653. * @param scene Defines the scene to parse the data for
  105654. * @param container Defines the container attached to the parsing sequence
  105655. * @param rootUrl Defines the root url of the data
  105656. */
  105657. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  105658. /**
  105659. * Gets the list of root nodes (ie. nodes with no parent)
  105660. */
  105661. rootNodes: Node[];
  105662. /** All of the cameras added to this scene
  105663. * @see http://doc.babylonjs.com/babylon101/cameras
  105664. */
  105665. cameras: Camera[];
  105666. /**
  105667. * All of the lights added to this scene
  105668. * @see http://doc.babylonjs.com/babylon101/lights
  105669. */
  105670. lights: Light[];
  105671. /**
  105672. * All of the (abstract) meshes added to this scene
  105673. */
  105674. meshes: AbstractMesh[];
  105675. /**
  105676. * The list of skeletons added to the scene
  105677. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  105678. */
  105679. skeletons: Skeleton[];
  105680. /**
  105681. * All of the particle systems added to this scene
  105682. * @see http://doc.babylonjs.com/babylon101/particles
  105683. */
  105684. particleSystems: IParticleSystem[];
  105685. /**
  105686. * Gets a list of Animations associated with the scene
  105687. */
  105688. animations: Animation[];
  105689. /**
  105690. * All of the animation groups added to this scene
  105691. * @see http://doc.babylonjs.com/how_to/group
  105692. */
  105693. animationGroups: AnimationGroup[];
  105694. /**
  105695. * All of the multi-materials added to this scene
  105696. * @see http://doc.babylonjs.com/how_to/multi_materials
  105697. */
  105698. multiMaterials: MultiMaterial[];
  105699. /**
  105700. * All of the materials added to this scene
  105701. * In the context of a Scene, it is not supposed to be modified manually.
  105702. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  105703. * Note also that the order of the Material within the array is not significant and might change.
  105704. * @see http://doc.babylonjs.com/babylon101/materials
  105705. */
  105706. materials: Material[];
  105707. /**
  105708. * The list of morph target managers added to the scene
  105709. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  105710. */
  105711. morphTargetManagers: MorphTargetManager[];
  105712. /**
  105713. * The list of geometries used in the scene.
  105714. */
  105715. geometries: Geometry[];
  105716. /**
  105717. * All of the tranform nodes added to this scene
  105718. * In the context of a Scene, it is not supposed to be modified manually.
  105719. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  105720. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  105721. * @see http://doc.babylonjs.com/how_to/transformnode
  105722. */
  105723. transformNodes: TransformNode[];
  105724. /**
  105725. * ActionManagers available on the scene.
  105726. */
  105727. actionManagers: AbstractActionManager[];
  105728. /**
  105729. * Textures to keep.
  105730. */
  105731. textures: BaseTexture[];
  105732. /**
  105733. * Environment texture for the scene
  105734. */
  105735. environmentTexture: Nullable<BaseTexture>;
  105736. }
  105737. }
  105738. declare module BABYLON {
  105739. /**
  105740. * Interface used to define options for Sound class
  105741. */
  105742. export interface ISoundOptions {
  105743. /**
  105744. * Does the sound autoplay once loaded.
  105745. */
  105746. autoplay?: boolean;
  105747. /**
  105748. * Does the sound loop after it finishes playing once.
  105749. */
  105750. loop?: boolean;
  105751. /**
  105752. * Sound's volume
  105753. */
  105754. volume?: number;
  105755. /**
  105756. * Is it a spatial sound?
  105757. */
  105758. spatialSound?: boolean;
  105759. /**
  105760. * Maximum distance to hear that sound
  105761. */
  105762. maxDistance?: number;
  105763. /**
  105764. * Uses user defined attenuation function
  105765. */
  105766. useCustomAttenuation?: boolean;
  105767. /**
  105768. * Define the roll off factor of spatial sounds.
  105769. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105770. */
  105771. rolloffFactor?: number;
  105772. /**
  105773. * Define the reference distance the sound should be heard perfectly.
  105774. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105775. */
  105776. refDistance?: number;
  105777. /**
  105778. * Define the distance attenuation model the sound will follow.
  105779. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105780. */
  105781. distanceModel?: string;
  105782. /**
  105783. * Defines the playback speed (1 by default)
  105784. */
  105785. playbackRate?: number;
  105786. /**
  105787. * Defines if the sound is from a streaming source
  105788. */
  105789. streaming?: boolean;
  105790. /**
  105791. * Defines an optional length (in seconds) inside the sound file
  105792. */
  105793. length?: number;
  105794. /**
  105795. * Defines an optional offset (in seconds) inside the sound file
  105796. */
  105797. offset?: number;
  105798. /**
  105799. * If true, URLs will not be required to state the audio file codec to use.
  105800. */
  105801. skipCodecCheck?: boolean;
  105802. }
  105803. /**
  105804. * Defines a sound that can be played in the application.
  105805. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  105806. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105807. */
  105808. export class Sound {
  105809. /**
  105810. * The name of the sound in the scene.
  105811. */
  105812. name: string;
  105813. /**
  105814. * Does the sound autoplay once loaded.
  105815. */
  105816. autoplay: boolean;
  105817. /**
  105818. * Does the sound loop after it finishes playing once.
  105819. */
  105820. loop: boolean;
  105821. /**
  105822. * Does the sound use a custom attenuation curve to simulate the falloff
  105823. * happening when the source gets further away from the camera.
  105824. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  105825. */
  105826. useCustomAttenuation: boolean;
  105827. /**
  105828. * The sound track id this sound belongs to.
  105829. */
  105830. soundTrackId: number;
  105831. /**
  105832. * Is this sound currently played.
  105833. */
  105834. isPlaying: boolean;
  105835. /**
  105836. * Is this sound currently paused.
  105837. */
  105838. isPaused: boolean;
  105839. /**
  105840. * Does this sound enables spatial sound.
  105841. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105842. */
  105843. spatialSound: boolean;
  105844. /**
  105845. * Define the reference distance the sound should be heard perfectly.
  105846. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105847. */
  105848. refDistance: number;
  105849. /**
  105850. * Define the roll off factor of spatial sounds.
  105851. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105852. */
  105853. rolloffFactor: number;
  105854. /**
  105855. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  105856. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105857. */
  105858. maxDistance: number;
  105859. /**
  105860. * Define the distance attenuation model the sound will follow.
  105861. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105862. */
  105863. distanceModel: string;
  105864. /**
  105865. * @hidden
  105866. * Back Compat
  105867. **/
  105868. onended: () => any;
  105869. /**
  105870. * Observable event when the current playing sound finishes.
  105871. */
  105872. onEndedObservable: Observable<Sound>;
  105873. private _panningModel;
  105874. private _playbackRate;
  105875. private _streaming;
  105876. private _startTime;
  105877. private _startOffset;
  105878. private _position;
  105879. /** @hidden */
  105880. _positionInEmitterSpace: boolean;
  105881. private _localDirection;
  105882. private _volume;
  105883. private _isReadyToPlay;
  105884. private _isDirectional;
  105885. private _readyToPlayCallback;
  105886. private _audioBuffer;
  105887. private _soundSource;
  105888. private _streamingSource;
  105889. private _soundPanner;
  105890. private _soundGain;
  105891. private _inputAudioNode;
  105892. private _outputAudioNode;
  105893. private _coneInnerAngle;
  105894. private _coneOuterAngle;
  105895. private _coneOuterGain;
  105896. private _scene;
  105897. private _connectedTransformNode;
  105898. private _customAttenuationFunction;
  105899. private _registerFunc;
  105900. private _isOutputConnected;
  105901. private _htmlAudioElement;
  105902. private _urlType;
  105903. private _length?;
  105904. private _offset?;
  105905. /** @hidden */
  105906. static _SceneComponentInitialization: (scene: Scene) => void;
  105907. /**
  105908. * Create a sound and attach it to a scene
  105909. * @param name Name of your sound
  105910. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  105911. * @param scene defines the scene the sound belongs to
  105912. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  105913. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  105914. */
  105915. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  105916. /**
  105917. * Release the sound and its associated resources
  105918. */
  105919. dispose(): void;
  105920. /**
  105921. * Gets if the sounds is ready to be played or not.
  105922. * @returns true if ready, otherwise false
  105923. */
  105924. isReady(): boolean;
  105925. private _soundLoaded;
  105926. /**
  105927. * Sets the data of the sound from an audiobuffer
  105928. * @param audioBuffer The audioBuffer containing the data
  105929. */
  105930. setAudioBuffer(audioBuffer: AudioBuffer): void;
  105931. /**
  105932. * Updates the current sounds options such as maxdistance, loop...
  105933. * @param options A JSON object containing values named as the object properties
  105934. */
  105935. updateOptions(options: ISoundOptions): void;
  105936. private _createSpatialParameters;
  105937. private _updateSpatialParameters;
  105938. /**
  105939. * Switch the panning model to HRTF:
  105940. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  105941. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105942. */
  105943. switchPanningModelToHRTF(): void;
  105944. /**
  105945. * Switch the panning model to Equal Power:
  105946. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  105947. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105948. */
  105949. switchPanningModelToEqualPower(): void;
  105950. private _switchPanningModel;
  105951. /**
  105952. * Connect this sound to a sound track audio node like gain...
  105953. * @param soundTrackAudioNode the sound track audio node to connect to
  105954. */
  105955. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  105956. /**
  105957. * Transform this sound into a directional source
  105958. * @param coneInnerAngle Size of the inner cone in degree
  105959. * @param coneOuterAngle Size of the outer cone in degree
  105960. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  105961. */
  105962. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  105963. /**
  105964. * Gets or sets the inner angle for the directional cone.
  105965. */
  105966. /**
  105967. * Gets or sets the inner angle for the directional cone.
  105968. */
  105969. directionalConeInnerAngle: number;
  105970. /**
  105971. * Gets or sets the outer angle for the directional cone.
  105972. */
  105973. /**
  105974. * Gets or sets the outer angle for the directional cone.
  105975. */
  105976. directionalConeOuterAngle: number;
  105977. /**
  105978. * Sets the position of the emitter if spatial sound is enabled
  105979. * @param newPosition Defines the new posisiton
  105980. */
  105981. setPosition(newPosition: Vector3): void;
  105982. /**
  105983. * Sets the local direction of the emitter if spatial sound is enabled
  105984. * @param newLocalDirection Defines the new local direction
  105985. */
  105986. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  105987. private _updateDirection;
  105988. /** @hidden */
  105989. updateDistanceFromListener(): void;
  105990. /**
  105991. * Sets a new custom attenuation function for the sound.
  105992. * @param callback Defines the function used for the attenuation
  105993. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  105994. */
  105995. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  105996. /**
  105997. * Play the sound
  105998. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  105999. * @param offset (optional) Start the sound at a specific time in seconds
  106000. * @param length (optional) Sound duration (in seconds)
  106001. */
  106002. play(time?: number, offset?: number, length?: number): void;
  106003. private _onended;
  106004. /**
  106005. * Stop the sound
  106006. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  106007. */
  106008. stop(time?: number): void;
  106009. /**
  106010. * Put the sound in pause
  106011. */
  106012. pause(): void;
  106013. /**
  106014. * Sets a dedicated volume for this sounds
  106015. * @param newVolume Define the new volume of the sound
  106016. * @param time Define time for gradual change to new volume
  106017. */
  106018. setVolume(newVolume: number, time?: number): void;
  106019. /**
  106020. * Set the sound play back rate
  106021. * @param newPlaybackRate Define the playback rate the sound should be played at
  106022. */
  106023. setPlaybackRate(newPlaybackRate: number): void;
  106024. /**
  106025. * Gets the volume of the sound.
  106026. * @returns the volume of the sound
  106027. */
  106028. getVolume(): number;
  106029. /**
  106030. * Attach the sound to a dedicated mesh
  106031. * @param transformNode The transform node to connect the sound with
  106032. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  106033. */
  106034. attachToMesh(transformNode: TransformNode): void;
  106035. /**
  106036. * Detach the sound from the previously attached mesh
  106037. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  106038. */
  106039. detachFromMesh(): void;
  106040. private _onRegisterAfterWorldMatrixUpdate;
  106041. /**
  106042. * Clone the current sound in the scene.
  106043. * @returns the new sound clone
  106044. */
  106045. clone(): Nullable<Sound>;
  106046. /**
  106047. * Gets the current underlying audio buffer containing the data
  106048. * @returns the audio buffer
  106049. */
  106050. getAudioBuffer(): Nullable<AudioBuffer>;
  106051. /**
  106052. * Serializes the Sound in a JSON representation
  106053. * @returns the JSON representation of the sound
  106054. */
  106055. serialize(): any;
  106056. /**
  106057. * Parse a JSON representation of a sound to innstantiate in a given scene
  106058. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  106059. * @param scene Define the scene the new parsed sound should be created in
  106060. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  106061. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  106062. * @returns the newly parsed sound
  106063. */
  106064. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  106065. }
  106066. }
  106067. declare module BABYLON {
  106068. /**
  106069. * This defines an action helpful to play a defined sound on a triggered action.
  106070. */
  106071. export class PlaySoundAction extends Action {
  106072. private _sound;
  106073. /**
  106074. * Instantiate the action
  106075. * @param triggerOptions defines the trigger options
  106076. * @param sound defines the sound to play
  106077. * @param condition defines the trigger related conditions
  106078. */
  106079. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  106080. /** @hidden */
  106081. _prepare(): void;
  106082. /**
  106083. * Execute the action and play the sound.
  106084. */
  106085. execute(): void;
  106086. /**
  106087. * Serializes the actions and its related information.
  106088. * @param parent defines the object to serialize in
  106089. * @returns the serialized object
  106090. */
  106091. serialize(parent: any): any;
  106092. }
  106093. /**
  106094. * This defines an action helpful to stop a defined sound on a triggered action.
  106095. */
  106096. export class StopSoundAction extends Action {
  106097. private _sound;
  106098. /**
  106099. * Instantiate the action
  106100. * @param triggerOptions defines the trigger options
  106101. * @param sound defines the sound to stop
  106102. * @param condition defines the trigger related conditions
  106103. */
  106104. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  106105. /** @hidden */
  106106. _prepare(): void;
  106107. /**
  106108. * Execute the action and stop the sound.
  106109. */
  106110. execute(): void;
  106111. /**
  106112. * Serializes the actions and its related information.
  106113. * @param parent defines the object to serialize in
  106114. * @returns the serialized object
  106115. */
  106116. serialize(parent: any): any;
  106117. }
  106118. }
  106119. declare module BABYLON {
  106120. /**
  106121. * This defines an action responsible to change the value of a property
  106122. * by interpolating between its current value and the newly set one once triggered.
  106123. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  106124. */
  106125. export class InterpolateValueAction extends Action {
  106126. /**
  106127. * Defines the path of the property where the value should be interpolated
  106128. */
  106129. propertyPath: string;
  106130. /**
  106131. * Defines the target value at the end of the interpolation.
  106132. */
  106133. value: any;
  106134. /**
  106135. * Defines the time it will take for the property to interpolate to the value.
  106136. */
  106137. duration: number;
  106138. /**
  106139. * Defines if the other scene animations should be stopped when the action has been triggered
  106140. */
  106141. stopOtherAnimations?: boolean;
  106142. /**
  106143. * Defines a callback raised once the interpolation animation has been done.
  106144. */
  106145. onInterpolationDone?: () => void;
  106146. /**
  106147. * Observable triggered once the interpolation animation has been done.
  106148. */
  106149. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  106150. private _target;
  106151. private _effectiveTarget;
  106152. private _property;
  106153. /**
  106154. * Instantiate the action
  106155. * @param triggerOptions defines the trigger options
  106156. * @param target defines the object containing the value to interpolate
  106157. * @param propertyPath defines the path to the property in the target object
  106158. * @param value defines the target value at the end of the interpolation
  106159. * @param duration deines the time it will take for the property to interpolate to the value.
  106160. * @param condition defines the trigger related conditions
  106161. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  106162. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  106163. */
  106164. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  106165. /** @hidden */
  106166. _prepare(): void;
  106167. /**
  106168. * Execute the action starts the value interpolation.
  106169. */
  106170. execute(): void;
  106171. /**
  106172. * Serializes the actions and its related information.
  106173. * @param parent defines the object to serialize in
  106174. * @returns the serialized object
  106175. */
  106176. serialize(parent: any): any;
  106177. }
  106178. }
  106179. declare module BABYLON {
  106180. /**
  106181. * Options allowed during the creation of a sound track.
  106182. */
  106183. export interface ISoundTrackOptions {
  106184. /**
  106185. * The volume the sound track should take during creation
  106186. */
  106187. volume?: number;
  106188. /**
  106189. * Define if the sound track is the main sound track of the scene
  106190. */
  106191. mainTrack?: boolean;
  106192. }
  106193. /**
  106194. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  106195. * It will be also used in a future release to apply effects on a specific track.
  106196. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  106197. */
  106198. export class SoundTrack {
  106199. /**
  106200. * The unique identifier of the sound track in the scene.
  106201. */
  106202. id: number;
  106203. /**
  106204. * The list of sounds included in the sound track.
  106205. */
  106206. soundCollection: Array<Sound>;
  106207. private _outputAudioNode;
  106208. private _scene;
  106209. private _connectedAnalyser;
  106210. private _options;
  106211. private _isInitialized;
  106212. /**
  106213. * Creates a new sound track.
  106214. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  106215. * @param scene Define the scene the sound track belongs to
  106216. * @param options
  106217. */
  106218. constructor(scene: Scene, options?: ISoundTrackOptions);
  106219. private _initializeSoundTrackAudioGraph;
  106220. /**
  106221. * Release the sound track and its associated resources
  106222. */
  106223. dispose(): void;
  106224. /**
  106225. * Adds a sound to this sound track
  106226. * @param sound define the cound to add
  106227. * @ignoreNaming
  106228. */
  106229. AddSound(sound: Sound): void;
  106230. /**
  106231. * Removes a sound to this sound track
  106232. * @param sound define the cound to remove
  106233. * @ignoreNaming
  106234. */
  106235. RemoveSound(sound: Sound): void;
  106236. /**
  106237. * Set a global volume for the full sound track.
  106238. * @param newVolume Define the new volume of the sound track
  106239. */
  106240. setVolume(newVolume: number): void;
  106241. /**
  106242. * Switch the panning model to HRTF:
  106243. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  106244. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  106245. */
  106246. switchPanningModelToHRTF(): void;
  106247. /**
  106248. * Switch the panning model to Equal Power:
  106249. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  106250. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  106251. */
  106252. switchPanningModelToEqualPower(): void;
  106253. /**
  106254. * Connect the sound track to an audio analyser allowing some amazing
  106255. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  106256. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  106257. * @param analyser The analyser to connect to the engine
  106258. */
  106259. connectToAnalyser(analyser: Analyser): void;
  106260. }
  106261. }
  106262. declare module BABYLON {
  106263. interface AbstractScene {
  106264. /**
  106265. * The list of sounds used in the scene.
  106266. */
  106267. sounds: Nullable<Array<Sound>>;
  106268. }
  106269. interface Scene {
  106270. /**
  106271. * @hidden
  106272. * Backing field
  106273. */
  106274. _mainSoundTrack: SoundTrack;
  106275. /**
  106276. * The main sound track played by the scene.
  106277. * It cotains your primary collection of sounds.
  106278. */
  106279. mainSoundTrack: SoundTrack;
  106280. /**
  106281. * The list of sound tracks added to the scene
  106282. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  106283. */
  106284. soundTracks: Nullable<Array<SoundTrack>>;
  106285. /**
  106286. * Gets a sound using a given name
  106287. * @param name defines the name to search for
  106288. * @return the found sound or null if not found at all.
  106289. */
  106290. getSoundByName(name: string): Nullable<Sound>;
  106291. /**
  106292. * Gets or sets if audio support is enabled
  106293. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  106294. */
  106295. audioEnabled: boolean;
  106296. /**
  106297. * Gets or sets if audio will be output to headphones
  106298. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  106299. */
  106300. headphone: boolean;
  106301. /**
  106302. * Gets or sets custom audio listener position provider
  106303. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  106304. */
  106305. audioListenerPositionProvider: Nullable<() => Vector3>;
  106306. /**
  106307. * Gets or sets a refresh rate when using 3D audio positioning
  106308. */
  106309. audioPositioningRefreshRate: number;
  106310. }
  106311. /**
  106312. * Defines the sound scene component responsible to manage any sounds
  106313. * in a given scene.
  106314. */
  106315. export class AudioSceneComponent implements ISceneSerializableComponent {
  106316. /**
  106317. * The component name helpfull to identify the component in the list of scene components.
  106318. */
  106319. readonly name: string;
  106320. /**
  106321. * The scene the component belongs to.
  106322. */
  106323. scene: Scene;
  106324. private _audioEnabled;
  106325. /**
  106326. * Gets whether audio is enabled or not.
  106327. * Please use related enable/disable method to switch state.
  106328. */
  106329. readonly audioEnabled: boolean;
  106330. private _headphone;
  106331. /**
  106332. * Gets whether audio is outputing to headphone or not.
  106333. * Please use the according Switch methods to change output.
  106334. */
  106335. readonly headphone: boolean;
  106336. /**
  106337. * Gets or sets a refresh rate when using 3D audio positioning
  106338. */
  106339. audioPositioningRefreshRate: number;
  106340. private _audioListenerPositionProvider;
  106341. /**
  106342. * Gets the current audio listener position provider
  106343. */
  106344. /**
  106345. * Sets a custom listener position for all sounds in the scene
  106346. * By default, this is the position of the first active camera
  106347. */
  106348. audioListenerPositionProvider: Nullable<() => Vector3>;
  106349. /**
  106350. * Creates a new instance of the component for the given scene
  106351. * @param scene Defines the scene to register the component in
  106352. */
  106353. constructor(scene: Scene);
  106354. /**
  106355. * Registers the component in a given scene
  106356. */
  106357. register(): void;
  106358. /**
  106359. * Rebuilds the elements related to this component in case of
  106360. * context lost for instance.
  106361. */
  106362. rebuild(): void;
  106363. /**
  106364. * Serializes the component data to the specified json object
  106365. * @param serializationObject The object to serialize to
  106366. */
  106367. serialize(serializationObject: any): void;
  106368. /**
  106369. * Adds all the elements from the container to the scene
  106370. * @param container the container holding the elements
  106371. */
  106372. addFromContainer(container: AbstractScene): void;
  106373. /**
  106374. * Removes all the elements in the container from the scene
  106375. * @param container contains the elements to remove
  106376. * @param dispose if the removed element should be disposed (default: false)
  106377. */
  106378. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  106379. /**
  106380. * Disposes the component and the associated ressources.
  106381. */
  106382. dispose(): void;
  106383. /**
  106384. * Disables audio in the associated scene.
  106385. */
  106386. disableAudio(): void;
  106387. /**
  106388. * Enables audio in the associated scene.
  106389. */
  106390. enableAudio(): void;
  106391. /**
  106392. * Switch audio to headphone output.
  106393. */
  106394. switchAudioModeForHeadphones(): void;
  106395. /**
  106396. * Switch audio to normal speakers.
  106397. */
  106398. switchAudioModeForNormalSpeakers(): void;
  106399. private _cachedCameraDirection;
  106400. private _cachedCameraPosition;
  106401. private _lastCheck;
  106402. private _afterRender;
  106403. }
  106404. }
  106405. declare module BABYLON {
  106406. /**
  106407. * Wraps one or more Sound objects and selects one with random weight for playback.
  106408. */
  106409. export class WeightedSound {
  106410. /** When true a Sound will be selected and played when the current playing Sound completes. */
  106411. loop: boolean;
  106412. private _coneInnerAngle;
  106413. private _coneOuterAngle;
  106414. private _volume;
  106415. /** A Sound is currently playing. */
  106416. isPlaying: boolean;
  106417. /** A Sound is currently paused. */
  106418. isPaused: boolean;
  106419. private _sounds;
  106420. private _weights;
  106421. private _currentIndex?;
  106422. /**
  106423. * Creates a new WeightedSound from the list of sounds given.
  106424. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  106425. * @param sounds Array of Sounds that will be selected from.
  106426. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  106427. */
  106428. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  106429. /**
  106430. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  106431. */
  106432. /**
  106433. * The size of cone in degress for a directional sound in which there will be no attenuation.
  106434. */
  106435. directionalConeInnerAngle: number;
  106436. /**
  106437. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  106438. * Listener angles between innerAngle and outerAngle will falloff linearly.
  106439. */
  106440. /**
  106441. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  106442. * Listener angles between innerAngle and outerAngle will falloff linearly.
  106443. */
  106444. directionalConeOuterAngle: number;
  106445. /**
  106446. * Playback volume.
  106447. */
  106448. /**
  106449. * Playback volume.
  106450. */
  106451. volume: number;
  106452. private _onended;
  106453. /**
  106454. * Suspend playback
  106455. */
  106456. pause(): void;
  106457. /**
  106458. * Stop playback
  106459. */
  106460. stop(): void;
  106461. /**
  106462. * Start playback.
  106463. * @param startOffset Position the clip head at a specific time in seconds.
  106464. */
  106465. play(startOffset?: number): void;
  106466. }
  106467. }
  106468. declare module BABYLON {
  106469. /**
  106470. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  106471. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  106472. */
  106473. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  106474. /**
  106475. * Gets the name of the behavior.
  106476. */
  106477. readonly name: string;
  106478. /**
  106479. * The easing function used by animations
  106480. */
  106481. static EasingFunction: BackEase;
  106482. /**
  106483. * The easing mode used by animations
  106484. */
  106485. static EasingMode: number;
  106486. /**
  106487. * The duration of the animation, in milliseconds
  106488. */
  106489. transitionDuration: number;
  106490. /**
  106491. * Length of the distance animated by the transition when lower radius is reached
  106492. */
  106493. lowerRadiusTransitionRange: number;
  106494. /**
  106495. * Length of the distance animated by the transition when upper radius is reached
  106496. */
  106497. upperRadiusTransitionRange: number;
  106498. private _autoTransitionRange;
  106499. /**
  106500. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  106501. */
  106502. /**
  106503. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  106504. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  106505. */
  106506. autoTransitionRange: boolean;
  106507. private _attachedCamera;
  106508. private _onAfterCheckInputsObserver;
  106509. private _onMeshTargetChangedObserver;
  106510. /**
  106511. * Initializes the behavior.
  106512. */
  106513. init(): void;
  106514. /**
  106515. * Attaches the behavior to its arc rotate camera.
  106516. * @param camera Defines the camera to attach the behavior to
  106517. */
  106518. attach(camera: ArcRotateCamera): void;
  106519. /**
  106520. * Detaches the behavior from its current arc rotate camera.
  106521. */
  106522. detach(): void;
  106523. private _radiusIsAnimating;
  106524. private _radiusBounceTransition;
  106525. private _animatables;
  106526. private _cachedWheelPrecision;
  106527. /**
  106528. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  106529. * @param radiusLimit The limit to check against.
  106530. * @return Bool to indicate if at limit.
  106531. */
  106532. private _isRadiusAtLimit;
  106533. /**
  106534. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  106535. * @param radiusDelta The delta by which to animate to. Can be negative.
  106536. */
  106537. private _applyBoundRadiusAnimation;
  106538. /**
  106539. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  106540. */
  106541. protected _clearAnimationLocks(): void;
  106542. /**
  106543. * Stops and removes all animations that have been applied to the camera
  106544. */
  106545. stopAllAnimations(): void;
  106546. }
  106547. }
  106548. declare module BABYLON {
  106549. /**
  106550. * 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.
  106551. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  106552. */
  106553. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  106554. /**
  106555. * Gets the name of the behavior.
  106556. */
  106557. readonly name: string;
  106558. private _mode;
  106559. private _radiusScale;
  106560. private _positionScale;
  106561. private _defaultElevation;
  106562. private _elevationReturnTime;
  106563. private _elevationReturnWaitTime;
  106564. private _zoomStopsAnimation;
  106565. private _framingTime;
  106566. /**
  106567. * The easing function used by animations
  106568. */
  106569. static EasingFunction: ExponentialEase;
  106570. /**
  106571. * The easing mode used by animations
  106572. */
  106573. static EasingMode: number;
  106574. /**
  106575. * Sets the current mode used by the behavior
  106576. */
  106577. /**
  106578. * Gets current mode used by the behavior.
  106579. */
  106580. mode: number;
  106581. /**
  106582. * Sets the scale applied to the radius (1 by default)
  106583. */
  106584. /**
  106585. * Gets the scale applied to the radius
  106586. */
  106587. radiusScale: number;
  106588. /**
  106589. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  106590. */
  106591. /**
  106592. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  106593. */
  106594. positionScale: number;
  106595. /**
  106596. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  106597. * behaviour is triggered, in radians.
  106598. */
  106599. /**
  106600. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  106601. * behaviour is triggered, in radians.
  106602. */
  106603. defaultElevation: number;
  106604. /**
  106605. * Sets the time (in milliseconds) taken to return to the default beta position.
  106606. * Negative value indicates camera should not return to default.
  106607. */
  106608. /**
  106609. * Gets the time (in milliseconds) taken to return to the default beta position.
  106610. * Negative value indicates camera should not return to default.
  106611. */
  106612. elevationReturnTime: number;
  106613. /**
  106614. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  106615. */
  106616. /**
  106617. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  106618. */
  106619. elevationReturnWaitTime: number;
  106620. /**
  106621. * Sets the flag that indicates if user zooming should stop animation.
  106622. */
  106623. /**
  106624. * Gets the flag that indicates if user zooming should stop animation.
  106625. */
  106626. zoomStopsAnimation: boolean;
  106627. /**
  106628. * Sets the transition time when framing the mesh, in milliseconds
  106629. */
  106630. /**
  106631. * Gets the transition time when framing the mesh, in milliseconds
  106632. */
  106633. framingTime: number;
  106634. /**
  106635. * Define if the behavior should automatically change the configured
  106636. * camera limits and sensibilities.
  106637. */
  106638. autoCorrectCameraLimitsAndSensibility: boolean;
  106639. private _onPrePointerObservableObserver;
  106640. private _onAfterCheckInputsObserver;
  106641. private _onMeshTargetChangedObserver;
  106642. private _attachedCamera;
  106643. private _isPointerDown;
  106644. private _lastInteractionTime;
  106645. /**
  106646. * Initializes the behavior.
  106647. */
  106648. init(): void;
  106649. /**
  106650. * Attaches the behavior to its arc rotate camera.
  106651. * @param camera Defines the camera to attach the behavior to
  106652. */
  106653. attach(camera: ArcRotateCamera): void;
  106654. /**
  106655. * Detaches the behavior from its current arc rotate camera.
  106656. */
  106657. detach(): void;
  106658. private _animatables;
  106659. private _betaIsAnimating;
  106660. private _betaTransition;
  106661. private _radiusTransition;
  106662. private _vectorTransition;
  106663. /**
  106664. * Targets the given mesh and updates zoom level accordingly.
  106665. * @param mesh The mesh to target.
  106666. * @param radius Optional. If a cached radius position already exists, overrides default.
  106667. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  106668. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  106669. * @param onAnimationEnd Callback triggered at the end of the framing animation
  106670. */
  106671. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  106672. /**
  106673. * Targets the given mesh with its children and updates zoom level accordingly.
  106674. * @param mesh The mesh to target.
  106675. * @param radius Optional. If a cached radius position already exists, overrides default.
  106676. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  106677. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  106678. * @param onAnimationEnd Callback triggered at the end of the framing animation
  106679. */
  106680. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  106681. /**
  106682. * Targets the given meshes with their children and updates zoom level accordingly.
  106683. * @param meshes The mesh to target.
  106684. * @param radius Optional. If a cached radius position already exists, overrides default.
  106685. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  106686. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  106687. * @param onAnimationEnd Callback triggered at the end of the framing animation
  106688. */
  106689. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  106690. /**
  106691. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  106692. * @param minimumWorld Determines the smaller position of the bounding box extend
  106693. * @param maximumWorld Determines the bigger position of the bounding box extend
  106694. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  106695. * @param onAnimationEnd Callback triggered at the end of the framing animation
  106696. */
  106697. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  106698. /**
  106699. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  106700. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  106701. * frustum width.
  106702. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  106703. * to fully enclose the mesh in the viewing frustum.
  106704. */
  106705. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  106706. /**
  106707. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  106708. * is automatically returned to its default position (expected to be above ground plane).
  106709. */
  106710. private _maintainCameraAboveGround;
  106711. /**
  106712. * Returns the frustum slope based on the canvas ratio and camera FOV
  106713. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  106714. */
  106715. private _getFrustumSlope;
  106716. /**
  106717. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  106718. */
  106719. private _clearAnimationLocks;
  106720. /**
  106721. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  106722. */
  106723. private _applyUserInteraction;
  106724. /**
  106725. * Stops and removes all animations that have been applied to the camera
  106726. */
  106727. stopAllAnimations(): void;
  106728. /**
  106729. * Gets a value indicating if the user is moving the camera
  106730. */
  106731. readonly isUserIsMoving: boolean;
  106732. /**
  106733. * The camera can move all the way towards the mesh.
  106734. */
  106735. static IgnoreBoundsSizeMode: number;
  106736. /**
  106737. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  106738. */
  106739. static FitFrustumSidesMode: number;
  106740. }
  106741. }
  106742. declare module BABYLON {
  106743. /**
  106744. * Base class for Camera Pointer Inputs.
  106745. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  106746. * for example usage.
  106747. */
  106748. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  106749. /**
  106750. * Defines the camera the input is attached to.
  106751. */
  106752. abstract camera: Camera;
  106753. /**
  106754. * Whether keyboard modifier keys are pressed at time of last mouse event.
  106755. */
  106756. protected _altKey: boolean;
  106757. protected _ctrlKey: boolean;
  106758. protected _metaKey: boolean;
  106759. protected _shiftKey: boolean;
  106760. /**
  106761. * Which mouse buttons were pressed at time of last mouse event.
  106762. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  106763. */
  106764. protected _buttonsPressed: number;
  106765. /**
  106766. * Defines the buttons associated with the input to handle camera move.
  106767. */
  106768. buttons: number[];
  106769. /**
  106770. * Attach the input controls to a specific dom element to get the input from.
  106771. * @param element Defines the element the controls should be listened from
  106772. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106773. */
  106774. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106775. /**
  106776. * Detach the current controls from the specified dom element.
  106777. * @param element Defines the element to stop listening the inputs from
  106778. */
  106779. detachControl(element: Nullable<HTMLElement>): void;
  106780. /**
  106781. * Gets the class name of the current input.
  106782. * @returns the class name
  106783. */
  106784. getClassName(): string;
  106785. /**
  106786. * Get the friendly name associated with the input class.
  106787. * @returns the input friendly name
  106788. */
  106789. getSimpleName(): string;
  106790. /**
  106791. * Called on pointer POINTERDOUBLETAP event.
  106792. * Override this method to provide functionality on POINTERDOUBLETAP event.
  106793. */
  106794. protected onDoubleTap(type: string): void;
  106795. /**
  106796. * Called on pointer POINTERMOVE event if only a single touch is active.
  106797. * Override this method to provide functionality.
  106798. */
  106799. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  106800. /**
  106801. * Called on pointer POINTERMOVE event if multiple touches are active.
  106802. * Override this method to provide functionality.
  106803. */
  106804. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  106805. /**
  106806. * Called on JS contextmenu event.
  106807. * Override this method to provide functionality.
  106808. */
  106809. protected onContextMenu(evt: PointerEvent): void;
  106810. /**
  106811. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  106812. * press.
  106813. * Override this method to provide functionality.
  106814. */
  106815. protected onButtonDown(evt: PointerEvent): void;
  106816. /**
  106817. * Called each time a new POINTERUP event occurs. Ie, for each button
  106818. * release.
  106819. * Override this method to provide functionality.
  106820. */
  106821. protected onButtonUp(evt: PointerEvent): void;
  106822. /**
  106823. * Called when window becomes inactive.
  106824. * Override this method to provide functionality.
  106825. */
  106826. protected onLostFocus(): void;
  106827. private _pointerInput;
  106828. private _observer;
  106829. private _onLostFocus;
  106830. private pointA;
  106831. private pointB;
  106832. }
  106833. }
  106834. declare module BABYLON {
  106835. /**
  106836. * Manage the pointers inputs to control an arc rotate camera.
  106837. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106838. */
  106839. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  106840. /**
  106841. * Defines the camera the input is attached to.
  106842. */
  106843. camera: ArcRotateCamera;
  106844. /**
  106845. * Gets the class name of the current input.
  106846. * @returns the class name
  106847. */
  106848. getClassName(): string;
  106849. /**
  106850. * Defines the buttons associated with the input to handle camera move.
  106851. */
  106852. buttons: number[];
  106853. /**
  106854. * Defines the pointer angular sensibility along the X axis or how fast is
  106855. * the camera rotating.
  106856. */
  106857. angularSensibilityX: number;
  106858. /**
  106859. * Defines the pointer angular sensibility along the Y axis or how fast is
  106860. * the camera rotating.
  106861. */
  106862. angularSensibilityY: number;
  106863. /**
  106864. * Defines the pointer pinch precision or how fast is the camera zooming.
  106865. */
  106866. pinchPrecision: number;
  106867. /**
  106868. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  106869. * from 0.
  106870. * It defines the percentage of current camera.radius to use as delta when
  106871. * pinch zoom is used.
  106872. */
  106873. pinchDeltaPercentage: number;
  106874. /**
  106875. * Defines the pointer panning sensibility or how fast is the camera moving.
  106876. */
  106877. panningSensibility: number;
  106878. /**
  106879. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  106880. */
  106881. multiTouchPanning: boolean;
  106882. /**
  106883. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  106884. * zoom (pinch) through multitouch.
  106885. */
  106886. multiTouchPanAndZoom: boolean;
  106887. /**
  106888. * Revers pinch action direction.
  106889. */
  106890. pinchInwards: boolean;
  106891. private _isPanClick;
  106892. private _twoFingerActivityCount;
  106893. private _isPinching;
  106894. /**
  106895. * Called on pointer POINTERMOVE event if only a single touch is active.
  106896. */
  106897. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  106898. /**
  106899. * Called on pointer POINTERDOUBLETAP event.
  106900. */
  106901. protected onDoubleTap(type: string): void;
  106902. /**
  106903. * Called on pointer POINTERMOVE event if multiple touches are active.
  106904. */
  106905. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  106906. /**
  106907. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  106908. * press.
  106909. */
  106910. protected onButtonDown(evt: PointerEvent): void;
  106911. /**
  106912. * Called each time a new POINTERUP event occurs. Ie, for each button
  106913. * release.
  106914. */
  106915. protected onButtonUp(evt: PointerEvent): void;
  106916. /**
  106917. * Called when window becomes inactive.
  106918. */
  106919. protected onLostFocus(): void;
  106920. }
  106921. }
  106922. declare module BABYLON {
  106923. /**
  106924. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  106925. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106926. */
  106927. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  106928. /**
  106929. * Defines the camera the input is attached to.
  106930. */
  106931. camera: ArcRotateCamera;
  106932. /**
  106933. * Defines the list of key codes associated with the up action (increase alpha)
  106934. */
  106935. keysUp: number[];
  106936. /**
  106937. * Defines the list of key codes associated with the down action (decrease alpha)
  106938. */
  106939. keysDown: number[];
  106940. /**
  106941. * Defines the list of key codes associated with the left action (increase beta)
  106942. */
  106943. keysLeft: number[];
  106944. /**
  106945. * Defines the list of key codes associated with the right action (decrease beta)
  106946. */
  106947. keysRight: number[];
  106948. /**
  106949. * Defines the list of key codes associated with the reset action.
  106950. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  106951. */
  106952. keysReset: number[];
  106953. /**
  106954. * Defines the panning sensibility of the inputs.
  106955. * (How fast is the camera paning)
  106956. */
  106957. panningSensibility: number;
  106958. /**
  106959. * Defines the zooming sensibility of the inputs.
  106960. * (How fast is the camera zooming)
  106961. */
  106962. zoomingSensibility: number;
  106963. /**
  106964. * Defines wether maintaining the alt key down switch the movement mode from
  106965. * orientation to zoom.
  106966. */
  106967. useAltToZoom: boolean;
  106968. /**
  106969. * Rotation speed of the camera
  106970. */
  106971. angularSpeed: number;
  106972. private _keys;
  106973. private _ctrlPressed;
  106974. private _altPressed;
  106975. private _onCanvasBlurObserver;
  106976. private _onKeyboardObserver;
  106977. private _engine;
  106978. private _scene;
  106979. /**
  106980. * Attach the input controls to a specific dom element to get the input from.
  106981. * @param element Defines the element the controls should be listened from
  106982. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106983. */
  106984. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106985. /**
  106986. * Detach the current controls from the specified dom element.
  106987. * @param element Defines the element to stop listening the inputs from
  106988. */
  106989. detachControl(element: Nullable<HTMLElement>): void;
  106990. /**
  106991. * Update the current camera state depending on the inputs that have been used this frame.
  106992. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  106993. */
  106994. checkInputs(): void;
  106995. /**
  106996. * Gets the class name of the current intput.
  106997. * @returns the class name
  106998. */
  106999. getClassName(): string;
  107000. /**
  107001. * Get the friendly name associated with the input class.
  107002. * @returns the input friendly name
  107003. */
  107004. getSimpleName(): string;
  107005. }
  107006. }
  107007. declare module BABYLON {
  107008. /**
  107009. * Manage the mouse wheel inputs to control an arc rotate camera.
  107010. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  107011. */
  107012. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  107013. /**
  107014. * Defines the camera the input is attached to.
  107015. */
  107016. camera: ArcRotateCamera;
  107017. /**
  107018. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  107019. */
  107020. wheelPrecision: number;
  107021. /**
  107022. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  107023. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  107024. */
  107025. wheelDeltaPercentage: number;
  107026. private _wheel;
  107027. private _observer;
  107028. private computeDeltaFromMouseWheelLegacyEvent;
  107029. /**
  107030. * Attach the input controls to a specific dom element to get the input from.
  107031. * @param element Defines the element the controls should be listened from
  107032. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  107033. */
  107034. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  107035. /**
  107036. * Detach the current controls from the specified dom element.
  107037. * @param element Defines the element to stop listening the inputs from
  107038. */
  107039. detachControl(element: Nullable<HTMLElement>): void;
  107040. /**
  107041. * Gets the class name of the current intput.
  107042. * @returns the class name
  107043. */
  107044. getClassName(): string;
  107045. /**
  107046. * Get the friendly name associated with the input class.
  107047. * @returns the input friendly name
  107048. */
  107049. getSimpleName(): string;
  107050. }
  107051. }
  107052. declare module BABYLON {
  107053. /**
  107054. * Default Inputs manager for the ArcRotateCamera.
  107055. * It groups all the default supported inputs for ease of use.
  107056. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  107057. */
  107058. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  107059. /**
  107060. * Instantiates a new ArcRotateCameraInputsManager.
  107061. * @param camera Defines the camera the inputs belong to
  107062. */
  107063. constructor(camera: ArcRotateCamera);
  107064. /**
  107065. * Add mouse wheel input support to the input manager.
  107066. * @returns the current input manager
  107067. */
  107068. addMouseWheel(): ArcRotateCameraInputsManager;
  107069. /**
  107070. * Add pointers input support to the input manager.
  107071. * @returns the current input manager
  107072. */
  107073. addPointers(): ArcRotateCameraInputsManager;
  107074. /**
  107075. * Add keyboard input support to the input manager.
  107076. * @returns the current input manager
  107077. */
  107078. addKeyboard(): ArcRotateCameraInputsManager;
  107079. }
  107080. }
  107081. declare module BABYLON {
  107082. /**
  107083. * This represents an orbital type of camera.
  107084. *
  107085. * 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.
  107086. * 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.
  107087. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  107088. */
  107089. export class ArcRotateCamera extends TargetCamera {
  107090. /**
  107091. * Defines the rotation angle of the camera along the longitudinal axis.
  107092. */
  107093. alpha: number;
  107094. /**
  107095. * Defines the rotation angle of the camera along the latitudinal axis.
  107096. */
  107097. beta: number;
  107098. /**
  107099. * Defines the radius of the camera from it s target point.
  107100. */
  107101. radius: number;
  107102. protected _target: Vector3;
  107103. protected _targetHost: Nullable<AbstractMesh>;
  107104. /**
  107105. * Defines the target point of the camera.
  107106. * The camera looks towards it form the radius distance.
  107107. */
  107108. target: Vector3;
  107109. /**
  107110. * Define the current local position of the camera in the scene
  107111. */
  107112. position: Vector3;
  107113. protected _upVector: Vector3;
  107114. protected _upToYMatrix: Matrix;
  107115. protected _YToUpMatrix: Matrix;
  107116. /**
  107117. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  107118. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  107119. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  107120. */
  107121. upVector: Vector3;
  107122. /**
  107123. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  107124. */
  107125. setMatUp(): void;
  107126. /**
  107127. * Current inertia value on the longitudinal axis.
  107128. * The bigger this number the longer it will take for the camera to stop.
  107129. */
  107130. inertialAlphaOffset: number;
  107131. /**
  107132. * Current inertia value on the latitudinal axis.
  107133. * The bigger this number the longer it will take for the camera to stop.
  107134. */
  107135. inertialBetaOffset: number;
  107136. /**
  107137. * Current inertia value on the radius axis.
  107138. * The bigger this number the longer it will take for the camera to stop.
  107139. */
  107140. inertialRadiusOffset: number;
  107141. /**
  107142. * Minimum allowed angle on the longitudinal axis.
  107143. * This can help limiting how the Camera is able to move in the scene.
  107144. */
  107145. lowerAlphaLimit: Nullable<number>;
  107146. /**
  107147. * Maximum allowed angle on the longitudinal axis.
  107148. * This can help limiting how the Camera is able to move in the scene.
  107149. */
  107150. upperAlphaLimit: Nullable<number>;
  107151. /**
  107152. * Minimum allowed angle on the latitudinal axis.
  107153. * This can help limiting how the Camera is able to move in the scene.
  107154. */
  107155. lowerBetaLimit: number;
  107156. /**
  107157. * Maximum allowed angle on the latitudinal axis.
  107158. * This can help limiting how the Camera is able to move in the scene.
  107159. */
  107160. upperBetaLimit: number;
  107161. /**
  107162. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  107163. * This can help limiting how the Camera is able to move in the scene.
  107164. */
  107165. lowerRadiusLimit: Nullable<number>;
  107166. /**
  107167. * Maximum allowed distance of the camera to the target (The camera can not get further).
  107168. * This can help limiting how the Camera is able to move in the scene.
  107169. */
  107170. upperRadiusLimit: Nullable<number>;
  107171. /**
  107172. * Defines the current inertia value used during panning of the camera along the X axis.
  107173. */
  107174. inertialPanningX: number;
  107175. /**
  107176. * Defines the current inertia value used during panning of the camera along the Y axis.
  107177. */
  107178. inertialPanningY: number;
  107179. /**
  107180. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  107181. * Basically if your fingers moves away from more than this distance you will be considered
  107182. * in pinch mode.
  107183. */
  107184. pinchToPanMaxDistance: number;
  107185. /**
  107186. * Defines the maximum distance the camera can pan.
  107187. * This could help keeping the cammera always in your scene.
  107188. */
  107189. panningDistanceLimit: Nullable<number>;
  107190. /**
  107191. * Defines the target of the camera before paning.
  107192. */
  107193. panningOriginTarget: Vector3;
  107194. /**
  107195. * Defines the value of the inertia used during panning.
  107196. * 0 would mean stop inertia and one would mean no decelleration at all.
  107197. */
  107198. panningInertia: number;
  107199. /**
  107200. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  107201. */
  107202. angularSensibilityX: number;
  107203. /**
  107204. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  107205. */
  107206. angularSensibilityY: number;
  107207. /**
  107208. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  107209. */
  107210. pinchPrecision: number;
  107211. /**
  107212. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  107213. * It will be used instead of pinchDeltaPrecision if different from 0.
  107214. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  107215. */
  107216. pinchDeltaPercentage: number;
  107217. /**
  107218. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  107219. */
  107220. panningSensibility: number;
  107221. /**
  107222. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  107223. */
  107224. keysUp: number[];
  107225. /**
  107226. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  107227. */
  107228. keysDown: number[];
  107229. /**
  107230. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  107231. */
  107232. keysLeft: number[];
  107233. /**
  107234. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  107235. */
  107236. keysRight: number[];
  107237. /**
  107238. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  107239. */
  107240. wheelPrecision: number;
  107241. /**
  107242. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  107243. * It will be used instead of pinchDeltaPrecision if different from 0.
  107244. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  107245. */
  107246. wheelDeltaPercentage: number;
  107247. /**
  107248. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  107249. */
  107250. zoomOnFactor: number;
  107251. /**
  107252. * Defines a screen offset for the camera position.
  107253. */
  107254. targetScreenOffset: Vector2;
  107255. /**
  107256. * Allows the camera to be completely reversed.
  107257. * If false the camera can not arrive upside down.
  107258. */
  107259. allowUpsideDown: boolean;
  107260. /**
  107261. * Define if double tap/click is used to restore the previously saved state of the camera.
  107262. */
  107263. useInputToRestoreState: boolean;
  107264. /** @hidden */
  107265. _viewMatrix: Matrix;
  107266. /** @hidden */
  107267. _useCtrlForPanning: boolean;
  107268. /** @hidden */
  107269. _panningMouseButton: number;
  107270. /**
  107271. * Defines the input associated to the camera.
  107272. */
  107273. inputs: ArcRotateCameraInputsManager;
  107274. /** @hidden */
  107275. _reset: () => void;
  107276. /**
  107277. * Defines the allowed panning axis.
  107278. */
  107279. panningAxis: Vector3;
  107280. protected _localDirection: Vector3;
  107281. protected _transformedDirection: Vector3;
  107282. private _bouncingBehavior;
  107283. /**
  107284. * Gets the bouncing behavior of the camera if it has been enabled.
  107285. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  107286. */
  107287. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  107288. /**
  107289. * Defines if the bouncing behavior of the camera is enabled on the camera.
  107290. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  107291. */
  107292. useBouncingBehavior: boolean;
  107293. private _framingBehavior;
  107294. /**
  107295. * Gets the framing behavior of the camera if it has been enabled.
  107296. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  107297. */
  107298. readonly framingBehavior: Nullable<FramingBehavior>;
  107299. /**
  107300. * Defines if the framing behavior of the camera is enabled on the camera.
  107301. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  107302. */
  107303. useFramingBehavior: boolean;
  107304. private _autoRotationBehavior;
  107305. /**
  107306. * Gets the auto rotation behavior of the camera if it has been enabled.
  107307. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  107308. */
  107309. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  107310. /**
  107311. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  107312. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  107313. */
  107314. useAutoRotationBehavior: boolean;
  107315. /**
  107316. * Observable triggered when the mesh target has been changed on the camera.
  107317. */
  107318. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  107319. /**
  107320. * Event raised when the camera is colliding with a mesh.
  107321. */
  107322. onCollide: (collidedMesh: AbstractMesh) => void;
  107323. /**
  107324. * Defines whether the camera should check collision with the objects oh the scene.
  107325. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  107326. */
  107327. checkCollisions: boolean;
  107328. /**
  107329. * Defines the collision radius of the camera.
  107330. * This simulates a sphere around the camera.
  107331. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  107332. */
  107333. collisionRadius: Vector3;
  107334. protected _collider: Collider;
  107335. protected _previousPosition: Vector3;
  107336. protected _collisionVelocity: Vector3;
  107337. protected _newPosition: Vector3;
  107338. protected _previousAlpha: number;
  107339. protected _previousBeta: number;
  107340. protected _previousRadius: number;
  107341. protected _collisionTriggered: boolean;
  107342. protected _targetBoundingCenter: Nullable<Vector3>;
  107343. private _computationVector;
  107344. /**
  107345. * Instantiates a new ArcRotateCamera in a given scene
  107346. * @param name Defines the name of the camera
  107347. * @param alpha Defines the camera rotation along the logitudinal axis
  107348. * @param beta Defines the camera rotation along the latitudinal axis
  107349. * @param radius Defines the camera distance from its target
  107350. * @param target Defines the camera target
  107351. * @param scene Defines the scene the camera belongs to
  107352. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  107353. */
  107354. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  107355. /** @hidden */
  107356. _initCache(): void;
  107357. /** @hidden */
  107358. _updateCache(ignoreParentClass?: boolean): void;
  107359. protected _getTargetPosition(): Vector3;
  107360. private _storedAlpha;
  107361. private _storedBeta;
  107362. private _storedRadius;
  107363. private _storedTarget;
  107364. private _storedTargetScreenOffset;
  107365. /**
  107366. * Stores the current state of the camera (alpha, beta, radius and target)
  107367. * @returns the camera itself
  107368. */
  107369. storeState(): Camera;
  107370. /**
  107371. * @hidden
  107372. * Restored camera state. You must call storeState() first
  107373. */
  107374. _restoreStateValues(): boolean;
  107375. /** @hidden */
  107376. _isSynchronizedViewMatrix(): boolean;
  107377. /**
  107378. * Attached controls to the current camera.
  107379. * @param element Defines the element the controls should be listened from
  107380. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  107381. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  107382. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  107383. */
  107384. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  107385. /**
  107386. * Detach the current controls from the camera.
  107387. * The camera will stop reacting to inputs.
  107388. * @param element Defines the element to stop listening the inputs from
  107389. */
  107390. detachControl(element: HTMLElement): void;
  107391. /** @hidden */
  107392. _checkInputs(): void;
  107393. protected _checkLimits(): void;
  107394. /**
  107395. * Rebuilds angles (alpha, beta) and radius from the give position and target
  107396. */
  107397. rebuildAnglesAndRadius(): void;
  107398. /**
  107399. * Use a position to define the current camera related information like alpha, beta and radius
  107400. * @param position Defines the position to set the camera at
  107401. */
  107402. setPosition(position: Vector3): void;
  107403. /**
  107404. * Defines the target the camera should look at.
  107405. * This will automatically adapt alpha beta and radius to fit within the new target.
  107406. * @param target Defines the new target as a Vector or a mesh
  107407. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  107408. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  107409. */
  107410. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  107411. /** @hidden */
  107412. _getViewMatrix(): Matrix;
  107413. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  107414. /**
  107415. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  107416. * @param meshes Defines the mesh to zoom on
  107417. * @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)
  107418. */
  107419. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  107420. /**
  107421. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  107422. * The target will be changed but the radius
  107423. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  107424. * @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)
  107425. */
  107426. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  107427. min: Vector3;
  107428. max: Vector3;
  107429. distance: number;
  107430. }, doNotUpdateMaxZ?: boolean): void;
  107431. /**
  107432. * @override
  107433. * Override Camera.createRigCamera
  107434. */
  107435. createRigCamera(name: string, cameraIndex: number): Camera;
  107436. /**
  107437. * @hidden
  107438. * @override
  107439. * Override Camera._updateRigCameras
  107440. */
  107441. _updateRigCameras(): void;
  107442. /**
  107443. * Destroy the camera and release the current resources hold by it.
  107444. */
  107445. dispose(): void;
  107446. /**
  107447. * Gets the current object class name.
  107448. * @return the class name
  107449. */
  107450. getClassName(): string;
  107451. }
  107452. }
  107453. declare module BABYLON {
  107454. /**
  107455. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  107456. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  107457. */
  107458. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  107459. /**
  107460. * Gets the name of the behavior.
  107461. */
  107462. readonly name: string;
  107463. private _zoomStopsAnimation;
  107464. private _idleRotationSpeed;
  107465. private _idleRotationWaitTime;
  107466. private _idleRotationSpinupTime;
  107467. /**
  107468. * Sets the flag that indicates if user zooming should stop animation.
  107469. */
  107470. /**
  107471. * Gets the flag that indicates if user zooming should stop animation.
  107472. */
  107473. zoomStopsAnimation: boolean;
  107474. /**
  107475. * Sets the default speed at which the camera rotates around the model.
  107476. */
  107477. /**
  107478. * Gets the default speed at which the camera rotates around the model.
  107479. */
  107480. idleRotationSpeed: number;
  107481. /**
  107482. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  107483. */
  107484. /**
  107485. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  107486. */
  107487. idleRotationWaitTime: number;
  107488. /**
  107489. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  107490. */
  107491. /**
  107492. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  107493. */
  107494. idleRotationSpinupTime: number;
  107495. /**
  107496. * Gets a value indicating if the camera is currently rotating because of this behavior
  107497. */
  107498. readonly rotationInProgress: boolean;
  107499. private _onPrePointerObservableObserver;
  107500. private _onAfterCheckInputsObserver;
  107501. private _attachedCamera;
  107502. private _isPointerDown;
  107503. private _lastFrameTime;
  107504. private _lastInteractionTime;
  107505. private _cameraRotationSpeed;
  107506. /**
  107507. * Initializes the behavior.
  107508. */
  107509. init(): void;
  107510. /**
  107511. * Attaches the behavior to its arc rotate camera.
  107512. * @param camera Defines the camera to attach the behavior to
  107513. */
  107514. attach(camera: ArcRotateCamera): void;
  107515. /**
  107516. * Detaches the behavior from its current arc rotate camera.
  107517. */
  107518. detach(): void;
  107519. /**
  107520. * Returns true if user is scrolling.
  107521. * @return true if user is scrolling.
  107522. */
  107523. private _userIsZooming;
  107524. private _lastFrameRadius;
  107525. private _shouldAnimationStopForInteraction;
  107526. /**
  107527. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  107528. */
  107529. private _applyUserInteraction;
  107530. private _userIsMoving;
  107531. }
  107532. }
  107533. declare module BABYLON {
  107534. /**
  107535. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  107536. */
  107537. export class AttachToBoxBehavior implements Behavior<Mesh> {
  107538. private ui;
  107539. /**
  107540. * The name of the behavior
  107541. */
  107542. name: string;
  107543. /**
  107544. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  107545. */
  107546. distanceAwayFromFace: number;
  107547. /**
  107548. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  107549. */
  107550. distanceAwayFromBottomOfFace: number;
  107551. private _faceVectors;
  107552. private _target;
  107553. private _scene;
  107554. private _onRenderObserver;
  107555. private _tmpMatrix;
  107556. private _tmpVector;
  107557. /**
  107558. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  107559. * @param ui The transform node that should be attched to the mesh
  107560. */
  107561. constructor(ui: TransformNode);
  107562. /**
  107563. * Initializes the behavior
  107564. */
  107565. init(): void;
  107566. private _closestFace;
  107567. private _zeroVector;
  107568. private _lookAtTmpMatrix;
  107569. private _lookAtToRef;
  107570. /**
  107571. * Attaches the AttachToBoxBehavior to the passed in mesh
  107572. * @param target The mesh that the specified node will be attached to
  107573. */
  107574. attach(target: Mesh): void;
  107575. /**
  107576. * Detaches the behavior from the mesh
  107577. */
  107578. detach(): void;
  107579. }
  107580. }
  107581. declare module BABYLON {
  107582. /**
  107583. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  107584. */
  107585. export class FadeInOutBehavior implements Behavior<Mesh> {
  107586. /**
  107587. * Time in milliseconds to delay before fading in (Default: 0)
  107588. */
  107589. delay: number;
  107590. /**
  107591. * Time in milliseconds for the mesh to fade in (Default: 300)
  107592. */
  107593. fadeInTime: number;
  107594. private _millisecondsPerFrame;
  107595. private _hovered;
  107596. private _hoverValue;
  107597. private _ownerNode;
  107598. /**
  107599. * Instatiates the FadeInOutBehavior
  107600. */
  107601. constructor();
  107602. /**
  107603. * The name of the behavior
  107604. */
  107605. readonly name: string;
  107606. /**
  107607. * Initializes the behavior
  107608. */
  107609. init(): void;
  107610. /**
  107611. * Attaches the fade behavior on the passed in mesh
  107612. * @param ownerNode The mesh that will be faded in/out once attached
  107613. */
  107614. attach(ownerNode: Mesh): void;
  107615. /**
  107616. * Detaches the behavior from the mesh
  107617. */
  107618. detach(): void;
  107619. /**
  107620. * Triggers the mesh to begin fading in or out
  107621. * @param value if the object should fade in or out (true to fade in)
  107622. */
  107623. fadeIn(value: boolean): void;
  107624. private _update;
  107625. private _setAllVisibility;
  107626. }
  107627. }
  107628. declare module BABYLON {
  107629. /**
  107630. * Class containing a set of static utilities functions for managing Pivots
  107631. * @hidden
  107632. */
  107633. export class PivotTools {
  107634. private static _PivotCached;
  107635. private static _OldPivotPoint;
  107636. private static _PivotTranslation;
  107637. private static _PivotTmpVector;
  107638. /** @hidden */
  107639. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  107640. /** @hidden */
  107641. static _RestorePivotPoint(mesh: AbstractMesh): void;
  107642. }
  107643. }
  107644. declare module BABYLON {
  107645. /**
  107646. * Class containing static functions to help procedurally build meshes
  107647. */
  107648. export class PlaneBuilder {
  107649. /**
  107650. * Creates a plane mesh
  107651. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  107652. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  107653. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  107654. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107655. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107656. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107657. * @param name defines the name of the mesh
  107658. * @param options defines the options used to create the mesh
  107659. * @param scene defines the hosting scene
  107660. * @returns the plane mesh
  107661. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  107662. */
  107663. static CreatePlane(name: string, options: {
  107664. size?: number;
  107665. width?: number;
  107666. height?: number;
  107667. sideOrientation?: number;
  107668. frontUVs?: Vector4;
  107669. backUVs?: Vector4;
  107670. updatable?: boolean;
  107671. sourcePlane?: Plane;
  107672. }, scene?: Nullable<Scene>): Mesh;
  107673. }
  107674. }
  107675. declare module BABYLON {
  107676. /**
  107677. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  107678. */
  107679. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  107680. private static _AnyMouseID;
  107681. /**
  107682. * Abstract mesh the behavior is set on
  107683. */
  107684. attachedNode: AbstractMesh;
  107685. private _dragPlane;
  107686. private _scene;
  107687. private _pointerObserver;
  107688. private _beforeRenderObserver;
  107689. private static _planeScene;
  107690. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  107691. /**
  107692. * 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)
  107693. */
  107694. maxDragAngle: number;
  107695. /**
  107696. * @hidden
  107697. */
  107698. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  107699. /**
  107700. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  107701. */
  107702. currentDraggingPointerID: number;
  107703. /**
  107704. * The last position where the pointer hit the drag plane in world space
  107705. */
  107706. lastDragPosition: Vector3;
  107707. /**
  107708. * If the behavior is currently in a dragging state
  107709. */
  107710. dragging: boolean;
  107711. /**
  107712. * 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)
  107713. */
  107714. dragDeltaRatio: number;
  107715. /**
  107716. * If the drag plane orientation should be updated during the dragging (Default: true)
  107717. */
  107718. updateDragPlane: boolean;
  107719. private _debugMode;
  107720. private _moving;
  107721. /**
  107722. * Fires each time the attached mesh is dragged with the pointer
  107723. * * delta between last drag position and current drag position in world space
  107724. * * dragDistance along the drag axis
  107725. * * dragPlaneNormal normal of the current drag plane used during the drag
  107726. * * dragPlanePoint in world space where the drag intersects the drag plane
  107727. */
  107728. onDragObservable: Observable<{
  107729. delta: Vector3;
  107730. dragPlanePoint: Vector3;
  107731. dragPlaneNormal: Vector3;
  107732. dragDistance: number;
  107733. pointerId: number;
  107734. }>;
  107735. /**
  107736. * Fires each time a drag begins (eg. mouse down on mesh)
  107737. */
  107738. onDragStartObservable: Observable<{
  107739. dragPlanePoint: Vector3;
  107740. pointerId: number;
  107741. }>;
  107742. /**
  107743. * Fires each time a drag ends (eg. mouse release after drag)
  107744. */
  107745. onDragEndObservable: Observable<{
  107746. dragPlanePoint: Vector3;
  107747. pointerId: number;
  107748. }>;
  107749. /**
  107750. * If the attached mesh should be moved when dragged
  107751. */
  107752. moveAttached: boolean;
  107753. /**
  107754. * If the drag behavior will react to drag events (Default: true)
  107755. */
  107756. enabled: boolean;
  107757. /**
  107758. * If pointer events should start and release the drag (Default: true)
  107759. */
  107760. startAndReleaseDragOnPointerEvents: boolean;
  107761. /**
  107762. * If camera controls should be detached during the drag
  107763. */
  107764. detachCameraControls: boolean;
  107765. /**
  107766. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  107767. */
  107768. useObjectOrienationForDragging: boolean;
  107769. private _options;
  107770. /**
  107771. * Gets the options used by the behavior
  107772. */
  107773. /**
  107774. * Sets the options used by the behavior
  107775. */
  107776. options: {
  107777. dragAxis?: Vector3;
  107778. dragPlaneNormal?: Vector3;
  107779. };
  107780. /**
  107781. * Creates a pointer drag behavior that can be attached to a mesh
  107782. * @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)
  107783. */
  107784. constructor(options?: {
  107785. dragAxis?: Vector3;
  107786. dragPlaneNormal?: Vector3;
  107787. });
  107788. /**
  107789. * Predicate to determine if it is valid to move the object to a new position when it is moved
  107790. */
  107791. validateDrag: (targetPosition: Vector3) => boolean;
  107792. /**
  107793. * The name of the behavior
  107794. */
  107795. readonly name: string;
  107796. /**
  107797. * Initializes the behavior
  107798. */
  107799. init(): void;
  107800. private _tmpVector;
  107801. private _alternatePickedPoint;
  107802. private _worldDragAxis;
  107803. private _targetPosition;
  107804. private _attachedElement;
  107805. /**
  107806. * Attaches the drag behavior the passed in mesh
  107807. * @param ownerNode The mesh that will be dragged around once attached
  107808. * @param predicate Predicate to use for pick filtering
  107809. */
  107810. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  107811. /**
  107812. * Force relase the drag action by code.
  107813. */
  107814. releaseDrag(): void;
  107815. private _startDragRay;
  107816. private _lastPointerRay;
  107817. /**
  107818. * Simulates the start of a pointer drag event on the behavior
  107819. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  107820. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  107821. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  107822. */
  107823. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  107824. private _startDrag;
  107825. private _dragDelta;
  107826. private _moveDrag;
  107827. private _pickWithRayOnDragPlane;
  107828. private _pointA;
  107829. private _pointB;
  107830. private _pointC;
  107831. private _lineA;
  107832. private _lineB;
  107833. private _localAxis;
  107834. private _lookAt;
  107835. private _updateDragPlanePosition;
  107836. /**
  107837. * Detaches the behavior from the mesh
  107838. */
  107839. detach(): void;
  107840. }
  107841. }
  107842. declare module BABYLON {
  107843. /**
  107844. * A behavior that when attached to a mesh will allow the mesh to be scaled
  107845. */
  107846. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  107847. private _dragBehaviorA;
  107848. private _dragBehaviorB;
  107849. private _startDistance;
  107850. private _initialScale;
  107851. private _targetScale;
  107852. private _ownerNode;
  107853. private _sceneRenderObserver;
  107854. /**
  107855. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  107856. */
  107857. constructor();
  107858. /**
  107859. * The name of the behavior
  107860. */
  107861. readonly name: string;
  107862. /**
  107863. * Initializes the behavior
  107864. */
  107865. init(): void;
  107866. private _getCurrentDistance;
  107867. /**
  107868. * Attaches the scale behavior the passed in mesh
  107869. * @param ownerNode The mesh that will be scaled around once attached
  107870. */
  107871. attach(ownerNode: Mesh): void;
  107872. /**
  107873. * Detaches the behavior from the mesh
  107874. */
  107875. detach(): void;
  107876. }
  107877. }
  107878. declare module BABYLON {
  107879. /**
  107880. * 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
  107881. */
  107882. export class SixDofDragBehavior implements Behavior<Mesh> {
  107883. private static _virtualScene;
  107884. private _ownerNode;
  107885. private _sceneRenderObserver;
  107886. private _scene;
  107887. private _targetPosition;
  107888. private _virtualOriginMesh;
  107889. private _virtualDragMesh;
  107890. private _pointerObserver;
  107891. private _moving;
  107892. private _startingOrientation;
  107893. /**
  107894. * 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)
  107895. */
  107896. private zDragFactor;
  107897. /**
  107898. * If the object should rotate to face the drag origin
  107899. */
  107900. rotateDraggedObject: boolean;
  107901. /**
  107902. * If the behavior is currently in a dragging state
  107903. */
  107904. dragging: boolean;
  107905. /**
  107906. * 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)
  107907. */
  107908. dragDeltaRatio: number;
  107909. /**
  107910. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  107911. */
  107912. currentDraggingPointerID: number;
  107913. /**
  107914. * If camera controls should be detached during the drag
  107915. */
  107916. detachCameraControls: boolean;
  107917. /**
  107918. * Fires each time a drag starts
  107919. */
  107920. onDragStartObservable: Observable<{}>;
  107921. /**
  107922. * Fires each time a drag ends (eg. mouse release after drag)
  107923. */
  107924. onDragEndObservable: Observable<{}>;
  107925. /**
  107926. * 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
  107927. */
  107928. constructor();
  107929. /**
  107930. * The name of the behavior
  107931. */
  107932. readonly name: string;
  107933. /**
  107934. * Initializes the behavior
  107935. */
  107936. init(): void;
  107937. /**
  107938. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  107939. */
  107940. private readonly _pointerCamera;
  107941. /**
  107942. * Attaches the scale behavior the passed in mesh
  107943. * @param ownerNode The mesh that will be scaled around once attached
  107944. */
  107945. attach(ownerNode: Mesh): void;
  107946. /**
  107947. * Detaches the behavior from the mesh
  107948. */
  107949. detach(): void;
  107950. }
  107951. }
  107952. declare module BABYLON {
  107953. /**
  107954. * Class used to apply inverse kinematics to bones
  107955. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  107956. */
  107957. export class BoneIKController {
  107958. private static _tmpVecs;
  107959. private static _tmpQuat;
  107960. private static _tmpMats;
  107961. /**
  107962. * Gets or sets the target mesh
  107963. */
  107964. targetMesh: AbstractMesh;
  107965. /** Gets or sets the mesh used as pole */
  107966. poleTargetMesh: AbstractMesh;
  107967. /**
  107968. * Gets or sets the bone used as pole
  107969. */
  107970. poleTargetBone: Nullable<Bone>;
  107971. /**
  107972. * Gets or sets the target position
  107973. */
  107974. targetPosition: Vector3;
  107975. /**
  107976. * Gets or sets the pole target position
  107977. */
  107978. poleTargetPosition: Vector3;
  107979. /**
  107980. * Gets or sets the pole target local offset
  107981. */
  107982. poleTargetLocalOffset: Vector3;
  107983. /**
  107984. * Gets or sets the pole angle
  107985. */
  107986. poleAngle: number;
  107987. /**
  107988. * Gets or sets the mesh associated with the controller
  107989. */
  107990. mesh: AbstractMesh;
  107991. /**
  107992. * 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)
  107993. */
  107994. slerpAmount: number;
  107995. private _bone1Quat;
  107996. private _bone1Mat;
  107997. private _bone2Ang;
  107998. private _bone1;
  107999. private _bone2;
  108000. private _bone1Length;
  108001. private _bone2Length;
  108002. private _maxAngle;
  108003. private _maxReach;
  108004. private _rightHandedSystem;
  108005. private _bendAxis;
  108006. private _slerping;
  108007. private _adjustRoll;
  108008. /**
  108009. * Gets or sets maximum allowed angle
  108010. */
  108011. maxAngle: number;
  108012. /**
  108013. * Creates a new BoneIKController
  108014. * @param mesh defines the mesh to control
  108015. * @param bone defines the bone to control
  108016. * @param options defines options to set up the controller
  108017. */
  108018. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  108019. targetMesh?: AbstractMesh;
  108020. poleTargetMesh?: AbstractMesh;
  108021. poleTargetBone?: Bone;
  108022. poleTargetLocalOffset?: Vector3;
  108023. poleAngle?: number;
  108024. bendAxis?: Vector3;
  108025. maxAngle?: number;
  108026. slerpAmount?: number;
  108027. });
  108028. private _setMaxAngle;
  108029. /**
  108030. * Force the controller to update the bones
  108031. */
  108032. update(): void;
  108033. }
  108034. }
  108035. declare module BABYLON {
  108036. /**
  108037. * Class used to make a bone look toward a point in space
  108038. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  108039. */
  108040. export class BoneLookController {
  108041. private static _tmpVecs;
  108042. private static _tmpQuat;
  108043. private static _tmpMats;
  108044. /**
  108045. * The target Vector3 that the bone will look at
  108046. */
  108047. target: Vector3;
  108048. /**
  108049. * The mesh that the bone is attached to
  108050. */
  108051. mesh: AbstractMesh;
  108052. /**
  108053. * The bone that will be looking to the target
  108054. */
  108055. bone: Bone;
  108056. /**
  108057. * The up axis of the coordinate system that is used when the bone is rotated
  108058. */
  108059. upAxis: Vector3;
  108060. /**
  108061. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  108062. */
  108063. upAxisSpace: Space;
  108064. /**
  108065. * Used to make an adjustment to the yaw of the bone
  108066. */
  108067. adjustYaw: number;
  108068. /**
  108069. * Used to make an adjustment to the pitch of the bone
  108070. */
  108071. adjustPitch: number;
  108072. /**
  108073. * Used to make an adjustment to the roll of the bone
  108074. */
  108075. adjustRoll: number;
  108076. /**
  108077. * 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)
  108078. */
  108079. slerpAmount: number;
  108080. private _minYaw;
  108081. private _maxYaw;
  108082. private _minPitch;
  108083. private _maxPitch;
  108084. private _minYawSin;
  108085. private _minYawCos;
  108086. private _maxYawSin;
  108087. private _maxYawCos;
  108088. private _midYawConstraint;
  108089. private _minPitchTan;
  108090. private _maxPitchTan;
  108091. private _boneQuat;
  108092. private _slerping;
  108093. private _transformYawPitch;
  108094. private _transformYawPitchInv;
  108095. private _firstFrameSkipped;
  108096. private _yawRange;
  108097. private _fowardAxis;
  108098. /**
  108099. * Gets or sets the minimum yaw angle that the bone can look to
  108100. */
  108101. minYaw: number;
  108102. /**
  108103. * Gets or sets the maximum yaw angle that the bone can look to
  108104. */
  108105. maxYaw: number;
  108106. /**
  108107. * Gets or sets the minimum pitch angle that the bone can look to
  108108. */
  108109. minPitch: number;
  108110. /**
  108111. * Gets or sets the maximum pitch angle that the bone can look to
  108112. */
  108113. maxPitch: number;
  108114. /**
  108115. * Create a BoneLookController
  108116. * @param mesh the mesh that the bone belongs to
  108117. * @param bone the bone that will be looking to the target
  108118. * @param target the target Vector3 to look at
  108119. * @param options optional settings:
  108120. * * maxYaw: the maximum angle the bone will yaw to
  108121. * * minYaw: the minimum angle the bone will yaw to
  108122. * * maxPitch: the maximum angle the bone will pitch to
  108123. * * minPitch: the minimum angle the bone will yaw to
  108124. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  108125. * * upAxis: the up axis of the coordinate system
  108126. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  108127. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  108128. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  108129. * * adjustYaw: used to make an adjustment to the yaw of the bone
  108130. * * adjustPitch: used to make an adjustment to the pitch of the bone
  108131. * * adjustRoll: used to make an adjustment to the roll of the bone
  108132. **/
  108133. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  108134. maxYaw?: number;
  108135. minYaw?: number;
  108136. maxPitch?: number;
  108137. minPitch?: number;
  108138. slerpAmount?: number;
  108139. upAxis?: Vector3;
  108140. upAxisSpace?: Space;
  108141. yawAxis?: Vector3;
  108142. pitchAxis?: Vector3;
  108143. adjustYaw?: number;
  108144. adjustPitch?: number;
  108145. adjustRoll?: number;
  108146. });
  108147. /**
  108148. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  108149. */
  108150. update(): void;
  108151. private _getAngleDiff;
  108152. private _getAngleBetween;
  108153. private _isAngleBetween;
  108154. }
  108155. }
  108156. declare module BABYLON {
  108157. /**
  108158. * Manage the gamepad inputs to control an arc rotate camera.
  108159. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108160. */
  108161. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  108162. /**
  108163. * Defines the camera the input is attached to.
  108164. */
  108165. camera: ArcRotateCamera;
  108166. /**
  108167. * Defines the gamepad the input is gathering event from.
  108168. */
  108169. gamepad: Nullable<Gamepad>;
  108170. /**
  108171. * Defines the gamepad rotation sensiblity.
  108172. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  108173. */
  108174. gamepadRotationSensibility: number;
  108175. /**
  108176. * Defines the gamepad move sensiblity.
  108177. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  108178. */
  108179. gamepadMoveSensibility: number;
  108180. private _yAxisScale;
  108181. /**
  108182. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  108183. */
  108184. invertYAxis: boolean;
  108185. private _onGamepadConnectedObserver;
  108186. private _onGamepadDisconnectedObserver;
  108187. /**
  108188. * Attach the input controls to a specific dom element to get the input from.
  108189. * @param element Defines the element the controls should be listened from
  108190. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108191. */
  108192. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108193. /**
  108194. * Detach the current controls from the specified dom element.
  108195. * @param element Defines the element to stop listening the inputs from
  108196. */
  108197. detachControl(element: Nullable<HTMLElement>): void;
  108198. /**
  108199. * Update the current camera state depending on the inputs that have been used this frame.
  108200. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  108201. */
  108202. checkInputs(): void;
  108203. /**
  108204. * Gets the class name of the current intput.
  108205. * @returns the class name
  108206. */
  108207. getClassName(): string;
  108208. /**
  108209. * Get the friendly name associated with the input class.
  108210. * @returns the input friendly name
  108211. */
  108212. getSimpleName(): string;
  108213. }
  108214. }
  108215. declare module BABYLON {
  108216. interface ArcRotateCameraInputsManager {
  108217. /**
  108218. * Add orientation input support to the input manager.
  108219. * @returns the current input manager
  108220. */
  108221. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  108222. }
  108223. /**
  108224. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  108225. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108226. */
  108227. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  108228. /**
  108229. * Defines the camera the input is attached to.
  108230. */
  108231. camera: ArcRotateCamera;
  108232. /**
  108233. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  108234. */
  108235. alphaCorrection: number;
  108236. /**
  108237. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  108238. */
  108239. gammaCorrection: number;
  108240. private _alpha;
  108241. private _gamma;
  108242. private _dirty;
  108243. private _deviceOrientationHandler;
  108244. /**
  108245. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  108246. */
  108247. constructor();
  108248. /**
  108249. * Attach the input controls to a specific dom element to get the input from.
  108250. * @param element Defines the element the controls should be listened from
  108251. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108252. */
  108253. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108254. /** @hidden */
  108255. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  108256. /**
  108257. * Update the current camera state depending on the inputs that have been used this frame.
  108258. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  108259. */
  108260. checkInputs(): void;
  108261. /**
  108262. * Detach the current controls from the specified dom element.
  108263. * @param element Defines the element to stop listening the inputs from
  108264. */
  108265. detachControl(element: Nullable<HTMLElement>): void;
  108266. /**
  108267. * Gets the class name of the current intput.
  108268. * @returns the class name
  108269. */
  108270. getClassName(): string;
  108271. /**
  108272. * Get the friendly name associated with the input class.
  108273. * @returns the input friendly name
  108274. */
  108275. getSimpleName(): string;
  108276. }
  108277. }
  108278. declare module BABYLON {
  108279. /**
  108280. * Listen to mouse events to control the camera.
  108281. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108282. */
  108283. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  108284. /**
  108285. * Defines the camera the input is attached to.
  108286. */
  108287. camera: FlyCamera;
  108288. /**
  108289. * Defines if touch is enabled. (Default is true.)
  108290. */
  108291. touchEnabled: boolean;
  108292. /**
  108293. * Defines the buttons associated with the input to handle camera rotation.
  108294. */
  108295. buttons: number[];
  108296. /**
  108297. * Assign buttons for Yaw control.
  108298. */
  108299. buttonsYaw: number[];
  108300. /**
  108301. * Assign buttons for Pitch control.
  108302. */
  108303. buttonsPitch: number[];
  108304. /**
  108305. * Assign buttons for Roll control.
  108306. */
  108307. buttonsRoll: number[];
  108308. /**
  108309. * Detect if any button is being pressed while mouse is moved.
  108310. * -1 = Mouse locked.
  108311. * 0 = Left button.
  108312. * 1 = Middle Button.
  108313. * 2 = Right Button.
  108314. */
  108315. activeButton: number;
  108316. /**
  108317. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  108318. * Higher values reduce its sensitivity.
  108319. */
  108320. angularSensibility: number;
  108321. private _mousemoveCallback;
  108322. private _observer;
  108323. private _rollObserver;
  108324. private previousPosition;
  108325. private noPreventDefault;
  108326. private element;
  108327. /**
  108328. * Listen to mouse events to control the camera.
  108329. * @param touchEnabled Define if touch is enabled. (Default is true.)
  108330. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108331. */
  108332. constructor(touchEnabled?: boolean);
  108333. /**
  108334. * Attach the mouse control to the HTML DOM element.
  108335. * @param element Defines the element that listens to the input events.
  108336. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  108337. */
  108338. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108339. /**
  108340. * Detach the current controls from the specified dom element.
  108341. * @param element Defines the element to stop listening the inputs from
  108342. */
  108343. detachControl(element: Nullable<HTMLElement>): void;
  108344. /**
  108345. * Gets the class name of the current input.
  108346. * @returns the class name.
  108347. */
  108348. getClassName(): string;
  108349. /**
  108350. * Get the friendly name associated with the input class.
  108351. * @returns the input's friendly name.
  108352. */
  108353. getSimpleName(): string;
  108354. private _pointerInput;
  108355. private _onMouseMove;
  108356. /**
  108357. * Rotate camera by mouse offset.
  108358. */
  108359. private rotateCamera;
  108360. }
  108361. }
  108362. declare module BABYLON {
  108363. /**
  108364. * Default Inputs manager for the FlyCamera.
  108365. * It groups all the default supported inputs for ease of use.
  108366. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108367. */
  108368. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  108369. /**
  108370. * Instantiates a new FlyCameraInputsManager.
  108371. * @param camera Defines the camera the inputs belong to.
  108372. */
  108373. constructor(camera: FlyCamera);
  108374. /**
  108375. * Add keyboard input support to the input manager.
  108376. * @returns the new FlyCameraKeyboardMoveInput().
  108377. */
  108378. addKeyboard(): FlyCameraInputsManager;
  108379. /**
  108380. * Add mouse input support to the input manager.
  108381. * @param touchEnabled Enable touch screen support.
  108382. * @returns the new FlyCameraMouseInput().
  108383. */
  108384. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  108385. }
  108386. }
  108387. declare module BABYLON {
  108388. /**
  108389. * This is a flying camera, designed for 3D movement and rotation in all directions,
  108390. * such as in a 3D Space Shooter or a Flight Simulator.
  108391. */
  108392. export class FlyCamera extends TargetCamera {
  108393. /**
  108394. * Define the collision ellipsoid of the camera.
  108395. * This is helpful for simulating a camera body, like a player's body.
  108396. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  108397. */
  108398. ellipsoid: Vector3;
  108399. /**
  108400. * Define an offset for the position of the ellipsoid around the camera.
  108401. * This can be helpful if the camera is attached away from the player's body center,
  108402. * such as at its head.
  108403. */
  108404. ellipsoidOffset: Vector3;
  108405. /**
  108406. * Enable or disable collisions of the camera with the rest of the scene objects.
  108407. */
  108408. checkCollisions: boolean;
  108409. /**
  108410. * Enable or disable gravity on the camera.
  108411. */
  108412. applyGravity: boolean;
  108413. /**
  108414. * Define the current direction the camera is moving to.
  108415. */
  108416. cameraDirection: Vector3;
  108417. /**
  108418. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  108419. * This overrides and empties cameraRotation.
  108420. */
  108421. rotationQuaternion: Quaternion;
  108422. /**
  108423. * Track Roll to maintain the wanted Rolling when looking around.
  108424. */
  108425. _trackRoll: number;
  108426. /**
  108427. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  108428. */
  108429. rollCorrect: number;
  108430. /**
  108431. * Mimic a banked turn, Rolling the camera when Yawing.
  108432. * It's recommended to use rollCorrect = 10 for faster banking correction.
  108433. */
  108434. bankedTurn: boolean;
  108435. /**
  108436. * Limit in radians for how much Roll banking will add. (Default: 90°)
  108437. */
  108438. bankedTurnLimit: number;
  108439. /**
  108440. * Value of 0 disables the banked Roll.
  108441. * Value of 1 is equal to the Yaw angle in radians.
  108442. */
  108443. bankedTurnMultiplier: number;
  108444. /**
  108445. * The inputs manager loads all the input sources, such as keyboard and mouse.
  108446. */
  108447. inputs: FlyCameraInputsManager;
  108448. /**
  108449. * Gets the input sensibility for mouse input.
  108450. * Higher values reduce sensitivity.
  108451. */
  108452. /**
  108453. * Sets the input sensibility for a mouse input.
  108454. * Higher values reduce sensitivity.
  108455. */
  108456. angularSensibility: number;
  108457. /**
  108458. * Get the keys for camera movement forward.
  108459. */
  108460. /**
  108461. * Set the keys for camera movement forward.
  108462. */
  108463. keysForward: number[];
  108464. /**
  108465. * Get the keys for camera movement backward.
  108466. */
  108467. keysBackward: number[];
  108468. /**
  108469. * Get the keys for camera movement up.
  108470. */
  108471. /**
  108472. * Set the keys for camera movement up.
  108473. */
  108474. keysUp: number[];
  108475. /**
  108476. * Get the keys for camera movement down.
  108477. */
  108478. /**
  108479. * Set the keys for camera movement down.
  108480. */
  108481. keysDown: number[];
  108482. /**
  108483. * Get the keys for camera movement left.
  108484. */
  108485. /**
  108486. * Set the keys for camera movement left.
  108487. */
  108488. keysLeft: number[];
  108489. /**
  108490. * Set the keys for camera movement right.
  108491. */
  108492. /**
  108493. * Set the keys for camera movement right.
  108494. */
  108495. keysRight: number[];
  108496. /**
  108497. * Event raised when the camera collides with a mesh in the scene.
  108498. */
  108499. onCollide: (collidedMesh: AbstractMesh) => void;
  108500. private _collider;
  108501. private _needMoveForGravity;
  108502. private _oldPosition;
  108503. private _diffPosition;
  108504. private _newPosition;
  108505. /** @hidden */
  108506. _localDirection: Vector3;
  108507. /** @hidden */
  108508. _transformedDirection: Vector3;
  108509. /**
  108510. * Instantiates a FlyCamera.
  108511. * This is a flying camera, designed for 3D movement and rotation in all directions,
  108512. * such as in a 3D Space Shooter or a Flight Simulator.
  108513. * @param name Define the name of the camera in the scene.
  108514. * @param position Define the starting position of the camera in the scene.
  108515. * @param scene Define the scene the camera belongs to.
  108516. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  108517. */
  108518. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  108519. /**
  108520. * Attach a control to the HTML DOM element.
  108521. * @param element Defines the element that listens to the input events.
  108522. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  108523. */
  108524. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108525. /**
  108526. * Detach a control from the HTML DOM element.
  108527. * The camera will stop reacting to that input.
  108528. * @param element Defines the element that listens to the input events.
  108529. */
  108530. detachControl(element: HTMLElement): void;
  108531. private _collisionMask;
  108532. /**
  108533. * Get the mask that the camera ignores in collision events.
  108534. */
  108535. /**
  108536. * Set the mask that the camera ignores in collision events.
  108537. */
  108538. collisionMask: number;
  108539. /** @hidden */
  108540. _collideWithWorld(displacement: Vector3): void;
  108541. /** @hidden */
  108542. private _onCollisionPositionChange;
  108543. /** @hidden */
  108544. _checkInputs(): void;
  108545. /** @hidden */
  108546. _decideIfNeedsToMove(): boolean;
  108547. /** @hidden */
  108548. _updatePosition(): void;
  108549. /**
  108550. * Restore the Roll to its target value at the rate specified.
  108551. * @param rate - Higher means slower restoring.
  108552. * @hidden
  108553. */
  108554. restoreRoll(rate: number): void;
  108555. /**
  108556. * Destroy the camera and release the current resources held by it.
  108557. */
  108558. dispose(): void;
  108559. /**
  108560. * Get the current object class name.
  108561. * @returns the class name.
  108562. */
  108563. getClassName(): string;
  108564. }
  108565. }
  108566. declare module BABYLON {
  108567. /**
  108568. * Listen to keyboard events to control the camera.
  108569. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108570. */
  108571. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  108572. /**
  108573. * Defines the camera the input is attached to.
  108574. */
  108575. camera: FlyCamera;
  108576. /**
  108577. * The list of keyboard keys used to control the forward move of the camera.
  108578. */
  108579. keysForward: number[];
  108580. /**
  108581. * The list of keyboard keys used to control the backward move of the camera.
  108582. */
  108583. keysBackward: number[];
  108584. /**
  108585. * The list of keyboard keys used to control the forward move of the camera.
  108586. */
  108587. keysUp: number[];
  108588. /**
  108589. * The list of keyboard keys used to control the backward move of the camera.
  108590. */
  108591. keysDown: number[];
  108592. /**
  108593. * The list of keyboard keys used to control the right strafe move of the camera.
  108594. */
  108595. keysRight: number[];
  108596. /**
  108597. * The list of keyboard keys used to control the left strafe move of the camera.
  108598. */
  108599. keysLeft: number[];
  108600. private _keys;
  108601. private _onCanvasBlurObserver;
  108602. private _onKeyboardObserver;
  108603. private _engine;
  108604. private _scene;
  108605. /**
  108606. * Attach the input controls to a specific dom element to get the input from.
  108607. * @param element Defines the element the controls should be listened from
  108608. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108609. */
  108610. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108611. /**
  108612. * Detach the current controls from the specified dom element.
  108613. * @param element Defines the element to stop listening the inputs from
  108614. */
  108615. detachControl(element: Nullable<HTMLElement>): void;
  108616. /**
  108617. * Gets the class name of the current intput.
  108618. * @returns the class name
  108619. */
  108620. getClassName(): string;
  108621. /** @hidden */
  108622. _onLostFocus(e: FocusEvent): void;
  108623. /**
  108624. * Get the friendly name associated with the input class.
  108625. * @returns the input friendly name
  108626. */
  108627. getSimpleName(): string;
  108628. /**
  108629. * Update the current camera state depending on the inputs that have been used this frame.
  108630. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  108631. */
  108632. checkInputs(): void;
  108633. }
  108634. }
  108635. declare module BABYLON {
  108636. /**
  108637. * Manage the mouse wheel inputs to control a follow camera.
  108638. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108639. */
  108640. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  108641. /**
  108642. * Defines the camera the input is attached to.
  108643. */
  108644. camera: FollowCamera;
  108645. /**
  108646. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  108647. */
  108648. axisControlRadius: boolean;
  108649. /**
  108650. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  108651. */
  108652. axisControlHeight: boolean;
  108653. /**
  108654. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  108655. */
  108656. axisControlRotation: boolean;
  108657. /**
  108658. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  108659. * relation to mouseWheel events.
  108660. */
  108661. wheelPrecision: number;
  108662. /**
  108663. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  108664. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  108665. */
  108666. wheelDeltaPercentage: number;
  108667. private _wheel;
  108668. private _observer;
  108669. /**
  108670. * Attach the input controls to a specific dom element to get the input from.
  108671. * @param element Defines the element the controls should be listened from
  108672. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108673. */
  108674. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108675. /**
  108676. * Detach the current controls from the specified dom element.
  108677. * @param element Defines the element to stop listening the inputs from
  108678. */
  108679. detachControl(element: Nullable<HTMLElement>): void;
  108680. /**
  108681. * Gets the class name of the current intput.
  108682. * @returns the class name
  108683. */
  108684. getClassName(): string;
  108685. /**
  108686. * Get the friendly name associated with the input class.
  108687. * @returns the input friendly name
  108688. */
  108689. getSimpleName(): string;
  108690. }
  108691. }
  108692. declare module BABYLON {
  108693. /**
  108694. * Manage the pointers inputs to control an follow camera.
  108695. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108696. */
  108697. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  108698. /**
  108699. * Defines the camera the input is attached to.
  108700. */
  108701. camera: FollowCamera;
  108702. /**
  108703. * Gets the class name of the current input.
  108704. * @returns the class name
  108705. */
  108706. getClassName(): string;
  108707. /**
  108708. * Defines the pointer angular sensibility along the X axis or how fast is
  108709. * the camera rotating.
  108710. * A negative number will reverse the axis direction.
  108711. */
  108712. angularSensibilityX: number;
  108713. /**
  108714. * Defines the pointer angular sensibility along the Y axis or how fast is
  108715. * the camera rotating.
  108716. * A negative number will reverse the axis direction.
  108717. */
  108718. angularSensibilityY: number;
  108719. /**
  108720. * Defines the pointer pinch precision or how fast is the camera zooming.
  108721. * A negative number will reverse the axis direction.
  108722. */
  108723. pinchPrecision: number;
  108724. /**
  108725. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  108726. * from 0.
  108727. * It defines the percentage of current camera.radius to use as delta when
  108728. * pinch zoom is used.
  108729. */
  108730. pinchDeltaPercentage: number;
  108731. /**
  108732. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  108733. */
  108734. axisXControlRadius: boolean;
  108735. /**
  108736. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  108737. */
  108738. axisXControlHeight: boolean;
  108739. /**
  108740. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  108741. */
  108742. axisXControlRotation: boolean;
  108743. /**
  108744. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  108745. */
  108746. axisYControlRadius: boolean;
  108747. /**
  108748. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  108749. */
  108750. axisYControlHeight: boolean;
  108751. /**
  108752. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  108753. */
  108754. axisYControlRotation: boolean;
  108755. /**
  108756. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  108757. */
  108758. axisPinchControlRadius: boolean;
  108759. /**
  108760. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  108761. */
  108762. axisPinchControlHeight: boolean;
  108763. /**
  108764. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  108765. */
  108766. axisPinchControlRotation: boolean;
  108767. /**
  108768. * Log error messages if basic misconfiguration has occurred.
  108769. */
  108770. warningEnable: boolean;
  108771. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  108772. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  108773. private _warningCounter;
  108774. private _warning;
  108775. }
  108776. }
  108777. declare module BABYLON {
  108778. /**
  108779. * Default Inputs manager for the FollowCamera.
  108780. * It groups all the default supported inputs for ease of use.
  108781. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108782. */
  108783. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  108784. /**
  108785. * Instantiates a new FollowCameraInputsManager.
  108786. * @param camera Defines the camera the inputs belong to
  108787. */
  108788. constructor(camera: FollowCamera);
  108789. /**
  108790. * Add keyboard input support to the input manager.
  108791. * @returns the current input manager
  108792. */
  108793. addKeyboard(): FollowCameraInputsManager;
  108794. /**
  108795. * Add mouse wheel input support to the input manager.
  108796. * @returns the current input manager
  108797. */
  108798. addMouseWheel(): FollowCameraInputsManager;
  108799. /**
  108800. * Add pointers input support to the input manager.
  108801. * @returns the current input manager
  108802. */
  108803. addPointers(): FollowCameraInputsManager;
  108804. /**
  108805. * Add orientation input support to the input manager.
  108806. * @returns the current input manager
  108807. */
  108808. addVRDeviceOrientation(): FollowCameraInputsManager;
  108809. }
  108810. }
  108811. declare module BABYLON {
  108812. /**
  108813. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  108814. * an arc rotate version arcFollowCamera are available.
  108815. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  108816. */
  108817. export class FollowCamera extends TargetCamera {
  108818. /**
  108819. * Distance the follow camera should follow an object at
  108820. */
  108821. radius: number;
  108822. /**
  108823. * Minimum allowed distance of the camera to the axis of rotation
  108824. * (The camera can not get closer).
  108825. * This can help limiting how the Camera is able to move in the scene.
  108826. */
  108827. lowerRadiusLimit: Nullable<number>;
  108828. /**
  108829. * Maximum allowed distance of the camera to the axis of rotation
  108830. * (The camera can not get further).
  108831. * This can help limiting how the Camera is able to move in the scene.
  108832. */
  108833. upperRadiusLimit: Nullable<number>;
  108834. /**
  108835. * Define a rotation offset between the camera and the object it follows
  108836. */
  108837. rotationOffset: number;
  108838. /**
  108839. * Minimum allowed angle to camera position relative to target object.
  108840. * This can help limiting how the Camera is able to move in the scene.
  108841. */
  108842. lowerRotationOffsetLimit: Nullable<number>;
  108843. /**
  108844. * Maximum allowed angle to camera position relative to target object.
  108845. * This can help limiting how the Camera is able to move in the scene.
  108846. */
  108847. upperRotationOffsetLimit: Nullable<number>;
  108848. /**
  108849. * Define a height offset between the camera and the object it follows.
  108850. * It can help following an object from the top (like a car chaing a plane)
  108851. */
  108852. heightOffset: number;
  108853. /**
  108854. * Minimum allowed height of camera position relative to target object.
  108855. * This can help limiting how the Camera is able to move in the scene.
  108856. */
  108857. lowerHeightOffsetLimit: Nullable<number>;
  108858. /**
  108859. * Maximum allowed height of camera position relative to target object.
  108860. * This can help limiting how the Camera is able to move in the scene.
  108861. */
  108862. upperHeightOffsetLimit: Nullable<number>;
  108863. /**
  108864. * Define how fast the camera can accelerate to follow it s target.
  108865. */
  108866. cameraAcceleration: number;
  108867. /**
  108868. * Define the speed limit of the camera following an object.
  108869. */
  108870. maxCameraSpeed: number;
  108871. /**
  108872. * Define the target of the camera.
  108873. */
  108874. lockedTarget: Nullable<AbstractMesh>;
  108875. /**
  108876. * Defines the input associated with the camera.
  108877. */
  108878. inputs: FollowCameraInputsManager;
  108879. /**
  108880. * Instantiates the follow camera.
  108881. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  108882. * @param name Define the name of the camera in the scene
  108883. * @param position Define the position of the camera
  108884. * @param scene Define the scene the camera belong to
  108885. * @param lockedTarget Define the target of the camera
  108886. */
  108887. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  108888. private _follow;
  108889. /**
  108890. * Attached controls to the current camera.
  108891. * @param element Defines the element the controls should be listened from
  108892. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108893. */
  108894. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108895. /**
  108896. * Detach the current controls from the camera.
  108897. * The camera will stop reacting to inputs.
  108898. * @param element Defines the element to stop listening the inputs from
  108899. */
  108900. detachControl(element: HTMLElement): void;
  108901. /** @hidden */
  108902. _checkInputs(): void;
  108903. private _checkLimits;
  108904. /**
  108905. * Gets the camera class name.
  108906. * @returns the class name
  108907. */
  108908. getClassName(): string;
  108909. }
  108910. /**
  108911. * Arc Rotate version of the follow camera.
  108912. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  108913. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  108914. */
  108915. export class ArcFollowCamera extends TargetCamera {
  108916. /** The longitudinal angle of the camera */
  108917. alpha: number;
  108918. /** The latitudinal angle of the camera */
  108919. beta: number;
  108920. /** The radius of the camera from its target */
  108921. radius: number;
  108922. /** Define the camera target (the messh it should follow) */
  108923. target: Nullable<AbstractMesh>;
  108924. private _cartesianCoordinates;
  108925. /**
  108926. * Instantiates a new ArcFollowCamera
  108927. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  108928. * @param name Define the name of the camera
  108929. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  108930. * @param beta Define the rotation angle of the camera around the elevation axis
  108931. * @param radius Define the radius of the camera from its target point
  108932. * @param target Define the target of the camera
  108933. * @param scene Define the scene the camera belongs to
  108934. */
  108935. constructor(name: string,
  108936. /** The longitudinal angle of the camera */
  108937. alpha: number,
  108938. /** The latitudinal angle of the camera */
  108939. beta: number,
  108940. /** The radius of the camera from its target */
  108941. radius: number,
  108942. /** Define the camera target (the messh it should follow) */
  108943. target: Nullable<AbstractMesh>, scene: Scene);
  108944. private _follow;
  108945. /** @hidden */
  108946. _checkInputs(): void;
  108947. /**
  108948. * Returns the class name of the object.
  108949. * It is mostly used internally for serialization purposes.
  108950. */
  108951. getClassName(): string;
  108952. }
  108953. }
  108954. declare module BABYLON {
  108955. /**
  108956. * Manage the keyboard inputs to control the movement of a follow camera.
  108957. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108958. */
  108959. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  108960. /**
  108961. * Defines the camera the input is attached to.
  108962. */
  108963. camera: FollowCamera;
  108964. /**
  108965. * Defines the list of key codes associated with the up action (increase heightOffset)
  108966. */
  108967. keysHeightOffsetIncr: number[];
  108968. /**
  108969. * Defines the list of key codes associated with the down action (decrease heightOffset)
  108970. */
  108971. keysHeightOffsetDecr: number[];
  108972. /**
  108973. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  108974. */
  108975. keysHeightOffsetModifierAlt: boolean;
  108976. /**
  108977. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  108978. */
  108979. keysHeightOffsetModifierCtrl: boolean;
  108980. /**
  108981. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  108982. */
  108983. keysHeightOffsetModifierShift: boolean;
  108984. /**
  108985. * Defines the list of key codes associated with the left action (increase rotationOffset)
  108986. */
  108987. keysRotationOffsetIncr: number[];
  108988. /**
  108989. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  108990. */
  108991. keysRotationOffsetDecr: number[];
  108992. /**
  108993. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  108994. */
  108995. keysRotationOffsetModifierAlt: boolean;
  108996. /**
  108997. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  108998. */
  108999. keysRotationOffsetModifierCtrl: boolean;
  109000. /**
  109001. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  109002. */
  109003. keysRotationOffsetModifierShift: boolean;
  109004. /**
  109005. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  109006. */
  109007. keysRadiusIncr: number[];
  109008. /**
  109009. * Defines the list of key codes associated with the zoom-out action (increase radius)
  109010. */
  109011. keysRadiusDecr: number[];
  109012. /**
  109013. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  109014. */
  109015. keysRadiusModifierAlt: boolean;
  109016. /**
  109017. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  109018. */
  109019. keysRadiusModifierCtrl: boolean;
  109020. /**
  109021. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  109022. */
  109023. keysRadiusModifierShift: boolean;
  109024. /**
  109025. * Defines the rate of change of heightOffset.
  109026. */
  109027. heightSensibility: number;
  109028. /**
  109029. * Defines the rate of change of rotationOffset.
  109030. */
  109031. rotationSensibility: number;
  109032. /**
  109033. * Defines the rate of change of radius.
  109034. */
  109035. radiusSensibility: number;
  109036. private _keys;
  109037. private _ctrlPressed;
  109038. private _altPressed;
  109039. private _shiftPressed;
  109040. private _onCanvasBlurObserver;
  109041. private _onKeyboardObserver;
  109042. private _engine;
  109043. private _scene;
  109044. /**
  109045. * Attach the input controls to a specific dom element to get the input from.
  109046. * @param element Defines the element the controls should be listened from
  109047. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109048. */
  109049. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  109050. /**
  109051. * Detach the current controls from the specified dom element.
  109052. * @param element Defines the element to stop listening the inputs from
  109053. */
  109054. detachControl(element: Nullable<HTMLElement>): void;
  109055. /**
  109056. * Update the current camera state depending on the inputs that have been used this frame.
  109057. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  109058. */
  109059. checkInputs(): void;
  109060. /**
  109061. * Gets the class name of the current input.
  109062. * @returns the class name
  109063. */
  109064. getClassName(): string;
  109065. /**
  109066. * Get the friendly name associated with the input class.
  109067. * @returns the input friendly name
  109068. */
  109069. getSimpleName(): string;
  109070. /**
  109071. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  109072. * allow modification of the heightOffset value.
  109073. */
  109074. private _modifierHeightOffset;
  109075. /**
  109076. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  109077. * allow modification of the rotationOffset value.
  109078. */
  109079. private _modifierRotationOffset;
  109080. /**
  109081. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  109082. * allow modification of the radius value.
  109083. */
  109084. private _modifierRadius;
  109085. }
  109086. }
  109087. declare module BABYLON {
  109088. interface FreeCameraInputsManager {
  109089. /**
  109090. * @hidden
  109091. */
  109092. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  109093. /**
  109094. * Add orientation input support to the input manager.
  109095. * @returns the current input manager
  109096. */
  109097. addDeviceOrientation(): FreeCameraInputsManager;
  109098. }
  109099. /**
  109100. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  109101. * Screen rotation is taken into account.
  109102. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  109103. */
  109104. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  109105. private _camera;
  109106. private _screenOrientationAngle;
  109107. private _constantTranform;
  109108. private _screenQuaternion;
  109109. private _alpha;
  109110. private _beta;
  109111. private _gamma;
  109112. /**
  109113. * Can be used to detect if a device orientation sensor is available on a device
  109114. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  109115. * @returns a promise that will resolve on orientation change
  109116. */
  109117. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  109118. /**
  109119. * @hidden
  109120. */
  109121. _onDeviceOrientationChangedObservable: Observable<void>;
  109122. /**
  109123. * Instantiates a new input
  109124. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  109125. */
  109126. constructor();
  109127. /**
  109128. * Define the camera controlled by the input.
  109129. */
  109130. camera: FreeCamera;
  109131. /**
  109132. * Attach the input controls to a specific dom element to get the input from.
  109133. * @param element Defines the element the controls should be listened from
  109134. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109135. */
  109136. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  109137. private _orientationChanged;
  109138. private _deviceOrientation;
  109139. /**
  109140. * Detach the current controls from the specified dom element.
  109141. * @param element Defines the element to stop listening the inputs from
  109142. */
  109143. detachControl(element: Nullable<HTMLElement>): void;
  109144. /**
  109145. * Update the current camera state depending on the inputs that have been used this frame.
  109146. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  109147. */
  109148. checkInputs(): void;
  109149. /**
  109150. * Gets the class name of the current intput.
  109151. * @returns the class name
  109152. */
  109153. getClassName(): string;
  109154. /**
  109155. * Get the friendly name associated with the input class.
  109156. * @returns the input friendly name
  109157. */
  109158. getSimpleName(): string;
  109159. }
  109160. }
  109161. declare module BABYLON {
  109162. /**
  109163. * Manage the gamepad inputs to control a free camera.
  109164. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  109165. */
  109166. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  109167. /**
  109168. * Define the camera the input is attached to.
  109169. */
  109170. camera: FreeCamera;
  109171. /**
  109172. * Define the Gamepad controlling the input
  109173. */
  109174. gamepad: Nullable<Gamepad>;
  109175. /**
  109176. * Defines the gamepad rotation sensiblity.
  109177. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  109178. */
  109179. gamepadAngularSensibility: number;
  109180. /**
  109181. * Defines the gamepad move sensiblity.
  109182. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  109183. */
  109184. gamepadMoveSensibility: number;
  109185. private _yAxisScale;
  109186. /**
  109187. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  109188. */
  109189. invertYAxis: boolean;
  109190. private _onGamepadConnectedObserver;
  109191. private _onGamepadDisconnectedObserver;
  109192. private _cameraTransform;
  109193. private _deltaTransform;
  109194. private _vector3;
  109195. private _vector2;
  109196. /**
  109197. * Attach the input controls to a specific dom element to get the input from.
  109198. * @param element Defines the element the controls should be listened from
  109199. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109200. */
  109201. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  109202. /**
  109203. * Detach the current controls from the specified dom element.
  109204. * @param element Defines the element to stop listening the inputs from
  109205. */
  109206. detachControl(element: Nullable<HTMLElement>): void;
  109207. /**
  109208. * Update the current camera state depending on the inputs that have been used this frame.
  109209. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  109210. */
  109211. checkInputs(): void;
  109212. /**
  109213. * Gets the class name of the current intput.
  109214. * @returns the class name
  109215. */
  109216. getClassName(): string;
  109217. /**
  109218. * Get the friendly name associated with the input class.
  109219. * @returns the input friendly name
  109220. */
  109221. getSimpleName(): string;
  109222. }
  109223. }
  109224. declare module BABYLON {
  109225. /**
  109226. * Defines the potential axis of a Joystick
  109227. */
  109228. export enum JoystickAxis {
  109229. /** X axis */
  109230. X = 0,
  109231. /** Y axis */
  109232. Y = 1,
  109233. /** Z axis */
  109234. Z = 2
  109235. }
  109236. /**
  109237. * Class used to define virtual joystick (used in touch mode)
  109238. */
  109239. export class VirtualJoystick {
  109240. /**
  109241. * Gets or sets a boolean indicating that left and right values must be inverted
  109242. */
  109243. reverseLeftRight: boolean;
  109244. /**
  109245. * Gets or sets a boolean indicating that up and down values must be inverted
  109246. */
  109247. reverseUpDown: boolean;
  109248. /**
  109249. * Gets the offset value for the position (ie. the change of the position value)
  109250. */
  109251. deltaPosition: Vector3;
  109252. /**
  109253. * Gets a boolean indicating if the virtual joystick was pressed
  109254. */
  109255. pressed: boolean;
  109256. /**
  109257. * Canvas the virtual joystick will render onto, default z-index of this is 5
  109258. */
  109259. static Canvas: Nullable<HTMLCanvasElement>;
  109260. private static _globalJoystickIndex;
  109261. private static vjCanvasContext;
  109262. private static vjCanvasWidth;
  109263. private static vjCanvasHeight;
  109264. private static halfWidth;
  109265. private _action;
  109266. private _axisTargetedByLeftAndRight;
  109267. private _axisTargetedByUpAndDown;
  109268. private _joystickSensibility;
  109269. private _inversedSensibility;
  109270. private _joystickPointerID;
  109271. private _joystickColor;
  109272. private _joystickPointerPos;
  109273. private _joystickPreviousPointerPos;
  109274. private _joystickPointerStartPos;
  109275. private _deltaJoystickVector;
  109276. private _leftJoystick;
  109277. private _touches;
  109278. private _onPointerDownHandlerRef;
  109279. private _onPointerMoveHandlerRef;
  109280. private _onPointerUpHandlerRef;
  109281. private _onResize;
  109282. /**
  109283. * Creates a new virtual joystick
  109284. * @param leftJoystick defines that the joystick is for left hand (false by default)
  109285. */
  109286. constructor(leftJoystick?: boolean);
  109287. /**
  109288. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  109289. * @param newJoystickSensibility defines the new sensibility
  109290. */
  109291. setJoystickSensibility(newJoystickSensibility: number): void;
  109292. private _onPointerDown;
  109293. private _onPointerMove;
  109294. private _onPointerUp;
  109295. /**
  109296. * Change the color of the virtual joystick
  109297. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  109298. */
  109299. setJoystickColor(newColor: string): void;
  109300. /**
  109301. * Defines a callback to call when the joystick is touched
  109302. * @param action defines the callback
  109303. */
  109304. setActionOnTouch(action: () => any): void;
  109305. /**
  109306. * Defines which axis you'd like to control for left & right
  109307. * @param axis defines the axis to use
  109308. */
  109309. setAxisForLeftRight(axis: JoystickAxis): void;
  109310. /**
  109311. * Defines which axis you'd like to control for up & down
  109312. * @param axis defines the axis to use
  109313. */
  109314. setAxisForUpDown(axis: JoystickAxis): void;
  109315. private _drawVirtualJoystick;
  109316. /**
  109317. * Release internal HTML canvas
  109318. */
  109319. releaseCanvas(): void;
  109320. }
  109321. }
  109322. declare module BABYLON {
  109323. interface FreeCameraInputsManager {
  109324. /**
  109325. * Add virtual joystick input support to the input manager.
  109326. * @returns the current input manager
  109327. */
  109328. addVirtualJoystick(): FreeCameraInputsManager;
  109329. }
  109330. /**
  109331. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  109332. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  109333. */
  109334. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  109335. /**
  109336. * Defines the camera the input is attached to.
  109337. */
  109338. camera: FreeCamera;
  109339. private _leftjoystick;
  109340. private _rightjoystick;
  109341. /**
  109342. * Gets the left stick of the virtual joystick.
  109343. * @returns The virtual Joystick
  109344. */
  109345. getLeftJoystick(): VirtualJoystick;
  109346. /**
  109347. * Gets the right stick of the virtual joystick.
  109348. * @returns The virtual Joystick
  109349. */
  109350. getRightJoystick(): VirtualJoystick;
  109351. /**
  109352. * Update the current camera state depending on the inputs that have been used this frame.
  109353. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  109354. */
  109355. checkInputs(): void;
  109356. /**
  109357. * Attach the input controls to a specific dom element to get the input from.
  109358. * @param element Defines the element the controls should be listened from
  109359. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109360. */
  109361. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  109362. /**
  109363. * Detach the current controls from the specified dom element.
  109364. * @param element Defines the element to stop listening the inputs from
  109365. */
  109366. detachControl(element: Nullable<HTMLElement>): void;
  109367. /**
  109368. * Gets the class name of the current intput.
  109369. * @returns the class name
  109370. */
  109371. getClassName(): string;
  109372. /**
  109373. * Get the friendly name associated with the input class.
  109374. * @returns the input friendly name
  109375. */
  109376. getSimpleName(): string;
  109377. }
  109378. }
  109379. declare module BABYLON {
  109380. /**
  109381. * This represents a FPS type of camera controlled by touch.
  109382. * This is like a universal camera minus the Gamepad controls.
  109383. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  109384. */
  109385. export class TouchCamera extends FreeCamera {
  109386. /**
  109387. * Defines the touch sensibility for rotation.
  109388. * The higher the faster.
  109389. */
  109390. touchAngularSensibility: number;
  109391. /**
  109392. * Defines the touch sensibility for move.
  109393. * The higher the faster.
  109394. */
  109395. touchMoveSensibility: number;
  109396. /**
  109397. * Instantiates a new touch camera.
  109398. * This represents a FPS type of camera controlled by touch.
  109399. * This is like a universal camera minus the Gamepad controls.
  109400. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  109401. * @param name Define the name of the camera in the scene
  109402. * @param position Define the start position of the camera in the scene
  109403. * @param scene Define the scene the camera belongs to
  109404. */
  109405. constructor(name: string, position: Vector3, scene: Scene);
  109406. /**
  109407. * Gets the current object class name.
  109408. * @return the class name
  109409. */
  109410. getClassName(): string;
  109411. /** @hidden */
  109412. _setupInputs(): void;
  109413. }
  109414. }
  109415. declare module BABYLON {
  109416. /**
  109417. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  109418. * being tilted forward or back and left or right.
  109419. */
  109420. export class DeviceOrientationCamera extends FreeCamera {
  109421. private _initialQuaternion;
  109422. private _quaternionCache;
  109423. private _tmpDragQuaternion;
  109424. private _disablePointerInputWhenUsingDeviceOrientation;
  109425. /**
  109426. * Creates a new device orientation camera
  109427. * @param name The name of the camera
  109428. * @param position The start position camera
  109429. * @param scene The scene the camera belongs to
  109430. */
  109431. constructor(name: string, position: Vector3, scene: Scene);
  109432. /**
  109433. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  109434. */
  109435. disablePointerInputWhenUsingDeviceOrientation: boolean;
  109436. private _dragFactor;
  109437. /**
  109438. * Enabled turning on the y axis when the orientation sensor is active
  109439. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  109440. */
  109441. enableHorizontalDragging(dragFactor?: number): void;
  109442. /**
  109443. * Gets the current instance class name ("DeviceOrientationCamera").
  109444. * This helps avoiding instanceof at run time.
  109445. * @returns the class name
  109446. */
  109447. getClassName(): string;
  109448. /**
  109449. * @hidden
  109450. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  109451. */
  109452. _checkInputs(): void;
  109453. /**
  109454. * Reset the camera to its default orientation on the specified axis only.
  109455. * @param axis The axis to reset
  109456. */
  109457. resetToCurrentRotation(axis?: Axis): void;
  109458. }
  109459. }
  109460. declare module BABYLON {
  109461. /**
  109462. * Defines supported buttons for XBox360 compatible gamepads
  109463. */
  109464. export enum Xbox360Button {
  109465. /** A */
  109466. A = 0,
  109467. /** B */
  109468. B = 1,
  109469. /** X */
  109470. X = 2,
  109471. /** Y */
  109472. Y = 3,
  109473. /** Start */
  109474. Start = 4,
  109475. /** Back */
  109476. Back = 5,
  109477. /** Left button */
  109478. LB = 6,
  109479. /** Right button */
  109480. RB = 7,
  109481. /** Left stick */
  109482. LeftStick = 8,
  109483. /** Right stick */
  109484. RightStick = 9
  109485. }
  109486. /** Defines values for XBox360 DPad */
  109487. export enum Xbox360Dpad {
  109488. /** Up */
  109489. Up = 0,
  109490. /** Down */
  109491. Down = 1,
  109492. /** Left */
  109493. Left = 2,
  109494. /** Right */
  109495. Right = 3
  109496. }
  109497. /**
  109498. * Defines a XBox360 gamepad
  109499. */
  109500. export class Xbox360Pad extends Gamepad {
  109501. private _leftTrigger;
  109502. private _rightTrigger;
  109503. private _onlefttriggerchanged;
  109504. private _onrighttriggerchanged;
  109505. private _onbuttondown;
  109506. private _onbuttonup;
  109507. private _ondpaddown;
  109508. private _ondpadup;
  109509. /** Observable raised when a button is pressed */
  109510. onButtonDownObservable: Observable<Xbox360Button>;
  109511. /** Observable raised when a button is released */
  109512. onButtonUpObservable: Observable<Xbox360Button>;
  109513. /** Observable raised when a pad is pressed */
  109514. onPadDownObservable: Observable<Xbox360Dpad>;
  109515. /** Observable raised when a pad is released */
  109516. onPadUpObservable: Observable<Xbox360Dpad>;
  109517. private _buttonA;
  109518. private _buttonB;
  109519. private _buttonX;
  109520. private _buttonY;
  109521. private _buttonBack;
  109522. private _buttonStart;
  109523. private _buttonLB;
  109524. private _buttonRB;
  109525. private _buttonLeftStick;
  109526. private _buttonRightStick;
  109527. private _dPadUp;
  109528. private _dPadDown;
  109529. private _dPadLeft;
  109530. private _dPadRight;
  109531. private _isXboxOnePad;
  109532. /**
  109533. * Creates a new XBox360 gamepad object
  109534. * @param id defines the id of this gamepad
  109535. * @param index defines its index
  109536. * @param gamepad defines the internal HTML gamepad object
  109537. * @param xboxOne defines if it is a XBox One gamepad
  109538. */
  109539. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  109540. /**
  109541. * Defines the callback to call when left trigger is pressed
  109542. * @param callback defines the callback to use
  109543. */
  109544. onlefttriggerchanged(callback: (value: number) => void): void;
  109545. /**
  109546. * Defines the callback to call when right trigger is pressed
  109547. * @param callback defines the callback to use
  109548. */
  109549. onrighttriggerchanged(callback: (value: number) => void): void;
  109550. /**
  109551. * Gets the left trigger value
  109552. */
  109553. /**
  109554. * Sets the left trigger value
  109555. */
  109556. leftTrigger: number;
  109557. /**
  109558. * Gets the right trigger value
  109559. */
  109560. /**
  109561. * Sets the right trigger value
  109562. */
  109563. rightTrigger: number;
  109564. /**
  109565. * Defines the callback to call when a button is pressed
  109566. * @param callback defines the callback to use
  109567. */
  109568. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  109569. /**
  109570. * Defines the callback to call when a button is released
  109571. * @param callback defines the callback to use
  109572. */
  109573. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  109574. /**
  109575. * Defines the callback to call when a pad is pressed
  109576. * @param callback defines the callback to use
  109577. */
  109578. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  109579. /**
  109580. * Defines the callback to call when a pad is released
  109581. * @param callback defines the callback to use
  109582. */
  109583. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  109584. private _setButtonValue;
  109585. private _setDPadValue;
  109586. /**
  109587. * Gets the value of the `A` button
  109588. */
  109589. /**
  109590. * Sets the value of the `A` button
  109591. */
  109592. buttonA: number;
  109593. /**
  109594. * Gets the value of the `B` button
  109595. */
  109596. /**
  109597. * Sets the value of the `B` button
  109598. */
  109599. buttonB: number;
  109600. /**
  109601. * Gets the value of the `X` button
  109602. */
  109603. /**
  109604. * Sets the value of the `X` button
  109605. */
  109606. buttonX: number;
  109607. /**
  109608. * Gets the value of the `Y` button
  109609. */
  109610. /**
  109611. * Sets the value of the `Y` button
  109612. */
  109613. buttonY: number;
  109614. /**
  109615. * Gets the value of the `Start` button
  109616. */
  109617. /**
  109618. * Sets the value of the `Start` button
  109619. */
  109620. buttonStart: number;
  109621. /**
  109622. * Gets the value of the `Back` button
  109623. */
  109624. /**
  109625. * Sets the value of the `Back` button
  109626. */
  109627. buttonBack: number;
  109628. /**
  109629. * Gets the value of the `Left` button
  109630. */
  109631. /**
  109632. * Sets the value of the `Left` button
  109633. */
  109634. buttonLB: number;
  109635. /**
  109636. * Gets the value of the `Right` button
  109637. */
  109638. /**
  109639. * Sets the value of the `Right` button
  109640. */
  109641. buttonRB: number;
  109642. /**
  109643. * Gets the value of the Left joystick
  109644. */
  109645. /**
  109646. * Sets the value of the Left joystick
  109647. */
  109648. buttonLeftStick: number;
  109649. /**
  109650. * Gets the value of the Right joystick
  109651. */
  109652. /**
  109653. * Sets the value of the Right joystick
  109654. */
  109655. buttonRightStick: number;
  109656. /**
  109657. * Gets the value of D-pad up
  109658. */
  109659. /**
  109660. * Sets the value of D-pad up
  109661. */
  109662. dPadUp: number;
  109663. /**
  109664. * Gets the value of D-pad down
  109665. */
  109666. /**
  109667. * Sets the value of D-pad down
  109668. */
  109669. dPadDown: number;
  109670. /**
  109671. * Gets the value of D-pad left
  109672. */
  109673. /**
  109674. * Sets the value of D-pad left
  109675. */
  109676. dPadLeft: number;
  109677. /**
  109678. * Gets the value of D-pad right
  109679. */
  109680. /**
  109681. * Sets the value of D-pad right
  109682. */
  109683. dPadRight: number;
  109684. /**
  109685. * Force the gamepad to synchronize with device values
  109686. */
  109687. update(): void;
  109688. /**
  109689. * Disposes the gamepad
  109690. */
  109691. dispose(): void;
  109692. }
  109693. }
  109694. declare module BABYLON {
  109695. /**
  109696. * Defines supported buttons for DualShock compatible gamepads
  109697. */
  109698. export enum DualShockButton {
  109699. /** Cross */
  109700. Cross = 0,
  109701. /** Circle */
  109702. Circle = 1,
  109703. /** Square */
  109704. Square = 2,
  109705. /** Triangle */
  109706. Triangle = 3,
  109707. /** Options */
  109708. Options = 4,
  109709. /** Share */
  109710. Share = 5,
  109711. /** L1 */
  109712. L1 = 6,
  109713. /** R1 */
  109714. R1 = 7,
  109715. /** Left stick */
  109716. LeftStick = 8,
  109717. /** Right stick */
  109718. RightStick = 9
  109719. }
  109720. /** Defines values for DualShock DPad */
  109721. export enum DualShockDpad {
  109722. /** Up */
  109723. Up = 0,
  109724. /** Down */
  109725. Down = 1,
  109726. /** Left */
  109727. Left = 2,
  109728. /** Right */
  109729. Right = 3
  109730. }
  109731. /**
  109732. * Defines a DualShock gamepad
  109733. */
  109734. export class DualShockPad extends Gamepad {
  109735. private _leftTrigger;
  109736. private _rightTrigger;
  109737. private _onlefttriggerchanged;
  109738. private _onrighttriggerchanged;
  109739. private _onbuttondown;
  109740. private _onbuttonup;
  109741. private _ondpaddown;
  109742. private _ondpadup;
  109743. /** Observable raised when a button is pressed */
  109744. onButtonDownObservable: Observable<DualShockButton>;
  109745. /** Observable raised when a button is released */
  109746. onButtonUpObservable: Observable<DualShockButton>;
  109747. /** Observable raised when a pad is pressed */
  109748. onPadDownObservable: Observable<DualShockDpad>;
  109749. /** Observable raised when a pad is released */
  109750. onPadUpObservable: Observable<DualShockDpad>;
  109751. private _buttonCross;
  109752. private _buttonCircle;
  109753. private _buttonSquare;
  109754. private _buttonTriangle;
  109755. private _buttonShare;
  109756. private _buttonOptions;
  109757. private _buttonL1;
  109758. private _buttonR1;
  109759. private _buttonLeftStick;
  109760. private _buttonRightStick;
  109761. private _dPadUp;
  109762. private _dPadDown;
  109763. private _dPadLeft;
  109764. private _dPadRight;
  109765. /**
  109766. * Creates a new DualShock gamepad object
  109767. * @param id defines the id of this gamepad
  109768. * @param index defines its index
  109769. * @param gamepad defines the internal HTML gamepad object
  109770. */
  109771. constructor(id: string, index: number, gamepad: any);
  109772. /**
  109773. * Defines the callback to call when left trigger is pressed
  109774. * @param callback defines the callback to use
  109775. */
  109776. onlefttriggerchanged(callback: (value: number) => void): void;
  109777. /**
  109778. * Defines the callback to call when right trigger is pressed
  109779. * @param callback defines the callback to use
  109780. */
  109781. onrighttriggerchanged(callback: (value: number) => void): void;
  109782. /**
  109783. * Gets the left trigger value
  109784. */
  109785. /**
  109786. * Sets the left trigger value
  109787. */
  109788. leftTrigger: number;
  109789. /**
  109790. * Gets the right trigger value
  109791. */
  109792. /**
  109793. * Sets the right trigger value
  109794. */
  109795. rightTrigger: number;
  109796. /**
  109797. * Defines the callback to call when a button is pressed
  109798. * @param callback defines the callback to use
  109799. */
  109800. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  109801. /**
  109802. * Defines the callback to call when a button is released
  109803. * @param callback defines the callback to use
  109804. */
  109805. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  109806. /**
  109807. * Defines the callback to call when a pad is pressed
  109808. * @param callback defines the callback to use
  109809. */
  109810. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  109811. /**
  109812. * Defines the callback to call when a pad is released
  109813. * @param callback defines the callback to use
  109814. */
  109815. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  109816. private _setButtonValue;
  109817. private _setDPadValue;
  109818. /**
  109819. * Gets the value of the `Cross` button
  109820. */
  109821. /**
  109822. * Sets the value of the `Cross` button
  109823. */
  109824. buttonCross: number;
  109825. /**
  109826. * Gets the value of the `Circle` button
  109827. */
  109828. /**
  109829. * Sets the value of the `Circle` button
  109830. */
  109831. buttonCircle: number;
  109832. /**
  109833. * Gets the value of the `Square` button
  109834. */
  109835. /**
  109836. * Sets the value of the `Square` button
  109837. */
  109838. buttonSquare: number;
  109839. /**
  109840. * Gets the value of the `Triangle` button
  109841. */
  109842. /**
  109843. * Sets the value of the `Triangle` button
  109844. */
  109845. buttonTriangle: number;
  109846. /**
  109847. * Gets the value of the `Options` button
  109848. */
  109849. /**
  109850. * Sets the value of the `Options` button
  109851. */
  109852. buttonOptions: number;
  109853. /**
  109854. * Gets the value of the `Share` button
  109855. */
  109856. /**
  109857. * Sets the value of the `Share` button
  109858. */
  109859. buttonShare: number;
  109860. /**
  109861. * Gets the value of the `L1` button
  109862. */
  109863. /**
  109864. * Sets the value of the `L1` button
  109865. */
  109866. buttonL1: number;
  109867. /**
  109868. * Gets the value of the `R1` button
  109869. */
  109870. /**
  109871. * Sets the value of the `R1` button
  109872. */
  109873. buttonR1: number;
  109874. /**
  109875. * Gets the value of the Left joystick
  109876. */
  109877. /**
  109878. * Sets the value of the Left joystick
  109879. */
  109880. buttonLeftStick: number;
  109881. /**
  109882. * Gets the value of the Right joystick
  109883. */
  109884. /**
  109885. * Sets the value of the Right joystick
  109886. */
  109887. buttonRightStick: number;
  109888. /**
  109889. * Gets the value of D-pad up
  109890. */
  109891. /**
  109892. * Sets the value of D-pad up
  109893. */
  109894. dPadUp: number;
  109895. /**
  109896. * Gets the value of D-pad down
  109897. */
  109898. /**
  109899. * Sets the value of D-pad down
  109900. */
  109901. dPadDown: number;
  109902. /**
  109903. * Gets the value of D-pad left
  109904. */
  109905. /**
  109906. * Sets the value of D-pad left
  109907. */
  109908. dPadLeft: number;
  109909. /**
  109910. * Gets the value of D-pad right
  109911. */
  109912. /**
  109913. * Sets the value of D-pad right
  109914. */
  109915. dPadRight: number;
  109916. /**
  109917. * Force the gamepad to synchronize with device values
  109918. */
  109919. update(): void;
  109920. /**
  109921. * Disposes the gamepad
  109922. */
  109923. dispose(): void;
  109924. }
  109925. }
  109926. declare module BABYLON {
  109927. /**
  109928. * Manager for handling gamepads
  109929. */
  109930. export class GamepadManager {
  109931. private _scene?;
  109932. private _babylonGamepads;
  109933. private _oneGamepadConnected;
  109934. /** @hidden */
  109935. _isMonitoring: boolean;
  109936. private _gamepadEventSupported;
  109937. private _gamepadSupport;
  109938. /**
  109939. * observable to be triggered when the gamepad controller has been connected
  109940. */
  109941. onGamepadConnectedObservable: Observable<Gamepad>;
  109942. /**
  109943. * observable to be triggered when the gamepad controller has been disconnected
  109944. */
  109945. onGamepadDisconnectedObservable: Observable<Gamepad>;
  109946. private _onGamepadConnectedEvent;
  109947. private _onGamepadDisconnectedEvent;
  109948. /**
  109949. * Initializes the gamepad manager
  109950. * @param _scene BabylonJS scene
  109951. */
  109952. constructor(_scene?: Scene | undefined);
  109953. /**
  109954. * The gamepads in the game pad manager
  109955. */
  109956. readonly gamepads: Gamepad[];
  109957. /**
  109958. * Get the gamepad controllers based on type
  109959. * @param type The type of gamepad controller
  109960. * @returns Nullable gamepad
  109961. */
  109962. getGamepadByType(type?: number): Nullable<Gamepad>;
  109963. /**
  109964. * Disposes the gamepad manager
  109965. */
  109966. dispose(): void;
  109967. private _addNewGamepad;
  109968. private _startMonitoringGamepads;
  109969. private _stopMonitoringGamepads;
  109970. /** @hidden */
  109971. _checkGamepadsStatus(): void;
  109972. private _updateGamepadObjects;
  109973. }
  109974. }
  109975. declare module BABYLON {
  109976. interface Scene {
  109977. /** @hidden */
  109978. _gamepadManager: Nullable<GamepadManager>;
  109979. /**
  109980. * Gets the gamepad manager associated with the scene
  109981. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  109982. */
  109983. gamepadManager: GamepadManager;
  109984. }
  109985. /**
  109986. * Interface representing a free camera inputs manager
  109987. */
  109988. interface FreeCameraInputsManager {
  109989. /**
  109990. * Adds gamepad input support to the FreeCameraInputsManager.
  109991. * @returns the FreeCameraInputsManager
  109992. */
  109993. addGamepad(): FreeCameraInputsManager;
  109994. }
  109995. /**
  109996. * Interface representing an arc rotate camera inputs manager
  109997. */
  109998. interface ArcRotateCameraInputsManager {
  109999. /**
  110000. * Adds gamepad input support to the ArcRotateCamera InputManager.
  110001. * @returns the camera inputs manager
  110002. */
  110003. addGamepad(): ArcRotateCameraInputsManager;
  110004. }
  110005. /**
  110006. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  110007. */
  110008. export class GamepadSystemSceneComponent implements ISceneComponent {
  110009. /**
  110010. * The component name helpfull to identify the component in the list of scene components.
  110011. */
  110012. readonly name: string;
  110013. /**
  110014. * The scene the component belongs to.
  110015. */
  110016. scene: Scene;
  110017. /**
  110018. * Creates a new instance of the component for the given scene
  110019. * @param scene Defines the scene to register the component in
  110020. */
  110021. constructor(scene: Scene);
  110022. /**
  110023. * Registers the component in a given scene
  110024. */
  110025. register(): void;
  110026. /**
  110027. * Rebuilds the elements related to this component in case of
  110028. * context lost for instance.
  110029. */
  110030. rebuild(): void;
  110031. /**
  110032. * Disposes the component and the associated ressources
  110033. */
  110034. dispose(): void;
  110035. private _beforeCameraUpdate;
  110036. }
  110037. }
  110038. declare module BABYLON {
  110039. /**
  110040. * 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,
  110041. * which still works and will still be found in many Playgrounds.
  110042. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  110043. */
  110044. export class UniversalCamera extends TouchCamera {
  110045. /**
  110046. * Defines the gamepad rotation sensiblity.
  110047. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  110048. */
  110049. gamepadAngularSensibility: number;
  110050. /**
  110051. * Defines the gamepad move sensiblity.
  110052. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  110053. */
  110054. gamepadMoveSensibility: number;
  110055. /**
  110056. * 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,
  110057. * which still works and will still be found in many Playgrounds.
  110058. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  110059. * @param name Define the name of the camera in the scene
  110060. * @param position Define the start position of the camera in the scene
  110061. * @param scene Define the scene the camera belongs to
  110062. */
  110063. constructor(name: string, position: Vector3, scene: Scene);
  110064. /**
  110065. * Gets the current object class name.
  110066. * @return the class name
  110067. */
  110068. getClassName(): string;
  110069. }
  110070. }
  110071. declare module BABYLON {
  110072. /**
  110073. * This represents a FPS type of camera. This is only here for back compat purpose.
  110074. * Please use the UniversalCamera instead as both are identical.
  110075. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  110076. */
  110077. export class GamepadCamera extends UniversalCamera {
  110078. /**
  110079. * Instantiates a new Gamepad Camera
  110080. * This represents a FPS type of camera. This is only here for back compat purpose.
  110081. * Please use the UniversalCamera instead as both are identical.
  110082. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  110083. * @param name Define the name of the camera in the scene
  110084. * @param position Define the start position of the camera in the scene
  110085. * @param scene Define the scene the camera belongs to
  110086. */
  110087. constructor(name: string, position: Vector3, scene: Scene);
  110088. /**
  110089. * Gets the current object class name.
  110090. * @return the class name
  110091. */
  110092. getClassName(): string;
  110093. }
  110094. }
  110095. declare module BABYLON {
  110096. /** @hidden */
  110097. export var passPixelShader: {
  110098. name: string;
  110099. shader: string;
  110100. };
  110101. }
  110102. declare module BABYLON {
  110103. /** @hidden */
  110104. export var passCubePixelShader: {
  110105. name: string;
  110106. shader: string;
  110107. };
  110108. }
  110109. declare module BABYLON {
  110110. /**
  110111. * PassPostProcess which produces an output the same as it's input
  110112. */
  110113. export class PassPostProcess extends PostProcess {
  110114. /**
  110115. * Creates the PassPostProcess
  110116. * @param name The name of the effect.
  110117. * @param options The required width/height ratio to downsize to before computing the render pass.
  110118. * @param camera The camera to apply the render pass to.
  110119. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110120. * @param engine The engine which the post process will be applied. (default: current engine)
  110121. * @param reusable If the post process can be reused on the same frame. (default: false)
  110122. * @param textureType The type of texture to be used when performing the post processing.
  110123. * @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)
  110124. */
  110125. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  110126. }
  110127. /**
  110128. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  110129. */
  110130. export class PassCubePostProcess extends PostProcess {
  110131. private _face;
  110132. /**
  110133. * Gets or sets the cube face to display.
  110134. * * 0 is +X
  110135. * * 1 is -X
  110136. * * 2 is +Y
  110137. * * 3 is -Y
  110138. * * 4 is +Z
  110139. * * 5 is -Z
  110140. */
  110141. face: number;
  110142. /**
  110143. * Creates the PassCubePostProcess
  110144. * @param name The name of the effect.
  110145. * @param options The required width/height ratio to downsize to before computing the render pass.
  110146. * @param camera The camera to apply the render pass to.
  110147. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110148. * @param engine The engine which the post process will be applied. (default: current engine)
  110149. * @param reusable If the post process can be reused on the same frame. (default: false)
  110150. * @param textureType The type of texture to be used when performing the post processing.
  110151. * @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)
  110152. */
  110153. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  110154. }
  110155. }
  110156. declare module BABYLON {
  110157. /** @hidden */
  110158. export var anaglyphPixelShader: {
  110159. name: string;
  110160. shader: string;
  110161. };
  110162. }
  110163. declare module BABYLON {
  110164. /**
  110165. * Postprocess used to generate anaglyphic rendering
  110166. */
  110167. export class AnaglyphPostProcess extends PostProcess {
  110168. private _passedProcess;
  110169. /**
  110170. * Creates a new AnaglyphPostProcess
  110171. * @param name defines postprocess name
  110172. * @param options defines creation options or target ratio scale
  110173. * @param rigCameras defines cameras using this postprocess
  110174. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  110175. * @param engine defines hosting engine
  110176. * @param reusable defines if the postprocess will be reused multiple times per frame
  110177. */
  110178. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  110179. }
  110180. }
  110181. declare module BABYLON {
  110182. /**
  110183. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  110184. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  110185. */
  110186. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  110187. /**
  110188. * Creates a new AnaglyphArcRotateCamera
  110189. * @param name defines camera name
  110190. * @param alpha defines alpha angle (in radians)
  110191. * @param beta defines beta angle (in radians)
  110192. * @param radius defines radius
  110193. * @param target defines camera target
  110194. * @param interaxialDistance defines distance between each color axis
  110195. * @param scene defines the hosting scene
  110196. */
  110197. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  110198. /**
  110199. * Gets camera class name
  110200. * @returns AnaglyphArcRotateCamera
  110201. */
  110202. getClassName(): string;
  110203. }
  110204. }
  110205. declare module BABYLON {
  110206. /**
  110207. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  110208. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  110209. */
  110210. export class AnaglyphFreeCamera extends FreeCamera {
  110211. /**
  110212. * Creates a new AnaglyphFreeCamera
  110213. * @param name defines camera name
  110214. * @param position defines initial position
  110215. * @param interaxialDistance defines distance between each color axis
  110216. * @param scene defines the hosting scene
  110217. */
  110218. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  110219. /**
  110220. * Gets camera class name
  110221. * @returns AnaglyphFreeCamera
  110222. */
  110223. getClassName(): string;
  110224. }
  110225. }
  110226. declare module BABYLON {
  110227. /**
  110228. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  110229. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  110230. */
  110231. export class AnaglyphGamepadCamera extends GamepadCamera {
  110232. /**
  110233. * Creates a new AnaglyphGamepadCamera
  110234. * @param name defines camera name
  110235. * @param position defines initial position
  110236. * @param interaxialDistance defines distance between each color axis
  110237. * @param scene defines the hosting scene
  110238. */
  110239. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  110240. /**
  110241. * Gets camera class name
  110242. * @returns AnaglyphGamepadCamera
  110243. */
  110244. getClassName(): string;
  110245. }
  110246. }
  110247. declare module BABYLON {
  110248. /**
  110249. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  110250. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  110251. */
  110252. export class AnaglyphUniversalCamera extends UniversalCamera {
  110253. /**
  110254. * Creates a new AnaglyphUniversalCamera
  110255. * @param name defines camera name
  110256. * @param position defines initial position
  110257. * @param interaxialDistance defines distance between each color axis
  110258. * @param scene defines the hosting scene
  110259. */
  110260. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  110261. /**
  110262. * Gets camera class name
  110263. * @returns AnaglyphUniversalCamera
  110264. */
  110265. getClassName(): string;
  110266. }
  110267. }
  110268. declare module BABYLON {
  110269. /** @hidden */
  110270. export var stereoscopicInterlacePixelShader: {
  110271. name: string;
  110272. shader: string;
  110273. };
  110274. }
  110275. declare module BABYLON {
  110276. /**
  110277. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  110278. */
  110279. export class StereoscopicInterlacePostProcess extends PostProcess {
  110280. private _stepSize;
  110281. private _passedProcess;
  110282. /**
  110283. * Initializes a StereoscopicInterlacePostProcess
  110284. * @param name The name of the effect.
  110285. * @param rigCameras The rig cameras to be appled to the post process
  110286. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  110287. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110288. * @param engine The engine which the post process will be applied. (default: current engine)
  110289. * @param reusable If the post process can be reused on the same frame. (default: false)
  110290. */
  110291. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  110292. }
  110293. }
  110294. declare module BABYLON {
  110295. /**
  110296. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  110297. * @see http://doc.babylonjs.com/features/cameras
  110298. */
  110299. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  110300. /**
  110301. * Creates a new StereoscopicArcRotateCamera
  110302. * @param name defines camera name
  110303. * @param alpha defines alpha angle (in radians)
  110304. * @param beta defines beta angle (in radians)
  110305. * @param radius defines radius
  110306. * @param target defines camera target
  110307. * @param interaxialDistance defines distance between each color axis
  110308. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  110309. * @param scene defines the hosting scene
  110310. */
  110311. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  110312. /**
  110313. * Gets camera class name
  110314. * @returns StereoscopicArcRotateCamera
  110315. */
  110316. getClassName(): string;
  110317. }
  110318. }
  110319. declare module BABYLON {
  110320. /**
  110321. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  110322. * @see http://doc.babylonjs.com/features/cameras
  110323. */
  110324. export class StereoscopicFreeCamera extends FreeCamera {
  110325. /**
  110326. * Creates a new StereoscopicFreeCamera
  110327. * @param name defines camera name
  110328. * @param position defines initial position
  110329. * @param interaxialDistance defines distance between each color axis
  110330. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  110331. * @param scene defines the hosting scene
  110332. */
  110333. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  110334. /**
  110335. * Gets camera class name
  110336. * @returns StereoscopicFreeCamera
  110337. */
  110338. getClassName(): string;
  110339. }
  110340. }
  110341. declare module BABYLON {
  110342. /**
  110343. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  110344. * @see http://doc.babylonjs.com/features/cameras
  110345. */
  110346. export class StereoscopicGamepadCamera extends GamepadCamera {
  110347. /**
  110348. * Creates a new StereoscopicGamepadCamera
  110349. * @param name defines camera name
  110350. * @param position defines initial position
  110351. * @param interaxialDistance defines distance between each color axis
  110352. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  110353. * @param scene defines the hosting scene
  110354. */
  110355. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  110356. /**
  110357. * Gets camera class name
  110358. * @returns StereoscopicGamepadCamera
  110359. */
  110360. getClassName(): string;
  110361. }
  110362. }
  110363. declare module BABYLON {
  110364. /**
  110365. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  110366. * @see http://doc.babylonjs.com/features/cameras
  110367. */
  110368. export class StereoscopicUniversalCamera extends UniversalCamera {
  110369. /**
  110370. * Creates a new StereoscopicUniversalCamera
  110371. * @param name defines camera name
  110372. * @param position defines initial position
  110373. * @param interaxialDistance defines distance between each color axis
  110374. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  110375. * @param scene defines the hosting scene
  110376. */
  110377. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  110378. /**
  110379. * Gets camera class name
  110380. * @returns StereoscopicUniversalCamera
  110381. */
  110382. getClassName(): string;
  110383. }
  110384. }
  110385. declare module BABYLON {
  110386. /**
  110387. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  110388. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  110389. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  110390. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  110391. */
  110392. export class VirtualJoysticksCamera extends FreeCamera {
  110393. /**
  110394. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  110395. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  110396. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  110397. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  110398. * @param name Define the name of the camera in the scene
  110399. * @param position Define the start position of the camera in the scene
  110400. * @param scene Define the scene the camera belongs to
  110401. */
  110402. constructor(name: string, position: Vector3, scene: Scene);
  110403. /**
  110404. * Gets the current object class name.
  110405. * @return the class name
  110406. */
  110407. getClassName(): string;
  110408. }
  110409. }
  110410. declare module BABYLON {
  110411. /**
  110412. * This represents all the required metrics to create a VR camera.
  110413. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  110414. */
  110415. export class VRCameraMetrics {
  110416. /**
  110417. * Define the horizontal resolution off the screen.
  110418. */
  110419. hResolution: number;
  110420. /**
  110421. * Define the vertical resolution off the screen.
  110422. */
  110423. vResolution: number;
  110424. /**
  110425. * Define the horizontal screen size.
  110426. */
  110427. hScreenSize: number;
  110428. /**
  110429. * Define the vertical screen size.
  110430. */
  110431. vScreenSize: number;
  110432. /**
  110433. * Define the vertical screen center position.
  110434. */
  110435. vScreenCenter: number;
  110436. /**
  110437. * Define the distance of the eyes to the screen.
  110438. */
  110439. eyeToScreenDistance: number;
  110440. /**
  110441. * Define the distance between both lenses
  110442. */
  110443. lensSeparationDistance: number;
  110444. /**
  110445. * Define the distance between both viewer's eyes.
  110446. */
  110447. interpupillaryDistance: number;
  110448. /**
  110449. * Define the distortion factor of the VR postprocess.
  110450. * Please, touch with care.
  110451. */
  110452. distortionK: number[];
  110453. /**
  110454. * Define the chromatic aberration correction factors for the VR post process.
  110455. */
  110456. chromaAbCorrection: number[];
  110457. /**
  110458. * Define the scale factor of the post process.
  110459. * The smaller the better but the slower.
  110460. */
  110461. postProcessScaleFactor: number;
  110462. /**
  110463. * Define an offset for the lens center.
  110464. */
  110465. lensCenterOffset: number;
  110466. /**
  110467. * Define if the current vr camera should compensate the distortion of the lense or not.
  110468. */
  110469. compensateDistortion: boolean;
  110470. /**
  110471. * Defines if multiview should be enabled when rendering (Default: false)
  110472. */
  110473. multiviewEnabled: boolean;
  110474. /**
  110475. * Gets the rendering aspect ratio based on the provided resolutions.
  110476. */
  110477. readonly aspectRatio: number;
  110478. /**
  110479. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  110480. */
  110481. readonly aspectRatioFov: number;
  110482. /**
  110483. * @hidden
  110484. */
  110485. readonly leftHMatrix: Matrix;
  110486. /**
  110487. * @hidden
  110488. */
  110489. readonly rightHMatrix: Matrix;
  110490. /**
  110491. * @hidden
  110492. */
  110493. readonly leftPreViewMatrix: Matrix;
  110494. /**
  110495. * @hidden
  110496. */
  110497. readonly rightPreViewMatrix: Matrix;
  110498. /**
  110499. * Get the default VRMetrics based on the most generic setup.
  110500. * @returns the default vr metrics
  110501. */
  110502. static GetDefault(): VRCameraMetrics;
  110503. }
  110504. }
  110505. declare module BABYLON {
  110506. /** @hidden */
  110507. export var vrDistortionCorrectionPixelShader: {
  110508. name: string;
  110509. shader: string;
  110510. };
  110511. }
  110512. declare module BABYLON {
  110513. /**
  110514. * VRDistortionCorrectionPostProcess used for mobile VR
  110515. */
  110516. export class VRDistortionCorrectionPostProcess extends PostProcess {
  110517. private _isRightEye;
  110518. private _distortionFactors;
  110519. private _postProcessScaleFactor;
  110520. private _lensCenterOffset;
  110521. private _scaleIn;
  110522. private _scaleFactor;
  110523. private _lensCenter;
  110524. /**
  110525. * Initializes the VRDistortionCorrectionPostProcess
  110526. * @param name The name of the effect.
  110527. * @param camera The camera to apply the render pass to.
  110528. * @param isRightEye If this is for the right eye distortion
  110529. * @param vrMetrics All the required metrics for the VR camera
  110530. */
  110531. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  110532. }
  110533. }
  110534. declare module BABYLON {
  110535. /**
  110536. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  110537. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  110538. */
  110539. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  110540. /**
  110541. * Creates a new VRDeviceOrientationArcRotateCamera
  110542. * @param name defines camera name
  110543. * @param alpha defines the camera rotation along the logitudinal axis
  110544. * @param beta defines the camera rotation along the latitudinal axis
  110545. * @param radius defines the camera distance from its target
  110546. * @param target defines the camera target
  110547. * @param scene defines the scene the camera belongs to
  110548. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  110549. * @param vrCameraMetrics defines the vr metrics associated to the camera
  110550. */
  110551. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  110552. /**
  110553. * Gets camera class name
  110554. * @returns VRDeviceOrientationArcRotateCamera
  110555. */
  110556. getClassName(): string;
  110557. }
  110558. }
  110559. declare module BABYLON {
  110560. /**
  110561. * Camera used to simulate VR rendering (based on FreeCamera)
  110562. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  110563. */
  110564. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  110565. /**
  110566. * Creates a new VRDeviceOrientationFreeCamera
  110567. * @param name defines camera name
  110568. * @param position defines the start position of the camera
  110569. * @param scene defines the scene the camera belongs to
  110570. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  110571. * @param vrCameraMetrics defines the vr metrics associated to the camera
  110572. */
  110573. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  110574. /**
  110575. * Gets camera class name
  110576. * @returns VRDeviceOrientationFreeCamera
  110577. */
  110578. getClassName(): string;
  110579. }
  110580. }
  110581. declare module BABYLON {
  110582. /**
  110583. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  110584. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  110585. */
  110586. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  110587. /**
  110588. * Creates a new VRDeviceOrientationGamepadCamera
  110589. * @param name defines camera name
  110590. * @param position defines the start position of the camera
  110591. * @param scene defines the scene the camera belongs to
  110592. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  110593. * @param vrCameraMetrics defines the vr metrics associated to the camera
  110594. */
  110595. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  110596. /**
  110597. * Gets camera class name
  110598. * @returns VRDeviceOrientationGamepadCamera
  110599. */
  110600. getClassName(): string;
  110601. }
  110602. }
  110603. declare module BABYLON {
  110604. /** @hidden */
  110605. export var imageProcessingPixelShader: {
  110606. name: string;
  110607. shader: string;
  110608. };
  110609. }
  110610. declare module BABYLON {
  110611. /**
  110612. * ImageProcessingPostProcess
  110613. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  110614. */
  110615. export class ImageProcessingPostProcess extends PostProcess {
  110616. /**
  110617. * Default configuration related to image processing available in the PBR Material.
  110618. */
  110619. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  110620. /**
  110621. * Gets the image processing configuration used either in this material.
  110622. */
  110623. /**
  110624. * Sets the Default image processing configuration used either in the this material.
  110625. *
  110626. * If sets to null, the scene one is in use.
  110627. */
  110628. imageProcessingConfiguration: ImageProcessingConfiguration;
  110629. /**
  110630. * Keep track of the image processing observer to allow dispose and replace.
  110631. */
  110632. private _imageProcessingObserver;
  110633. /**
  110634. * Attaches a new image processing configuration to the PBR Material.
  110635. * @param configuration
  110636. */
  110637. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  110638. /**
  110639. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  110640. */
  110641. /**
  110642. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  110643. */
  110644. colorCurves: Nullable<ColorCurves>;
  110645. /**
  110646. * Gets wether the color curves effect is enabled.
  110647. */
  110648. /**
  110649. * Sets wether the color curves effect is enabled.
  110650. */
  110651. colorCurvesEnabled: boolean;
  110652. /**
  110653. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  110654. */
  110655. /**
  110656. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  110657. */
  110658. colorGradingTexture: Nullable<BaseTexture>;
  110659. /**
  110660. * Gets wether the color grading effect is enabled.
  110661. */
  110662. /**
  110663. * Gets wether the color grading effect is enabled.
  110664. */
  110665. colorGradingEnabled: boolean;
  110666. /**
  110667. * Gets exposure used in the effect.
  110668. */
  110669. /**
  110670. * Sets exposure used in the effect.
  110671. */
  110672. exposure: number;
  110673. /**
  110674. * Gets wether tonemapping is enabled or not.
  110675. */
  110676. /**
  110677. * Sets wether tonemapping is enabled or not
  110678. */
  110679. toneMappingEnabled: boolean;
  110680. /**
  110681. * Gets the type of tone mapping effect.
  110682. */
  110683. /**
  110684. * Sets the type of tone mapping effect.
  110685. */
  110686. toneMappingType: number;
  110687. /**
  110688. * Gets contrast used in the effect.
  110689. */
  110690. /**
  110691. * Sets contrast used in the effect.
  110692. */
  110693. contrast: number;
  110694. /**
  110695. * Gets Vignette stretch size.
  110696. */
  110697. /**
  110698. * Sets Vignette stretch size.
  110699. */
  110700. vignetteStretch: number;
  110701. /**
  110702. * Gets Vignette centre X Offset.
  110703. */
  110704. /**
  110705. * Sets Vignette centre X Offset.
  110706. */
  110707. vignetteCentreX: number;
  110708. /**
  110709. * Gets Vignette centre Y Offset.
  110710. */
  110711. /**
  110712. * Sets Vignette centre Y Offset.
  110713. */
  110714. vignetteCentreY: number;
  110715. /**
  110716. * Gets Vignette weight or intensity of the vignette effect.
  110717. */
  110718. /**
  110719. * Sets Vignette weight or intensity of the vignette effect.
  110720. */
  110721. vignetteWeight: number;
  110722. /**
  110723. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  110724. * if vignetteEnabled is set to true.
  110725. */
  110726. /**
  110727. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  110728. * if vignetteEnabled is set to true.
  110729. */
  110730. vignetteColor: Color4;
  110731. /**
  110732. * Gets Camera field of view used by the Vignette effect.
  110733. */
  110734. /**
  110735. * Sets Camera field of view used by the Vignette effect.
  110736. */
  110737. vignetteCameraFov: number;
  110738. /**
  110739. * Gets the vignette blend mode allowing different kind of effect.
  110740. */
  110741. /**
  110742. * Sets the vignette blend mode allowing different kind of effect.
  110743. */
  110744. vignetteBlendMode: number;
  110745. /**
  110746. * Gets wether the vignette effect is enabled.
  110747. */
  110748. /**
  110749. * Sets wether the vignette effect is enabled.
  110750. */
  110751. vignetteEnabled: boolean;
  110752. private _fromLinearSpace;
  110753. /**
  110754. * Gets wether the input of the processing is in Gamma or Linear Space.
  110755. */
  110756. /**
  110757. * Sets wether the input of the processing is in Gamma or Linear Space.
  110758. */
  110759. fromLinearSpace: boolean;
  110760. /**
  110761. * Defines cache preventing GC.
  110762. */
  110763. private _defines;
  110764. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  110765. /**
  110766. * "ImageProcessingPostProcess"
  110767. * @returns "ImageProcessingPostProcess"
  110768. */
  110769. getClassName(): string;
  110770. protected _updateParameters(): void;
  110771. dispose(camera?: Camera): void;
  110772. }
  110773. }
  110774. declare module BABYLON {
  110775. /**
  110776. * Class containing static functions to help procedurally build meshes
  110777. */
  110778. export class GroundBuilder {
  110779. /**
  110780. * Creates a ground mesh
  110781. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  110782. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  110783. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110784. * @param name defines the name of the mesh
  110785. * @param options defines the options used to create the mesh
  110786. * @param scene defines the hosting scene
  110787. * @returns the ground mesh
  110788. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  110789. */
  110790. static CreateGround(name: string, options: {
  110791. width?: number;
  110792. height?: number;
  110793. subdivisions?: number;
  110794. subdivisionsX?: number;
  110795. subdivisionsY?: number;
  110796. updatable?: boolean;
  110797. }, scene: any): Mesh;
  110798. /**
  110799. * Creates a tiled ground mesh
  110800. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  110801. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  110802. * * 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
  110803. * * 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
  110804. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110805. * @param name defines the name of the mesh
  110806. * @param options defines the options used to create the mesh
  110807. * @param scene defines the hosting scene
  110808. * @returns the tiled ground mesh
  110809. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  110810. */
  110811. static CreateTiledGround(name: string, options: {
  110812. xmin: number;
  110813. zmin: number;
  110814. xmax: number;
  110815. zmax: number;
  110816. subdivisions?: {
  110817. w: number;
  110818. h: number;
  110819. };
  110820. precision?: {
  110821. w: number;
  110822. h: number;
  110823. };
  110824. updatable?: boolean;
  110825. }, scene?: Nullable<Scene>): Mesh;
  110826. /**
  110827. * Creates a ground mesh from a height map
  110828. * * The parameter `url` sets the URL of the height map image resource.
  110829. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  110830. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  110831. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  110832. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  110833. * * 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.
  110834. * * 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).
  110835. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  110836. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110837. * @param name defines the name of the mesh
  110838. * @param url defines the url to the height map
  110839. * @param options defines the options used to create the mesh
  110840. * @param scene defines the hosting scene
  110841. * @returns the ground mesh
  110842. * @see https://doc.babylonjs.com/babylon101/height_map
  110843. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  110844. */
  110845. static CreateGroundFromHeightMap(name: string, url: string, options: {
  110846. width?: number;
  110847. height?: number;
  110848. subdivisions?: number;
  110849. minHeight?: number;
  110850. maxHeight?: number;
  110851. colorFilter?: Color3;
  110852. alphaFilter?: number;
  110853. updatable?: boolean;
  110854. onReady?: (mesh: GroundMesh) => void;
  110855. }, scene?: Nullable<Scene>): GroundMesh;
  110856. }
  110857. }
  110858. declare module BABYLON {
  110859. /**
  110860. * Class containing static functions to help procedurally build meshes
  110861. */
  110862. export class TorusBuilder {
  110863. /**
  110864. * Creates a torus mesh
  110865. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  110866. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  110867. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  110868. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110869. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110870. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110871. * @param name defines the name of the mesh
  110872. * @param options defines the options used to create the mesh
  110873. * @param scene defines the hosting scene
  110874. * @returns the torus mesh
  110875. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  110876. */
  110877. static CreateTorus(name: string, options: {
  110878. diameter?: number;
  110879. thickness?: number;
  110880. tessellation?: number;
  110881. updatable?: boolean;
  110882. sideOrientation?: number;
  110883. frontUVs?: Vector4;
  110884. backUVs?: Vector4;
  110885. }, scene: any): Mesh;
  110886. }
  110887. }
  110888. declare module BABYLON {
  110889. /**
  110890. * Class containing static functions to help procedurally build meshes
  110891. */
  110892. export class CylinderBuilder {
  110893. /**
  110894. * Creates a cylinder or a cone mesh
  110895. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  110896. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  110897. * * 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.
  110898. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  110899. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  110900. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  110901. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  110902. * * 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).
  110903. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  110904. * * 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).
  110905. * * 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
  110906. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  110907. * * 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
  110908. * * 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.
  110909. * * If `enclose` is false, a ring surface is one element.
  110910. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  110911. * * 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
  110912. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110913. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110914. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110915. * @param name defines the name of the mesh
  110916. * @param options defines the options used to create the mesh
  110917. * @param scene defines the hosting scene
  110918. * @returns the cylinder mesh
  110919. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  110920. */
  110921. static CreateCylinder(name: string, options: {
  110922. height?: number;
  110923. diameterTop?: number;
  110924. diameterBottom?: number;
  110925. diameter?: number;
  110926. tessellation?: number;
  110927. subdivisions?: number;
  110928. arc?: number;
  110929. faceColors?: Color4[];
  110930. faceUV?: Vector4[];
  110931. updatable?: boolean;
  110932. hasRings?: boolean;
  110933. enclose?: boolean;
  110934. cap?: number;
  110935. sideOrientation?: number;
  110936. frontUVs?: Vector4;
  110937. backUVs?: Vector4;
  110938. }, scene: any): Mesh;
  110939. }
  110940. }
  110941. declare module BABYLON {
  110942. /**
  110943. * States of the webXR experience
  110944. */
  110945. export enum WebXRState {
  110946. /**
  110947. * Transitioning to being in XR mode
  110948. */
  110949. ENTERING_XR = 0,
  110950. /**
  110951. * Transitioning to non XR mode
  110952. */
  110953. EXITING_XR = 1,
  110954. /**
  110955. * In XR mode and presenting
  110956. */
  110957. IN_XR = 2,
  110958. /**
  110959. * Not entered XR mode
  110960. */
  110961. NOT_IN_XR = 3
  110962. }
  110963. /**
  110964. * Abstraction of the XR render target
  110965. */
  110966. export interface WebXRRenderTarget extends IDisposable {
  110967. /**
  110968. * xrpresent context of the canvas which can be used to display/mirror xr content
  110969. */
  110970. canvasContext: WebGLRenderingContext;
  110971. /**
  110972. * xr layer for the canvas
  110973. */
  110974. xrLayer: Nullable<XRWebGLLayer>;
  110975. /**
  110976. * Initializes the xr layer for the session
  110977. * @param xrSession xr session
  110978. * @returns a promise that will resolve once the XR Layer has been created
  110979. */
  110980. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  110981. }
  110982. }
  110983. declare module BABYLON {
  110984. /**
  110985. * COnfiguration object for WebXR output canvas
  110986. */
  110987. export class WebXRManagedOutputCanvasOptions {
  110988. /**
  110989. * Options for this XR Layer output
  110990. */
  110991. canvasOptions: XRWebGLLayerOptions;
  110992. /**
  110993. * CSS styling for a newly created canvas (if not provided)
  110994. */
  110995. newCanvasCssStyle?: string;
  110996. /**
  110997. * Get the default values of the configuration object
  110998. * @returns default values of this configuration object
  110999. */
  111000. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  111001. }
  111002. /**
  111003. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  111004. */
  111005. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  111006. private configuration;
  111007. private _engine;
  111008. private _canvas;
  111009. /**
  111010. * xrpresent context of the canvas which can be used to display/mirror xr content
  111011. */
  111012. canvasContext: WebGLRenderingContext;
  111013. /**
  111014. * xr layer for the canvas
  111015. */
  111016. xrLayer: Nullable<XRWebGLLayer>;
  111017. /**
  111018. * Initializes the xr layer for the session
  111019. * @param xrSession xr session
  111020. * @returns a promise that will resolve once the XR Layer has been created
  111021. */
  111022. initializeXRLayerAsync(xrSession: any): any;
  111023. /**
  111024. * Initializes the canvas to be added/removed upon entering/exiting xr
  111025. * @param engine the Babylon engine
  111026. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  111027. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  111028. * @param configuration optional configuration for this canvas output. defaults will be used if not provided
  111029. */
  111030. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>, configuration?: WebXRManagedOutputCanvasOptions);
  111031. /**
  111032. * Disposes of the object
  111033. */
  111034. dispose(): void;
  111035. private _setManagedOutputCanvas;
  111036. private _addCanvas;
  111037. private _removeCanvas;
  111038. }
  111039. }
  111040. declare module BABYLON {
  111041. /**
  111042. * Manages an XRSession to work with Babylon's engine
  111043. * @see https://doc.babylonjs.com/how_to/webxr
  111044. */
  111045. export class WebXRSessionManager implements IDisposable {
  111046. /** The scene which the session should be created for */
  111047. scene: Scene;
  111048. /**
  111049. * Fires every time a new xrFrame arrives which can be used to update the camera
  111050. */
  111051. onXRFrameObservable: Observable<XRFrame>;
  111052. /**
  111053. * Fires when the xr session is ended either by the device or manually done
  111054. */
  111055. onXRSessionEnded: Observable<any>;
  111056. /**
  111057. * Fires when the xr session is ended either by the device or manually done
  111058. */
  111059. onXRSessionInit: Observable<XRSession>;
  111060. /**
  111061. * Underlying xr session
  111062. */
  111063. session: XRSession;
  111064. /**
  111065. * Type of reference space used when creating the session
  111066. */
  111067. referenceSpace: XRReferenceSpace;
  111068. /**
  111069. * Current XR frame
  111070. */
  111071. currentFrame: Nullable<XRFrame>;
  111072. private _xrNavigator;
  111073. private baseLayer;
  111074. private _rttProvider;
  111075. private _sessionEnded;
  111076. /**
  111077. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  111078. * @param scene The scene which the session should be created for
  111079. */
  111080. constructor(
  111081. /** The scene which the session should be created for */
  111082. scene: Scene);
  111083. /**
  111084. * Initializes the manager
  111085. * After initialization enterXR can be called to start an XR session
  111086. * @returns Promise which resolves after it is initialized
  111087. */
  111088. initializeAsync(): Promise<void>;
  111089. /**
  111090. * Initializes an xr session
  111091. * @param xrSessionMode mode to initialize
  111092. * @param optionalFeatures defines optional values to pass to the session builder
  111093. * @returns a promise which will resolve once the session has been initialized
  111094. */
  111095. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): Promise<XRSession>;
  111096. /**
  111097. * Sets the reference space on the xr session
  111098. * @param referenceSpace space to set
  111099. * @returns a promise that will resolve once the reference space has been set
  111100. */
  111101. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  111102. /**
  111103. * Updates the render state of the session
  111104. * @param state state to set
  111105. * @returns a promise that resolves once the render state has been updated
  111106. */
  111107. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  111108. /**
  111109. * Starts rendering to the xr layer
  111110. * @returns a promise that will resolve once rendering has started
  111111. */
  111112. startRenderingToXRAsync(): Promise<void>;
  111113. /**
  111114. * Gets the correct render target texture to be rendered this frame for this eye
  111115. * @param eye the eye for which to get the render target
  111116. * @returns the render target for the specified eye
  111117. */
  111118. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  111119. /**
  111120. * Stops the xrSession and restores the renderloop
  111121. * @returns Promise which resolves after it exits XR
  111122. */
  111123. exitXRAsync(): Promise<void>;
  111124. /**
  111125. * Checks if a session would be supported for the creation options specified
  111126. * @param sessionMode session mode to check if supported eg. immersive-vr
  111127. * @returns true if supported
  111128. */
  111129. supportsSessionAsync(sessionMode: XRSessionMode): Promise<boolean>;
  111130. /**
  111131. * Creates a WebXRRenderTarget object for the XR session
  111132. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  111133. * @param options optional options to provide when creating a new render target
  111134. * @returns a WebXR render target to which the session can render
  111135. */
  111136. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>, options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  111137. /**
  111138. * @hidden
  111139. * Converts the render layer of xrSession to a render target
  111140. * @param session session to create render target for
  111141. * @param scene scene the new render target should be created for
  111142. * @param baseLayer the webgl layer to create the render target for
  111143. */
  111144. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  111145. /**
  111146. * Disposes of the session manager
  111147. */
  111148. dispose(): void;
  111149. /**
  111150. * Gets a promise returning true when fullfiled if the given session mode is supported
  111151. * @param sessionMode defines the session to test
  111152. * @returns a promise
  111153. */
  111154. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  111155. }
  111156. }
  111157. declare module BABYLON {
  111158. /**
  111159. * WebXR Camera which holds the views for the xrSession
  111160. * @see https://doc.babylonjs.com/how_to/webxr
  111161. */
  111162. export class WebXRCamera extends FreeCamera {
  111163. /**
  111164. * Is the camera in debug mode. Used when using an emulator
  111165. */
  111166. debugMode: boolean;
  111167. /**
  111168. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  111169. * @param name the name of the camera
  111170. * @param scene the scene to add the camera to
  111171. */
  111172. constructor(name: string, scene: Scene);
  111173. private _updateNumberOfRigCameras;
  111174. /** @hidden */
  111175. _updateForDualEyeDebugging(): void;
  111176. /**
  111177. * Updates the cameras position from the current pose information of the XR session
  111178. * @param xrSessionManager the session containing pose information
  111179. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  111180. */
  111181. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  111182. }
  111183. }
  111184. declare module BABYLON {
  111185. /**
  111186. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  111187. * @see https://doc.babylonjs.com/how_to/webxr
  111188. */
  111189. export class WebXRExperienceHelper implements IDisposable {
  111190. private scene;
  111191. /**
  111192. * 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
  111193. */
  111194. container: AbstractMesh;
  111195. /**
  111196. * Camera used to render xr content
  111197. */
  111198. camera: WebXRCamera;
  111199. /**
  111200. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  111201. */
  111202. state: WebXRState;
  111203. private _setState;
  111204. private static _TmpVector;
  111205. /**
  111206. * Fires when the state of the experience helper has changed
  111207. */
  111208. onStateChangedObservable: Observable<WebXRState>;
  111209. /** Session manager used to keep track of xr session */
  111210. sessionManager: WebXRSessionManager;
  111211. private _nonVRCamera;
  111212. private _originalSceneAutoClear;
  111213. private _supported;
  111214. /**
  111215. * Creates the experience helper
  111216. * @param scene the scene to attach the experience helper to
  111217. * @returns a promise for the experience helper
  111218. */
  111219. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  111220. /**
  111221. * Creates a WebXRExperienceHelper
  111222. * @param scene The scene the helper should be created in
  111223. */
  111224. private constructor();
  111225. /**
  111226. * Exits XR mode and returns the scene to its original state
  111227. * @returns promise that resolves after xr mode has exited
  111228. */
  111229. exitXRAsync(): Promise<void>;
  111230. /**
  111231. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  111232. * @param sessionMode options for the XR session
  111233. * @param referenceSpaceType frame of reference of the XR session
  111234. * @param renderTarget the output canvas that will be used to enter XR mode
  111235. * @returns promise that resolves after xr mode has entered
  111236. */
  111237. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): Promise<WebXRSessionManager>;
  111238. /**
  111239. * Updates the global position of the camera by moving the camera's container
  111240. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  111241. * @param position The desired global position of the camera
  111242. */
  111243. setPositionOfCameraUsingContainer(position: Vector3): void;
  111244. /**
  111245. * Rotates the xr camera by rotating the camera's container around the camera's position
  111246. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  111247. * @param rotation the desired quaternion rotation to apply to the camera
  111248. */
  111249. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  111250. /**
  111251. * Disposes of the experience helper
  111252. */
  111253. dispose(): void;
  111254. }
  111255. }
  111256. declare module BABYLON {
  111257. /**
  111258. * Represents an XR input
  111259. */
  111260. export class WebXRController {
  111261. private scene;
  111262. /** The underlying input source for the controller */
  111263. inputSource: XRInputSource;
  111264. private parentContainer;
  111265. /**
  111266. * 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
  111267. */
  111268. grip?: AbstractMesh;
  111269. /**
  111270. * Pointer which can be used to select objects or attach a visible laser to
  111271. */
  111272. pointer: AbstractMesh;
  111273. private _gamepadMode;
  111274. /**
  111275. * If available, this is the gamepad object related to this controller.
  111276. * Using this object it is possible to get click events and trackpad changes of the
  111277. * webxr controller that is currently being used.
  111278. */
  111279. gamepadController?: WebVRController;
  111280. /**
  111281. * Event that fires when the controller is removed/disposed
  111282. */
  111283. onDisposeObservable: Observable<{}>;
  111284. private _tmpQuaternion;
  111285. private _tmpVector;
  111286. /**
  111287. * Creates the controller
  111288. * @see https://doc.babylonjs.com/how_to/webxr
  111289. * @param scene the scene which the controller should be associated to
  111290. * @param inputSource the underlying input source for the controller
  111291. * @param parentContainer parent that the controller meshes should be children of
  111292. */
  111293. constructor(scene: Scene,
  111294. /** The underlying input source for the controller */
  111295. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  111296. /**
  111297. * Updates the controller pose based on the given XRFrame
  111298. * @param xrFrame xr frame to update the pose with
  111299. * @param referenceSpace reference space to use
  111300. */
  111301. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  111302. /**
  111303. * Gets a world space ray coming from the controller
  111304. * @param result the resulting ray
  111305. */
  111306. getWorldPointerRayToRef(result: Ray): void;
  111307. /**
  111308. * Get the scene associated with this controller
  111309. * @returns the scene object
  111310. */
  111311. getScene(): Scene;
  111312. /**
  111313. * Disposes of the object
  111314. */
  111315. dispose(): void;
  111316. }
  111317. }
  111318. declare module BABYLON {
  111319. /**
  111320. * XR input used to track XR inputs such as controllers/rays
  111321. */
  111322. export class WebXRInput implements IDisposable {
  111323. /**
  111324. * Base experience the input listens to
  111325. */
  111326. baseExperience: WebXRExperienceHelper;
  111327. /**
  111328. * XR controllers being tracked
  111329. */
  111330. controllers: Array<WebXRController>;
  111331. private _frameObserver;
  111332. private _stateObserver;
  111333. /**
  111334. * Event when a controller has been connected/added
  111335. */
  111336. onControllerAddedObservable: Observable<WebXRController>;
  111337. /**
  111338. * Event when a controller has been removed/disconnected
  111339. */
  111340. onControllerRemovedObservable: Observable<WebXRController>;
  111341. /**
  111342. * Initializes the WebXRInput
  111343. * @param baseExperience experience helper which the input should be created for
  111344. */
  111345. constructor(
  111346. /**
  111347. * Base experience the input listens to
  111348. */
  111349. baseExperience: WebXRExperienceHelper);
  111350. private _onInputSourcesChange;
  111351. private _addAndRemoveControllers;
  111352. /**
  111353. * Disposes of the object
  111354. */
  111355. dispose(): void;
  111356. }
  111357. }
  111358. declare module BABYLON {
  111359. /**
  111360. * Class used to represent data loading progression
  111361. */
  111362. export class SceneLoaderProgressEvent {
  111363. /** defines if data length to load can be evaluated */
  111364. readonly lengthComputable: boolean;
  111365. /** defines the loaded data length */
  111366. readonly loaded: number;
  111367. /** defines the data length to load */
  111368. readonly total: number;
  111369. /**
  111370. * Create a new progress event
  111371. * @param lengthComputable defines if data length to load can be evaluated
  111372. * @param loaded defines the loaded data length
  111373. * @param total defines the data length to load
  111374. */
  111375. constructor(
  111376. /** defines if data length to load can be evaluated */
  111377. lengthComputable: boolean,
  111378. /** defines the loaded data length */
  111379. loaded: number,
  111380. /** defines the data length to load */
  111381. total: number);
  111382. /**
  111383. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  111384. * @param event defines the source event
  111385. * @returns a new SceneLoaderProgressEvent
  111386. */
  111387. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  111388. }
  111389. /**
  111390. * Interface used by SceneLoader plugins to define supported file extensions
  111391. */
  111392. export interface ISceneLoaderPluginExtensions {
  111393. /**
  111394. * Defines the list of supported extensions
  111395. */
  111396. [extension: string]: {
  111397. isBinary: boolean;
  111398. };
  111399. }
  111400. /**
  111401. * Interface used by SceneLoader plugin factory
  111402. */
  111403. export interface ISceneLoaderPluginFactory {
  111404. /**
  111405. * Defines the name of the factory
  111406. */
  111407. name: string;
  111408. /**
  111409. * Function called to create a new plugin
  111410. * @return the new plugin
  111411. */
  111412. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  111413. /**
  111414. * The callback that returns true if the data can be directly loaded.
  111415. * @param data string containing the file data
  111416. * @returns if the data can be loaded directly
  111417. */
  111418. canDirectLoad?(data: string): boolean;
  111419. }
  111420. /**
  111421. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  111422. */
  111423. export interface ISceneLoaderPluginBase {
  111424. /**
  111425. * The friendly name of this plugin.
  111426. */
  111427. name: string;
  111428. /**
  111429. * The file extensions supported by this plugin.
  111430. */
  111431. extensions: string | ISceneLoaderPluginExtensions;
  111432. /**
  111433. * The callback called when loading from a url.
  111434. * @param scene scene loading this url
  111435. * @param url url to load
  111436. * @param onSuccess callback called when the file successfully loads
  111437. * @param onProgress callback called while file is loading (if the server supports this mode)
  111438. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  111439. * @param onError callback called when the file fails to load
  111440. * @returns a file request object
  111441. */
  111442. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  111443. /**
  111444. * The callback called when loading from a file object.
  111445. * @param scene scene loading this file
  111446. * @param file defines the file to load
  111447. * @param onSuccess defines the callback to call when data is loaded
  111448. * @param onProgress defines the callback to call during loading process
  111449. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  111450. * @param onError defines the callback to call when an error occurs
  111451. * @returns a file request object
  111452. */
  111453. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  111454. /**
  111455. * The callback that returns true if the data can be directly loaded.
  111456. * @param data string containing the file data
  111457. * @returns if the data can be loaded directly
  111458. */
  111459. canDirectLoad?(data: string): boolean;
  111460. /**
  111461. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  111462. * @param scene scene loading this data
  111463. * @param data string containing the data
  111464. * @returns data to pass to the plugin
  111465. */
  111466. directLoad?(scene: Scene, data: string): any;
  111467. /**
  111468. * The callback that allows custom handling of the root url based on the response url.
  111469. * @param rootUrl the original root url
  111470. * @param responseURL the response url if available
  111471. * @returns the new root url
  111472. */
  111473. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  111474. }
  111475. /**
  111476. * Interface used to define a SceneLoader plugin
  111477. */
  111478. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  111479. /**
  111480. * Import meshes into a scene.
  111481. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  111482. * @param scene The scene to import into
  111483. * @param data The data to import
  111484. * @param rootUrl The root url for scene and resources
  111485. * @param meshes The meshes array to import into
  111486. * @param particleSystems The particle systems array to import into
  111487. * @param skeletons The skeletons array to import into
  111488. * @param onError The callback when import fails
  111489. * @returns True if successful or false otherwise
  111490. */
  111491. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  111492. /**
  111493. * Load into a scene.
  111494. * @param scene The scene to load into
  111495. * @param data The data to import
  111496. * @param rootUrl The root url for scene and resources
  111497. * @param onError The callback when import fails
  111498. * @returns True if successful or false otherwise
  111499. */
  111500. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  111501. /**
  111502. * Load into an asset container.
  111503. * @param scene The scene to load into
  111504. * @param data The data to import
  111505. * @param rootUrl The root url for scene and resources
  111506. * @param onError The callback when import fails
  111507. * @returns The loaded asset container
  111508. */
  111509. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  111510. }
  111511. /**
  111512. * Interface used to define an async SceneLoader plugin
  111513. */
  111514. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  111515. /**
  111516. * Import meshes into a scene.
  111517. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  111518. * @param scene The scene to import into
  111519. * @param data The data to import
  111520. * @param rootUrl The root url for scene and resources
  111521. * @param onProgress The callback when the load progresses
  111522. * @param fileName Defines the name of the file to load
  111523. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  111524. */
  111525. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  111526. meshes: AbstractMesh[];
  111527. particleSystems: IParticleSystem[];
  111528. skeletons: Skeleton[];
  111529. animationGroups: AnimationGroup[];
  111530. }>;
  111531. /**
  111532. * Load into a scene.
  111533. * @param scene The scene to load into
  111534. * @param data The data to import
  111535. * @param rootUrl The root url for scene and resources
  111536. * @param onProgress The callback when the load progresses
  111537. * @param fileName Defines the name of the file to load
  111538. * @returns Nothing
  111539. */
  111540. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  111541. /**
  111542. * Load into an asset container.
  111543. * @param scene The scene to load into
  111544. * @param data The data to import
  111545. * @param rootUrl The root url for scene and resources
  111546. * @param onProgress The callback when the load progresses
  111547. * @param fileName Defines the name of the file to load
  111548. * @returns The loaded asset container
  111549. */
  111550. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  111551. }
  111552. /**
  111553. * Class used to load scene from various file formats using registered plugins
  111554. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  111555. */
  111556. export class SceneLoader {
  111557. /**
  111558. * No logging while loading
  111559. */
  111560. static readonly NO_LOGGING: number;
  111561. /**
  111562. * Minimal logging while loading
  111563. */
  111564. static readonly MINIMAL_LOGGING: number;
  111565. /**
  111566. * Summary logging while loading
  111567. */
  111568. static readonly SUMMARY_LOGGING: number;
  111569. /**
  111570. * Detailled logging while loading
  111571. */
  111572. static readonly DETAILED_LOGGING: number;
  111573. /**
  111574. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  111575. */
  111576. static ForceFullSceneLoadingForIncremental: boolean;
  111577. /**
  111578. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  111579. */
  111580. static ShowLoadingScreen: boolean;
  111581. /**
  111582. * Defines the current logging level (while loading the scene)
  111583. * @ignorenaming
  111584. */
  111585. static loggingLevel: number;
  111586. /**
  111587. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  111588. */
  111589. static CleanBoneMatrixWeights: boolean;
  111590. /**
  111591. * Event raised when a plugin is used to load a scene
  111592. */
  111593. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  111594. private static _registeredPlugins;
  111595. private static _getDefaultPlugin;
  111596. private static _getPluginForExtension;
  111597. private static _getPluginForDirectLoad;
  111598. private static _getPluginForFilename;
  111599. private static _getDirectLoad;
  111600. private static _loadData;
  111601. private static _getFileInfo;
  111602. /**
  111603. * Gets a plugin that can load the given extension
  111604. * @param extension defines the extension to load
  111605. * @returns a plugin or null if none works
  111606. */
  111607. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  111608. /**
  111609. * Gets a boolean indicating that the given extension can be loaded
  111610. * @param extension defines the extension to load
  111611. * @returns true if the extension is supported
  111612. */
  111613. static IsPluginForExtensionAvailable(extension: string): boolean;
  111614. /**
  111615. * Adds a new plugin to the list of registered plugins
  111616. * @param plugin defines the plugin to add
  111617. */
  111618. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  111619. /**
  111620. * Import meshes into a scene
  111621. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  111622. * @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)
  111623. * @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)
  111624. * @param scene the instance of BABYLON.Scene to append to
  111625. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  111626. * @param onProgress a callback with a progress event for each file being loaded
  111627. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  111628. * @param pluginExtension the extension used to determine the plugin
  111629. * @returns The loaded plugin
  111630. */
  111631. 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>;
  111632. /**
  111633. * Import meshes into a scene
  111634. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  111635. * @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)
  111636. * @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)
  111637. * @param scene the instance of BABYLON.Scene to append to
  111638. * @param onProgress a callback with a progress event for each file being loaded
  111639. * @param pluginExtension the extension used to determine the plugin
  111640. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  111641. */
  111642. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  111643. meshes: AbstractMesh[];
  111644. particleSystems: IParticleSystem[];
  111645. skeletons: Skeleton[];
  111646. animationGroups: AnimationGroup[];
  111647. }>;
  111648. /**
  111649. * Load a scene
  111650. * @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)
  111651. * @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)
  111652. * @param engine is the instance of BABYLON.Engine to use to create the scene
  111653. * @param onSuccess a callback with the scene when import succeeds
  111654. * @param onProgress a callback with a progress event for each file being loaded
  111655. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  111656. * @param pluginExtension the extension used to determine the plugin
  111657. * @returns The loaded plugin
  111658. */
  111659. 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>;
  111660. /**
  111661. * Load a scene
  111662. * @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)
  111663. * @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)
  111664. * @param engine is the instance of BABYLON.Engine to use to create the scene
  111665. * @param onProgress a callback with a progress event for each file being loaded
  111666. * @param pluginExtension the extension used to determine the plugin
  111667. * @returns The loaded scene
  111668. */
  111669. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  111670. /**
  111671. * Append a scene
  111672. * @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)
  111673. * @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)
  111674. * @param scene is the instance of BABYLON.Scene to append to
  111675. * @param onSuccess a callback with the scene when import succeeds
  111676. * @param onProgress a callback with a progress event for each file being loaded
  111677. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  111678. * @param pluginExtension the extension used to determine the plugin
  111679. * @returns The loaded plugin
  111680. */
  111681. 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>;
  111682. /**
  111683. * Append a scene
  111684. * @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)
  111685. * @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)
  111686. * @param scene is the instance of BABYLON.Scene to append to
  111687. * @param onProgress a callback with a progress event for each file being loaded
  111688. * @param pluginExtension the extension used to determine the plugin
  111689. * @returns The given scene
  111690. */
  111691. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  111692. /**
  111693. * Load a scene into an asset container
  111694. * @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)
  111695. * @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)
  111696. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  111697. * @param onSuccess a callback with the scene when import succeeds
  111698. * @param onProgress a callback with a progress event for each file being loaded
  111699. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  111700. * @param pluginExtension the extension used to determine the plugin
  111701. * @returns The loaded plugin
  111702. */
  111703. 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>;
  111704. /**
  111705. * Load a scene into an asset container
  111706. * @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)
  111707. * @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)
  111708. * @param scene is the instance of Scene to append to
  111709. * @param onProgress a callback with a progress event for each file being loaded
  111710. * @param pluginExtension the extension used to determine the plugin
  111711. * @returns The loaded asset container
  111712. */
  111713. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  111714. }
  111715. }
  111716. declare module BABYLON {
  111717. /**
  111718. * Generic Controller
  111719. */
  111720. export class GenericController extends WebVRController {
  111721. /**
  111722. * Base Url for the controller model.
  111723. */
  111724. static readonly MODEL_BASE_URL: string;
  111725. /**
  111726. * File name for the controller model.
  111727. */
  111728. static readonly MODEL_FILENAME: string;
  111729. /**
  111730. * Creates a new GenericController from a gamepad
  111731. * @param vrGamepad the gamepad that the controller should be created from
  111732. */
  111733. constructor(vrGamepad: any);
  111734. /**
  111735. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111736. * @param scene scene in which to add meshes
  111737. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111738. */
  111739. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  111740. /**
  111741. * Called once for each button that changed state since the last frame
  111742. * @param buttonIdx Which button index changed
  111743. * @param state New state of the button
  111744. * @param changes Which properties on the state changed since last frame
  111745. */
  111746. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111747. }
  111748. }
  111749. declare module BABYLON {
  111750. /**
  111751. * Defines the WindowsMotionController object that the state of the windows motion controller
  111752. */
  111753. export class WindowsMotionController extends WebVRController {
  111754. /**
  111755. * The base url used to load the left and right controller models
  111756. */
  111757. static MODEL_BASE_URL: string;
  111758. /**
  111759. * The name of the left controller model file
  111760. */
  111761. static MODEL_LEFT_FILENAME: string;
  111762. /**
  111763. * The name of the right controller model file
  111764. */
  111765. static MODEL_RIGHT_FILENAME: string;
  111766. /**
  111767. * The controller name prefix for this controller type
  111768. */
  111769. static readonly GAMEPAD_ID_PREFIX: string;
  111770. /**
  111771. * The controller id pattern for this controller type
  111772. */
  111773. private static readonly GAMEPAD_ID_PATTERN;
  111774. private _loadedMeshInfo;
  111775. protected readonly _mapping: {
  111776. buttons: string[];
  111777. buttonMeshNames: {
  111778. 'trigger': string;
  111779. 'menu': string;
  111780. 'grip': string;
  111781. 'thumbstick': string;
  111782. 'trackpad': string;
  111783. };
  111784. buttonObservableNames: {
  111785. 'trigger': string;
  111786. 'menu': string;
  111787. 'grip': string;
  111788. 'thumbstick': string;
  111789. 'trackpad': string;
  111790. };
  111791. axisMeshNames: string[];
  111792. pointingPoseMeshName: string;
  111793. };
  111794. /**
  111795. * Fired when the trackpad on this controller is clicked
  111796. */
  111797. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  111798. /**
  111799. * Fired when the trackpad on this controller is modified
  111800. */
  111801. onTrackpadValuesChangedObservable: Observable<StickValues>;
  111802. /**
  111803. * The current x and y values of this controller's trackpad
  111804. */
  111805. trackpad: StickValues;
  111806. /**
  111807. * Creates a new WindowsMotionController from a gamepad
  111808. * @param vrGamepad the gamepad that the controller should be created from
  111809. */
  111810. constructor(vrGamepad: any);
  111811. /**
  111812. * Fired when the trigger on this controller is modified
  111813. */
  111814. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111815. /**
  111816. * Fired when the menu button on this controller is modified
  111817. */
  111818. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111819. /**
  111820. * Fired when the grip button on this controller is modified
  111821. */
  111822. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111823. /**
  111824. * Fired when the thumbstick button on this controller is modified
  111825. */
  111826. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111827. /**
  111828. * Fired when the touchpad button on this controller is modified
  111829. */
  111830. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111831. /**
  111832. * Fired when the touchpad values on this controller are modified
  111833. */
  111834. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  111835. protected _updateTrackpad(): void;
  111836. /**
  111837. * Called once per frame by the engine.
  111838. */
  111839. update(): void;
  111840. /**
  111841. * Called once for each button that changed state since the last frame
  111842. * @param buttonIdx Which button index changed
  111843. * @param state New state of the button
  111844. * @param changes Which properties on the state changed since last frame
  111845. */
  111846. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111847. /**
  111848. * Moves the buttons on the controller mesh based on their current state
  111849. * @param buttonName the name of the button to move
  111850. * @param buttonValue the value of the button which determines the buttons new position
  111851. */
  111852. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  111853. /**
  111854. * Moves the axis on the controller mesh based on its current state
  111855. * @param axis the index of the axis
  111856. * @param axisValue the value of the axis which determines the meshes new position
  111857. * @hidden
  111858. */
  111859. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  111860. /**
  111861. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111862. * @param scene scene in which to add meshes
  111863. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111864. */
  111865. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  111866. /**
  111867. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  111868. * can be transformed by button presses and axes values, based on this._mapping.
  111869. *
  111870. * @param scene scene in which the meshes exist
  111871. * @param meshes list of meshes that make up the controller model to process
  111872. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  111873. */
  111874. private processModel;
  111875. private createMeshInfo;
  111876. /**
  111877. * Gets the ray of the controller in the direction the controller is pointing
  111878. * @param length the length the resulting ray should be
  111879. * @returns a ray in the direction the controller is pointing
  111880. */
  111881. getForwardRay(length?: number): Ray;
  111882. /**
  111883. * Disposes of the controller
  111884. */
  111885. dispose(): void;
  111886. }
  111887. /**
  111888. * This class represents a new windows motion controller in XR.
  111889. */
  111890. export class XRWindowsMotionController extends WindowsMotionController {
  111891. /**
  111892. * Changing the original WIndowsMotionController mapping to fir the new mapping
  111893. */
  111894. protected readonly _mapping: {
  111895. buttons: string[];
  111896. buttonMeshNames: {
  111897. 'trigger': string;
  111898. 'menu': string;
  111899. 'grip': string;
  111900. 'thumbstick': string;
  111901. 'trackpad': string;
  111902. };
  111903. buttonObservableNames: {
  111904. 'trigger': string;
  111905. 'menu': string;
  111906. 'grip': string;
  111907. 'thumbstick': string;
  111908. 'trackpad': string;
  111909. };
  111910. axisMeshNames: string[];
  111911. pointingPoseMeshName: string;
  111912. };
  111913. /**
  111914. * Construct a new XR-Based windows motion controller
  111915. *
  111916. * @param gamepadInfo the gamepad object from the browser
  111917. */
  111918. constructor(gamepadInfo: any);
  111919. /**
  111920. * holds the thumbstick values (X,Y)
  111921. */
  111922. thumbstickValues: StickValues;
  111923. /**
  111924. * Fired when the thumbstick on this controller is clicked
  111925. */
  111926. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  111927. /**
  111928. * Fired when the thumbstick on this controller is modified
  111929. */
  111930. onThumbstickValuesChangedObservable: Observable<StickValues>;
  111931. /**
  111932. * Fired when the touchpad button on this controller is modified
  111933. */
  111934. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  111935. /**
  111936. * Fired when the touchpad values on this controller are modified
  111937. */
  111938. onTrackpadValuesChangedObservable: Observable<StickValues>;
  111939. /**
  111940. * Fired when the thumbstick button on this controller is modified
  111941. * here to prevent breaking changes
  111942. */
  111943. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111944. /**
  111945. * updating the thumbstick(!) and not the trackpad.
  111946. * This is named this way due to the difference between WebVR and XR and to avoid
  111947. * changing the parent class.
  111948. */
  111949. protected _updateTrackpad(): void;
  111950. /**
  111951. * Disposes the class with joy
  111952. */
  111953. dispose(): void;
  111954. }
  111955. }
  111956. declare module BABYLON {
  111957. /**
  111958. * Oculus Touch Controller
  111959. */
  111960. export class OculusTouchController extends WebVRController {
  111961. /**
  111962. * Base Url for the controller model.
  111963. */
  111964. static MODEL_BASE_URL: string;
  111965. /**
  111966. * File name for the left controller model.
  111967. */
  111968. static MODEL_LEFT_FILENAME: string;
  111969. /**
  111970. * File name for the right controller model.
  111971. */
  111972. static MODEL_RIGHT_FILENAME: string;
  111973. /**
  111974. * Base Url for the Quest controller model.
  111975. */
  111976. static QUEST_MODEL_BASE_URL: string;
  111977. /**
  111978. * @hidden
  111979. * If the controllers are running on a device that needs the updated Quest controller models
  111980. */
  111981. static _IsQuest: boolean;
  111982. /**
  111983. * Fired when the secondary trigger on this controller is modified
  111984. */
  111985. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  111986. /**
  111987. * Fired when the thumb rest on this controller is modified
  111988. */
  111989. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  111990. /**
  111991. * Creates a new OculusTouchController from a gamepad
  111992. * @param vrGamepad the gamepad that the controller should be created from
  111993. */
  111994. constructor(vrGamepad: any);
  111995. /**
  111996. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111997. * @param scene scene in which to add meshes
  111998. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111999. */
  112000. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  112001. /**
  112002. * Fired when the A button on this controller is modified
  112003. */
  112004. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  112005. /**
  112006. * Fired when the B button on this controller is modified
  112007. */
  112008. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  112009. /**
  112010. * Fired when the X button on this controller is modified
  112011. */
  112012. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  112013. /**
  112014. * Fired when the Y button on this controller is modified
  112015. */
  112016. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  112017. /**
  112018. * Called once for each button that changed state since the last frame
  112019. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  112020. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  112021. * 2) secondary trigger (same)
  112022. * 3) A (right) X (left), touch, pressed = value
  112023. * 4) B / Y
  112024. * 5) thumb rest
  112025. * @param buttonIdx Which button index changed
  112026. * @param state New state of the button
  112027. * @param changes Which properties on the state changed since last frame
  112028. */
  112029. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  112030. }
  112031. }
  112032. declare module BABYLON {
  112033. /**
  112034. * Vive Controller
  112035. */
  112036. export class ViveController extends WebVRController {
  112037. /**
  112038. * Base Url for the controller model.
  112039. */
  112040. static MODEL_BASE_URL: string;
  112041. /**
  112042. * File name for the controller model.
  112043. */
  112044. static MODEL_FILENAME: string;
  112045. /**
  112046. * Creates a new ViveController from a gamepad
  112047. * @param vrGamepad the gamepad that the controller should be created from
  112048. */
  112049. constructor(vrGamepad: any);
  112050. /**
  112051. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  112052. * @param scene scene in which to add meshes
  112053. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  112054. */
  112055. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  112056. /**
  112057. * Fired when the left button on this controller is modified
  112058. */
  112059. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  112060. /**
  112061. * Fired when the right button on this controller is modified
  112062. */
  112063. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  112064. /**
  112065. * Fired when the menu button on this controller is modified
  112066. */
  112067. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  112068. /**
  112069. * Called once for each button that changed state since the last frame
  112070. * Vive mapping:
  112071. * 0: touchpad
  112072. * 1: trigger
  112073. * 2: left AND right buttons
  112074. * 3: menu button
  112075. * @param buttonIdx Which button index changed
  112076. * @param state New state of the button
  112077. * @param changes Which properties on the state changed since last frame
  112078. */
  112079. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  112080. }
  112081. }
  112082. declare module BABYLON {
  112083. /**
  112084. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  112085. */
  112086. export class WebXRControllerModelLoader {
  112087. /**
  112088. * an observable that triggers when a new model (the mesh itself) was initialized.
  112089. * To know when the mesh was loaded use the controller's own modelLoaded() method
  112090. */
  112091. onControllerModelLoaded: Observable<WebXRController>;
  112092. /**
  112093. * Creates the WebXRControllerModelLoader
  112094. * @param input xr input that creates the controllers
  112095. */
  112096. constructor(input: WebXRInput);
  112097. }
  112098. }
  112099. declare module BABYLON {
  112100. /**
  112101. * Handles pointer input automatically for the pointer of XR controllers
  112102. */
  112103. export class WebXRControllerPointerSelection {
  112104. private static _idCounter;
  112105. private _tmpRay;
  112106. /**
  112107. * Creates a WebXRControllerPointerSelection
  112108. * @param input input manager to setup pointer selection
  112109. */
  112110. constructor(input: WebXRInput);
  112111. private _convertNormalToDirectionOfRay;
  112112. private _updatePointerDistance;
  112113. }
  112114. }
  112115. declare module BABYLON {
  112116. /**
  112117. * Enables teleportation
  112118. */
  112119. export class WebXRControllerTeleportation {
  112120. private _teleportationFillColor;
  112121. private _teleportationBorderColor;
  112122. private _tmpRay;
  112123. private _tmpVector;
  112124. /**
  112125. * Creates a WebXRControllerTeleportation
  112126. * @param input input manager to add teleportation to
  112127. * @param floorMeshes floormeshes which can be teleported to
  112128. */
  112129. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  112130. }
  112131. }
  112132. declare module BABYLON {
  112133. /**
  112134. * Button which can be used to enter a different mode of XR
  112135. */
  112136. export class WebXREnterExitUIButton {
  112137. /** button element */
  112138. element: HTMLElement;
  112139. /** XR initialization options for the button */
  112140. sessionMode: XRSessionMode;
  112141. /** Reference space type */
  112142. referenceSpaceType: XRReferenceSpaceType;
  112143. /**
  112144. * Creates a WebXREnterExitUIButton
  112145. * @param element button element
  112146. * @param sessionMode XR initialization session mode
  112147. * @param referenceSpaceType the type of reference space to be used
  112148. */
  112149. constructor(
  112150. /** button element */
  112151. element: HTMLElement,
  112152. /** XR initialization options for the button */
  112153. sessionMode: XRSessionMode,
  112154. /** Reference space type */
  112155. referenceSpaceType: XRReferenceSpaceType);
  112156. /**
  112157. * Overwritable function which can be used to update the button's visuals when the state changes
  112158. * @param activeButton the current active button in the UI
  112159. */
  112160. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  112161. }
  112162. /**
  112163. * Options to create the webXR UI
  112164. */
  112165. export class WebXREnterExitUIOptions {
  112166. /**
  112167. * Context to enter xr with
  112168. */
  112169. renderTarget?: Nullable<WebXRRenderTarget>;
  112170. /**
  112171. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  112172. */
  112173. customButtons?: Array<WebXREnterExitUIButton>;
  112174. /**
  112175. * A session mode to use when creating the default button.
  112176. * Default is immersive-vr
  112177. */
  112178. sessionMode?: XRSessionMode;
  112179. /**
  112180. * A reference space type to use when creating the default button.
  112181. * Default is local-floor
  112182. */
  112183. referenceSpaceType?: XRReferenceSpaceType;
  112184. }
  112185. /**
  112186. * UI to allow the user to enter/exit XR mode
  112187. */
  112188. export class WebXREnterExitUI implements IDisposable {
  112189. private scene;
  112190. /** version of the options passed to this UI */
  112191. options: WebXREnterExitUIOptions;
  112192. private _overlay;
  112193. private _buttons;
  112194. private _activeButton;
  112195. /**
  112196. * Fired every time the active button is changed.
  112197. *
  112198. * When xr is entered via a button that launches xr that button will be the callback parameter
  112199. *
  112200. * When exiting xr the callback parameter will be null)
  112201. */
  112202. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  112203. /**
  112204. * Creates UI to allow the user to enter/exit XR mode
  112205. * @param scene the scene to add the ui to
  112206. * @param helper the xr experience helper to enter/exit xr with
  112207. * @param options options to configure the UI
  112208. * @returns the created ui
  112209. */
  112210. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  112211. /**
  112212. *
  112213. * @param scene babylon scene object to use
  112214. * @param options (read-only) version of the options passed to this UI
  112215. */
  112216. private constructor();
  112217. private _updateButtons;
  112218. /**
  112219. * Disposes of the object
  112220. */
  112221. dispose(): void;
  112222. }
  112223. }
  112224. declare module BABYLON {
  112225. /**
  112226. * Options for the default xr helper
  112227. */
  112228. export class WebXRDefaultExperienceOptions {
  112229. /**
  112230. * Floor meshes that should be used for teleporting
  112231. */
  112232. floorMeshes: Array<AbstractMesh>;
  112233. /**
  112234. * Enable or disable default UI to enter XR
  112235. */
  112236. disableDefaultUI?: boolean;
  112237. /**
  112238. * optional configuration for the output canvas
  112239. */
  112240. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  112241. /**
  112242. * optional UI options. This can be used among other to change session mode and reference space type
  112243. */
  112244. uiOptions?: WebXREnterExitUIOptions;
  112245. }
  112246. /**
  112247. * Default experience which provides a similar setup to the previous webVRExperience
  112248. */
  112249. export class WebXRDefaultExperience {
  112250. /**
  112251. * Base experience
  112252. */
  112253. baseExperience: WebXRExperienceHelper;
  112254. /**
  112255. * Input experience extension
  112256. */
  112257. input: WebXRInput;
  112258. /**
  112259. * Loads the controller models
  112260. */
  112261. controllerModelLoader: WebXRControllerModelLoader;
  112262. /**
  112263. * Enables laser pointer and selection
  112264. */
  112265. pointerSelection: WebXRControllerPointerSelection;
  112266. /**
  112267. * Enables teleportation
  112268. */
  112269. teleportation: WebXRControllerTeleportation;
  112270. /**
  112271. * Enables ui for entering/exiting xr
  112272. */
  112273. enterExitUI: WebXREnterExitUI;
  112274. /**
  112275. * Default target xr should render to
  112276. */
  112277. renderTarget: WebXRRenderTarget;
  112278. /**
  112279. * Creates the default xr experience
  112280. * @param scene scene
  112281. * @param options options for basic configuration
  112282. * @returns resulting WebXRDefaultExperience
  112283. */
  112284. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  112285. private constructor();
  112286. /**
  112287. * DIsposes of the experience helper
  112288. */
  112289. dispose(): void;
  112290. }
  112291. }
  112292. declare module BABYLON {
  112293. /**
  112294. * Options to modify the vr teleportation behavior.
  112295. */
  112296. export interface VRTeleportationOptions {
  112297. /**
  112298. * The name of the mesh which should be used as the teleportation floor. (default: null)
  112299. */
  112300. floorMeshName?: string;
  112301. /**
  112302. * A list of meshes to be used as the teleportation floor. (default: empty)
  112303. */
  112304. floorMeshes?: Mesh[];
  112305. /**
  112306. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  112307. */
  112308. teleportationMode?: number;
  112309. /**
  112310. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  112311. */
  112312. teleportationTime?: number;
  112313. /**
  112314. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  112315. */
  112316. teleportationSpeed?: number;
  112317. /**
  112318. * The easing function used in the animation or null for Linear. (default CircleEase)
  112319. */
  112320. easingFunction?: EasingFunction;
  112321. }
  112322. /**
  112323. * Options to modify the vr experience helper's behavior.
  112324. */
  112325. export interface VRExperienceHelperOptions extends WebVROptions {
  112326. /**
  112327. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  112328. */
  112329. createDeviceOrientationCamera?: boolean;
  112330. /**
  112331. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  112332. */
  112333. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  112334. /**
  112335. * Uses the main button on the controller to toggle the laser casted. (default: true)
  112336. */
  112337. laserToggle?: boolean;
  112338. /**
  112339. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  112340. */
  112341. floorMeshes?: Mesh[];
  112342. /**
  112343. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  112344. */
  112345. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  112346. /**
  112347. * Defines if WebXR should be used instead of WebVR (if available)
  112348. */
  112349. useXR?: boolean;
  112350. }
  112351. /**
  112352. * Event containing information after VR has been entered
  112353. */
  112354. export class OnAfterEnteringVRObservableEvent {
  112355. /**
  112356. * If entering vr was successful
  112357. */
  112358. success: boolean;
  112359. }
  112360. /**
  112361. * Helps to quickly add VR support to an existing scene.
  112362. * See http://doc.babylonjs.com/how_to/webvr_helper
  112363. */
  112364. export class VRExperienceHelper {
  112365. /** Options to modify the vr experience helper's behavior. */
  112366. webVROptions: VRExperienceHelperOptions;
  112367. private _scene;
  112368. private _position;
  112369. private _btnVR;
  112370. private _btnVRDisplayed;
  112371. private _webVRsupported;
  112372. private _webVRready;
  112373. private _webVRrequesting;
  112374. private _webVRpresenting;
  112375. private _hasEnteredVR;
  112376. private _fullscreenVRpresenting;
  112377. private _inputElement;
  112378. private _webVRCamera;
  112379. private _vrDeviceOrientationCamera;
  112380. private _deviceOrientationCamera;
  112381. private _existingCamera;
  112382. private _onKeyDown;
  112383. private _onVrDisplayPresentChange;
  112384. private _onVRDisplayChanged;
  112385. private _onVRRequestPresentStart;
  112386. private _onVRRequestPresentComplete;
  112387. /**
  112388. * Gets or sets a boolean indicating that gaze can be enabled even if pointer lock is not engage (useful on iOS where fullscreen mode and pointer lock are not supported)
  112389. */
  112390. enableGazeEvenWhenNoPointerLock: boolean;
  112391. /**
  112392. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  112393. */
  112394. exitVROnDoubleTap: boolean;
  112395. /**
  112396. * Observable raised right before entering VR.
  112397. */
  112398. onEnteringVRObservable: Observable<VRExperienceHelper>;
  112399. /**
  112400. * Observable raised when entering VR has completed.
  112401. */
  112402. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  112403. /**
  112404. * Observable raised when exiting VR.
  112405. */
  112406. onExitingVRObservable: Observable<VRExperienceHelper>;
  112407. /**
  112408. * Observable raised when controller mesh is loaded.
  112409. */
  112410. onControllerMeshLoadedObservable: Observable<WebVRController>;
  112411. /** Return this.onEnteringVRObservable
  112412. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  112413. */
  112414. readonly onEnteringVR: Observable<VRExperienceHelper>;
  112415. /** Return this.onExitingVRObservable
  112416. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  112417. */
  112418. readonly onExitingVR: Observable<VRExperienceHelper>;
  112419. /** Return this.onControllerMeshLoadedObservable
  112420. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  112421. */
  112422. readonly onControllerMeshLoaded: Observable<WebVRController>;
  112423. private _rayLength;
  112424. private _useCustomVRButton;
  112425. private _teleportationRequested;
  112426. private _teleportActive;
  112427. private _floorMeshName;
  112428. private _floorMeshesCollection;
  112429. private _teleportationMode;
  112430. private _teleportationTime;
  112431. private _teleportationSpeed;
  112432. private _teleportationEasing;
  112433. private _rotationAllowed;
  112434. private _teleportBackwardsVector;
  112435. private _teleportationTarget;
  112436. private _isDefaultTeleportationTarget;
  112437. private _postProcessMove;
  112438. private _teleportationFillColor;
  112439. private _teleportationBorderColor;
  112440. private _rotationAngle;
  112441. private _haloCenter;
  112442. private _cameraGazer;
  112443. private _padSensibilityUp;
  112444. private _padSensibilityDown;
  112445. private _leftController;
  112446. private _rightController;
  112447. /**
  112448. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  112449. */
  112450. onNewMeshSelected: Observable<AbstractMesh>;
  112451. /**
  112452. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  112453. * This observable will provide the mesh and the controller used to select the mesh
  112454. */
  112455. onMeshSelectedWithController: Observable<{
  112456. mesh: AbstractMesh;
  112457. controller: WebVRController;
  112458. }>;
  112459. /**
  112460. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  112461. */
  112462. onNewMeshPicked: Observable<PickingInfo>;
  112463. private _circleEase;
  112464. /**
  112465. * Observable raised before camera teleportation
  112466. */
  112467. onBeforeCameraTeleport: Observable<Vector3>;
  112468. /**
  112469. * Observable raised after camera teleportation
  112470. */
  112471. onAfterCameraTeleport: Observable<Vector3>;
  112472. /**
  112473. * Observable raised when current selected mesh gets unselected
  112474. */
  112475. onSelectedMeshUnselected: Observable<AbstractMesh>;
  112476. private _raySelectionPredicate;
  112477. /**
  112478. * To be optionaly changed by user to define custom ray selection
  112479. */
  112480. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  112481. /**
  112482. * To be optionaly changed by user to define custom selection logic (after ray selection)
  112483. */
  112484. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  112485. /**
  112486. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  112487. */
  112488. teleportationEnabled: boolean;
  112489. private _defaultHeight;
  112490. private _teleportationInitialized;
  112491. private _interactionsEnabled;
  112492. private _interactionsRequested;
  112493. private _displayGaze;
  112494. private _displayLaserPointer;
  112495. /**
  112496. * The mesh used to display where the user is going to teleport.
  112497. */
  112498. /**
  112499. * Sets the mesh to be used to display where the user is going to teleport.
  112500. */
  112501. teleportationTarget: Mesh;
  112502. /**
  112503. * 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
  112504. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  112505. * See http://doc.babylonjs.com/resources/baking_transformations
  112506. */
  112507. gazeTrackerMesh: Mesh;
  112508. /**
  112509. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  112510. */
  112511. updateGazeTrackerScale: boolean;
  112512. /**
  112513. * If the gaze trackers color should be updated when selecting meshes
  112514. */
  112515. updateGazeTrackerColor: boolean;
  112516. /**
  112517. * If the controller laser color should be updated when selecting meshes
  112518. */
  112519. updateControllerLaserColor: boolean;
  112520. /**
  112521. * The gaze tracking mesh corresponding to the left controller
  112522. */
  112523. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  112524. /**
  112525. * The gaze tracking mesh corresponding to the right controller
  112526. */
  112527. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  112528. /**
  112529. * If the ray of the gaze should be displayed.
  112530. */
  112531. /**
  112532. * Sets if the ray of the gaze should be displayed.
  112533. */
  112534. displayGaze: boolean;
  112535. /**
  112536. * If the ray of the LaserPointer should be displayed.
  112537. */
  112538. /**
  112539. * Sets if the ray of the LaserPointer should be displayed.
  112540. */
  112541. displayLaserPointer: boolean;
  112542. /**
  112543. * The deviceOrientationCamera used as the camera when not in VR.
  112544. */
  112545. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  112546. /**
  112547. * Based on the current WebVR support, returns the current VR camera used.
  112548. */
  112549. readonly currentVRCamera: Nullable<Camera>;
  112550. /**
  112551. * The webVRCamera which is used when in VR.
  112552. */
  112553. readonly webVRCamera: WebVRFreeCamera;
  112554. /**
  112555. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  112556. */
  112557. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  112558. /**
  112559. * The html button that is used to trigger entering into VR.
  112560. */
  112561. readonly vrButton: Nullable<HTMLButtonElement>;
  112562. private readonly _teleportationRequestInitiated;
  112563. /**
  112564. * Defines wether or not Pointer lock should be requested when switching to
  112565. * full screen.
  112566. */
  112567. requestPointerLockOnFullScreen: boolean;
  112568. /**
  112569. * If asking to force XR, this will be populated with the default xr experience
  112570. */
  112571. xr: WebXRDefaultExperience;
  112572. /**
  112573. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  112574. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  112575. */
  112576. xrTestDone: boolean;
  112577. /**
  112578. * Instantiates a VRExperienceHelper.
  112579. * Helps to quickly add VR support to an existing scene.
  112580. * @param scene The scene the VRExperienceHelper belongs to.
  112581. * @param webVROptions Options to modify the vr experience helper's behavior.
  112582. */
  112583. constructor(scene: Scene,
  112584. /** Options to modify the vr experience helper's behavior. */
  112585. webVROptions?: VRExperienceHelperOptions);
  112586. private completeVRInit;
  112587. private _onDefaultMeshLoaded;
  112588. private _onResize;
  112589. private _onFullscreenChange;
  112590. /**
  112591. * Gets a value indicating if we are currently in VR mode.
  112592. */
  112593. readonly isInVRMode: boolean;
  112594. private onVrDisplayPresentChange;
  112595. private onVRDisplayChanged;
  112596. private moveButtonToBottomRight;
  112597. private displayVRButton;
  112598. private updateButtonVisibility;
  112599. private _cachedAngularSensibility;
  112600. /**
  112601. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  112602. * Otherwise, will use the fullscreen API.
  112603. */
  112604. enterVR(): void;
  112605. /**
  112606. * Attempt to exit VR, or fullscreen.
  112607. */
  112608. exitVR(): void;
  112609. /**
  112610. * The position of the vr experience helper.
  112611. */
  112612. /**
  112613. * Sets the position of the vr experience helper.
  112614. */
  112615. position: Vector3;
  112616. /**
  112617. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  112618. */
  112619. enableInteractions(): void;
  112620. private readonly _noControllerIsActive;
  112621. private beforeRender;
  112622. private _isTeleportationFloor;
  112623. /**
  112624. * Adds a floor mesh to be used for teleportation.
  112625. * @param floorMesh the mesh to be used for teleportation.
  112626. */
  112627. addFloorMesh(floorMesh: Mesh): void;
  112628. /**
  112629. * Removes a floor mesh from being used for teleportation.
  112630. * @param floorMesh the mesh to be removed.
  112631. */
  112632. removeFloorMesh(floorMesh: Mesh): void;
  112633. /**
  112634. * Enables interactions and teleportation using the VR controllers and gaze.
  112635. * @param vrTeleportationOptions options to modify teleportation behavior.
  112636. */
  112637. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  112638. private _onNewGamepadConnected;
  112639. private _tryEnableInteractionOnController;
  112640. private _onNewGamepadDisconnected;
  112641. private _enableInteractionOnController;
  112642. private _checkTeleportWithRay;
  112643. private _checkRotate;
  112644. private _checkTeleportBackwards;
  112645. private _enableTeleportationOnController;
  112646. private _createTeleportationCircles;
  112647. private _displayTeleportationTarget;
  112648. private _hideTeleportationTarget;
  112649. private _rotateCamera;
  112650. private _moveTeleportationSelectorTo;
  112651. private _workingVector;
  112652. private _workingQuaternion;
  112653. private _workingMatrix;
  112654. /**
  112655. * Time Constant Teleportation Mode
  112656. */
  112657. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  112658. /**
  112659. * Speed Constant Teleportation Mode
  112660. */
  112661. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  112662. /**
  112663. * Teleports the users feet to the desired location
  112664. * @param location The location where the user's feet should be placed
  112665. */
  112666. teleportCamera(location: Vector3): void;
  112667. private _convertNormalToDirectionOfRay;
  112668. private _castRayAndSelectObject;
  112669. private _notifySelectedMeshUnselected;
  112670. /**
  112671. * Sets the color of the laser ray from the vr controllers.
  112672. * @param color new color for the ray.
  112673. */
  112674. changeLaserColor(color: Color3): void;
  112675. /**
  112676. * Sets the color of the ray from the vr headsets gaze.
  112677. * @param color new color for the ray.
  112678. */
  112679. changeGazeColor(color: Color3): void;
  112680. /**
  112681. * Exits VR and disposes of the vr experience helper
  112682. */
  112683. dispose(): void;
  112684. /**
  112685. * Gets the name of the VRExperienceHelper class
  112686. * @returns "VRExperienceHelper"
  112687. */
  112688. getClassName(): string;
  112689. }
  112690. }
  112691. declare module BABYLON {
  112692. /**
  112693. * Contains an array of blocks representing the octree
  112694. */
  112695. export interface IOctreeContainer<T> {
  112696. /**
  112697. * Blocks within the octree
  112698. */
  112699. blocks: Array<OctreeBlock<T>>;
  112700. }
  112701. /**
  112702. * Class used to store a cell in an octree
  112703. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  112704. */
  112705. export class OctreeBlock<T> {
  112706. /**
  112707. * Gets the content of the current block
  112708. */
  112709. entries: T[];
  112710. /**
  112711. * Gets the list of block children
  112712. */
  112713. blocks: Array<OctreeBlock<T>>;
  112714. private _depth;
  112715. private _maxDepth;
  112716. private _capacity;
  112717. private _minPoint;
  112718. private _maxPoint;
  112719. private _boundingVectors;
  112720. private _creationFunc;
  112721. /**
  112722. * Creates a new block
  112723. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  112724. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  112725. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  112726. * @param depth defines the current depth of this block in the octree
  112727. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  112728. * @param creationFunc defines a callback to call when an element is added to the block
  112729. */
  112730. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  112731. /**
  112732. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  112733. */
  112734. readonly capacity: number;
  112735. /**
  112736. * Gets the minimum vector (in world space) of the block's bounding box
  112737. */
  112738. readonly minPoint: Vector3;
  112739. /**
  112740. * Gets the maximum vector (in world space) of the block's bounding box
  112741. */
  112742. readonly maxPoint: Vector3;
  112743. /**
  112744. * Add a new element to this block
  112745. * @param entry defines the element to add
  112746. */
  112747. addEntry(entry: T): void;
  112748. /**
  112749. * Remove an element from this block
  112750. * @param entry defines the element to remove
  112751. */
  112752. removeEntry(entry: T): void;
  112753. /**
  112754. * Add an array of elements to this block
  112755. * @param entries defines the array of elements to add
  112756. */
  112757. addEntries(entries: T[]): void;
  112758. /**
  112759. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  112760. * @param frustumPlanes defines the frustum planes to test
  112761. * @param selection defines the array to store current content if selection is positive
  112762. * @param allowDuplicate defines if the selection array can contains duplicated entries
  112763. */
  112764. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  112765. /**
  112766. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  112767. * @param sphereCenter defines the bounding sphere center
  112768. * @param sphereRadius defines the bounding sphere radius
  112769. * @param selection defines the array to store current content if selection is positive
  112770. * @param allowDuplicate defines if the selection array can contains duplicated entries
  112771. */
  112772. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  112773. /**
  112774. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  112775. * @param ray defines the ray to test with
  112776. * @param selection defines the array to store current content if selection is positive
  112777. */
  112778. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  112779. /**
  112780. * Subdivide the content into child blocks (this block will then be empty)
  112781. */
  112782. createInnerBlocks(): void;
  112783. /**
  112784. * @hidden
  112785. */
  112786. 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;
  112787. }
  112788. }
  112789. declare module BABYLON {
  112790. /**
  112791. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  112792. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  112793. */
  112794. export class Octree<T> {
  112795. /** 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.) */
  112796. maxDepth: number;
  112797. /**
  112798. * Blocks within the octree containing objects
  112799. */
  112800. blocks: Array<OctreeBlock<T>>;
  112801. /**
  112802. * Content stored in the octree
  112803. */
  112804. dynamicContent: T[];
  112805. private _maxBlockCapacity;
  112806. private _selectionContent;
  112807. private _creationFunc;
  112808. /**
  112809. * Creates a octree
  112810. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  112811. * @param creationFunc function to be used to instatiate the octree
  112812. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  112813. * @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.)
  112814. */
  112815. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  112816. /** 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.) */
  112817. maxDepth?: number);
  112818. /**
  112819. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  112820. * @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);
  112821. * @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);
  112822. * @param entries meshes to be added to the octree blocks
  112823. */
  112824. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  112825. /**
  112826. * Adds a mesh to the octree
  112827. * @param entry Mesh to add to the octree
  112828. */
  112829. addMesh(entry: T): void;
  112830. /**
  112831. * Remove an element from the octree
  112832. * @param entry defines the element to remove
  112833. */
  112834. removeMesh(entry: T): void;
  112835. /**
  112836. * Selects an array of meshes within the frustum
  112837. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  112838. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  112839. * @returns array of meshes within the frustum
  112840. */
  112841. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  112842. /**
  112843. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  112844. * @param sphereCenter defines the bounding sphere center
  112845. * @param sphereRadius defines the bounding sphere radius
  112846. * @param allowDuplicate defines if the selection array can contains duplicated entries
  112847. * @returns an array of objects that intersect the sphere
  112848. */
  112849. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  112850. /**
  112851. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  112852. * @param ray defines the ray to test with
  112853. * @returns array of intersected objects
  112854. */
  112855. intersectsRay(ray: Ray): SmartArray<T>;
  112856. /**
  112857. * Adds a mesh into the octree block if it intersects the block
  112858. */
  112859. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  112860. /**
  112861. * Adds a submesh into the octree block if it intersects the block
  112862. */
  112863. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  112864. }
  112865. }
  112866. declare module BABYLON {
  112867. interface Scene {
  112868. /**
  112869. * @hidden
  112870. * Backing Filed
  112871. */
  112872. _selectionOctree: Octree<AbstractMesh>;
  112873. /**
  112874. * Gets the octree used to boost mesh selection (picking)
  112875. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  112876. */
  112877. selectionOctree: Octree<AbstractMesh>;
  112878. /**
  112879. * Creates or updates the octree used to boost selection (picking)
  112880. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  112881. * @param maxCapacity defines the maximum capacity per leaf
  112882. * @param maxDepth defines the maximum depth of the octree
  112883. * @returns an octree of AbstractMesh
  112884. */
  112885. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  112886. }
  112887. interface AbstractMesh {
  112888. /**
  112889. * @hidden
  112890. * Backing Field
  112891. */
  112892. _submeshesOctree: Octree<SubMesh>;
  112893. /**
  112894. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  112895. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  112896. * @param maxCapacity defines the maximum size of each block (64 by default)
  112897. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  112898. * @returns the new octree
  112899. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  112900. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  112901. */
  112902. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  112903. }
  112904. /**
  112905. * Defines the octree scene component responsible to manage any octrees
  112906. * in a given scene.
  112907. */
  112908. export class OctreeSceneComponent {
  112909. /**
  112910. * The component name help to identify the component in the list of scene components.
  112911. */
  112912. readonly name: string;
  112913. /**
  112914. * The scene the component belongs to.
  112915. */
  112916. scene: Scene;
  112917. /**
  112918. * Indicates if the meshes have been checked to make sure they are isEnabled()
  112919. */
  112920. readonly checksIsEnabled: boolean;
  112921. /**
  112922. * Creates a new instance of the component for the given scene
  112923. * @param scene Defines the scene to register the component in
  112924. */
  112925. constructor(scene: Scene);
  112926. /**
  112927. * Registers the component in a given scene
  112928. */
  112929. register(): void;
  112930. /**
  112931. * Return the list of active meshes
  112932. * @returns the list of active meshes
  112933. */
  112934. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  112935. /**
  112936. * Return the list of active sub meshes
  112937. * @param mesh The mesh to get the candidates sub meshes from
  112938. * @returns the list of active sub meshes
  112939. */
  112940. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  112941. private _tempRay;
  112942. /**
  112943. * Return the list of sub meshes intersecting with a given local ray
  112944. * @param mesh defines the mesh to find the submesh for
  112945. * @param localRay defines the ray in local space
  112946. * @returns the list of intersecting sub meshes
  112947. */
  112948. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  112949. /**
  112950. * Return the list of sub meshes colliding with a collider
  112951. * @param mesh defines the mesh to find the submesh for
  112952. * @param collider defines the collider to evaluate the collision against
  112953. * @returns the list of colliding sub meshes
  112954. */
  112955. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  112956. /**
  112957. * Rebuilds the elements related to this component in case of
  112958. * context lost for instance.
  112959. */
  112960. rebuild(): void;
  112961. /**
  112962. * Disposes the component and the associated ressources.
  112963. */
  112964. dispose(): void;
  112965. }
  112966. }
  112967. declare module BABYLON {
  112968. /**
  112969. * Renders a layer on top of an existing scene
  112970. */
  112971. export class UtilityLayerRenderer implements IDisposable {
  112972. /** the original scene that will be rendered on top of */
  112973. originalScene: Scene;
  112974. private _pointerCaptures;
  112975. private _lastPointerEvents;
  112976. private static _DefaultUtilityLayer;
  112977. private static _DefaultKeepDepthUtilityLayer;
  112978. private _sharedGizmoLight;
  112979. private _renderCamera;
  112980. /**
  112981. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  112982. * @returns the camera that is used when rendering the utility layer
  112983. */
  112984. getRenderCamera(): Nullable<Camera>;
  112985. /**
  112986. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  112987. * @param cam the camera that should be used when rendering the utility layer
  112988. */
  112989. setRenderCamera(cam: Nullable<Camera>): void;
  112990. /**
  112991. * @hidden
  112992. * Light which used by gizmos to get light shading
  112993. */
  112994. _getSharedGizmoLight(): HemisphericLight;
  112995. /**
  112996. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  112997. */
  112998. pickUtilitySceneFirst: boolean;
  112999. /**
  113000. * 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)
  113001. */
  113002. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  113003. /**
  113004. * 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)
  113005. */
  113006. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  113007. /**
  113008. * The scene that is rendered on top of the original scene
  113009. */
  113010. utilityLayerScene: Scene;
  113011. /**
  113012. * If the utility layer should automatically be rendered on top of existing scene
  113013. */
  113014. shouldRender: boolean;
  113015. /**
  113016. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  113017. */
  113018. onlyCheckPointerDownEvents: boolean;
  113019. /**
  113020. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  113021. */
  113022. processAllEvents: boolean;
  113023. /**
  113024. * Observable raised when the pointer move from the utility layer scene to the main scene
  113025. */
  113026. onPointerOutObservable: Observable<number>;
  113027. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  113028. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  113029. private _afterRenderObserver;
  113030. private _sceneDisposeObserver;
  113031. private _originalPointerObserver;
  113032. /**
  113033. * Instantiates a UtilityLayerRenderer
  113034. * @param originalScene the original scene that will be rendered on top of
  113035. * @param handleEvents boolean indicating if the utility layer should handle events
  113036. */
  113037. constructor(
  113038. /** the original scene that will be rendered on top of */
  113039. originalScene: Scene, handleEvents?: boolean);
  113040. private _notifyObservers;
  113041. /**
  113042. * Renders the utility layers scene on top of the original scene
  113043. */
  113044. render(): void;
  113045. /**
  113046. * Disposes of the renderer
  113047. */
  113048. dispose(): void;
  113049. private _updateCamera;
  113050. }
  113051. }
  113052. declare module BABYLON {
  113053. /**
  113054. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  113055. */
  113056. export class Gizmo implements IDisposable {
  113057. /** The utility layer the gizmo will be added to */
  113058. gizmoLayer: UtilityLayerRenderer;
  113059. /**
  113060. * The root mesh of the gizmo
  113061. */
  113062. _rootMesh: Mesh;
  113063. private _attachedMesh;
  113064. /**
  113065. * Ratio for the scale of the gizmo (Default: 1)
  113066. */
  113067. scaleRatio: number;
  113068. /**
  113069. * If a custom mesh has been set (Default: false)
  113070. */
  113071. protected _customMeshSet: boolean;
  113072. /**
  113073. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  113074. * * When set, interactions will be enabled
  113075. */
  113076. attachedMesh: Nullable<AbstractMesh>;
  113077. /**
  113078. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  113079. * @param mesh The mesh to replace the default mesh of the gizmo
  113080. */
  113081. setCustomMesh(mesh: Mesh): void;
  113082. /**
  113083. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  113084. */
  113085. updateGizmoRotationToMatchAttachedMesh: boolean;
  113086. /**
  113087. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  113088. */
  113089. updateGizmoPositionToMatchAttachedMesh: boolean;
  113090. /**
  113091. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  113092. */
  113093. updateScale: boolean;
  113094. protected _interactionsEnabled: boolean;
  113095. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  113096. private _beforeRenderObserver;
  113097. private _tempVector;
  113098. /**
  113099. * Creates a gizmo
  113100. * @param gizmoLayer The utility layer the gizmo will be added to
  113101. */
  113102. constructor(
  113103. /** The utility layer the gizmo will be added to */
  113104. gizmoLayer?: UtilityLayerRenderer);
  113105. /**
  113106. * Updates the gizmo to match the attached mesh's position/rotation
  113107. */
  113108. protected _update(): void;
  113109. /**
  113110. * Disposes of the gizmo
  113111. */
  113112. dispose(): void;
  113113. }
  113114. }
  113115. declare module BABYLON {
  113116. /**
  113117. * Single plane drag gizmo
  113118. */
  113119. export class PlaneDragGizmo extends Gizmo {
  113120. /**
  113121. * Drag behavior responsible for the gizmos dragging interactions
  113122. */
  113123. dragBehavior: PointerDragBehavior;
  113124. private _pointerObserver;
  113125. /**
  113126. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  113127. */
  113128. snapDistance: number;
  113129. /**
  113130. * Event that fires each time the gizmo snaps to a new location.
  113131. * * snapDistance is the the change in distance
  113132. */
  113133. onSnapObservable: Observable<{
  113134. snapDistance: number;
  113135. }>;
  113136. private _plane;
  113137. private _coloredMaterial;
  113138. private _hoverMaterial;
  113139. private _isEnabled;
  113140. private _parent;
  113141. /** @hidden */
  113142. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  113143. /** @hidden */
  113144. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  113145. /**
  113146. * Creates a PlaneDragGizmo
  113147. * @param gizmoLayer The utility layer the gizmo will be added to
  113148. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  113149. * @param color The color of the gizmo
  113150. */
  113151. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  113152. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  113153. /**
  113154. * If the gizmo is enabled
  113155. */
  113156. isEnabled: boolean;
  113157. /**
  113158. * Disposes of the gizmo
  113159. */
  113160. dispose(): void;
  113161. }
  113162. }
  113163. declare module BABYLON {
  113164. /**
  113165. * Gizmo that enables dragging a mesh along 3 axis
  113166. */
  113167. export class PositionGizmo extends Gizmo {
  113168. /**
  113169. * Internal gizmo used for interactions on the x axis
  113170. */
  113171. xGizmo: AxisDragGizmo;
  113172. /**
  113173. * Internal gizmo used for interactions on the y axis
  113174. */
  113175. yGizmo: AxisDragGizmo;
  113176. /**
  113177. * Internal gizmo used for interactions on the z axis
  113178. */
  113179. zGizmo: AxisDragGizmo;
  113180. /**
  113181. * Internal gizmo used for interactions on the yz plane
  113182. */
  113183. xPlaneGizmo: PlaneDragGizmo;
  113184. /**
  113185. * Internal gizmo used for interactions on the xz plane
  113186. */
  113187. yPlaneGizmo: PlaneDragGizmo;
  113188. /**
  113189. * Internal gizmo used for interactions on the xy plane
  113190. */
  113191. zPlaneGizmo: PlaneDragGizmo;
  113192. /**
  113193. * private variables
  113194. */
  113195. private _meshAttached;
  113196. private _updateGizmoRotationToMatchAttachedMesh;
  113197. private _snapDistance;
  113198. private _scaleRatio;
  113199. /** Fires an event when any of it's sub gizmos are dragged */
  113200. onDragStartObservable: Observable<unknown>;
  113201. /** Fires an event when any of it's sub gizmos are released from dragging */
  113202. onDragEndObservable: Observable<unknown>;
  113203. /**
  113204. * If set to true, planar drag is enabled
  113205. */
  113206. private _planarGizmoEnabled;
  113207. attachedMesh: Nullable<AbstractMesh>;
  113208. /**
  113209. * Creates a PositionGizmo
  113210. * @param gizmoLayer The utility layer the gizmo will be added to
  113211. */
  113212. constructor(gizmoLayer?: UtilityLayerRenderer);
  113213. /**
  113214. * If the planar drag gizmo is enabled
  113215. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  113216. */
  113217. planarGizmoEnabled: boolean;
  113218. updateGizmoRotationToMatchAttachedMesh: boolean;
  113219. /**
  113220. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  113221. */
  113222. snapDistance: number;
  113223. /**
  113224. * Ratio for the scale of the gizmo (Default: 1)
  113225. */
  113226. scaleRatio: number;
  113227. /**
  113228. * Disposes of the gizmo
  113229. */
  113230. dispose(): void;
  113231. /**
  113232. * CustomMeshes are not supported by this gizmo
  113233. * @param mesh The mesh to replace the default mesh of the gizmo
  113234. */
  113235. setCustomMesh(mesh: Mesh): void;
  113236. }
  113237. }
  113238. declare module BABYLON {
  113239. /**
  113240. * Single axis drag gizmo
  113241. */
  113242. export class AxisDragGizmo extends Gizmo {
  113243. /**
  113244. * Drag behavior responsible for the gizmos dragging interactions
  113245. */
  113246. dragBehavior: PointerDragBehavior;
  113247. private _pointerObserver;
  113248. /**
  113249. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  113250. */
  113251. snapDistance: number;
  113252. /**
  113253. * Event that fires each time the gizmo snaps to a new location.
  113254. * * snapDistance is the the change in distance
  113255. */
  113256. onSnapObservable: Observable<{
  113257. snapDistance: number;
  113258. }>;
  113259. private _isEnabled;
  113260. private _parent;
  113261. private _arrow;
  113262. private _coloredMaterial;
  113263. private _hoverMaterial;
  113264. /** @hidden */
  113265. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  113266. /** @hidden */
  113267. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  113268. /**
  113269. * Creates an AxisDragGizmo
  113270. * @param gizmoLayer The utility layer the gizmo will be added to
  113271. * @param dragAxis The axis which the gizmo will be able to drag on
  113272. * @param color The color of the gizmo
  113273. */
  113274. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  113275. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  113276. /**
  113277. * If the gizmo is enabled
  113278. */
  113279. isEnabled: boolean;
  113280. /**
  113281. * Disposes of the gizmo
  113282. */
  113283. dispose(): void;
  113284. }
  113285. }
  113286. declare module BABYLON.Debug {
  113287. /**
  113288. * The Axes viewer will show 3 axes in a specific point in space
  113289. */
  113290. export class AxesViewer {
  113291. private _xAxis;
  113292. private _yAxis;
  113293. private _zAxis;
  113294. private _scaleLinesFactor;
  113295. private _instanced;
  113296. /**
  113297. * Gets the hosting scene
  113298. */
  113299. scene: Scene;
  113300. /**
  113301. * Gets or sets a number used to scale line length
  113302. */
  113303. scaleLines: number;
  113304. /** Gets the node hierarchy used to render x-axis */
  113305. readonly xAxis: TransformNode;
  113306. /** Gets the node hierarchy used to render y-axis */
  113307. readonly yAxis: TransformNode;
  113308. /** Gets the node hierarchy used to render z-axis */
  113309. readonly zAxis: TransformNode;
  113310. /**
  113311. * Creates a new AxesViewer
  113312. * @param scene defines the hosting scene
  113313. * @param scaleLines defines a number used to scale line length (1 by default)
  113314. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  113315. * @param xAxis defines the node hierarchy used to render the x-axis
  113316. * @param yAxis defines the node hierarchy used to render the y-axis
  113317. * @param zAxis defines the node hierarchy used to render the z-axis
  113318. */
  113319. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  113320. /**
  113321. * Force the viewer to update
  113322. * @param position defines the position of the viewer
  113323. * @param xaxis defines the x axis of the viewer
  113324. * @param yaxis defines the y axis of the viewer
  113325. * @param zaxis defines the z axis of the viewer
  113326. */
  113327. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  113328. /**
  113329. * Creates an instance of this axes viewer.
  113330. * @returns a new axes viewer with instanced meshes
  113331. */
  113332. createInstance(): AxesViewer;
  113333. /** Releases resources */
  113334. dispose(): void;
  113335. private static _SetRenderingGroupId;
  113336. }
  113337. }
  113338. declare module BABYLON.Debug {
  113339. /**
  113340. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  113341. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  113342. */
  113343. export class BoneAxesViewer extends AxesViewer {
  113344. /**
  113345. * Gets or sets the target mesh where to display the axes viewer
  113346. */
  113347. mesh: Nullable<Mesh>;
  113348. /**
  113349. * Gets or sets the target bone where to display the axes viewer
  113350. */
  113351. bone: Nullable<Bone>;
  113352. /** Gets current position */
  113353. pos: Vector3;
  113354. /** Gets direction of X axis */
  113355. xaxis: Vector3;
  113356. /** Gets direction of Y axis */
  113357. yaxis: Vector3;
  113358. /** Gets direction of Z axis */
  113359. zaxis: Vector3;
  113360. /**
  113361. * Creates a new BoneAxesViewer
  113362. * @param scene defines the hosting scene
  113363. * @param bone defines the target bone
  113364. * @param mesh defines the target mesh
  113365. * @param scaleLines defines a scaling factor for line length (1 by default)
  113366. */
  113367. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  113368. /**
  113369. * Force the viewer to update
  113370. */
  113371. update(): void;
  113372. /** Releases resources */
  113373. dispose(): void;
  113374. }
  113375. }
  113376. declare module BABYLON {
  113377. /**
  113378. * Interface used to define scene explorer extensibility option
  113379. */
  113380. export interface IExplorerExtensibilityOption {
  113381. /**
  113382. * Define the option label
  113383. */
  113384. label: string;
  113385. /**
  113386. * Defines the action to execute on click
  113387. */
  113388. action: (entity: any) => void;
  113389. }
  113390. /**
  113391. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  113392. */
  113393. export interface IExplorerExtensibilityGroup {
  113394. /**
  113395. * Defines a predicate to test if a given type mut be extended
  113396. */
  113397. predicate: (entity: any) => boolean;
  113398. /**
  113399. * Gets the list of options added to a type
  113400. */
  113401. entries: IExplorerExtensibilityOption[];
  113402. }
  113403. /**
  113404. * Interface used to define the options to use to create the Inspector
  113405. */
  113406. export interface IInspectorOptions {
  113407. /**
  113408. * Display in overlay mode (default: false)
  113409. */
  113410. overlay?: boolean;
  113411. /**
  113412. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  113413. */
  113414. globalRoot?: HTMLElement;
  113415. /**
  113416. * Display the Scene explorer
  113417. */
  113418. showExplorer?: boolean;
  113419. /**
  113420. * Display the property inspector
  113421. */
  113422. showInspector?: boolean;
  113423. /**
  113424. * Display in embed mode (both panes on the right)
  113425. */
  113426. embedMode?: boolean;
  113427. /**
  113428. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  113429. */
  113430. handleResize?: boolean;
  113431. /**
  113432. * Allow the panes to popup (default: true)
  113433. */
  113434. enablePopup?: boolean;
  113435. /**
  113436. * Allow the panes to be closed by users (default: true)
  113437. */
  113438. enableClose?: boolean;
  113439. /**
  113440. * Optional list of extensibility entries
  113441. */
  113442. explorerExtensibility?: IExplorerExtensibilityGroup[];
  113443. /**
  113444. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  113445. */
  113446. inspectorURL?: string;
  113447. /**
  113448. * Optional initial tab (default to DebugLayerTab.Properties)
  113449. */
  113450. initialTab?: DebugLayerTab;
  113451. }
  113452. interface Scene {
  113453. /**
  113454. * @hidden
  113455. * Backing field
  113456. */
  113457. _debugLayer: DebugLayer;
  113458. /**
  113459. * Gets the debug layer (aka Inspector) associated with the scene
  113460. * @see http://doc.babylonjs.com/features/playground_debuglayer
  113461. */
  113462. debugLayer: DebugLayer;
  113463. }
  113464. /**
  113465. * Enum of inspector action tab
  113466. */
  113467. export enum DebugLayerTab {
  113468. /**
  113469. * Properties tag (default)
  113470. */
  113471. Properties = 0,
  113472. /**
  113473. * Debug tab
  113474. */
  113475. Debug = 1,
  113476. /**
  113477. * Statistics tab
  113478. */
  113479. Statistics = 2,
  113480. /**
  113481. * Tools tab
  113482. */
  113483. Tools = 3,
  113484. /**
  113485. * Settings tab
  113486. */
  113487. Settings = 4
  113488. }
  113489. /**
  113490. * The debug layer (aka Inspector) is the go to tool in order to better understand
  113491. * what is happening in your scene
  113492. * @see http://doc.babylonjs.com/features/playground_debuglayer
  113493. */
  113494. export class DebugLayer {
  113495. /**
  113496. * Define the url to get the inspector script from.
  113497. * By default it uses the babylonjs CDN.
  113498. * @ignoreNaming
  113499. */
  113500. static InspectorURL: string;
  113501. private _scene;
  113502. private BJSINSPECTOR;
  113503. private _onPropertyChangedObservable?;
  113504. /**
  113505. * Observable triggered when a property is changed through the inspector.
  113506. */
  113507. readonly onPropertyChangedObservable: any;
  113508. /**
  113509. * Instantiates a new debug layer.
  113510. * The debug layer (aka Inspector) is the go to tool in order to better understand
  113511. * what is happening in your scene
  113512. * @see http://doc.babylonjs.com/features/playground_debuglayer
  113513. * @param scene Defines the scene to inspect
  113514. */
  113515. constructor(scene: Scene);
  113516. /** Creates the inspector window. */
  113517. private _createInspector;
  113518. /**
  113519. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  113520. * @param entity defines the entity to select
  113521. * @param lineContainerTitle defines the specific block to highlight
  113522. */
  113523. select(entity: any, lineContainerTitle?: string): void;
  113524. /** Get the inspector from bundle or global */
  113525. private _getGlobalInspector;
  113526. /**
  113527. * Get if the inspector is visible or not.
  113528. * @returns true if visible otherwise, false
  113529. */
  113530. isVisible(): boolean;
  113531. /**
  113532. * Hide the inspector and close its window.
  113533. */
  113534. hide(): void;
  113535. /**
  113536. * Launch the debugLayer.
  113537. * @param config Define the configuration of the inspector
  113538. * @return a promise fulfilled when the debug layer is visible
  113539. */
  113540. show(config?: IInspectorOptions): Promise<DebugLayer>;
  113541. }
  113542. }
  113543. declare module BABYLON {
  113544. /**
  113545. * Class containing static functions to help procedurally build meshes
  113546. */
  113547. export class BoxBuilder {
  113548. /**
  113549. * Creates a box mesh
  113550. * * The parameter `size` sets the size (float) of each box side (default 1)
  113551. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  113552. * * 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)
  113553. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  113554. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  113555. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  113556. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113557. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  113558. * @param name defines the name of the mesh
  113559. * @param options defines the options used to create the mesh
  113560. * @param scene defines the hosting scene
  113561. * @returns the box mesh
  113562. */
  113563. static CreateBox(name: string, options: {
  113564. size?: number;
  113565. width?: number;
  113566. height?: number;
  113567. depth?: number;
  113568. faceUV?: Vector4[];
  113569. faceColors?: Color4[];
  113570. sideOrientation?: number;
  113571. frontUVs?: Vector4;
  113572. backUVs?: Vector4;
  113573. wrap?: boolean;
  113574. topBaseAt?: number;
  113575. bottomBaseAt?: number;
  113576. updatable?: boolean;
  113577. }, scene?: Nullable<Scene>): Mesh;
  113578. }
  113579. }
  113580. declare module BABYLON {
  113581. /**
  113582. * Class containing static functions to help procedurally build meshes
  113583. */
  113584. export class SphereBuilder {
  113585. /**
  113586. * Creates a sphere mesh
  113587. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  113588. * * 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`)
  113589. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  113590. * * 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
  113591. * * 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)
  113592. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  113593. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  113594. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113595. * @param name defines the name of the mesh
  113596. * @param options defines the options used to create the mesh
  113597. * @param scene defines the hosting scene
  113598. * @returns the sphere mesh
  113599. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  113600. */
  113601. static CreateSphere(name: string, options: {
  113602. segments?: number;
  113603. diameter?: number;
  113604. diameterX?: number;
  113605. diameterY?: number;
  113606. diameterZ?: number;
  113607. arc?: number;
  113608. slice?: number;
  113609. sideOrientation?: number;
  113610. frontUVs?: Vector4;
  113611. backUVs?: Vector4;
  113612. updatable?: boolean;
  113613. }, scene?: Nullable<Scene>): Mesh;
  113614. }
  113615. }
  113616. declare module BABYLON.Debug {
  113617. /**
  113618. * Used to show the physics impostor around the specific mesh
  113619. */
  113620. export class PhysicsViewer {
  113621. /** @hidden */
  113622. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  113623. /** @hidden */
  113624. protected _meshes: Array<Nullable<AbstractMesh>>;
  113625. /** @hidden */
  113626. protected _scene: Nullable<Scene>;
  113627. /** @hidden */
  113628. protected _numMeshes: number;
  113629. /** @hidden */
  113630. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  113631. private _renderFunction;
  113632. private _utilityLayer;
  113633. private _debugBoxMesh;
  113634. private _debugSphereMesh;
  113635. private _debugCylinderMesh;
  113636. private _debugMaterial;
  113637. private _debugMeshMeshes;
  113638. /**
  113639. * Creates a new PhysicsViewer
  113640. * @param scene defines the hosting scene
  113641. */
  113642. constructor(scene: Scene);
  113643. /** @hidden */
  113644. protected _updateDebugMeshes(): void;
  113645. /**
  113646. * Renders a specified physic impostor
  113647. * @param impostor defines the impostor to render
  113648. * @param targetMesh defines the mesh represented by the impostor
  113649. * @returns the new debug mesh used to render the impostor
  113650. */
  113651. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  113652. /**
  113653. * Hides a specified physic impostor
  113654. * @param impostor defines the impostor to hide
  113655. */
  113656. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  113657. private _getDebugMaterial;
  113658. private _getDebugBoxMesh;
  113659. private _getDebugSphereMesh;
  113660. private _getDebugCylinderMesh;
  113661. private _getDebugMeshMesh;
  113662. private _getDebugMesh;
  113663. /** Releases all resources */
  113664. dispose(): void;
  113665. }
  113666. }
  113667. declare module BABYLON {
  113668. /**
  113669. * Class containing static functions to help procedurally build meshes
  113670. */
  113671. export class LinesBuilder {
  113672. /**
  113673. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  113674. * * 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
  113675. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  113676. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  113677. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  113678. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  113679. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  113680. * * 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
  113681. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  113682. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113683. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  113684. * @param name defines the name of the new line system
  113685. * @param options defines the options used to create the line system
  113686. * @param scene defines the hosting scene
  113687. * @returns a new line system mesh
  113688. */
  113689. static CreateLineSystem(name: string, options: {
  113690. lines: Vector3[][];
  113691. updatable?: boolean;
  113692. instance?: Nullable<LinesMesh>;
  113693. colors?: Nullable<Color4[][]>;
  113694. useVertexAlpha?: boolean;
  113695. }, scene: Nullable<Scene>): LinesMesh;
  113696. /**
  113697. * Creates a line mesh
  113698. * 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
  113699. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  113700. * * The parameter `points` is an array successive Vector3
  113701. * * 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
  113702. * * The optional parameter `colors` is an array of successive Color4, one per line point
  113703. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  113704. * * When updating an instance, remember that only point positions can change, not the number of points
  113705. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113706. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  113707. * @param name defines the name of the new line system
  113708. * @param options defines the options used to create the line system
  113709. * @param scene defines the hosting scene
  113710. * @returns a new line mesh
  113711. */
  113712. static CreateLines(name: string, options: {
  113713. points: Vector3[];
  113714. updatable?: boolean;
  113715. instance?: Nullable<LinesMesh>;
  113716. colors?: Color4[];
  113717. useVertexAlpha?: boolean;
  113718. }, scene?: Nullable<Scene>): LinesMesh;
  113719. /**
  113720. * Creates a dashed line mesh
  113721. * * 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
  113722. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  113723. * * The parameter `points` is an array successive Vector3
  113724. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  113725. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  113726. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  113727. * * 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
  113728. * * When updating an instance, remember that only point positions can change, not the number of points
  113729. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113730. * @param name defines the name of the mesh
  113731. * @param options defines the options used to create the mesh
  113732. * @param scene defines the hosting scene
  113733. * @returns the dashed line mesh
  113734. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  113735. */
  113736. static CreateDashedLines(name: string, options: {
  113737. points: Vector3[];
  113738. dashSize?: number;
  113739. gapSize?: number;
  113740. dashNb?: number;
  113741. updatable?: boolean;
  113742. instance?: LinesMesh;
  113743. }, scene?: Nullable<Scene>): LinesMesh;
  113744. }
  113745. }
  113746. declare module BABYLON {
  113747. /**
  113748. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  113749. * in order to better appreciate the issue one might have.
  113750. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  113751. */
  113752. export class RayHelper {
  113753. /**
  113754. * Defines the ray we are currently tryin to visualize.
  113755. */
  113756. ray: Nullable<Ray>;
  113757. private _renderPoints;
  113758. private _renderLine;
  113759. private _renderFunction;
  113760. private _scene;
  113761. private _updateToMeshFunction;
  113762. private _attachedToMesh;
  113763. private _meshSpaceDirection;
  113764. private _meshSpaceOrigin;
  113765. /**
  113766. * Helper function to create a colored helper in a scene in one line.
  113767. * @param ray Defines the ray we are currently tryin to visualize
  113768. * @param scene Defines the scene the ray is used in
  113769. * @param color Defines the color we want to see the ray in
  113770. * @returns The newly created ray helper.
  113771. */
  113772. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  113773. /**
  113774. * Instantiate a new ray helper.
  113775. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  113776. * in order to better appreciate the issue one might have.
  113777. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  113778. * @param ray Defines the ray we are currently tryin to visualize
  113779. */
  113780. constructor(ray: Ray);
  113781. /**
  113782. * Shows the ray we are willing to debug.
  113783. * @param scene Defines the scene the ray needs to be rendered in
  113784. * @param color Defines the color the ray needs to be rendered in
  113785. */
  113786. show(scene: Scene, color?: Color3): void;
  113787. /**
  113788. * Hides the ray we are debugging.
  113789. */
  113790. hide(): void;
  113791. private _render;
  113792. /**
  113793. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  113794. * @param mesh Defines the mesh we want the helper attached to
  113795. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  113796. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  113797. * @param length Defines the length of the ray
  113798. */
  113799. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  113800. /**
  113801. * Detach the ray helper from the mesh it has previously been attached to.
  113802. */
  113803. detachFromMesh(): void;
  113804. private _updateToMesh;
  113805. /**
  113806. * Dispose the helper and release its associated resources.
  113807. */
  113808. dispose(): void;
  113809. }
  113810. }
  113811. declare module BABYLON.Debug {
  113812. /**
  113813. * Class used to render a debug view of a given skeleton
  113814. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  113815. */
  113816. export class SkeletonViewer {
  113817. /** defines the skeleton to render */
  113818. skeleton: Skeleton;
  113819. /** defines the mesh attached to the skeleton */
  113820. mesh: AbstractMesh;
  113821. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  113822. autoUpdateBonesMatrices: boolean;
  113823. /** defines the rendering group id to use with the viewer */
  113824. renderingGroupId: number;
  113825. /** Gets or sets the color used to render the skeleton */
  113826. color: Color3;
  113827. private _scene;
  113828. private _debugLines;
  113829. private _debugMesh;
  113830. private _isEnabled;
  113831. private _renderFunction;
  113832. private _utilityLayer;
  113833. /**
  113834. * Returns the mesh used to render the bones
  113835. */
  113836. readonly debugMesh: Nullable<LinesMesh>;
  113837. /**
  113838. * Creates a new SkeletonViewer
  113839. * @param skeleton defines the skeleton to render
  113840. * @param mesh defines the mesh attached to the skeleton
  113841. * @param scene defines the hosting scene
  113842. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  113843. * @param renderingGroupId defines the rendering group id to use with the viewer
  113844. */
  113845. constructor(
  113846. /** defines the skeleton to render */
  113847. skeleton: Skeleton,
  113848. /** defines the mesh attached to the skeleton */
  113849. mesh: AbstractMesh, scene: Scene,
  113850. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  113851. autoUpdateBonesMatrices?: boolean,
  113852. /** defines the rendering group id to use with the viewer */
  113853. renderingGroupId?: number);
  113854. /** Gets or sets a boolean indicating if the viewer is enabled */
  113855. isEnabled: boolean;
  113856. private _getBonePosition;
  113857. private _getLinesForBonesWithLength;
  113858. private _getLinesForBonesNoLength;
  113859. /** Update the viewer to sync with current skeleton state */
  113860. update(): void;
  113861. /** Release associated resources */
  113862. dispose(): void;
  113863. }
  113864. }
  113865. declare module BABYLON {
  113866. /**
  113867. * Options to create the null engine
  113868. */
  113869. export class NullEngineOptions {
  113870. /**
  113871. * Render width (Default: 512)
  113872. */
  113873. renderWidth: number;
  113874. /**
  113875. * Render height (Default: 256)
  113876. */
  113877. renderHeight: number;
  113878. /**
  113879. * Texture size (Default: 512)
  113880. */
  113881. textureSize: number;
  113882. /**
  113883. * If delta time between frames should be constant
  113884. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  113885. */
  113886. deterministicLockstep: boolean;
  113887. /**
  113888. * Maximum about of steps between frames (Default: 4)
  113889. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  113890. */
  113891. lockstepMaxSteps: number;
  113892. }
  113893. /**
  113894. * The null engine class provides support for headless version of babylon.js.
  113895. * This can be used in server side scenario or for testing purposes
  113896. */
  113897. export class NullEngine extends Engine {
  113898. private _options;
  113899. /**
  113900. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  113901. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  113902. * @returns true if engine is in deterministic lock step mode
  113903. */
  113904. isDeterministicLockStep(): boolean;
  113905. /**
  113906. * Gets the max steps when engine is running in deterministic lock step
  113907. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  113908. * @returns the max steps
  113909. */
  113910. getLockstepMaxSteps(): number;
  113911. /**
  113912. * Gets the current hardware scaling level.
  113913. * By default the hardware scaling level is computed from the window device ratio.
  113914. * 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.
  113915. * @returns a number indicating the current hardware scaling level
  113916. */
  113917. getHardwareScalingLevel(): number;
  113918. constructor(options?: NullEngineOptions);
  113919. /**
  113920. * Creates a vertex buffer
  113921. * @param vertices the data for the vertex buffer
  113922. * @returns the new WebGL static buffer
  113923. */
  113924. createVertexBuffer(vertices: FloatArray): DataBuffer;
  113925. /**
  113926. * Creates a new index buffer
  113927. * @param indices defines the content of the index buffer
  113928. * @param updatable defines if the index buffer must be updatable
  113929. * @returns a new webGL buffer
  113930. */
  113931. createIndexBuffer(indices: IndicesArray): DataBuffer;
  113932. /**
  113933. * Clear the current render buffer or the current render target (if any is set up)
  113934. * @param color defines the color to use
  113935. * @param backBuffer defines if the back buffer must be cleared
  113936. * @param depth defines if the depth buffer must be cleared
  113937. * @param stencil defines if the stencil buffer must be cleared
  113938. */
  113939. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  113940. /**
  113941. * Gets the current render width
  113942. * @param useScreen defines if screen size must be used (or the current render target if any)
  113943. * @returns a number defining the current render width
  113944. */
  113945. getRenderWidth(useScreen?: boolean): number;
  113946. /**
  113947. * Gets the current render height
  113948. * @param useScreen defines if screen size must be used (or the current render target if any)
  113949. * @returns a number defining the current render height
  113950. */
  113951. getRenderHeight(useScreen?: boolean): number;
  113952. /**
  113953. * Set the WebGL's viewport
  113954. * @param viewport defines the viewport element to be used
  113955. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  113956. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  113957. */
  113958. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  113959. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  113960. /**
  113961. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  113962. * @param pipelineContext defines the pipeline context to use
  113963. * @param uniformsNames defines the list of uniform names
  113964. * @returns an array of webGL uniform locations
  113965. */
  113966. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  113967. /**
  113968. * Gets the lsit of active attributes for a given webGL program
  113969. * @param pipelineContext defines the pipeline context to use
  113970. * @param attributesNames defines the list of attribute names to get
  113971. * @returns an array of indices indicating the offset of each attribute
  113972. */
  113973. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  113974. /**
  113975. * Binds an effect to the webGL context
  113976. * @param effect defines the effect to bind
  113977. */
  113978. bindSamplers(effect: Effect): void;
  113979. /**
  113980. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  113981. * @param effect defines the effect to activate
  113982. */
  113983. enableEffect(effect: Effect): void;
  113984. /**
  113985. * Set various states to the webGL context
  113986. * @param culling defines backface culling state
  113987. * @param zOffset defines the value to apply to zOffset (0 by default)
  113988. * @param force defines if states must be applied even if cache is up to date
  113989. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  113990. */
  113991. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  113992. /**
  113993. * Set the value of an uniform to an array of int32
  113994. * @param uniform defines the webGL uniform location where to store the value
  113995. * @param array defines the array of int32 to store
  113996. */
  113997. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  113998. /**
  113999. * Set the value of an uniform to an array of int32 (stored as vec2)
  114000. * @param uniform defines the webGL uniform location where to store the value
  114001. * @param array defines the array of int32 to store
  114002. */
  114003. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  114004. /**
  114005. * Set the value of an uniform to an array of int32 (stored as vec3)
  114006. * @param uniform defines the webGL uniform location where to store the value
  114007. * @param array defines the array of int32 to store
  114008. */
  114009. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  114010. /**
  114011. * Set the value of an uniform to an array of int32 (stored as vec4)
  114012. * @param uniform defines the webGL uniform location where to store the value
  114013. * @param array defines the array of int32 to store
  114014. */
  114015. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  114016. /**
  114017. * Set the value of an uniform to an array of float32
  114018. * @param uniform defines the webGL uniform location where to store the value
  114019. * @param array defines the array of float32 to store
  114020. */
  114021. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  114022. /**
  114023. * Set the value of an uniform to an array of float32 (stored as vec2)
  114024. * @param uniform defines the webGL uniform location where to store the value
  114025. * @param array defines the array of float32 to store
  114026. */
  114027. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  114028. /**
  114029. * Set the value of an uniform to an array of float32 (stored as vec3)
  114030. * @param uniform defines the webGL uniform location where to store the value
  114031. * @param array defines the array of float32 to store
  114032. */
  114033. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  114034. /**
  114035. * Set the value of an uniform to an array of float32 (stored as vec4)
  114036. * @param uniform defines the webGL uniform location where to store the value
  114037. * @param array defines the array of float32 to store
  114038. */
  114039. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  114040. /**
  114041. * Set the value of an uniform to an array of number
  114042. * @param uniform defines the webGL uniform location where to store the value
  114043. * @param array defines the array of number to store
  114044. */
  114045. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  114046. /**
  114047. * Set the value of an uniform to an array of number (stored as vec2)
  114048. * @param uniform defines the webGL uniform location where to store the value
  114049. * @param array defines the array of number to store
  114050. */
  114051. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  114052. /**
  114053. * Set the value of an uniform to an array of number (stored as vec3)
  114054. * @param uniform defines the webGL uniform location where to store the value
  114055. * @param array defines the array of number to store
  114056. */
  114057. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  114058. /**
  114059. * Set the value of an uniform to an array of number (stored as vec4)
  114060. * @param uniform defines the webGL uniform location where to store the value
  114061. * @param array defines the array of number to store
  114062. */
  114063. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  114064. /**
  114065. * Set the value of an uniform to an array of float32 (stored as matrices)
  114066. * @param uniform defines the webGL uniform location where to store the value
  114067. * @param matrices defines the array of float32 to store
  114068. */
  114069. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  114070. /**
  114071. * Set the value of an uniform to a matrix (3x3)
  114072. * @param uniform defines the webGL uniform location where to store the value
  114073. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  114074. */
  114075. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  114076. /**
  114077. * Set the value of an uniform to a matrix (2x2)
  114078. * @param uniform defines the webGL uniform location where to store the value
  114079. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  114080. */
  114081. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  114082. /**
  114083. * Set the value of an uniform to a number (float)
  114084. * @param uniform defines the webGL uniform location where to store the value
  114085. * @param value defines the float number to store
  114086. */
  114087. setFloat(uniform: WebGLUniformLocation, value: number): void;
  114088. /**
  114089. * Set the value of an uniform to a vec2
  114090. * @param uniform defines the webGL uniform location where to store the value
  114091. * @param x defines the 1st component of the value
  114092. * @param y defines the 2nd component of the value
  114093. */
  114094. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  114095. /**
  114096. * Set the value of an uniform to a vec3
  114097. * @param uniform defines the webGL uniform location where to store the value
  114098. * @param x defines the 1st component of the value
  114099. * @param y defines the 2nd component of the value
  114100. * @param z defines the 3rd component of the value
  114101. */
  114102. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  114103. /**
  114104. * Set the value of an uniform to a boolean
  114105. * @param uniform defines the webGL uniform location where to store the value
  114106. * @param bool defines the boolean to store
  114107. */
  114108. setBool(uniform: WebGLUniformLocation, bool: number): void;
  114109. /**
  114110. * Set the value of an uniform to a vec4
  114111. * @param uniform defines the webGL uniform location where to store the value
  114112. * @param x defines the 1st component of the value
  114113. * @param y defines the 2nd component of the value
  114114. * @param z defines the 3rd component of the value
  114115. * @param w defines the 4th component of the value
  114116. */
  114117. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  114118. /**
  114119. * Sets the current alpha mode
  114120. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  114121. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  114122. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  114123. */
  114124. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  114125. /**
  114126. * Bind webGl buffers directly to the webGL context
  114127. * @param vertexBuffers defines the vertex buffer to bind
  114128. * @param indexBuffer defines the index buffer to bind
  114129. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  114130. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  114131. * @param effect defines the effect associated with the vertex buffer
  114132. */
  114133. bindBuffers(vertexBuffers: {
  114134. [key: string]: VertexBuffer;
  114135. }, indexBuffer: DataBuffer, effect: Effect): void;
  114136. /**
  114137. * Force the entire cache to be cleared
  114138. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  114139. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  114140. */
  114141. wipeCaches(bruteForce?: boolean): void;
  114142. /**
  114143. * Send a draw order
  114144. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  114145. * @param indexStart defines the starting index
  114146. * @param indexCount defines the number of index to draw
  114147. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  114148. */
  114149. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  114150. /**
  114151. * Draw a list of indexed primitives
  114152. * @param fillMode defines the primitive to use
  114153. * @param indexStart defines the starting index
  114154. * @param indexCount defines the number of index to draw
  114155. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  114156. */
  114157. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  114158. /**
  114159. * Draw a list of unindexed primitives
  114160. * @param fillMode defines the primitive to use
  114161. * @param verticesStart defines the index of first vertex to draw
  114162. * @param verticesCount defines the count of vertices to draw
  114163. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  114164. */
  114165. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  114166. /** @hidden */
  114167. _createTexture(): WebGLTexture;
  114168. /** @hidden */
  114169. _releaseTexture(texture: InternalTexture): void;
  114170. /**
  114171. * Usually called from Texture.ts.
  114172. * Passed information to create a WebGLTexture
  114173. * @param urlArg defines a value which contains one of the following:
  114174. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  114175. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  114176. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  114177. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  114178. * @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)
  114179. * @param scene needed for loading to the correct scene
  114180. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  114181. * @param onLoad optional callback to be called upon successful completion
  114182. * @param onError optional callback to be called upon failure
  114183. * @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
  114184. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  114185. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  114186. * @param forcedExtension defines the extension to use to pick the right loader
  114187. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  114188. * @returns a InternalTexture for assignment back into BABYLON.Texture
  114189. */
  114190. 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;
  114191. /**
  114192. * Creates a new render target texture
  114193. * @param size defines the size of the texture
  114194. * @param options defines the options used to create the texture
  114195. * @returns a new render target texture stored in an InternalTexture
  114196. */
  114197. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  114198. /**
  114199. * Update the sampling mode of a given texture
  114200. * @param samplingMode defines the required sampling mode
  114201. * @param texture defines the texture to update
  114202. */
  114203. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  114204. /**
  114205. * Binds the frame buffer to the specified texture.
  114206. * @param texture The texture to render to or null for the default canvas
  114207. * @param faceIndex The face of the texture to render to in case of cube texture
  114208. * @param requiredWidth The width of the target to render to
  114209. * @param requiredHeight The height of the target to render to
  114210. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  114211. * @param depthStencilTexture The depth stencil texture to use to render
  114212. * @param lodLevel defines le lod level to bind to the frame buffer
  114213. */
  114214. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  114215. /**
  114216. * Unbind the current render target texture from the webGL context
  114217. * @param texture defines the render target texture to unbind
  114218. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  114219. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  114220. */
  114221. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  114222. /**
  114223. * Creates a dynamic vertex buffer
  114224. * @param vertices the data for the dynamic vertex buffer
  114225. * @returns the new WebGL dynamic buffer
  114226. */
  114227. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  114228. /**
  114229. * Update the content of a dynamic texture
  114230. * @param texture defines the texture to update
  114231. * @param canvas defines the canvas containing the source
  114232. * @param invertY defines if data must be stored with Y axis inverted
  114233. * @param premulAlpha defines if alpha is stored as premultiplied
  114234. * @param format defines the format of the data
  114235. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  114236. */
  114237. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  114238. /**
  114239. * Gets a boolean indicating if all created effects are ready
  114240. * @returns true if all effects are ready
  114241. */
  114242. areAllEffectsReady(): boolean;
  114243. /**
  114244. * @hidden
  114245. * Get the current error code of the webGL context
  114246. * @returns the error code
  114247. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  114248. */
  114249. getError(): number;
  114250. /** @hidden */
  114251. _getUnpackAlignement(): number;
  114252. /** @hidden */
  114253. _unpackFlipY(value: boolean): void;
  114254. /**
  114255. * Update a dynamic index buffer
  114256. * @param indexBuffer defines the target index buffer
  114257. * @param indices defines the data to update
  114258. * @param offset defines the offset in the target index buffer where update should start
  114259. */
  114260. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  114261. /**
  114262. * Updates a dynamic vertex buffer.
  114263. * @param vertexBuffer the vertex buffer to update
  114264. * @param vertices the data used to update the vertex buffer
  114265. * @param byteOffset the byte offset of the data (optional)
  114266. * @param byteLength the byte length of the data (optional)
  114267. */
  114268. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  114269. /** @hidden */
  114270. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  114271. /** @hidden */
  114272. _bindTexture(channel: number, texture: InternalTexture): void;
  114273. protected _deleteBuffer(buffer: WebGLBuffer): void;
  114274. /**
  114275. * 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
  114276. */
  114277. releaseEffects(): void;
  114278. displayLoadingUI(): void;
  114279. hideLoadingUI(): void;
  114280. /** @hidden */
  114281. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  114282. /** @hidden */
  114283. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  114284. /** @hidden */
  114285. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  114286. /** @hidden */
  114287. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  114288. }
  114289. }
  114290. declare module BABYLON {
  114291. /** @hidden */
  114292. export class _OcclusionDataStorage {
  114293. /** @hidden */
  114294. occlusionInternalRetryCounter: number;
  114295. /** @hidden */
  114296. isOcclusionQueryInProgress: boolean;
  114297. /** @hidden */
  114298. isOccluded: boolean;
  114299. /** @hidden */
  114300. occlusionRetryCount: number;
  114301. /** @hidden */
  114302. occlusionType: number;
  114303. /** @hidden */
  114304. occlusionQueryAlgorithmType: number;
  114305. }
  114306. interface Engine {
  114307. /**
  114308. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  114309. * @return the new query
  114310. */
  114311. createQuery(): WebGLQuery;
  114312. /**
  114313. * Delete and release a webGL query
  114314. * @param query defines the query to delete
  114315. * @return the current engine
  114316. */
  114317. deleteQuery(query: WebGLQuery): Engine;
  114318. /**
  114319. * Check if a given query has resolved and got its value
  114320. * @param query defines the query to check
  114321. * @returns true if the query got its value
  114322. */
  114323. isQueryResultAvailable(query: WebGLQuery): boolean;
  114324. /**
  114325. * Gets the value of a given query
  114326. * @param query defines the query to check
  114327. * @returns the value of the query
  114328. */
  114329. getQueryResult(query: WebGLQuery): number;
  114330. /**
  114331. * Initiates an occlusion query
  114332. * @param algorithmType defines the algorithm to use
  114333. * @param query defines the query to use
  114334. * @returns the current engine
  114335. * @see http://doc.babylonjs.com/features/occlusionquery
  114336. */
  114337. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  114338. /**
  114339. * Ends an occlusion query
  114340. * @see http://doc.babylonjs.com/features/occlusionquery
  114341. * @param algorithmType defines the algorithm to use
  114342. * @returns the current engine
  114343. */
  114344. endOcclusionQuery(algorithmType: number): Engine;
  114345. /**
  114346. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  114347. * Please note that only one query can be issued at a time
  114348. * @returns a time token used to track the time span
  114349. */
  114350. startTimeQuery(): Nullable<_TimeToken>;
  114351. /**
  114352. * Ends a time query
  114353. * @param token defines the token used to measure the time span
  114354. * @returns the time spent (in ns)
  114355. */
  114356. endTimeQuery(token: _TimeToken): int;
  114357. /** @hidden */
  114358. _currentNonTimestampToken: Nullable<_TimeToken>;
  114359. /** @hidden */
  114360. _createTimeQuery(): WebGLQuery;
  114361. /** @hidden */
  114362. _deleteTimeQuery(query: WebGLQuery): void;
  114363. /** @hidden */
  114364. _getGlAlgorithmType(algorithmType: number): number;
  114365. /** @hidden */
  114366. _getTimeQueryResult(query: WebGLQuery): any;
  114367. /** @hidden */
  114368. _getTimeQueryAvailability(query: WebGLQuery): any;
  114369. }
  114370. interface AbstractMesh {
  114371. /**
  114372. * Backing filed
  114373. * @hidden
  114374. */
  114375. __occlusionDataStorage: _OcclusionDataStorage;
  114376. /**
  114377. * Access property
  114378. * @hidden
  114379. */
  114380. _occlusionDataStorage: _OcclusionDataStorage;
  114381. /**
  114382. * 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.
  114383. * The default value is -1 which means don't break the query and wait till the result
  114384. * @see http://doc.babylonjs.com/features/occlusionquery
  114385. */
  114386. occlusionRetryCount: number;
  114387. /**
  114388. * 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:
  114389. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  114390. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  114391. * * 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.
  114392. * @see http://doc.babylonjs.com/features/occlusionquery
  114393. */
  114394. occlusionType: number;
  114395. /**
  114396. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  114397. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  114398. * * 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.
  114399. * @see http://doc.babylonjs.com/features/occlusionquery
  114400. */
  114401. occlusionQueryAlgorithmType: number;
  114402. /**
  114403. * 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
  114404. * @see http://doc.babylonjs.com/features/occlusionquery
  114405. */
  114406. isOccluded: boolean;
  114407. /**
  114408. * Flag to check the progress status of the query
  114409. * @see http://doc.babylonjs.com/features/occlusionquery
  114410. */
  114411. isOcclusionQueryInProgress: boolean;
  114412. }
  114413. }
  114414. declare module BABYLON {
  114415. /** @hidden */
  114416. export var _forceTransformFeedbackToBundle: boolean;
  114417. interface Engine {
  114418. /**
  114419. * Creates a webGL transform feedback object
  114420. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  114421. * @returns the webGL transform feedback object
  114422. */
  114423. createTransformFeedback(): WebGLTransformFeedback;
  114424. /**
  114425. * Delete a webGL transform feedback object
  114426. * @param value defines the webGL transform feedback object to delete
  114427. */
  114428. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  114429. /**
  114430. * Bind a webGL transform feedback object to the webgl context
  114431. * @param value defines the webGL transform feedback object to bind
  114432. */
  114433. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  114434. /**
  114435. * Begins a transform feedback operation
  114436. * @param usePoints defines if points or triangles must be used
  114437. */
  114438. beginTransformFeedback(usePoints: boolean): void;
  114439. /**
  114440. * Ends a transform feedback operation
  114441. */
  114442. endTransformFeedback(): void;
  114443. /**
  114444. * Specify the varyings to use with transform feedback
  114445. * @param program defines the associated webGL program
  114446. * @param value defines the list of strings representing the varying names
  114447. */
  114448. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  114449. /**
  114450. * Bind a webGL buffer for a transform feedback operation
  114451. * @param value defines the webGL buffer to bind
  114452. */
  114453. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  114454. }
  114455. }
  114456. declare module BABYLON {
  114457. /**
  114458. * Creation options of the multi render target texture.
  114459. */
  114460. export interface IMultiRenderTargetOptions {
  114461. /**
  114462. * Define if the texture needs to create mip maps after render.
  114463. */
  114464. generateMipMaps?: boolean;
  114465. /**
  114466. * Define the types of all the draw buffers we want to create
  114467. */
  114468. types?: number[];
  114469. /**
  114470. * Define the sampling modes of all the draw buffers we want to create
  114471. */
  114472. samplingModes?: number[];
  114473. /**
  114474. * Define if a depth buffer is required
  114475. */
  114476. generateDepthBuffer?: boolean;
  114477. /**
  114478. * Define if a stencil buffer is required
  114479. */
  114480. generateStencilBuffer?: boolean;
  114481. /**
  114482. * Define if a depth texture is required instead of a depth buffer
  114483. */
  114484. generateDepthTexture?: boolean;
  114485. /**
  114486. * Define the number of desired draw buffers
  114487. */
  114488. textureCount?: number;
  114489. /**
  114490. * Define if aspect ratio should be adapted to the texture or stay the scene one
  114491. */
  114492. doNotChangeAspectRatio?: boolean;
  114493. /**
  114494. * Define the default type of the buffers we are creating
  114495. */
  114496. defaultType?: number;
  114497. }
  114498. /**
  114499. * A multi render target, like a render target provides the ability to render to a texture.
  114500. * Unlike the render target, it can render to several draw buffers in one draw.
  114501. * This is specially interesting in deferred rendering or for any effects requiring more than
  114502. * just one color from a single pass.
  114503. */
  114504. export class MultiRenderTarget extends RenderTargetTexture {
  114505. private _internalTextures;
  114506. private _textures;
  114507. private _multiRenderTargetOptions;
  114508. /**
  114509. * Get if draw buffers are currently supported by the used hardware and browser.
  114510. */
  114511. readonly isSupported: boolean;
  114512. /**
  114513. * Get the list of textures generated by the multi render target.
  114514. */
  114515. readonly textures: Texture[];
  114516. /**
  114517. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  114518. */
  114519. readonly depthTexture: Texture;
  114520. /**
  114521. * Set the wrapping mode on U of all the textures we are rendering to.
  114522. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  114523. */
  114524. wrapU: number;
  114525. /**
  114526. * Set the wrapping mode on V of all the textures we are rendering to.
  114527. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  114528. */
  114529. wrapV: number;
  114530. /**
  114531. * Instantiate a new multi render target texture.
  114532. * A multi render target, like a render target provides the ability to render to a texture.
  114533. * Unlike the render target, it can render to several draw buffers in one draw.
  114534. * This is specially interesting in deferred rendering or for any effects requiring more than
  114535. * just one color from a single pass.
  114536. * @param name Define the name of the texture
  114537. * @param size Define the size of the buffers to render to
  114538. * @param count Define the number of target we are rendering into
  114539. * @param scene Define the scene the texture belongs to
  114540. * @param options Define the options used to create the multi render target
  114541. */
  114542. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  114543. /** @hidden */
  114544. _rebuild(): void;
  114545. private _createInternalTextures;
  114546. private _createTextures;
  114547. /**
  114548. * Define the number of samples used if MSAA is enabled.
  114549. */
  114550. samples: number;
  114551. /**
  114552. * Resize all the textures in the multi render target.
  114553. * Be carrefull as it will recreate all the data in the new texture.
  114554. * @param size Define the new size
  114555. */
  114556. resize(size: any): void;
  114557. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  114558. /**
  114559. * Dispose the render targets and their associated resources
  114560. */
  114561. dispose(): void;
  114562. /**
  114563. * Release all the underlying texture used as draw buffers.
  114564. */
  114565. releaseInternalTextures(): void;
  114566. }
  114567. }
  114568. declare module BABYLON {
  114569. interface ThinEngine {
  114570. /**
  114571. * Unbind a list of render target textures from the webGL context
  114572. * This is used only when drawBuffer extension or webGL2 are active
  114573. * @param textures defines the render target textures to unbind
  114574. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  114575. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  114576. */
  114577. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  114578. /**
  114579. * Create a multi render target texture
  114580. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  114581. * @param size defines the size of the texture
  114582. * @param options defines the creation options
  114583. * @returns the cube texture as an InternalTexture
  114584. */
  114585. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  114586. /**
  114587. * Update the sample count for a given multiple render target texture
  114588. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  114589. * @param textures defines the textures to update
  114590. * @param samples defines the sample count to set
  114591. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  114592. */
  114593. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  114594. }
  114595. }
  114596. declare module BABYLON {
  114597. /**
  114598. * Class used to define an additional view for the engine
  114599. * @see https://doc.babylonjs.com/how_to/multi_canvases
  114600. */
  114601. export class EngineView {
  114602. /** Defines the canvas where to render the view */
  114603. target: HTMLCanvasElement;
  114604. /** Defines an optional camera used to render the view (will use active camera else) */
  114605. camera?: Camera;
  114606. }
  114607. interface Engine {
  114608. /**
  114609. * Gets or sets the HTML element to use for attaching events
  114610. */
  114611. inputElement: Nullable<HTMLElement>;
  114612. /**
  114613. * Gets the current engine view
  114614. * @see https://doc.babylonjs.com/how_to/multi_canvases
  114615. */
  114616. activeView: Nullable<EngineView>;
  114617. /** Gets or sets the list of views */
  114618. views: EngineView[];
  114619. /**
  114620. * Register a new child canvas
  114621. * @param canvas defines the canvas to register
  114622. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  114623. * @returns the associated view
  114624. */
  114625. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  114626. /**
  114627. * Remove a registered child canvas
  114628. * @param canvas defines the canvas to remove
  114629. * @returns the current engine
  114630. */
  114631. unRegisterView(canvas: HTMLCanvasElement): Engine;
  114632. }
  114633. }
  114634. declare module BABYLON {
  114635. /**
  114636. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  114637. */
  114638. export interface CubeMapInfo {
  114639. /**
  114640. * The pixel array for the front face.
  114641. * This is stored in format, left to right, up to down format.
  114642. */
  114643. front: Nullable<ArrayBufferView>;
  114644. /**
  114645. * The pixel array for the back face.
  114646. * This is stored in format, left to right, up to down format.
  114647. */
  114648. back: Nullable<ArrayBufferView>;
  114649. /**
  114650. * The pixel array for the left face.
  114651. * This is stored in format, left to right, up to down format.
  114652. */
  114653. left: Nullable<ArrayBufferView>;
  114654. /**
  114655. * The pixel array for the right face.
  114656. * This is stored in format, left to right, up to down format.
  114657. */
  114658. right: Nullable<ArrayBufferView>;
  114659. /**
  114660. * The pixel array for the up face.
  114661. * This is stored in format, left to right, up to down format.
  114662. */
  114663. up: Nullable<ArrayBufferView>;
  114664. /**
  114665. * The pixel array for the down face.
  114666. * This is stored in format, left to right, up to down format.
  114667. */
  114668. down: Nullable<ArrayBufferView>;
  114669. /**
  114670. * The size of the cubemap stored.
  114671. *
  114672. * Each faces will be size * size pixels.
  114673. */
  114674. size: number;
  114675. /**
  114676. * The format of the texture.
  114677. *
  114678. * RGBA, RGB.
  114679. */
  114680. format: number;
  114681. /**
  114682. * The type of the texture data.
  114683. *
  114684. * UNSIGNED_INT, FLOAT.
  114685. */
  114686. type: number;
  114687. /**
  114688. * Specifies whether the texture is in gamma space.
  114689. */
  114690. gammaSpace: boolean;
  114691. }
  114692. /**
  114693. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  114694. */
  114695. export class PanoramaToCubeMapTools {
  114696. private static FACE_FRONT;
  114697. private static FACE_BACK;
  114698. private static FACE_RIGHT;
  114699. private static FACE_LEFT;
  114700. private static FACE_DOWN;
  114701. private static FACE_UP;
  114702. /**
  114703. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  114704. *
  114705. * @param float32Array The source data.
  114706. * @param inputWidth The width of the input panorama.
  114707. * @param inputHeight The height of the input panorama.
  114708. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  114709. * @return The cubemap data
  114710. */
  114711. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  114712. private static CreateCubemapTexture;
  114713. private static CalcProjectionSpherical;
  114714. }
  114715. }
  114716. declare module BABYLON {
  114717. /**
  114718. * Helper class dealing with the extraction of spherical polynomial dataArray
  114719. * from a cube map.
  114720. */
  114721. export class CubeMapToSphericalPolynomialTools {
  114722. private static FileFaces;
  114723. /**
  114724. * Converts a texture to the according Spherical Polynomial data.
  114725. * This extracts the first 3 orders only as they are the only one used in the lighting.
  114726. *
  114727. * @param texture The texture to extract the information from.
  114728. * @return The Spherical Polynomial data.
  114729. */
  114730. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  114731. /**
  114732. * Converts a cubemap to the according Spherical Polynomial data.
  114733. * This extracts the first 3 orders only as they are the only one used in the lighting.
  114734. *
  114735. * @param cubeInfo The Cube map to extract the information from.
  114736. * @return The Spherical Polynomial data.
  114737. */
  114738. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  114739. }
  114740. }
  114741. declare module BABYLON {
  114742. interface BaseTexture {
  114743. /**
  114744. * Get the polynomial representation of the texture data.
  114745. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  114746. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  114747. */
  114748. sphericalPolynomial: Nullable<SphericalPolynomial>;
  114749. }
  114750. }
  114751. declare module BABYLON {
  114752. /** @hidden */
  114753. export var rgbdEncodePixelShader: {
  114754. name: string;
  114755. shader: string;
  114756. };
  114757. }
  114758. declare module BABYLON {
  114759. /** @hidden */
  114760. export var rgbdDecodePixelShader: {
  114761. name: string;
  114762. shader: string;
  114763. };
  114764. }
  114765. declare module BABYLON {
  114766. /**
  114767. * Raw texture data and descriptor sufficient for WebGL texture upload
  114768. */
  114769. export interface EnvironmentTextureInfo {
  114770. /**
  114771. * Version of the environment map
  114772. */
  114773. version: number;
  114774. /**
  114775. * Width of image
  114776. */
  114777. width: number;
  114778. /**
  114779. * Irradiance information stored in the file.
  114780. */
  114781. irradiance: any;
  114782. /**
  114783. * Specular information stored in the file.
  114784. */
  114785. specular: any;
  114786. }
  114787. /**
  114788. * Defines One Image in the file. It requires only the position in the file
  114789. * as well as the length.
  114790. */
  114791. interface BufferImageData {
  114792. /**
  114793. * Length of the image data.
  114794. */
  114795. length: number;
  114796. /**
  114797. * Position of the data from the null terminator delimiting the end of the JSON.
  114798. */
  114799. position: number;
  114800. }
  114801. /**
  114802. * Defines the specular data enclosed in the file.
  114803. * This corresponds to the version 1 of the data.
  114804. */
  114805. export interface EnvironmentTextureSpecularInfoV1 {
  114806. /**
  114807. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  114808. */
  114809. specularDataPosition?: number;
  114810. /**
  114811. * This contains all the images data needed to reconstruct the cubemap.
  114812. */
  114813. mipmaps: Array<BufferImageData>;
  114814. /**
  114815. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  114816. */
  114817. lodGenerationScale: number;
  114818. }
  114819. /**
  114820. * Sets of helpers addressing the serialization and deserialization of environment texture
  114821. * stored in a BabylonJS env file.
  114822. * Those files are usually stored as .env files.
  114823. */
  114824. export class EnvironmentTextureTools {
  114825. /**
  114826. * Magic number identifying the env file.
  114827. */
  114828. private static _MagicBytes;
  114829. /**
  114830. * Gets the environment info from an env file.
  114831. * @param data The array buffer containing the .env bytes.
  114832. * @returns the environment file info (the json header) if successfully parsed.
  114833. */
  114834. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  114835. /**
  114836. * Creates an environment texture from a loaded cube texture.
  114837. * @param texture defines the cube texture to convert in env file
  114838. * @return a promise containing the environment data if succesfull.
  114839. */
  114840. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  114841. /**
  114842. * Creates a JSON representation of the spherical data.
  114843. * @param texture defines the texture containing the polynomials
  114844. * @return the JSON representation of the spherical info
  114845. */
  114846. private static _CreateEnvTextureIrradiance;
  114847. /**
  114848. * Creates the ArrayBufferViews used for initializing environment texture image data.
  114849. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  114850. * @param info parameters that determine what views will be created for accessing the underlying buffer
  114851. * @return the views described by info providing access to the underlying buffer
  114852. */
  114853. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  114854. /**
  114855. * Uploads the texture info contained in the env file to the GPU.
  114856. * @param texture defines the internal texture to upload to
  114857. * @param arrayBuffer defines the buffer cotaining the data to load
  114858. * @param info defines the texture info retrieved through the GetEnvInfo method
  114859. * @returns a promise
  114860. */
  114861. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  114862. private static _OnImageReadyAsync;
  114863. /**
  114864. * Uploads the levels of image data to the GPU.
  114865. * @param texture defines the internal texture to upload to
  114866. * @param imageData defines the array buffer views of image data [mipmap][face]
  114867. * @returns a promise
  114868. */
  114869. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  114870. /**
  114871. * Uploads spherical polynomials information to the texture.
  114872. * @param texture defines the texture we are trying to upload the information to
  114873. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  114874. */
  114875. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  114876. /** @hidden */
  114877. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  114878. }
  114879. }
  114880. declare module BABYLON {
  114881. /**
  114882. * Contains position and normal vectors for a vertex
  114883. */
  114884. export class PositionNormalVertex {
  114885. /** the position of the vertex (defaut: 0,0,0) */
  114886. position: Vector3;
  114887. /** the normal of the vertex (defaut: 0,1,0) */
  114888. normal: Vector3;
  114889. /**
  114890. * Creates a PositionNormalVertex
  114891. * @param position the position of the vertex (defaut: 0,0,0)
  114892. * @param normal the normal of the vertex (defaut: 0,1,0)
  114893. */
  114894. constructor(
  114895. /** the position of the vertex (defaut: 0,0,0) */
  114896. position?: Vector3,
  114897. /** the normal of the vertex (defaut: 0,1,0) */
  114898. normal?: Vector3);
  114899. /**
  114900. * Clones the PositionNormalVertex
  114901. * @returns the cloned PositionNormalVertex
  114902. */
  114903. clone(): PositionNormalVertex;
  114904. }
  114905. /**
  114906. * Contains position, normal and uv vectors for a vertex
  114907. */
  114908. export class PositionNormalTextureVertex {
  114909. /** the position of the vertex (defaut: 0,0,0) */
  114910. position: Vector3;
  114911. /** the normal of the vertex (defaut: 0,1,0) */
  114912. normal: Vector3;
  114913. /** the uv of the vertex (default: 0,0) */
  114914. uv: Vector2;
  114915. /**
  114916. * Creates a PositionNormalTextureVertex
  114917. * @param position the position of the vertex (defaut: 0,0,0)
  114918. * @param normal the normal of the vertex (defaut: 0,1,0)
  114919. * @param uv the uv of the vertex (default: 0,0)
  114920. */
  114921. constructor(
  114922. /** the position of the vertex (defaut: 0,0,0) */
  114923. position?: Vector3,
  114924. /** the normal of the vertex (defaut: 0,1,0) */
  114925. normal?: Vector3,
  114926. /** the uv of the vertex (default: 0,0) */
  114927. uv?: Vector2);
  114928. /**
  114929. * Clones the PositionNormalTextureVertex
  114930. * @returns the cloned PositionNormalTextureVertex
  114931. */
  114932. clone(): PositionNormalTextureVertex;
  114933. }
  114934. }
  114935. declare module BABYLON {
  114936. /** @hidden */
  114937. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  114938. private _genericAttributeLocation;
  114939. private _varyingLocationCount;
  114940. private _varyingLocationMap;
  114941. private _replacements;
  114942. private _textureCount;
  114943. private _uniforms;
  114944. lineProcessor(line: string): string;
  114945. attributeProcessor(attribute: string): string;
  114946. varyingProcessor(varying: string, isFragment: boolean): string;
  114947. uniformProcessor(uniform: string): string;
  114948. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  114949. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  114950. }
  114951. }
  114952. declare module BABYLON {
  114953. /**
  114954. * Container for accessors for natively-stored mesh data buffers.
  114955. */
  114956. class NativeDataBuffer extends DataBuffer {
  114957. /**
  114958. * Accessor value used to identify/retrieve a natively-stored index buffer.
  114959. */
  114960. nativeIndexBuffer?: any;
  114961. /**
  114962. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  114963. */
  114964. nativeVertexBuffer?: any;
  114965. }
  114966. /** @hidden */
  114967. class NativeTexture extends InternalTexture {
  114968. getInternalTexture(): InternalTexture;
  114969. getViewCount(): number;
  114970. }
  114971. /** @hidden */
  114972. export class NativeEngine extends Engine {
  114973. private readonly _native;
  114974. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  114975. private readonly INVALID_HANDLE;
  114976. getHardwareScalingLevel(): number;
  114977. constructor();
  114978. /**
  114979. * Can be used to override the current requestAnimationFrame requester.
  114980. * @hidden
  114981. */
  114982. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  114983. /**
  114984. * Override default engine behavior.
  114985. * @param color
  114986. * @param backBuffer
  114987. * @param depth
  114988. * @param stencil
  114989. */
  114990. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  114991. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  114992. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  114993. createVertexBuffer(data: DataArray): NativeDataBuffer;
  114994. recordVertexArrayObject(vertexBuffers: {
  114995. [key: string]: VertexBuffer;
  114996. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  114997. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  114998. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  114999. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  115000. /**
  115001. * Draw a list of indexed primitives
  115002. * @param fillMode defines the primitive to use
  115003. * @param indexStart defines the starting index
  115004. * @param indexCount defines the number of index to draw
  115005. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  115006. */
  115007. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  115008. /**
  115009. * Draw a list of unindexed primitives
  115010. * @param fillMode defines the primitive to use
  115011. * @param verticesStart defines the index of first vertex to draw
  115012. * @param verticesCount defines the count of vertices to draw
  115013. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  115014. */
  115015. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  115016. createPipelineContext(): IPipelineContext;
  115017. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  115018. /** @hidden */
  115019. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  115020. /** @hidden */
  115021. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  115022. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  115023. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  115024. protected _setProgram(program: WebGLProgram): void;
  115025. _releaseEffect(effect: Effect): void;
  115026. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  115027. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  115028. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  115029. bindSamplers(effect: Effect): void;
  115030. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  115031. getRenderWidth(useScreen?: boolean): number;
  115032. getRenderHeight(useScreen?: boolean): number;
  115033. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  115034. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  115035. /**
  115036. * Set the z offset to apply to current rendering
  115037. * @param value defines the offset to apply
  115038. */
  115039. setZOffset(value: number): void;
  115040. /**
  115041. * Gets the current value of the zOffset
  115042. * @returns the current zOffset state
  115043. */
  115044. getZOffset(): number;
  115045. /**
  115046. * Enable or disable depth buffering
  115047. * @param enable defines the state to set
  115048. */
  115049. setDepthBuffer(enable: boolean): void;
  115050. /**
  115051. * Gets a boolean indicating if depth writing is enabled
  115052. * @returns the current depth writing state
  115053. */
  115054. getDepthWrite(): boolean;
  115055. /**
  115056. * Enable or disable depth writing
  115057. * @param enable defines the state to set
  115058. */
  115059. setDepthWrite(enable: boolean): void;
  115060. /**
  115061. * Enable or disable color writing
  115062. * @param enable defines the state to set
  115063. */
  115064. setColorWrite(enable: boolean): void;
  115065. /**
  115066. * Gets a boolean indicating if color writing is enabled
  115067. * @returns the current color writing state
  115068. */
  115069. getColorWrite(): boolean;
  115070. /**
  115071. * Sets alpha constants used by some alpha blending modes
  115072. * @param r defines the red component
  115073. * @param g defines the green component
  115074. * @param b defines the blue component
  115075. * @param a defines the alpha component
  115076. */
  115077. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  115078. /**
  115079. * Sets the current alpha mode
  115080. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  115081. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  115082. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  115083. */
  115084. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  115085. /**
  115086. * Gets the current alpha mode
  115087. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  115088. * @returns the current alpha mode
  115089. */
  115090. getAlphaMode(): number;
  115091. setInt(uniform: WebGLUniformLocation, int: number): void;
  115092. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  115093. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  115094. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  115095. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  115096. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  115097. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  115098. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  115099. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  115100. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  115101. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  115102. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  115103. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  115104. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  115105. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  115106. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  115107. setFloat(uniform: WebGLUniformLocation, value: number): void;
  115108. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  115109. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  115110. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  115111. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  115112. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  115113. wipeCaches(bruteForce?: boolean): void;
  115114. _createTexture(): WebGLTexture;
  115115. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  115116. /**
  115117. * Usually called from BABYLON.Texture.ts.
  115118. * Passed information to create a WebGLTexture
  115119. * @param urlArg defines a value which contains one of the following:
  115120. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  115121. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  115122. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  115123. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  115124. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  115125. * @param scene needed for loading to the correct scene
  115126. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  115127. * @param onLoad optional callback to be called upon successful completion
  115128. * @param onError optional callback to be called upon failure
  115129. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  115130. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  115131. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  115132. * @param forcedExtension defines the extension to use to pick the right loader
  115133. * @returns a InternalTexture for assignment back into BABYLON.Texture
  115134. */
  115135. 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 | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>): InternalTexture;
  115136. /**
  115137. * Creates a cube texture
  115138. * @param rootUrl defines the url where the files to load is located
  115139. * @param scene defines the current scene
  115140. * @param files defines the list of files to load (1 per face)
  115141. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  115142. * @param onLoad defines an optional callback raised when the texture is loaded
  115143. * @param onError defines an optional callback raised if there is an issue to load the texture
  115144. * @param format defines the format of the data
  115145. * @param forcedExtension defines the extension to use to pick the right loader
  115146. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  115147. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  115148. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  115149. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  115150. * @returns the cube texture as an InternalTexture
  115151. */
  115152. 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, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>): InternalTexture;
  115153. private _getSamplingFilter;
  115154. private static _GetNativeTextureFormat;
  115155. createRenderTargetTexture(size: number | {
  115156. width: number;
  115157. height: number;
  115158. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  115159. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  115160. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  115161. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  115162. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  115163. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  115164. /**
  115165. * Updates a dynamic vertex buffer.
  115166. * @param vertexBuffer the vertex buffer to update
  115167. * @param data the data used to update the vertex buffer
  115168. * @param byteOffset the byte offset of the data (optional)
  115169. * @param byteLength the byte length of the data (optional)
  115170. */
  115171. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  115172. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  115173. private _updateAnisotropicLevel;
  115174. private _getAddressMode;
  115175. /** @hidden */
  115176. _bindTexture(channel: number, texture: InternalTexture): void;
  115177. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  115178. releaseEffects(): void;
  115179. /** @hidden */
  115180. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  115181. /** @hidden */
  115182. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  115183. /** @hidden */
  115184. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  115185. /** @hidden */
  115186. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  115187. }
  115188. }
  115189. declare module BABYLON {
  115190. /**
  115191. * Gather the list of clipboard event types as constants.
  115192. */
  115193. export class ClipboardEventTypes {
  115194. /**
  115195. * The clipboard event is fired when a copy command is active (pressed).
  115196. */
  115197. static readonly COPY: number;
  115198. /**
  115199. * The clipboard event is fired when a cut command is active (pressed).
  115200. */
  115201. static readonly CUT: number;
  115202. /**
  115203. * The clipboard event is fired when a paste command is active (pressed).
  115204. */
  115205. static readonly PASTE: number;
  115206. }
  115207. /**
  115208. * This class is used to store clipboard related info for the onClipboardObservable event.
  115209. */
  115210. export class ClipboardInfo {
  115211. /**
  115212. * Defines the type of event (BABYLON.ClipboardEventTypes)
  115213. */
  115214. type: number;
  115215. /**
  115216. * Defines the related dom event
  115217. */
  115218. event: ClipboardEvent;
  115219. /**
  115220. *Creates an instance of ClipboardInfo.
  115221. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  115222. * @param event Defines the related dom event
  115223. */
  115224. constructor(
  115225. /**
  115226. * Defines the type of event (BABYLON.ClipboardEventTypes)
  115227. */
  115228. type: number,
  115229. /**
  115230. * Defines the related dom event
  115231. */
  115232. event: ClipboardEvent);
  115233. /**
  115234. * Get the clipboard event's type from the keycode.
  115235. * @param keyCode Defines the keyCode for the current keyboard event.
  115236. * @return {number}
  115237. */
  115238. static GetTypeFromCharacter(keyCode: number): number;
  115239. }
  115240. }
  115241. declare module BABYLON {
  115242. /**
  115243. * Google Daydream controller
  115244. */
  115245. export class DaydreamController extends WebVRController {
  115246. /**
  115247. * Base Url for the controller model.
  115248. */
  115249. static MODEL_BASE_URL: string;
  115250. /**
  115251. * File name for the controller model.
  115252. */
  115253. static MODEL_FILENAME: string;
  115254. /**
  115255. * Gamepad Id prefix used to identify Daydream Controller.
  115256. */
  115257. static readonly GAMEPAD_ID_PREFIX: string;
  115258. /**
  115259. * Creates a new DaydreamController from a gamepad
  115260. * @param vrGamepad the gamepad that the controller should be created from
  115261. */
  115262. constructor(vrGamepad: any);
  115263. /**
  115264. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  115265. * @param scene scene in which to add meshes
  115266. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  115267. */
  115268. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  115269. /**
  115270. * Called once for each button that changed state since the last frame
  115271. * @param buttonIdx Which button index changed
  115272. * @param state New state of the button
  115273. * @param changes Which properties on the state changed since last frame
  115274. */
  115275. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  115276. }
  115277. }
  115278. declare module BABYLON {
  115279. /**
  115280. * Gear VR Controller
  115281. */
  115282. export class GearVRController extends WebVRController {
  115283. /**
  115284. * Base Url for the controller model.
  115285. */
  115286. static MODEL_BASE_URL: string;
  115287. /**
  115288. * File name for the controller model.
  115289. */
  115290. static MODEL_FILENAME: string;
  115291. /**
  115292. * Gamepad Id prefix used to identify this controller.
  115293. */
  115294. static readonly GAMEPAD_ID_PREFIX: string;
  115295. private readonly _buttonIndexToObservableNameMap;
  115296. /**
  115297. * Creates a new GearVRController from a gamepad
  115298. * @param vrGamepad the gamepad that the controller should be created from
  115299. */
  115300. constructor(vrGamepad: any);
  115301. /**
  115302. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  115303. * @param scene scene in which to add meshes
  115304. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  115305. */
  115306. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  115307. /**
  115308. * Called once for each button that changed state since the last frame
  115309. * @param buttonIdx Which button index changed
  115310. * @param state New state of the button
  115311. * @param changes Which properties on the state changed since last frame
  115312. */
  115313. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  115314. }
  115315. }
  115316. declare module BABYLON {
  115317. /**
  115318. * Class containing static functions to help procedurally build meshes
  115319. */
  115320. export class PolyhedronBuilder {
  115321. /**
  115322. * Creates a polyhedron mesh
  115323. * * 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
  115324. * * The parameter `size` (positive float, default 1) sets the polygon size
  115325. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  115326. * * 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`
  115327. * * 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
  115328. * * 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)`)
  115329. * * 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
  115330. * * 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
  115331. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115332. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115333. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115334. * @param name defines the name of the mesh
  115335. * @param options defines the options used to create the mesh
  115336. * @param scene defines the hosting scene
  115337. * @returns the polyhedron mesh
  115338. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  115339. */
  115340. static CreatePolyhedron(name: string, options: {
  115341. type?: number;
  115342. size?: number;
  115343. sizeX?: number;
  115344. sizeY?: number;
  115345. sizeZ?: number;
  115346. custom?: any;
  115347. faceUV?: Vector4[];
  115348. faceColors?: Color4[];
  115349. flat?: boolean;
  115350. updatable?: boolean;
  115351. sideOrientation?: number;
  115352. frontUVs?: Vector4;
  115353. backUVs?: Vector4;
  115354. }, scene?: Nullable<Scene>): Mesh;
  115355. }
  115356. }
  115357. declare module BABYLON {
  115358. /**
  115359. * Gizmo that enables scaling a mesh along 3 axis
  115360. */
  115361. export class ScaleGizmo extends Gizmo {
  115362. /**
  115363. * Internal gizmo used for interactions on the x axis
  115364. */
  115365. xGizmo: AxisScaleGizmo;
  115366. /**
  115367. * Internal gizmo used for interactions on the y axis
  115368. */
  115369. yGizmo: AxisScaleGizmo;
  115370. /**
  115371. * Internal gizmo used for interactions on the z axis
  115372. */
  115373. zGizmo: AxisScaleGizmo;
  115374. /**
  115375. * Internal gizmo used to scale all axis equally
  115376. */
  115377. uniformScaleGizmo: AxisScaleGizmo;
  115378. private _meshAttached;
  115379. private _updateGizmoRotationToMatchAttachedMesh;
  115380. private _snapDistance;
  115381. private _scaleRatio;
  115382. private _uniformScalingMesh;
  115383. private _octahedron;
  115384. private _sensitivity;
  115385. /** Fires an event when any of it's sub gizmos are dragged */
  115386. onDragStartObservable: Observable<unknown>;
  115387. /** Fires an event when any of it's sub gizmos are released from dragging */
  115388. onDragEndObservable: Observable<unknown>;
  115389. attachedMesh: Nullable<AbstractMesh>;
  115390. /**
  115391. * Creates a ScaleGizmo
  115392. * @param gizmoLayer The utility layer the gizmo will be added to
  115393. */
  115394. constructor(gizmoLayer?: UtilityLayerRenderer);
  115395. updateGizmoRotationToMatchAttachedMesh: boolean;
  115396. /**
  115397. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  115398. */
  115399. snapDistance: number;
  115400. /**
  115401. * Ratio for the scale of the gizmo (Default: 1)
  115402. */
  115403. scaleRatio: number;
  115404. /**
  115405. * Sensitivity factor for dragging (Default: 1)
  115406. */
  115407. sensitivity: number;
  115408. /**
  115409. * Disposes of the gizmo
  115410. */
  115411. dispose(): void;
  115412. }
  115413. }
  115414. declare module BABYLON {
  115415. /**
  115416. * Single axis scale gizmo
  115417. */
  115418. export class AxisScaleGizmo extends Gizmo {
  115419. /**
  115420. * Drag behavior responsible for the gizmos dragging interactions
  115421. */
  115422. dragBehavior: PointerDragBehavior;
  115423. private _pointerObserver;
  115424. /**
  115425. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  115426. */
  115427. snapDistance: number;
  115428. /**
  115429. * Event that fires each time the gizmo snaps to a new location.
  115430. * * snapDistance is the the change in distance
  115431. */
  115432. onSnapObservable: Observable<{
  115433. snapDistance: number;
  115434. }>;
  115435. /**
  115436. * If the scaling operation should be done on all axis (default: false)
  115437. */
  115438. uniformScaling: boolean;
  115439. /**
  115440. * Custom sensitivity value for the drag strength
  115441. */
  115442. sensitivity: number;
  115443. private _isEnabled;
  115444. private _parent;
  115445. private _arrow;
  115446. private _coloredMaterial;
  115447. private _hoverMaterial;
  115448. /**
  115449. * Creates an AxisScaleGizmo
  115450. * @param gizmoLayer The utility layer the gizmo will be added to
  115451. * @param dragAxis The axis which the gizmo will be able to scale on
  115452. * @param color The color of the gizmo
  115453. */
  115454. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  115455. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  115456. /**
  115457. * If the gizmo is enabled
  115458. */
  115459. isEnabled: boolean;
  115460. /**
  115461. * Disposes of the gizmo
  115462. */
  115463. dispose(): void;
  115464. /**
  115465. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  115466. * @param mesh The mesh to replace the default mesh of the gizmo
  115467. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  115468. */
  115469. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  115470. }
  115471. }
  115472. declare module BABYLON {
  115473. /**
  115474. * Bounding box gizmo
  115475. */
  115476. export class BoundingBoxGizmo extends Gizmo {
  115477. private _lineBoundingBox;
  115478. private _rotateSpheresParent;
  115479. private _scaleBoxesParent;
  115480. private _boundingDimensions;
  115481. private _renderObserver;
  115482. private _pointerObserver;
  115483. private _scaleDragSpeed;
  115484. private _tmpQuaternion;
  115485. private _tmpVector;
  115486. private _tmpRotationMatrix;
  115487. /**
  115488. * 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)
  115489. */
  115490. ignoreChildren: boolean;
  115491. /**
  115492. * 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)
  115493. */
  115494. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  115495. /**
  115496. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  115497. */
  115498. rotationSphereSize: number;
  115499. /**
  115500. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  115501. */
  115502. scaleBoxSize: number;
  115503. /**
  115504. * 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)
  115505. */
  115506. fixedDragMeshScreenSize: boolean;
  115507. /**
  115508. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  115509. */
  115510. fixedDragMeshScreenSizeDistanceFactor: number;
  115511. /**
  115512. * Fired when a rotation sphere or scale box is dragged
  115513. */
  115514. onDragStartObservable: Observable<{}>;
  115515. /**
  115516. * Fired when a scale box is dragged
  115517. */
  115518. onScaleBoxDragObservable: Observable<{}>;
  115519. /**
  115520. * Fired when a scale box drag is ended
  115521. */
  115522. onScaleBoxDragEndObservable: Observable<{}>;
  115523. /**
  115524. * Fired when a rotation sphere is dragged
  115525. */
  115526. onRotationSphereDragObservable: Observable<{}>;
  115527. /**
  115528. * Fired when a rotation sphere drag is ended
  115529. */
  115530. onRotationSphereDragEndObservable: Observable<{}>;
  115531. /**
  115532. * 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)
  115533. */
  115534. scalePivot: Nullable<Vector3>;
  115535. /**
  115536. * Mesh used as a pivot to rotate the attached mesh
  115537. */
  115538. private _anchorMesh;
  115539. private _existingMeshScale;
  115540. private _dragMesh;
  115541. private pointerDragBehavior;
  115542. private coloredMaterial;
  115543. private hoverColoredMaterial;
  115544. /**
  115545. * Sets the color of the bounding box gizmo
  115546. * @param color the color to set
  115547. */
  115548. setColor(color: Color3): void;
  115549. /**
  115550. * Creates an BoundingBoxGizmo
  115551. * @param gizmoLayer The utility layer the gizmo will be added to
  115552. * @param color The color of the gizmo
  115553. */
  115554. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  115555. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  115556. private _selectNode;
  115557. /**
  115558. * Updates the bounding box information for the Gizmo
  115559. */
  115560. updateBoundingBox(): void;
  115561. private _updateRotationSpheres;
  115562. private _updateScaleBoxes;
  115563. /**
  115564. * Enables rotation on the specified axis and disables rotation on the others
  115565. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  115566. */
  115567. setEnabledRotationAxis(axis: string): void;
  115568. /**
  115569. * Enables/disables scaling
  115570. * @param enable if scaling should be enabled
  115571. */
  115572. setEnabledScaling(enable: boolean): void;
  115573. private _updateDummy;
  115574. /**
  115575. * Enables a pointer drag behavior on the bounding box of the gizmo
  115576. */
  115577. enableDragBehavior(): void;
  115578. /**
  115579. * Disposes of the gizmo
  115580. */
  115581. dispose(): void;
  115582. /**
  115583. * 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)
  115584. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  115585. * @returns the bounding box mesh with the passed in mesh as a child
  115586. */
  115587. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  115588. /**
  115589. * CustomMeshes are not supported by this gizmo
  115590. * @param mesh The mesh to replace the default mesh of the gizmo
  115591. */
  115592. setCustomMesh(mesh: Mesh): void;
  115593. }
  115594. }
  115595. declare module BABYLON {
  115596. /**
  115597. * Single plane rotation gizmo
  115598. */
  115599. export class PlaneRotationGizmo extends Gizmo {
  115600. /**
  115601. * Drag behavior responsible for the gizmos dragging interactions
  115602. */
  115603. dragBehavior: PointerDragBehavior;
  115604. private _pointerObserver;
  115605. /**
  115606. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  115607. */
  115608. snapDistance: number;
  115609. /**
  115610. * Event that fires each time the gizmo snaps to a new location.
  115611. * * snapDistance is the the change in distance
  115612. */
  115613. onSnapObservable: Observable<{
  115614. snapDistance: number;
  115615. }>;
  115616. private _isEnabled;
  115617. private _parent;
  115618. /**
  115619. * Creates a PlaneRotationGizmo
  115620. * @param gizmoLayer The utility layer the gizmo will be added to
  115621. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  115622. * @param color The color of the gizmo
  115623. * @param tessellation Amount of tessellation to be used when creating rotation circles
  115624. * @param useEulerRotation Use and update Euler angle instead of quaternion
  115625. */
  115626. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  115627. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  115628. /**
  115629. * If the gizmo is enabled
  115630. */
  115631. isEnabled: boolean;
  115632. /**
  115633. * Disposes of the gizmo
  115634. */
  115635. dispose(): void;
  115636. }
  115637. }
  115638. declare module BABYLON {
  115639. /**
  115640. * Gizmo that enables rotating a mesh along 3 axis
  115641. */
  115642. export class RotationGizmo extends Gizmo {
  115643. /**
  115644. * Internal gizmo used for interactions on the x axis
  115645. */
  115646. xGizmo: PlaneRotationGizmo;
  115647. /**
  115648. * Internal gizmo used for interactions on the y axis
  115649. */
  115650. yGizmo: PlaneRotationGizmo;
  115651. /**
  115652. * Internal gizmo used for interactions on the z axis
  115653. */
  115654. zGizmo: PlaneRotationGizmo;
  115655. /** Fires an event when any of it's sub gizmos are dragged */
  115656. onDragStartObservable: Observable<unknown>;
  115657. /** Fires an event when any of it's sub gizmos are released from dragging */
  115658. onDragEndObservable: Observable<unknown>;
  115659. private _meshAttached;
  115660. attachedMesh: Nullable<AbstractMesh>;
  115661. /**
  115662. * Creates a RotationGizmo
  115663. * @param gizmoLayer The utility layer the gizmo will be added to
  115664. * @param tessellation Amount of tessellation to be used when creating rotation circles
  115665. * @param useEulerRotation Use and update Euler angle instead of quaternion
  115666. */
  115667. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  115668. updateGizmoRotationToMatchAttachedMesh: boolean;
  115669. /**
  115670. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  115671. */
  115672. snapDistance: number;
  115673. /**
  115674. * Ratio for the scale of the gizmo (Default: 1)
  115675. */
  115676. scaleRatio: number;
  115677. /**
  115678. * Disposes of the gizmo
  115679. */
  115680. dispose(): void;
  115681. /**
  115682. * CustomMeshes are not supported by this gizmo
  115683. * @param mesh The mesh to replace the default mesh of the gizmo
  115684. */
  115685. setCustomMesh(mesh: Mesh): void;
  115686. }
  115687. }
  115688. declare module BABYLON {
  115689. /**
  115690. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  115691. */
  115692. export class GizmoManager implements IDisposable {
  115693. private scene;
  115694. /**
  115695. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  115696. */
  115697. gizmos: {
  115698. positionGizmo: Nullable<PositionGizmo>;
  115699. rotationGizmo: Nullable<RotationGizmo>;
  115700. scaleGizmo: Nullable<ScaleGizmo>;
  115701. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  115702. };
  115703. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  115704. clearGizmoOnEmptyPointerEvent: boolean;
  115705. /** Fires an event when the manager is attached to a mesh */
  115706. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  115707. private _gizmosEnabled;
  115708. private _pointerObserver;
  115709. private _attachedMesh;
  115710. private _boundingBoxColor;
  115711. private _defaultUtilityLayer;
  115712. private _defaultKeepDepthUtilityLayer;
  115713. /**
  115714. * When bounding box gizmo is enabled, this can be used to track drag/end events
  115715. */
  115716. boundingBoxDragBehavior: SixDofDragBehavior;
  115717. /**
  115718. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  115719. */
  115720. attachableMeshes: Nullable<Array<AbstractMesh>>;
  115721. /**
  115722. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  115723. */
  115724. usePointerToAttachGizmos: boolean;
  115725. /**
  115726. * Utility layer that the bounding box gizmo belongs to
  115727. */
  115728. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  115729. /**
  115730. * Utility layer that all gizmos besides bounding box belong to
  115731. */
  115732. readonly utilityLayer: UtilityLayerRenderer;
  115733. /**
  115734. * Instatiates a gizmo manager
  115735. * @param scene the scene to overlay the gizmos on top of
  115736. */
  115737. constructor(scene: Scene);
  115738. /**
  115739. * Attaches a set of gizmos to the specified mesh
  115740. * @param mesh The mesh the gizmo's should be attached to
  115741. */
  115742. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  115743. /**
  115744. * If the position gizmo is enabled
  115745. */
  115746. positionGizmoEnabled: boolean;
  115747. /**
  115748. * If the rotation gizmo is enabled
  115749. */
  115750. rotationGizmoEnabled: boolean;
  115751. /**
  115752. * If the scale gizmo is enabled
  115753. */
  115754. scaleGizmoEnabled: boolean;
  115755. /**
  115756. * If the boundingBox gizmo is enabled
  115757. */
  115758. boundingBoxGizmoEnabled: boolean;
  115759. /**
  115760. * Disposes of the gizmo manager
  115761. */
  115762. dispose(): void;
  115763. }
  115764. }
  115765. declare module BABYLON {
  115766. /**
  115767. * A directional light is defined by a direction (what a surprise!).
  115768. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  115769. * 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.
  115770. * Documentation: https://doc.babylonjs.com/babylon101/lights
  115771. */
  115772. export class DirectionalLight extends ShadowLight {
  115773. private _shadowFrustumSize;
  115774. /**
  115775. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  115776. */
  115777. /**
  115778. * Specifies a fix frustum size for the shadow generation.
  115779. */
  115780. shadowFrustumSize: number;
  115781. private _shadowOrthoScale;
  115782. /**
  115783. * Gets the shadow projection scale against the optimal computed one.
  115784. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  115785. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  115786. */
  115787. /**
  115788. * Sets the shadow projection scale against the optimal computed one.
  115789. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  115790. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  115791. */
  115792. shadowOrthoScale: number;
  115793. /**
  115794. * Automatically compute the projection matrix to best fit (including all the casters)
  115795. * on each frame.
  115796. */
  115797. autoUpdateExtends: boolean;
  115798. private _orthoLeft;
  115799. private _orthoRight;
  115800. private _orthoTop;
  115801. private _orthoBottom;
  115802. /**
  115803. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  115804. * The directional light is emitted from everywhere in the given direction.
  115805. * It can cast shadows.
  115806. * Documentation : https://doc.babylonjs.com/babylon101/lights
  115807. * @param name The friendly name of the light
  115808. * @param direction The direction of the light
  115809. * @param scene The scene the light belongs to
  115810. */
  115811. constructor(name: string, direction: Vector3, scene: Scene);
  115812. /**
  115813. * Returns the string "DirectionalLight".
  115814. * @return The class name
  115815. */
  115816. getClassName(): string;
  115817. /**
  115818. * Returns the integer 1.
  115819. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  115820. */
  115821. getTypeID(): number;
  115822. /**
  115823. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  115824. * Returns the DirectionalLight Shadow projection matrix.
  115825. */
  115826. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  115827. /**
  115828. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  115829. * Returns the DirectionalLight Shadow projection matrix.
  115830. */
  115831. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  115832. /**
  115833. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  115834. * Returns the DirectionalLight Shadow projection matrix.
  115835. */
  115836. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  115837. protected _buildUniformLayout(): void;
  115838. /**
  115839. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  115840. * @param effect The effect to update
  115841. * @param lightIndex The index of the light in the effect to update
  115842. * @returns The directional light
  115843. */
  115844. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  115845. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  115846. /**
  115847. * Gets the minZ used for shadow according to both the scene and the light.
  115848. *
  115849. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  115850. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  115851. * @param activeCamera The camera we are returning the min for
  115852. * @returns the depth min z
  115853. */
  115854. getDepthMinZ(activeCamera: Camera): number;
  115855. /**
  115856. * Gets the maxZ used for shadow according to both the scene and the light.
  115857. *
  115858. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  115859. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  115860. * @param activeCamera The camera we are returning the max for
  115861. * @returns the depth max z
  115862. */
  115863. getDepthMaxZ(activeCamera: Camera): number;
  115864. /**
  115865. * Prepares the list of defines specific to the light type.
  115866. * @param defines the list of defines
  115867. * @param lightIndex defines the index of the light for the effect
  115868. */
  115869. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  115870. }
  115871. }
  115872. declare module BABYLON {
  115873. /**
  115874. * Class containing static functions to help procedurally build meshes
  115875. */
  115876. export class HemisphereBuilder {
  115877. /**
  115878. * Creates a hemisphere mesh
  115879. * @param name defines the name of the mesh
  115880. * @param options defines the options used to create the mesh
  115881. * @param scene defines the hosting scene
  115882. * @returns the hemisphere mesh
  115883. */
  115884. static CreateHemisphere(name: string, options: {
  115885. segments?: number;
  115886. diameter?: number;
  115887. sideOrientation?: number;
  115888. }, scene: any): Mesh;
  115889. }
  115890. }
  115891. declare module BABYLON {
  115892. /**
  115893. * A spot light is defined by a position, a direction, an angle, and an exponent.
  115894. * These values define a cone of light starting from the position, emitting toward the direction.
  115895. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  115896. * and the exponent defines the speed of the decay of the light with distance (reach).
  115897. * Documentation: https://doc.babylonjs.com/babylon101/lights
  115898. */
  115899. export class SpotLight extends ShadowLight {
  115900. private _angle;
  115901. private _innerAngle;
  115902. private _cosHalfAngle;
  115903. private _lightAngleScale;
  115904. private _lightAngleOffset;
  115905. /**
  115906. * Gets the cone angle of the spot light in Radians.
  115907. */
  115908. /**
  115909. * Sets the cone angle of the spot light in Radians.
  115910. */
  115911. angle: number;
  115912. /**
  115913. * Only used in gltf falloff mode, this defines the angle where
  115914. * the directional falloff will start before cutting at angle which could be seen
  115915. * as outer angle.
  115916. */
  115917. /**
  115918. * Only used in gltf falloff mode, this defines the angle where
  115919. * the directional falloff will start before cutting at angle which could be seen
  115920. * as outer angle.
  115921. */
  115922. innerAngle: number;
  115923. private _shadowAngleScale;
  115924. /**
  115925. * Allows scaling the angle of the light for shadow generation only.
  115926. */
  115927. /**
  115928. * Allows scaling the angle of the light for shadow generation only.
  115929. */
  115930. shadowAngleScale: number;
  115931. /**
  115932. * The light decay speed with the distance from the emission spot.
  115933. */
  115934. exponent: number;
  115935. private _projectionTextureMatrix;
  115936. /**
  115937. * Allows reading the projecton texture
  115938. */
  115939. readonly projectionTextureMatrix: Matrix;
  115940. protected _projectionTextureLightNear: number;
  115941. /**
  115942. * Gets the near clip of the Spotlight for texture projection.
  115943. */
  115944. /**
  115945. * Sets the near clip of the Spotlight for texture projection.
  115946. */
  115947. projectionTextureLightNear: number;
  115948. protected _projectionTextureLightFar: number;
  115949. /**
  115950. * Gets the far clip of the Spotlight for texture projection.
  115951. */
  115952. /**
  115953. * Sets the far clip of the Spotlight for texture projection.
  115954. */
  115955. projectionTextureLightFar: number;
  115956. protected _projectionTextureUpDirection: Vector3;
  115957. /**
  115958. * Gets the Up vector of the Spotlight for texture projection.
  115959. */
  115960. /**
  115961. * Sets the Up vector of the Spotlight for texture projection.
  115962. */
  115963. projectionTextureUpDirection: Vector3;
  115964. private _projectionTexture;
  115965. /**
  115966. * Gets the projection texture of the light.
  115967. */
  115968. /**
  115969. * Sets the projection texture of the light.
  115970. */
  115971. projectionTexture: Nullable<BaseTexture>;
  115972. private _projectionTextureViewLightDirty;
  115973. private _projectionTextureProjectionLightDirty;
  115974. private _projectionTextureDirty;
  115975. private _projectionTextureViewTargetVector;
  115976. private _projectionTextureViewLightMatrix;
  115977. private _projectionTextureProjectionLightMatrix;
  115978. private _projectionTextureScalingMatrix;
  115979. /**
  115980. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  115981. * It can cast shadows.
  115982. * Documentation : https://doc.babylonjs.com/babylon101/lights
  115983. * @param name The light friendly name
  115984. * @param position The position of the spot light in the scene
  115985. * @param direction The direction of the light in the scene
  115986. * @param angle The cone angle of the light in Radians
  115987. * @param exponent The light decay speed with the distance from the emission spot
  115988. * @param scene The scene the lights belongs to
  115989. */
  115990. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  115991. /**
  115992. * Returns the string "SpotLight".
  115993. * @returns the class name
  115994. */
  115995. getClassName(): string;
  115996. /**
  115997. * Returns the integer 2.
  115998. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  115999. */
  116000. getTypeID(): number;
  116001. /**
  116002. * Overrides the direction setter to recompute the projection texture view light Matrix.
  116003. */
  116004. protected _setDirection(value: Vector3): void;
  116005. /**
  116006. * Overrides the position setter to recompute the projection texture view light Matrix.
  116007. */
  116008. protected _setPosition(value: Vector3): void;
  116009. /**
  116010. * 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.
  116011. * Returns the SpotLight.
  116012. */
  116013. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  116014. protected _computeProjectionTextureViewLightMatrix(): void;
  116015. protected _computeProjectionTextureProjectionLightMatrix(): void;
  116016. /**
  116017. * Main function for light texture projection matrix computing.
  116018. */
  116019. protected _computeProjectionTextureMatrix(): void;
  116020. protected _buildUniformLayout(): void;
  116021. private _computeAngleValues;
  116022. /**
  116023. * Sets the passed Effect "effect" with the Light textures.
  116024. * @param effect The effect to update
  116025. * @param lightIndex The index of the light in the effect to update
  116026. * @returns The light
  116027. */
  116028. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  116029. /**
  116030. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  116031. * @param effect The effect to update
  116032. * @param lightIndex The index of the light in the effect to update
  116033. * @returns The spot light
  116034. */
  116035. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  116036. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  116037. /**
  116038. * Disposes the light and the associated resources.
  116039. */
  116040. dispose(): void;
  116041. /**
  116042. * Prepares the list of defines specific to the light type.
  116043. * @param defines the list of defines
  116044. * @param lightIndex defines the index of the light for the effect
  116045. */
  116046. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  116047. }
  116048. }
  116049. declare module BABYLON {
  116050. /**
  116051. * Gizmo that enables viewing a light
  116052. */
  116053. export class LightGizmo extends Gizmo {
  116054. private _lightMesh;
  116055. private _material;
  116056. private _cachedPosition;
  116057. private _cachedForward;
  116058. private _attachedMeshParent;
  116059. /**
  116060. * Creates a LightGizmo
  116061. * @param gizmoLayer The utility layer the gizmo will be added to
  116062. */
  116063. constructor(gizmoLayer?: UtilityLayerRenderer);
  116064. private _light;
  116065. /**
  116066. * The light that the gizmo is attached to
  116067. */
  116068. light: Nullable<Light>;
  116069. /**
  116070. * Gets the material used to render the light gizmo
  116071. */
  116072. readonly material: StandardMaterial;
  116073. /**
  116074. * @hidden
  116075. * Updates the gizmo to match the attached mesh's position/rotation
  116076. */
  116077. protected _update(): void;
  116078. private static _Scale;
  116079. /**
  116080. * Creates the lines for a light mesh
  116081. */
  116082. private static _CreateLightLines;
  116083. /**
  116084. * Disposes of the light gizmo
  116085. */
  116086. dispose(): void;
  116087. private static _CreateHemisphericLightMesh;
  116088. private static _CreatePointLightMesh;
  116089. private static _CreateSpotLightMesh;
  116090. private static _CreateDirectionalLightMesh;
  116091. }
  116092. }
  116093. declare module BABYLON {
  116094. /** @hidden */
  116095. export var backgroundFragmentDeclaration: {
  116096. name: string;
  116097. shader: string;
  116098. };
  116099. }
  116100. declare module BABYLON {
  116101. /** @hidden */
  116102. export var backgroundUboDeclaration: {
  116103. name: string;
  116104. shader: string;
  116105. };
  116106. }
  116107. declare module BABYLON {
  116108. /** @hidden */
  116109. export var backgroundPixelShader: {
  116110. name: string;
  116111. shader: string;
  116112. };
  116113. }
  116114. declare module BABYLON {
  116115. /** @hidden */
  116116. export var backgroundVertexDeclaration: {
  116117. name: string;
  116118. shader: string;
  116119. };
  116120. }
  116121. declare module BABYLON {
  116122. /** @hidden */
  116123. export var backgroundVertexShader: {
  116124. name: string;
  116125. shader: string;
  116126. };
  116127. }
  116128. declare module BABYLON {
  116129. /**
  116130. * Background material used to create an efficient environement around your scene.
  116131. */
  116132. export class BackgroundMaterial extends PushMaterial {
  116133. /**
  116134. * Standard reflectance value at parallel view angle.
  116135. */
  116136. static StandardReflectance0: number;
  116137. /**
  116138. * Standard reflectance value at grazing angle.
  116139. */
  116140. static StandardReflectance90: number;
  116141. protected _primaryColor: Color3;
  116142. /**
  116143. * Key light Color (multiply against the environement texture)
  116144. */
  116145. primaryColor: Color3;
  116146. protected __perceptualColor: Nullable<Color3>;
  116147. /**
  116148. * Experimental Internal Use Only.
  116149. *
  116150. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  116151. * This acts as a helper to set the primary color to a more "human friendly" value.
  116152. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  116153. * output color as close as possible from the chosen value.
  116154. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  116155. * part of lighting setup.)
  116156. */
  116157. _perceptualColor: Nullable<Color3>;
  116158. protected _primaryColorShadowLevel: float;
  116159. /**
  116160. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  116161. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  116162. */
  116163. primaryColorShadowLevel: float;
  116164. protected _primaryColorHighlightLevel: float;
  116165. /**
  116166. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  116167. * The primary color is used at the level chosen to define what the white area would look.
  116168. */
  116169. primaryColorHighlightLevel: float;
  116170. protected _reflectionTexture: Nullable<BaseTexture>;
  116171. /**
  116172. * Reflection Texture used in the material.
  116173. * Should be author in a specific way for the best result (refer to the documentation).
  116174. */
  116175. reflectionTexture: Nullable<BaseTexture>;
  116176. protected _reflectionBlur: float;
  116177. /**
  116178. * Reflection Texture level of blur.
  116179. *
  116180. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  116181. * texture twice.
  116182. */
  116183. reflectionBlur: float;
  116184. protected _diffuseTexture: Nullable<BaseTexture>;
  116185. /**
  116186. * Diffuse Texture used in the material.
  116187. * Should be author in a specific way for the best result (refer to the documentation).
  116188. */
  116189. diffuseTexture: Nullable<BaseTexture>;
  116190. protected _shadowLights: Nullable<IShadowLight[]>;
  116191. /**
  116192. * Specify the list of lights casting shadow on the material.
  116193. * All scene shadow lights will be included if null.
  116194. */
  116195. shadowLights: Nullable<IShadowLight[]>;
  116196. protected _shadowLevel: float;
  116197. /**
  116198. * Helps adjusting the shadow to a softer level if required.
  116199. * 0 means black shadows and 1 means no shadows.
  116200. */
  116201. shadowLevel: float;
  116202. protected _sceneCenter: Vector3;
  116203. /**
  116204. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  116205. * It is usually zero but might be interesting to modify according to your setup.
  116206. */
  116207. sceneCenter: Vector3;
  116208. protected _opacityFresnel: boolean;
  116209. /**
  116210. * This helps specifying that the material is falling off to the sky box at grazing angle.
  116211. * This helps ensuring a nice transition when the camera goes under the ground.
  116212. */
  116213. opacityFresnel: boolean;
  116214. protected _reflectionFresnel: boolean;
  116215. /**
  116216. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  116217. * This helps adding a mirror texture on the ground.
  116218. */
  116219. reflectionFresnel: boolean;
  116220. protected _reflectionFalloffDistance: number;
  116221. /**
  116222. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  116223. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  116224. */
  116225. reflectionFalloffDistance: number;
  116226. protected _reflectionAmount: number;
  116227. /**
  116228. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  116229. */
  116230. reflectionAmount: number;
  116231. protected _reflectionReflectance0: number;
  116232. /**
  116233. * This specifies the weight of the reflection at grazing angle.
  116234. */
  116235. reflectionReflectance0: number;
  116236. protected _reflectionReflectance90: number;
  116237. /**
  116238. * This specifies the weight of the reflection at a perpendicular point of view.
  116239. */
  116240. reflectionReflectance90: number;
  116241. /**
  116242. * Sets the reflection reflectance fresnel values according to the default standard
  116243. * empirically know to work well :-)
  116244. */
  116245. reflectionStandardFresnelWeight: number;
  116246. protected _useRGBColor: boolean;
  116247. /**
  116248. * Helps to directly use the maps channels instead of their level.
  116249. */
  116250. useRGBColor: boolean;
  116251. protected _enableNoise: boolean;
  116252. /**
  116253. * This helps reducing the banding effect that could occur on the background.
  116254. */
  116255. enableNoise: boolean;
  116256. /**
  116257. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  116258. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  116259. * Recommended to be keep at 1.0 except for special cases.
  116260. */
  116261. fovMultiplier: number;
  116262. private _fovMultiplier;
  116263. /**
  116264. * Enable the FOV adjustment feature controlled by fovMultiplier.
  116265. */
  116266. useEquirectangularFOV: boolean;
  116267. private _maxSimultaneousLights;
  116268. /**
  116269. * Number of Simultaneous lights allowed on the material.
  116270. */
  116271. maxSimultaneousLights: int;
  116272. /**
  116273. * Default configuration related to image processing available in the Background Material.
  116274. */
  116275. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  116276. /**
  116277. * Keep track of the image processing observer to allow dispose and replace.
  116278. */
  116279. private _imageProcessingObserver;
  116280. /**
  116281. * Attaches a new image processing configuration to the PBR Material.
  116282. * @param configuration (if null the scene configuration will be use)
  116283. */
  116284. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  116285. /**
  116286. * Gets the image processing configuration used either in this material.
  116287. */
  116288. /**
  116289. * Sets the Default image processing configuration used either in the this material.
  116290. *
  116291. * If sets to null, the scene one is in use.
  116292. */
  116293. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  116294. /**
  116295. * Gets wether the color curves effect is enabled.
  116296. */
  116297. /**
  116298. * Sets wether the color curves effect is enabled.
  116299. */
  116300. cameraColorCurvesEnabled: boolean;
  116301. /**
  116302. * Gets wether the color grading effect is enabled.
  116303. */
  116304. /**
  116305. * Gets wether the color grading effect is enabled.
  116306. */
  116307. cameraColorGradingEnabled: boolean;
  116308. /**
  116309. * Gets wether tonemapping is enabled or not.
  116310. */
  116311. /**
  116312. * Sets wether tonemapping is enabled or not
  116313. */
  116314. cameraToneMappingEnabled: boolean;
  116315. /**
  116316. * The camera exposure used on this material.
  116317. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  116318. * This corresponds to a photographic exposure.
  116319. */
  116320. /**
  116321. * The camera exposure used on this material.
  116322. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  116323. * This corresponds to a photographic exposure.
  116324. */
  116325. cameraExposure: float;
  116326. /**
  116327. * Gets The camera contrast used on this material.
  116328. */
  116329. /**
  116330. * Sets The camera contrast used on this material.
  116331. */
  116332. cameraContrast: float;
  116333. /**
  116334. * Gets the Color Grading 2D Lookup Texture.
  116335. */
  116336. /**
  116337. * Sets the Color Grading 2D Lookup Texture.
  116338. */
  116339. cameraColorGradingTexture: Nullable<BaseTexture>;
  116340. /**
  116341. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  116342. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  116343. * 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;
  116344. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  116345. */
  116346. /**
  116347. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  116348. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  116349. * 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;
  116350. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  116351. */
  116352. cameraColorCurves: Nullable<ColorCurves>;
  116353. /**
  116354. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  116355. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  116356. */
  116357. switchToBGR: boolean;
  116358. private _renderTargets;
  116359. private _reflectionControls;
  116360. private _white;
  116361. private _primaryShadowColor;
  116362. private _primaryHighlightColor;
  116363. /**
  116364. * Instantiates a Background Material in the given scene
  116365. * @param name The friendly name of the material
  116366. * @param scene The scene to add the material to
  116367. */
  116368. constructor(name: string, scene: Scene);
  116369. /**
  116370. * Gets a boolean indicating that current material needs to register RTT
  116371. */
  116372. readonly hasRenderTargetTextures: boolean;
  116373. /**
  116374. * The entire material has been created in order to prevent overdraw.
  116375. * @returns false
  116376. */
  116377. needAlphaTesting(): boolean;
  116378. /**
  116379. * The entire material has been created in order to prevent overdraw.
  116380. * @returns true if blending is enable
  116381. */
  116382. needAlphaBlending(): boolean;
  116383. /**
  116384. * Checks wether the material is ready to be rendered for a given mesh.
  116385. * @param mesh The mesh to render
  116386. * @param subMesh The submesh to check against
  116387. * @param useInstances Specify wether or not the material is used with instances
  116388. * @returns true if all the dependencies are ready (Textures, Effects...)
  116389. */
  116390. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  116391. /**
  116392. * Compute the primary color according to the chosen perceptual color.
  116393. */
  116394. private _computePrimaryColorFromPerceptualColor;
  116395. /**
  116396. * Compute the highlights and shadow colors according to their chosen levels.
  116397. */
  116398. private _computePrimaryColors;
  116399. /**
  116400. * Build the uniform buffer used in the material.
  116401. */
  116402. buildUniformLayout(): void;
  116403. /**
  116404. * Unbind the material.
  116405. */
  116406. unbind(): void;
  116407. /**
  116408. * Bind only the world matrix to the material.
  116409. * @param world The world matrix to bind.
  116410. */
  116411. bindOnlyWorldMatrix(world: Matrix): void;
  116412. /**
  116413. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  116414. * @param world The world matrix to bind.
  116415. * @param subMesh The submesh to bind for.
  116416. */
  116417. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  116418. /**
  116419. * Checks to see if a texture is used in the material.
  116420. * @param texture - Base texture to use.
  116421. * @returns - Boolean specifying if a texture is used in the material.
  116422. */
  116423. hasTexture(texture: BaseTexture): boolean;
  116424. /**
  116425. * Dispose the material.
  116426. * @param forceDisposeEffect Force disposal of the associated effect.
  116427. * @param forceDisposeTextures Force disposal of the associated textures.
  116428. */
  116429. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  116430. /**
  116431. * Clones the material.
  116432. * @param name The cloned name.
  116433. * @returns The cloned material.
  116434. */
  116435. clone(name: string): BackgroundMaterial;
  116436. /**
  116437. * Serializes the current material to its JSON representation.
  116438. * @returns The JSON representation.
  116439. */
  116440. serialize(): any;
  116441. /**
  116442. * Gets the class name of the material
  116443. * @returns "BackgroundMaterial"
  116444. */
  116445. getClassName(): string;
  116446. /**
  116447. * Parse a JSON input to create back a background material.
  116448. * @param source The JSON data to parse
  116449. * @param scene The scene to create the parsed material in
  116450. * @param rootUrl The root url of the assets the material depends upon
  116451. * @returns the instantiated BackgroundMaterial.
  116452. */
  116453. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  116454. }
  116455. }
  116456. declare module BABYLON {
  116457. /**
  116458. * Represents the different options available during the creation of
  116459. * a Environment helper.
  116460. *
  116461. * This can control the default ground, skybox and image processing setup of your scene.
  116462. */
  116463. export interface IEnvironmentHelperOptions {
  116464. /**
  116465. * Specifies wether or not to create a ground.
  116466. * True by default.
  116467. */
  116468. createGround: boolean;
  116469. /**
  116470. * Specifies the ground size.
  116471. * 15 by default.
  116472. */
  116473. groundSize: number;
  116474. /**
  116475. * The texture used on the ground for the main color.
  116476. * Comes from the BabylonJS CDN by default.
  116477. *
  116478. * Remarks: Can be either a texture or a url.
  116479. */
  116480. groundTexture: string | BaseTexture;
  116481. /**
  116482. * The color mixed in the ground texture by default.
  116483. * BabylonJS clearColor by default.
  116484. */
  116485. groundColor: Color3;
  116486. /**
  116487. * Specifies the ground opacity.
  116488. * 1 by default.
  116489. */
  116490. groundOpacity: number;
  116491. /**
  116492. * Enables the ground to receive shadows.
  116493. * True by default.
  116494. */
  116495. enableGroundShadow: boolean;
  116496. /**
  116497. * Helps preventing the shadow to be fully black on the ground.
  116498. * 0.5 by default.
  116499. */
  116500. groundShadowLevel: number;
  116501. /**
  116502. * Creates a mirror texture attach to the ground.
  116503. * false by default.
  116504. */
  116505. enableGroundMirror: boolean;
  116506. /**
  116507. * Specifies the ground mirror size ratio.
  116508. * 0.3 by default as the default kernel is 64.
  116509. */
  116510. groundMirrorSizeRatio: number;
  116511. /**
  116512. * Specifies the ground mirror blur kernel size.
  116513. * 64 by default.
  116514. */
  116515. groundMirrorBlurKernel: number;
  116516. /**
  116517. * Specifies the ground mirror visibility amount.
  116518. * 1 by default
  116519. */
  116520. groundMirrorAmount: number;
  116521. /**
  116522. * Specifies the ground mirror reflectance weight.
  116523. * This uses the standard weight of the background material to setup the fresnel effect
  116524. * of the mirror.
  116525. * 1 by default.
  116526. */
  116527. groundMirrorFresnelWeight: number;
  116528. /**
  116529. * Specifies the ground mirror Falloff distance.
  116530. * This can helps reducing the size of the reflection.
  116531. * 0 by Default.
  116532. */
  116533. groundMirrorFallOffDistance: number;
  116534. /**
  116535. * Specifies the ground mirror texture type.
  116536. * Unsigned Int by Default.
  116537. */
  116538. groundMirrorTextureType: number;
  116539. /**
  116540. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  116541. * the shown objects.
  116542. */
  116543. groundYBias: number;
  116544. /**
  116545. * Specifies wether or not to create a skybox.
  116546. * True by default.
  116547. */
  116548. createSkybox: boolean;
  116549. /**
  116550. * Specifies the skybox size.
  116551. * 20 by default.
  116552. */
  116553. skyboxSize: number;
  116554. /**
  116555. * The texture used on the skybox for the main color.
  116556. * Comes from the BabylonJS CDN by default.
  116557. *
  116558. * Remarks: Can be either a texture or a url.
  116559. */
  116560. skyboxTexture: string | BaseTexture;
  116561. /**
  116562. * The color mixed in the skybox texture by default.
  116563. * BabylonJS clearColor by default.
  116564. */
  116565. skyboxColor: Color3;
  116566. /**
  116567. * The background rotation around the Y axis of the scene.
  116568. * This helps aligning the key lights of your scene with the background.
  116569. * 0 by default.
  116570. */
  116571. backgroundYRotation: number;
  116572. /**
  116573. * Compute automatically the size of the elements to best fit with the scene.
  116574. */
  116575. sizeAuto: boolean;
  116576. /**
  116577. * Default position of the rootMesh if autoSize is not true.
  116578. */
  116579. rootPosition: Vector3;
  116580. /**
  116581. * Sets up the image processing in the scene.
  116582. * true by default.
  116583. */
  116584. setupImageProcessing: boolean;
  116585. /**
  116586. * The texture used as your environment texture in the scene.
  116587. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  116588. *
  116589. * Remarks: Can be either a texture or a url.
  116590. */
  116591. environmentTexture: string | BaseTexture;
  116592. /**
  116593. * The value of the exposure to apply to the scene.
  116594. * 0.6 by default if setupImageProcessing is true.
  116595. */
  116596. cameraExposure: number;
  116597. /**
  116598. * The value of the contrast to apply to the scene.
  116599. * 1.6 by default if setupImageProcessing is true.
  116600. */
  116601. cameraContrast: number;
  116602. /**
  116603. * Specifies wether or not tonemapping should be enabled in the scene.
  116604. * true by default if setupImageProcessing is true.
  116605. */
  116606. toneMappingEnabled: boolean;
  116607. }
  116608. /**
  116609. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  116610. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  116611. * It also helps with the default setup of your imageProcessing configuration.
  116612. */
  116613. export class EnvironmentHelper {
  116614. /**
  116615. * Default ground texture URL.
  116616. */
  116617. private static _groundTextureCDNUrl;
  116618. /**
  116619. * Default skybox texture URL.
  116620. */
  116621. private static _skyboxTextureCDNUrl;
  116622. /**
  116623. * Default environment texture URL.
  116624. */
  116625. private static _environmentTextureCDNUrl;
  116626. /**
  116627. * Creates the default options for the helper.
  116628. */
  116629. private static _getDefaultOptions;
  116630. private _rootMesh;
  116631. /**
  116632. * Gets the root mesh created by the helper.
  116633. */
  116634. readonly rootMesh: Mesh;
  116635. private _skybox;
  116636. /**
  116637. * Gets the skybox created by the helper.
  116638. */
  116639. readonly skybox: Nullable<Mesh>;
  116640. private _skyboxTexture;
  116641. /**
  116642. * Gets the skybox texture created by the helper.
  116643. */
  116644. readonly skyboxTexture: Nullable<BaseTexture>;
  116645. private _skyboxMaterial;
  116646. /**
  116647. * Gets the skybox material created by the helper.
  116648. */
  116649. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  116650. private _ground;
  116651. /**
  116652. * Gets the ground mesh created by the helper.
  116653. */
  116654. readonly ground: Nullable<Mesh>;
  116655. private _groundTexture;
  116656. /**
  116657. * Gets the ground texture created by the helper.
  116658. */
  116659. readonly groundTexture: Nullable<BaseTexture>;
  116660. private _groundMirror;
  116661. /**
  116662. * Gets the ground mirror created by the helper.
  116663. */
  116664. readonly groundMirror: Nullable<MirrorTexture>;
  116665. /**
  116666. * Gets the ground mirror render list to helps pushing the meshes
  116667. * you wish in the ground reflection.
  116668. */
  116669. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  116670. private _groundMaterial;
  116671. /**
  116672. * Gets the ground material created by the helper.
  116673. */
  116674. readonly groundMaterial: Nullable<BackgroundMaterial>;
  116675. /**
  116676. * Stores the creation options.
  116677. */
  116678. private readonly _scene;
  116679. private _options;
  116680. /**
  116681. * This observable will be notified with any error during the creation of the environment,
  116682. * mainly texture creation errors.
  116683. */
  116684. onErrorObservable: Observable<{
  116685. message?: string;
  116686. exception?: any;
  116687. }>;
  116688. /**
  116689. * constructor
  116690. * @param options Defines the options we want to customize the helper
  116691. * @param scene The scene to add the material to
  116692. */
  116693. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  116694. /**
  116695. * Updates the background according to the new options
  116696. * @param options
  116697. */
  116698. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  116699. /**
  116700. * Sets the primary color of all the available elements.
  116701. * @param color the main color to affect to the ground and the background
  116702. */
  116703. setMainColor(color: Color3): void;
  116704. /**
  116705. * Setup the image processing according to the specified options.
  116706. */
  116707. private _setupImageProcessing;
  116708. /**
  116709. * Setup the environment texture according to the specified options.
  116710. */
  116711. private _setupEnvironmentTexture;
  116712. /**
  116713. * Setup the background according to the specified options.
  116714. */
  116715. private _setupBackground;
  116716. /**
  116717. * Get the scene sizes according to the setup.
  116718. */
  116719. private _getSceneSize;
  116720. /**
  116721. * Setup the ground according to the specified options.
  116722. */
  116723. private _setupGround;
  116724. /**
  116725. * Setup the ground material according to the specified options.
  116726. */
  116727. private _setupGroundMaterial;
  116728. /**
  116729. * Setup the ground diffuse texture according to the specified options.
  116730. */
  116731. private _setupGroundDiffuseTexture;
  116732. /**
  116733. * Setup the ground mirror texture according to the specified options.
  116734. */
  116735. private _setupGroundMirrorTexture;
  116736. /**
  116737. * Setup the ground to receive the mirror texture.
  116738. */
  116739. private _setupMirrorInGroundMaterial;
  116740. /**
  116741. * Setup the skybox according to the specified options.
  116742. */
  116743. private _setupSkybox;
  116744. /**
  116745. * Setup the skybox material according to the specified options.
  116746. */
  116747. private _setupSkyboxMaterial;
  116748. /**
  116749. * Setup the skybox reflection texture according to the specified options.
  116750. */
  116751. private _setupSkyboxReflectionTexture;
  116752. private _errorHandler;
  116753. /**
  116754. * Dispose all the elements created by the Helper.
  116755. */
  116756. dispose(): void;
  116757. }
  116758. }
  116759. declare module BABYLON {
  116760. /**
  116761. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  116762. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  116763. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  116764. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  116765. */
  116766. export class PhotoDome extends TransformNode {
  116767. /**
  116768. * Define the image as a Monoscopic panoramic 360 image.
  116769. */
  116770. static readonly MODE_MONOSCOPIC: number;
  116771. /**
  116772. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  116773. */
  116774. static readonly MODE_TOPBOTTOM: number;
  116775. /**
  116776. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  116777. */
  116778. static readonly MODE_SIDEBYSIDE: number;
  116779. private _useDirectMapping;
  116780. /**
  116781. * The texture being displayed on the sphere
  116782. */
  116783. protected _photoTexture: Texture;
  116784. /**
  116785. * Gets or sets the texture being displayed on the sphere
  116786. */
  116787. photoTexture: Texture;
  116788. /**
  116789. * Observable raised when an error occured while loading the 360 image
  116790. */
  116791. onLoadErrorObservable: Observable<string>;
  116792. /**
  116793. * The skybox material
  116794. */
  116795. protected _material: BackgroundMaterial;
  116796. /**
  116797. * The surface used for the skybox
  116798. */
  116799. protected _mesh: Mesh;
  116800. /**
  116801. * Gets the mesh used for the skybox.
  116802. */
  116803. readonly mesh: Mesh;
  116804. /**
  116805. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  116806. * Also see the options.resolution property.
  116807. */
  116808. fovMultiplier: number;
  116809. private _imageMode;
  116810. /**
  116811. * Gets or set the current video mode for the video. It can be:
  116812. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  116813. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  116814. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  116815. */
  116816. imageMode: number;
  116817. /**
  116818. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  116819. * @param name Element's name, child elements will append suffixes for their own names.
  116820. * @param urlsOfPhoto defines the url of the photo to display
  116821. * @param options defines an object containing optional or exposed sub element properties
  116822. * @param onError defines a callback called when an error occured while loading the texture
  116823. */
  116824. constructor(name: string, urlOfPhoto: string, options: {
  116825. resolution?: number;
  116826. size?: number;
  116827. useDirectMapping?: boolean;
  116828. faceForward?: boolean;
  116829. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  116830. private _onBeforeCameraRenderObserver;
  116831. private _changeImageMode;
  116832. /**
  116833. * Releases resources associated with this node.
  116834. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  116835. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  116836. */
  116837. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  116838. }
  116839. }
  116840. declare module BABYLON {
  116841. /**
  116842. * Class used to host RGBD texture specific utilities
  116843. */
  116844. export class RGBDTextureTools {
  116845. /**
  116846. * Expand the RGBD Texture from RGBD to Half Float if possible.
  116847. * @param texture the texture to expand.
  116848. */
  116849. static ExpandRGBDTexture(texture: Texture): void;
  116850. }
  116851. }
  116852. declare module BABYLON {
  116853. /**
  116854. * Class used to host texture specific utilities
  116855. */
  116856. export class BRDFTextureTools {
  116857. /**
  116858. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  116859. * @param scene defines the hosting scene
  116860. * @returns the environment BRDF texture
  116861. */
  116862. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  116863. private static _environmentBRDFBase64Texture;
  116864. }
  116865. }
  116866. declare module BABYLON {
  116867. /**
  116868. * @hidden
  116869. */
  116870. export interface IMaterialClearCoatDefines {
  116871. CLEARCOAT: boolean;
  116872. CLEARCOAT_DEFAULTIOR: boolean;
  116873. CLEARCOAT_TEXTURE: boolean;
  116874. CLEARCOAT_TEXTUREDIRECTUV: number;
  116875. CLEARCOAT_BUMP: boolean;
  116876. CLEARCOAT_BUMPDIRECTUV: number;
  116877. CLEARCOAT_TINT: boolean;
  116878. CLEARCOAT_TINT_TEXTURE: boolean;
  116879. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  116880. /** @hidden */
  116881. _areTexturesDirty: boolean;
  116882. }
  116883. /**
  116884. * Define the code related to the clear coat parameters of the pbr material.
  116885. */
  116886. export class PBRClearCoatConfiguration {
  116887. /**
  116888. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  116889. * The default fits with a polyurethane material.
  116890. */
  116891. private static readonly _DefaultIndexOfRefraction;
  116892. private _isEnabled;
  116893. /**
  116894. * Defines if the clear coat is enabled in the material.
  116895. */
  116896. isEnabled: boolean;
  116897. /**
  116898. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  116899. */
  116900. intensity: number;
  116901. /**
  116902. * Defines the clear coat layer roughness.
  116903. */
  116904. roughness: number;
  116905. private _indexOfRefraction;
  116906. /**
  116907. * Defines the index of refraction of the clear coat.
  116908. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  116909. * The default fits with a polyurethane material.
  116910. * Changing the default value is more performance intensive.
  116911. */
  116912. indexOfRefraction: number;
  116913. private _texture;
  116914. /**
  116915. * Stores the clear coat values in a texture.
  116916. */
  116917. texture: Nullable<BaseTexture>;
  116918. private _bumpTexture;
  116919. /**
  116920. * Define the clear coat specific bump texture.
  116921. */
  116922. bumpTexture: Nullable<BaseTexture>;
  116923. private _isTintEnabled;
  116924. /**
  116925. * Defines if the clear coat tint is enabled in the material.
  116926. */
  116927. isTintEnabled: boolean;
  116928. /**
  116929. * Defines the clear coat tint of the material.
  116930. * This is only use if tint is enabled
  116931. */
  116932. tintColor: Color3;
  116933. /**
  116934. * Defines the distance at which the tint color should be found in the
  116935. * clear coat media.
  116936. * This is only use if tint is enabled
  116937. */
  116938. tintColorAtDistance: number;
  116939. /**
  116940. * Defines the clear coat layer thickness.
  116941. * This is only use if tint is enabled
  116942. */
  116943. tintThickness: number;
  116944. private _tintTexture;
  116945. /**
  116946. * Stores the clear tint values in a texture.
  116947. * rgb is tint
  116948. * a is a thickness factor
  116949. */
  116950. tintTexture: Nullable<BaseTexture>;
  116951. /** @hidden */
  116952. private _internalMarkAllSubMeshesAsTexturesDirty;
  116953. /** @hidden */
  116954. _markAllSubMeshesAsTexturesDirty(): void;
  116955. /**
  116956. * Instantiate a new istance of clear coat configuration.
  116957. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  116958. */
  116959. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  116960. /**
  116961. * Gets wehter the submesh is ready to be used or not.
  116962. * @param defines the list of "defines" to update.
  116963. * @param scene defines the scene the material belongs to.
  116964. * @param engine defines the engine the material belongs to.
  116965. * @param disableBumpMap defines wether the material disables bump or not.
  116966. * @returns - boolean indicating that the submesh is ready or not.
  116967. */
  116968. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  116969. /**
  116970. * Checks to see if a texture is used in the material.
  116971. * @param defines the list of "defines" to update.
  116972. * @param scene defines the scene to the material belongs to.
  116973. */
  116974. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  116975. /**
  116976. * Binds the material data.
  116977. * @param uniformBuffer defines the Uniform buffer to fill in.
  116978. * @param scene defines the scene the material belongs to.
  116979. * @param engine defines the engine the material belongs to.
  116980. * @param disableBumpMap defines wether the material disables bump or not.
  116981. * @param isFrozen defines wether the material is frozen or not.
  116982. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  116983. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  116984. */
  116985. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  116986. /**
  116987. * Checks to see if a texture is used in the material.
  116988. * @param texture - Base texture to use.
  116989. * @returns - Boolean specifying if a texture is used in the material.
  116990. */
  116991. hasTexture(texture: BaseTexture): boolean;
  116992. /**
  116993. * Returns an array of the actively used textures.
  116994. * @param activeTextures Array of BaseTextures
  116995. */
  116996. getActiveTextures(activeTextures: BaseTexture[]): void;
  116997. /**
  116998. * Returns the animatable textures.
  116999. * @param animatables Array of animatable textures.
  117000. */
  117001. getAnimatables(animatables: IAnimatable[]): void;
  117002. /**
  117003. * Disposes the resources of the material.
  117004. * @param forceDisposeTextures - Forces the disposal of all textures.
  117005. */
  117006. dispose(forceDisposeTextures?: boolean): void;
  117007. /**
  117008. * Get the current class name of the texture useful for serialization or dynamic coding.
  117009. * @returns "PBRClearCoatConfiguration"
  117010. */
  117011. getClassName(): string;
  117012. /**
  117013. * Add fallbacks to the effect fallbacks list.
  117014. * @param defines defines the Base texture to use.
  117015. * @param fallbacks defines the current fallback list.
  117016. * @param currentRank defines the current fallback rank.
  117017. * @returns the new fallback rank.
  117018. */
  117019. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  117020. /**
  117021. * Add the required uniforms to the current list.
  117022. * @param uniforms defines the current uniform list.
  117023. */
  117024. static AddUniforms(uniforms: string[]): void;
  117025. /**
  117026. * Add the required samplers to the current list.
  117027. * @param samplers defines the current sampler list.
  117028. */
  117029. static AddSamplers(samplers: string[]): void;
  117030. /**
  117031. * Add the required uniforms to the current buffer.
  117032. * @param uniformBuffer defines the current uniform buffer.
  117033. */
  117034. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  117035. /**
  117036. * Makes a duplicate of the current configuration into another one.
  117037. * @param clearCoatConfiguration define the config where to copy the info
  117038. */
  117039. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  117040. /**
  117041. * Serializes this clear coat configuration.
  117042. * @returns - An object with the serialized config.
  117043. */
  117044. serialize(): any;
  117045. /**
  117046. * Parses a anisotropy Configuration from a serialized object.
  117047. * @param source - Serialized object.
  117048. * @param scene Defines the scene we are parsing for
  117049. * @param rootUrl Defines the rootUrl to load from
  117050. */
  117051. parse(source: any, scene: Scene, rootUrl: string): void;
  117052. }
  117053. }
  117054. declare module BABYLON {
  117055. /**
  117056. * @hidden
  117057. */
  117058. export interface IMaterialAnisotropicDefines {
  117059. ANISOTROPIC: boolean;
  117060. ANISOTROPIC_TEXTURE: boolean;
  117061. ANISOTROPIC_TEXTUREDIRECTUV: number;
  117062. MAINUV1: boolean;
  117063. _areTexturesDirty: boolean;
  117064. _needUVs: boolean;
  117065. }
  117066. /**
  117067. * Define the code related to the anisotropic parameters of the pbr material.
  117068. */
  117069. export class PBRAnisotropicConfiguration {
  117070. private _isEnabled;
  117071. /**
  117072. * Defines if the anisotropy is enabled in the material.
  117073. */
  117074. isEnabled: boolean;
  117075. /**
  117076. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  117077. */
  117078. intensity: number;
  117079. /**
  117080. * Defines if the effect is along the tangents, bitangents or in between.
  117081. * By default, the effect is "strectching" the highlights along the tangents.
  117082. */
  117083. direction: Vector2;
  117084. private _texture;
  117085. /**
  117086. * Stores the anisotropy values in a texture.
  117087. * rg is direction (like normal from -1 to 1)
  117088. * b is a intensity
  117089. */
  117090. texture: Nullable<BaseTexture>;
  117091. /** @hidden */
  117092. private _internalMarkAllSubMeshesAsTexturesDirty;
  117093. /** @hidden */
  117094. _markAllSubMeshesAsTexturesDirty(): void;
  117095. /**
  117096. * Instantiate a new istance of anisotropy configuration.
  117097. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  117098. */
  117099. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  117100. /**
  117101. * Specifies that the submesh is ready to be used.
  117102. * @param defines the list of "defines" to update.
  117103. * @param scene defines the scene the material belongs to.
  117104. * @returns - boolean indicating that the submesh is ready or not.
  117105. */
  117106. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  117107. /**
  117108. * Checks to see if a texture is used in the material.
  117109. * @param defines the list of "defines" to update.
  117110. * @param mesh the mesh we are preparing the defines for.
  117111. * @param scene defines the scene the material belongs to.
  117112. */
  117113. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  117114. /**
  117115. * Binds the material data.
  117116. * @param uniformBuffer defines the Uniform buffer to fill in.
  117117. * @param scene defines the scene the material belongs to.
  117118. * @param isFrozen defines wether the material is frozen or not.
  117119. */
  117120. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  117121. /**
  117122. * Checks to see if a texture is used in the material.
  117123. * @param texture - Base texture to use.
  117124. * @returns - Boolean specifying if a texture is used in the material.
  117125. */
  117126. hasTexture(texture: BaseTexture): boolean;
  117127. /**
  117128. * Returns an array of the actively used textures.
  117129. * @param activeTextures Array of BaseTextures
  117130. */
  117131. getActiveTextures(activeTextures: BaseTexture[]): void;
  117132. /**
  117133. * Returns the animatable textures.
  117134. * @param animatables Array of animatable textures.
  117135. */
  117136. getAnimatables(animatables: IAnimatable[]): void;
  117137. /**
  117138. * Disposes the resources of the material.
  117139. * @param forceDisposeTextures - Forces the disposal of all textures.
  117140. */
  117141. dispose(forceDisposeTextures?: boolean): void;
  117142. /**
  117143. * Get the current class name of the texture useful for serialization or dynamic coding.
  117144. * @returns "PBRAnisotropicConfiguration"
  117145. */
  117146. getClassName(): string;
  117147. /**
  117148. * Add fallbacks to the effect fallbacks list.
  117149. * @param defines defines the Base texture to use.
  117150. * @param fallbacks defines the current fallback list.
  117151. * @param currentRank defines the current fallback rank.
  117152. * @returns the new fallback rank.
  117153. */
  117154. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  117155. /**
  117156. * Add the required uniforms to the current list.
  117157. * @param uniforms defines the current uniform list.
  117158. */
  117159. static AddUniforms(uniforms: string[]): void;
  117160. /**
  117161. * Add the required uniforms to the current buffer.
  117162. * @param uniformBuffer defines the current uniform buffer.
  117163. */
  117164. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  117165. /**
  117166. * Add the required samplers to the current list.
  117167. * @param samplers defines the current sampler list.
  117168. */
  117169. static AddSamplers(samplers: string[]): void;
  117170. /**
  117171. * Makes a duplicate of the current configuration into another one.
  117172. * @param anisotropicConfiguration define the config where to copy the info
  117173. */
  117174. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  117175. /**
  117176. * Serializes this anisotropy configuration.
  117177. * @returns - An object with the serialized config.
  117178. */
  117179. serialize(): any;
  117180. /**
  117181. * Parses a anisotropy Configuration from a serialized object.
  117182. * @param source - Serialized object.
  117183. * @param scene Defines the scene we are parsing for
  117184. * @param rootUrl Defines the rootUrl to load from
  117185. */
  117186. parse(source: any, scene: Scene, rootUrl: string): void;
  117187. }
  117188. }
  117189. declare module BABYLON {
  117190. /**
  117191. * @hidden
  117192. */
  117193. export interface IMaterialBRDFDefines {
  117194. BRDF_V_HEIGHT_CORRELATED: boolean;
  117195. MS_BRDF_ENERGY_CONSERVATION: boolean;
  117196. SPHERICAL_HARMONICS: boolean;
  117197. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  117198. /** @hidden */
  117199. _areMiscDirty: boolean;
  117200. }
  117201. /**
  117202. * Define the code related to the BRDF parameters of the pbr material.
  117203. */
  117204. export class PBRBRDFConfiguration {
  117205. /**
  117206. * Default value used for the energy conservation.
  117207. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  117208. */
  117209. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  117210. /**
  117211. * Default value used for the Smith Visibility Height Correlated mode.
  117212. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  117213. */
  117214. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  117215. /**
  117216. * Default value used for the IBL diffuse part.
  117217. * This can help switching back to the polynomials mode globally which is a tiny bit
  117218. * less GPU intensive at the drawback of a lower quality.
  117219. */
  117220. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  117221. /**
  117222. * Default value used for activating energy conservation for the specular workflow.
  117223. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  117224. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  117225. */
  117226. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  117227. private _useEnergyConservation;
  117228. /**
  117229. * Defines if the material uses energy conservation.
  117230. */
  117231. useEnergyConservation: boolean;
  117232. private _useSmithVisibilityHeightCorrelated;
  117233. /**
  117234. * LEGACY Mode set to false
  117235. * Defines if the material uses height smith correlated visibility term.
  117236. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  117237. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  117238. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  117239. * Not relying on height correlated will also disable energy conservation.
  117240. */
  117241. useSmithVisibilityHeightCorrelated: boolean;
  117242. private _useSphericalHarmonics;
  117243. /**
  117244. * LEGACY Mode set to false
  117245. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  117246. * diffuse part of the IBL.
  117247. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  117248. * to the ground truth.
  117249. */
  117250. useSphericalHarmonics: boolean;
  117251. private _useSpecularGlossinessInputEnergyConservation;
  117252. /**
  117253. * Defines if the material uses energy conservation, when the specular workflow is active.
  117254. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  117255. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  117256. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  117257. */
  117258. useSpecularGlossinessInputEnergyConservation: boolean;
  117259. /** @hidden */
  117260. private _internalMarkAllSubMeshesAsMiscDirty;
  117261. /** @hidden */
  117262. _markAllSubMeshesAsMiscDirty(): void;
  117263. /**
  117264. * Instantiate a new istance of clear coat configuration.
  117265. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  117266. */
  117267. constructor(markAllSubMeshesAsMiscDirty: () => void);
  117268. /**
  117269. * Checks to see if a texture is used in the material.
  117270. * @param defines the list of "defines" to update.
  117271. */
  117272. prepareDefines(defines: IMaterialBRDFDefines): void;
  117273. /**
  117274. * Get the current class name of the texture useful for serialization or dynamic coding.
  117275. * @returns "PBRClearCoatConfiguration"
  117276. */
  117277. getClassName(): string;
  117278. /**
  117279. * Makes a duplicate of the current configuration into another one.
  117280. * @param brdfConfiguration define the config where to copy the info
  117281. */
  117282. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  117283. /**
  117284. * Serializes this BRDF configuration.
  117285. * @returns - An object with the serialized config.
  117286. */
  117287. serialize(): any;
  117288. /**
  117289. * Parses a anisotropy Configuration from a serialized object.
  117290. * @param source - Serialized object.
  117291. * @param scene Defines the scene we are parsing for
  117292. * @param rootUrl Defines the rootUrl to load from
  117293. */
  117294. parse(source: any, scene: Scene, rootUrl: string): void;
  117295. }
  117296. }
  117297. declare module BABYLON {
  117298. /**
  117299. * @hidden
  117300. */
  117301. export interface IMaterialSheenDefines {
  117302. SHEEN: boolean;
  117303. SHEEN_TEXTURE: boolean;
  117304. SHEEN_TEXTUREDIRECTUV: number;
  117305. SHEEN_LINKWITHALBEDO: boolean;
  117306. /** @hidden */
  117307. _areTexturesDirty: boolean;
  117308. }
  117309. /**
  117310. * Define the code related to the Sheen parameters of the pbr material.
  117311. */
  117312. export class PBRSheenConfiguration {
  117313. private _isEnabled;
  117314. /**
  117315. * Defines if the material uses sheen.
  117316. */
  117317. isEnabled: boolean;
  117318. private _linkSheenWithAlbedo;
  117319. /**
  117320. * Defines if the sheen is linked to the sheen color.
  117321. */
  117322. linkSheenWithAlbedo: boolean;
  117323. /**
  117324. * Defines the sheen intensity.
  117325. */
  117326. intensity: number;
  117327. /**
  117328. * Defines the sheen color.
  117329. */
  117330. color: Color3;
  117331. private _texture;
  117332. /**
  117333. * Stores the sheen tint values in a texture.
  117334. * rgb is tint
  117335. * a is a intensity
  117336. */
  117337. texture: Nullable<BaseTexture>;
  117338. /** @hidden */
  117339. private _internalMarkAllSubMeshesAsTexturesDirty;
  117340. /** @hidden */
  117341. _markAllSubMeshesAsTexturesDirty(): void;
  117342. /**
  117343. * Instantiate a new istance of clear coat configuration.
  117344. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  117345. */
  117346. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  117347. /**
  117348. * Specifies that the submesh is ready to be used.
  117349. * @param defines the list of "defines" to update.
  117350. * @param scene defines the scene the material belongs to.
  117351. * @returns - boolean indicating that the submesh is ready or not.
  117352. */
  117353. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  117354. /**
  117355. * Checks to see if a texture is used in the material.
  117356. * @param defines the list of "defines" to update.
  117357. * @param scene defines the scene the material belongs to.
  117358. */
  117359. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  117360. /**
  117361. * Binds the material data.
  117362. * @param uniformBuffer defines the Uniform buffer to fill in.
  117363. * @param scene defines the scene the material belongs to.
  117364. * @param isFrozen defines wether the material is frozen or not.
  117365. */
  117366. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  117367. /**
  117368. * Checks to see if a texture is used in the material.
  117369. * @param texture - Base texture to use.
  117370. * @returns - Boolean specifying if a texture is used in the material.
  117371. */
  117372. hasTexture(texture: BaseTexture): boolean;
  117373. /**
  117374. * Returns an array of the actively used textures.
  117375. * @param activeTextures Array of BaseTextures
  117376. */
  117377. getActiveTextures(activeTextures: BaseTexture[]): void;
  117378. /**
  117379. * Returns the animatable textures.
  117380. * @param animatables Array of animatable textures.
  117381. */
  117382. getAnimatables(animatables: IAnimatable[]): void;
  117383. /**
  117384. * Disposes the resources of the material.
  117385. * @param forceDisposeTextures - Forces the disposal of all textures.
  117386. */
  117387. dispose(forceDisposeTextures?: boolean): void;
  117388. /**
  117389. * Get the current class name of the texture useful for serialization or dynamic coding.
  117390. * @returns "PBRSheenConfiguration"
  117391. */
  117392. getClassName(): string;
  117393. /**
  117394. * Add fallbacks to the effect fallbacks list.
  117395. * @param defines defines the Base texture to use.
  117396. * @param fallbacks defines the current fallback list.
  117397. * @param currentRank defines the current fallback rank.
  117398. * @returns the new fallback rank.
  117399. */
  117400. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  117401. /**
  117402. * Add the required uniforms to the current list.
  117403. * @param uniforms defines the current uniform list.
  117404. */
  117405. static AddUniforms(uniforms: string[]): void;
  117406. /**
  117407. * Add the required uniforms to the current buffer.
  117408. * @param uniformBuffer defines the current uniform buffer.
  117409. */
  117410. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  117411. /**
  117412. * Add the required samplers to the current list.
  117413. * @param samplers defines the current sampler list.
  117414. */
  117415. static AddSamplers(samplers: string[]): void;
  117416. /**
  117417. * Makes a duplicate of the current configuration into another one.
  117418. * @param sheenConfiguration define the config where to copy the info
  117419. */
  117420. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  117421. /**
  117422. * Serializes this BRDF configuration.
  117423. * @returns - An object with the serialized config.
  117424. */
  117425. serialize(): any;
  117426. /**
  117427. * Parses a anisotropy Configuration from a serialized object.
  117428. * @param source - Serialized object.
  117429. * @param scene Defines the scene we are parsing for
  117430. * @param rootUrl Defines the rootUrl to load from
  117431. */
  117432. parse(source: any, scene: Scene, rootUrl: string): void;
  117433. }
  117434. }
  117435. declare module BABYLON {
  117436. /**
  117437. * @hidden
  117438. */
  117439. export interface IMaterialSubSurfaceDefines {
  117440. SUBSURFACE: boolean;
  117441. SS_REFRACTION: boolean;
  117442. SS_TRANSLUCENCY: boolean;
  117443. SS_SCATERRING: boolean;
  117444. SS_THICKNESSANDMASK_TEXTURE: boolean;
  117445. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  117446. SS_REFRACTIONMAP_3D: boolean;
  117447. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  117448. SS_LODINREFRACTIONALPHA: boolean;
  117449. SS_GAMMAREFRACTION: boolean;
  117450. SS_RGBDREFRACTION: boolean;
  117451. SS_LINEARSPECULARREFRACTION: boolean;
  117452. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  117453. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  117454. /** @hidden */
  117455. _areTexturesDirty: boolean;
  117456. }
  117457. /**
  117458. * Define the code related to the sub surface parameters of the pbr material.
  117459. */
  117460. export class PBRSubSurfaceConfiguration {
  117461. private _isRefractionEnabled;
  117462. /**
  117463. * Defines if the refraction is enabled in the material.
  117464. */
  117465. isRefractionEnabled: boolean;
  117466. private _isTranslucencyEnabled;
  117467. /**
  117468. * Defines if the translucency is enabled in the material.
  117469. */
  117470. isTranslucencyEnabled: boolean;
  117471. private _isScatteringEnabled;
  117472. /**
  117473. * Defines the refraction intensity of the material.
  117474. * The refraction when enabled replaces the Diffuse part of the material.
  117475. * The intensity helps transitionning between diffuse and refraction.
  117476. */
  117477. refractionIntensity: number;
  117478. /**
  117479. * Defines the translucency intensity of the material.
  117480. * When translucency has been enabled, this defines how much of the "translucency"
  117481. * is addded to the diffuse part of the material.
  117482. */
  117483. translucencyIntensity: number;
  117484. /**
  117485. * Defines the scattering intensity of the material.
  117486. * When scattering has been enabled, this defines how much of the "scattered light"
  117487. * is addded to the diffuse part of the material.
  117488. */
  117489. scatteringIntensity: number;
  117490. private _thicknessTexture;
  117491. /**
  117492. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  117493. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  117494. * 0 would mean minimumThickness
  117495. * 1 would mean maximumThickness
  117496. * The other channels might be use as a mask to vary the different effects intensity.
  117497. */
  117498. thicknessTexture: Nullable<BaseTexture>;
  117499. private _refractionTexture;
  117500. /**
  117501. * Defines the texture to use for refraction.
  117502. */
  117503. refractionTexture: Nullable<BaseTexture>;
  117504. private _indexOfRefraction;
  117505. /**
  117506. * Defines the index of refraction used in the material.
  117507. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  117508. */
  117509. indexOfRefraction: number;
  117510. private _invertRefractionY;
  117511. /**
  117512. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  117513. */
  117514. invertRefractionY: boolean;
  117515. private _linkRefractionWithTransparency;
  117516. /**
  117517. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  117518. * Materials half opaque for instance using refraction could benefit from this control.
  117519. */
  117520. linkRefractionWithTransparency: boolean;
  117521. /**
  117522. * Defines the minimum thickness stored in the thickness map.
  117523. * If no thickness map is defined, this value will be used to simulate thickness.
  117524. */
  117525. minimumThickness: number;
  117526. /**
  117527. * Defines the maximum thickness stored in the thickness map.
  117528. */
  117529. maximumThickness: number;
  117530. /**
  117531. * Defines the volume tint of the material.
  117532. * This is used for both translucency and scattering.
  117533. */
  117534. tintColor: Color3;
  117535. /**
  117536. * Defines the distance at which the tint color should be found in the media.
  117537. * This is used for refraction only.
  117538. */
  117539. tintColorAtDistance: number;
  117540. /**
  117541. * Defines how far each channel transmit through the media.
  117542. * It is defined as a color to simplify it selection.
  117543. */
  117544. diffusionDistance: Color3;
  117545. private _useMaskFromThicknessTexture;
  117546. /**
  117547. * Stores the intensity of the different subsurface effects in the thickness texture.
  117548. * * the green channel is the translucency intensity.
  117549. * * the blue channel is the scattering intensity.
  117550. * * the alpha channel is the refraction intensity.
  117551. */
  117552. useMaskFromThicknessTexture: boolean;
  117553. /** @hidden */
  117554. private _internalMarkAllSubMeshesAsTexturesDirty;
  117555. /** @hidden */
  117556. _markAllSubMeshesAsTexturesDirty(): void;
  117557. /**
  117558. * Instantiate a new istance of sub surface configuration.
  117559. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  117560. */
  117561. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  117562. /**
  117563. * Gets wehter the submesh is ready to be used or not.
  117564. * @param defines the list of "defines" to update.
  117565. * @param scene defines the scene the material belongs to.
  117566. * @returns - boolean indicating that the submesh is ready or not.
  117567. */
  117568. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  117569. /**
  117570. * Checks to see if a texture is used in the material.
  117571. * @param defines the list of "defines" to update.
  117572. * @param scene defines the scene to the material belongs to.
  117573. */
  117574. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  117575. /**
  117576. * Binds the material data.
  117577. * @param uniformBuffer defines the Uniform buffer to fill in.
  117578. * @param scene defines the scene the material belongs to.
  117579. * @param engine defines the engine the material belongs to.
  117580. * @param isFrozen defines wether the material is frozen or not.
  117581. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  117582. */
  117583. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  117584. /**
  117585. * Unbinds the material from the mesh.
  117586. * @param activeEffect defines the effect that should be unbound from.
  117587. * @returns true if unbound, otherwise false
  117588. */
  117589. unbind(activeEffect: Effect): boolean;
  117590. /**
  117591. * Returns the texture used for refraction or null if none is used.
  117592. * @param scene defines the scene the material belongs to.
  117593. * @returns - Refraction texture if present. If no refraction texture and refraction
  117594. * is linked with transparency, returns environment texture. Otherwise, returns null.
  117595. */
  117596. private _getRefractionTexture;
  117597. /**
  117598. * Returns true if alpha blending should be disabled.
  117599. */
  117600. readonly disableAlphaBlending: boolean;
  117601. /**
  117602. * Fills the list of render target textures.
  117603. * @param renderTargets the list of render targets to update
  117604. */
  117605. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  117606. /**
  117607. * Checks to see if a texture is used in the material.
  117608. * @param texture - Base texture to use.
  117609. * @returns - Boolean specifying if a texture is used in the material.
  117610. */
  117611. hasTexture(texture: BaseTexture): boolean;
  117612. /**
  117613. * Gets a boolean indicating that current material needs to register RTT
  117614. * @returns true if this uses a render target otherwise false.
  117615. */
  117616. hasRenderTargetTextures(): boolean;
  117617. /**
  117618. * Returns an array of the actively used textures.
  117619. * @param activeTextures Array of BaseTextures
  117620. */
  117621. getActiveTextures(activeTextures: BaseTexture[]): void;
  117622. /**
  117623. * Returns the animatable textures.
  117624. * @param animatables Array of animatable textures.
  117625. */
  117626. getAnimatables(animatables: IAnimatable[]): void;
  117627. /**
  117628. * Disposes the resources of the material.
  117629. * @param forceDisposeTextures - Forces the disposal of all textures.
  117630. */
  117631. dispose(forceDisposeTextures?: boolean): void;
  117632. /**
  117633. * Get the current class name of the texture useful for serialization or dynamic coding.
  117634. * @returns "PBRSubSurfaceConfiguration"
  117635. */
  117636. getClassName(): string;
  117637. /**
  117638. * Add fallbacks to the effect fallbacks list.
  117639. * @param defines defines the Base texture to use.
  117640. * @param fallbacks defines the current fallback list.
  117641. * @param currentRank defines the current fallback rank.
  117642. * @returns the new fallback rank.
  117643. */
  117644. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  117645. /**
  117646. * Add the required uniforms to the current list.
  117647. * @param uniforms defines the current uniform list.
  117648. */
  117649. static AddUniforms(uniforms: string[]): void;
  117650. /**
  117651. * Add the required samplers to the current list.
  117652. * @param samplers defines the current sampler list.
  117653. */
  117654. static AddSamplers(samplers: string[]): void;
  117655. /**
  117656. * Add the required uniforms to the current buffer.
  117657. * @param uniformBuffer defines the current uniform buffer.
  117658. */
  117659. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  117660. /**
  117661. * Makes a duplicate of the current configuration into another one.
  117662. * @param configuration define the config where to copy the info
  117663. */
  117664. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  117665. /**
  117666. * Serializes this Sub Surface configuration.
  117667. * @returns - An object with the serialized config.
  117668. */
  117669. serialize(): any;
  117670. /**
  117671. * Parses a anisotropy Configuration from a serialized object.
  117672. * @param source - Serialized object.
  117673. * @param scene Defines the scene we are parsing for
  117674. * @param rootUrl Defines the rootUrl to load from
  117675. */
  117676. parse(source: any, scene: Scene, rootUrl: string): void;
  117677. }
  117678. }
  117679. declare module BABYLON {
  117680. /** @hidden */
  117681. export var pbrFragmentDeclaration: {
  117682. name: string;
  117683. shader: string;
  117684. };
  117685. }
  117686. declare module BABYLON {
  117687. /** @hidden */
  117688. export var pbrUboDeclaration: {
  117689. name: string;
  117690. shader: string;
  117691. };
  117692. }
  117693. declare module BABYLON {
  117694. /** @hidden */
  117695. export var pbrFragmentExtraDeclaration: {
  117696. name: string;
  117697. shader: string;
  117698. };
  117699. }
  117700. declare module BABYLON {
  117701. /** @hidden */
  117702. export var pbrFragmentSamplersDeclaration: {
  117703. name: string;
  117704. shader: string;
  117705. };
  117706. }
  117707. declare module BABYLON {
  117708. /** @hidden */
  117709. export var pbrHelperFunctions: {
  117710. name: string;
  117711. shader: string;
  117712. };
  117713. }
  117714. declare module BABYLON {
  117715. /** @hidden */
  117716. export var harmonicsFunctions: {
  117717. name: string;
  117718. shader: string;
  117719. };
  117720. }
  117721. declare module BABYLON {
  117722. /** @hidden */
  117723. export var pbrDirectLightingSetupFunctions: {
  117724. name: string;
  117725. shader: string;
  117726. };
  117727. }
  117728. declare module BABYLON {
  117729. /** @hidden */
  117730. export var pbrDirectLightingFalloffFunctions: {
  117731. name: string;
  117732. shader: string;
  117733. };
  117734. }
  117735. declare module BABYLON {
  117736. /** @hidden */
  117737. export var pbrBRDFFunctions: {
  117738. name: string;
  117739. shader: string;
  117740. };
  117741. }
  117742. declare module BABYLON {
  117743. /** @hidden */
  117744. export var pbrDirectLightingFunctions: {
  117745. name: string;
  117746. shader: string;
  117747. };
  117748. }
  117749. declare module BABYLON {
  117750. /** @hidden */
  117751. export var pbrIBLFunctions: {
  117752. name: string;
  117753. shader: string;
  117754. };
  117755. }
  117756. declare module BABYLON {
  117757. /** @hidden */
  117758. export var pbrDebug: {
  117759. name: string;
  117760. shader: string;
  117761. };
  117762. }
  117763. declare module BABYLON {
  117764. /** @hidden */
  117765. export var pbrPixelShader: {
  117766. name: string;
  117767. shader: string;
  117768. };
  117769. }
  117770. declare module BABYLON {
  117771. /** @hidden */
  117772. export var pbrVertexDeclaration: {
  117773. name: string;
  117774. shader: string;
  117775. };
  117776. }
  117777. declare module BABYLON {
  117778. /** @hidden */
  117779. export var pbrVertexShader: {
  117780. name: string;
  117781. shader: string;
  117782. };
  117783. }
  117784. declare module BABYLON {
  117785. /**
  117786. * Manages the defines for the PBR Material.
  117787. * @hidden
  117788. */
  117789. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  117790. PBR: boolean;
  117791. MAINUV1: boolean;
  117792. MAINUV2: boolean;
  117793. UV1: boolean;
  117794. UV2: boolean;
  117795. ALBEDO: boolean;
  117796. ALBEDODIRECTUV: number;
  117797. VERTEXCOLOR: boolean;
  117798. AMBIENT: boolean;
  117799. AMBIENTDIRECTUV: number;
  117800. AMBIENTINGRAYSCALE: boolean;
  117801. OPACITY: boolean;
  117802. VERTEXALPHA: boolean;
  117803. OPACITYDIRECTUV: number;
  117804. OPACITYRGB: boolean;
  117805. ALPHATEST: boolean;
  117806. DEPTHPREPASS: boolean;
  117807. ALPHABLEND: boolean;
  117808. ALPHAFROMALBEDO: boolean;
  117809. ALPHATESTVALUE: string;
  117810. SPECULAROVERALPHA: boolean;
  117811. RADIANCEOVERALPHA: boolean;
  117812. ALPHAFRESNEL: boolean;
  117813. LINEARALPHAFRESNEL: boolean;
  117814. PREMULTIPLYALPHA: boolean;
  117815. EMISSIVE: boolean;
  117816. EMISSIVEDIRECTUV: number;
  117817. REFLECTIVITY: boolean;
  117818. REFLECTIVITYDIRECTUV: number;
  117819. SPECULARTERM: boolean;
  117820. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  117821. MICROSURFACEAUTOMATIC: boolean;
  117822. LODBASEDMICROSFURACE: boolean;
  117823. MICROSURFACEMAP: boolean;
  117824. MICROSURFACEMAPDIRECTUV: number;
  117825. METALLICWORKFLOW: boolean;
  117826. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  117827. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  117828. METALLNESSSTOREINMETALMAPBLUE: boolean;
  117829. AOSTOREINMETALMAPRED: boolean;
  117830. METALLICF0FACTORFROMMETALLICMAP: boolean;
  117831. ENVIRONMENTBRDF: boolean;
  117832. ENVIRONMENTBRDF_RGBD: boolean;
  117833. NORMAL: boolean;
  117834. TANGENT: boolean;
  117835. BUMP: boolean;
  117836. BUMPDIRECTUV: number;
  117837. OBJECTSPACE_NORMALMAP: boolean;
  117838. PARALLAX: boolean;
  117839. PARALLAXOCCLUSION: boolean;
  117840. NORMALXYSCALE: boolean;
  117841. LIGHTMAP: boolean;
  117842. LIGHTMAPDIRECTUV: number;
  117843. USELIGHTMAPASSHADOWMAP: boolean;
  117844. GAMMALIGHTMAP: boolean;
  117845. RGBDLIGHTMAP: boolean;
  117846. REFLECTION: boolean;
  117847. REFLECTIONMAP_3D: boolean;
  117848. REFLECTIONMAP_SPHERICAL: boolean;
  117849. REFLECTIONMAP_PLANAR: boolean;
  117850. REFLECTIONMAP_CUBIC: boolean;
  117851. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  117852. REFLECTIONMAP_PROJECTION: boolean;
  117853. REFLECTIONMAP_SKYBOX: boolean;
  117854. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  117855. REFLECTIONMAP_EXPLICIT: boolean;
  117856. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  117857. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  117858. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  117859. INVERTCUBICMAP: boolean;
  117860. USESPHERICALFROMREFLECTIONMAP: boolean;
  117861. USEIRRADIANCEMAP: boolean;
  117862. SPHERICAL_HARMONICS: boolean;
  117863. USESPHERICALINVERTEX: boolean;
  117864. REFLECTIONMAP_OPPOSITEZ: boolean;
  117865. LODINREFLECTIONALPHA: boolean;
  117866. GAMMAREFLECTION: boolean;
  117867. RGBDREFLECTION: boolean;
  117868. LINEARSPECULARREFLECTION: boolean;
  117869. RADIANCEOCCLUSION: boolean;
  117870. HORIZONOCCLUSION: boolean;
  117871. INSTANCES: boolean;
  117872. NUM_BONE_INFLUENCERS: number;
  117873. BonesPerMesh: number;
  117874. BONETEXTURE: boolean;
  117875. NONUNIFORMSCALING: boolean;
  117876. MORPHTARGETS: boolean;
  117877. MORPHTARGETS_NORMAL: boolean;
  117878. MORPHTARGETS_TANGENT: boolean;
  117879. MORPHTARGETS_UV: boolean;
  117880. NUM_MORPH_INFLUENCERS: number;
  117881. IMAGEPROCESSING: boolean;
  117882. VIGNETTE: boolean;
  117883. VIGNETTEBLENDMODEMULTIPLY: boolean;
  117884. VIGNETTEBLENDMODEOPAQUE: boolean;
  117885. TONEMAPPING: boolean;
  117886. TONEMAPPING_ACES: boolean;
  117887. CONTRAST: boolean;
  117888. COLORCURVES: boolean;
  117889. COLORGRADING: boolean;
  117890. COLORGRADING3D: boolean;
  117891. SAMPLER3DGREENDEPTH: boolean;
  117892. SAMPLER3DBGRMAP: boolean;
  117893. IMAGEPROCESSINGPOSTPROCESS: boolean;
  117894. EXPOSURE: boolean;
  117895. MULTIVIEW: boolean;
  117896. USEPHYSICALLIGHTFALLOFF: boolean;
  117897. USEGLTFLIGHTFALLOFF: boolean;
  117898. TWOSIDEDLIGHTING: boolean;
  117899. SHADOWFLOAT: boolean;
  117900. CLIPPLANE: boolean;
  117901. CLIPPLANE2: boolean;
  117902. CLIPPLANE3: boolean;
  117903. CLIPPLANE4: boolean;
  117904. POINTSIZE: boolean;
  117905. FOG: boolean;
  117906. LOGARITHMICDEPTH: boolean;
  117907. FORCENORMALFORWARD: boolean;
  117908. SPECULARAA: boolean;
  117909. CLEARCOAT: boolean;
  117910. CLEARCOAT_DEFAULTIOR: boolean;
  117911. CLEARCOAT_TEXTURE: boolean;
  117912. CLEARCOAT_TEXTUREDIRECTUV: number;
  117913. CLEARCOAT_BUMP: boolean;
  117914. CLEARCOAT_BUMPDIRECTUV: number;
  117915. CLEARCOAT_TINT: boolean;
  117916. CLEARCOAT_TINT_TEXTURE: boolean;
  117917. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  117918. ANISOTROPIC: boolean;
  117919. ANISOTROPIC_TEXTURE: boolean;
  117920. ANISOTROPIC_TEXTUREDIRECTUV: number;
  117921. BRDF_V_HEIGHT_CORRELATED: boolean;
  117922. MS_BRDF_ENERGY_CONSERVATION: boolean;
  117923. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  117924. SHEEN: boolean;
  117925. SHEEN_TEXTURE: boolean;
  117926. SHEEN_TEXTUREDIRECTUV: number;
  117927. SHEEN_LINKWITHALBEDO: boolean;
  117928. SUBSURFACE: boolean;
  117929. SS_REFRACTION: boolean;
  117930. SS_TRANSLUCENCY: boolean;
  117931. SS_SCATERRING: boolean;
  117932. SS_THICKNESSANDMASK_TEXTURE: boolean;
  117933. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  117934. SS_REFRACTIONMAP_3D: boolean;
  117935. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  117936. SS_LODINREFRACTIONALPHA: boolean;
  117937. SS_GAMMAREFRACTION: boolean;
  117938. SS_RGBDREFRACTION: boolean;
  117939. SS_LINEARSPECULARREFRACTION: boolean;
  117940. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  117941. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  117942. UNLIT: boolean;
  117943. DEBUGMODE: number;
  117944. /**
  117945. * Initializes the PBR Material defines.
  117946. */
  117947. constructor();
  117948. /**
  117949. * Resets the PBR Material defines.
  117950. */
  117951. reset(): void;
  117952. }
  117953. /**
  117954. * The Physically based material base class of BJS.
  117955. *
  117956. * This offers the main features of a standard PBR material.
  117957. * For more information, please refer to the documentation :
  117958. * https://doc.babylonjs.com/how_to/physically_based_rendering
  117959. */
  117960. export abstract class PBRBaseMaterial extends PushMaterial {
  117961. /**
  117962. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  117963. */
  117964. static readonly PBRMATERIAL_OPAQUE: number;
  117965. /**
  117966. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  117967. */
  117968. static readonly PBRMATERIAL_ALPHATEST: number;
  117969. /**
  117970. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  117971. */
  117972. static readonly PBRMATERIAL_ALPHABLEND: number;
  117973. /**
  117974. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  117975. * They are also discarded below the alpha cutoff threshold to improve performances.
  117976. */
  117977. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  117978. /**
  117979. * Defines the default value of how much AO map is occluding the analytical lights
  117980. * (point spot...).
  117981. */
  117982. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  117983. /**
  117984. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  117985. */
  117986. static readonly LIGHTFALLOFF_PHYSICAL: number;
  117987. /**
  117988. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  117989. * to enhance interoperability with other engines.
  117990. */
  117991. static readonly LIGHTFALLOFF_GLTF: number;
  117992. /**
  117993. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  117994. * to enhance interoperability with other materials.
  117995. */
  117996. static readonly LIGHTFALLOFF_STANDARD: number;
  117997. /**
  117998. * Intensity of the direct lights e.g. the four lights available in your scene.
  117999. * This impacts both the direct diffuse and specular highlights.
  118000. */
  118001. protected _directIntensity: number;
  118002. /**
  118003. * Intensity of the emissive part of the material.
  118004. * This helps controlling the emissive effect without modifying the emissive color.
  118005. */
  118006. protected _emissiveIntensity: number;
  118007. /**
  118008. * Intensity of the environment e.g. how much the environment will light the object
  118009. * either through harmonics for rough material or through the refelction for shiny ones.
  118010. */
  118011. protected _environmentIntensity: number;
  118012. /**
  118013. * This is a special control allowing the reduction of the specular highlights coming from the
  118014. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  118015. */
  118016. protected _specularIntensity: number;
  118017. /**
  118018. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  118019. */
  118020. private _lightingInfos;
  118021. /**
  118022. * Debug Control allowing disabling the bump map on this material.
  118023. */
  118024. protected _disableBumpMap: boolean;
  118025. /**
  118026. * AKA Diffuse Texture in standard nomenclature.
  118027. */
  118028. protected _albedoTexture: Nullable<BaseTexture>;
  118029. /**
  118030. * AKA Occlusion Texture in other nomenclature.
  118031. */
  118032. protected _ambientTexture: Nullable<BaseTexture>;
  118033. /**
  118034. * AKA Occlusion Texture Intensity in other nomenclature.
  118035. */
  118036. protected _ambientTextureStrength: number;
  118037. /**
  118038. * Defines how much the AO map is occluding the analytical lights (point spot...).
  118039. * 1 means it completely occludes it
  118040. * 0 mean it has no impact
  118041. */
  118042. protected _ambientTextureImpactOnAnalyticalLights: number;
  118043. /**
  118044. * Stores the alpha values in a texture.
  118045. */
  118046. protected _opacityTexture: Nullable<BaseTexture>;
  118047. /**
  118048. * Stores the reflection values in a texture.
  118049. */
  118050. protected _reflectionTexture: Nullable<BaseTexture>;
  118051. /**
  118052. * Stores the emissive values in a texture.
  118053. */
  118054. protected _emissiveTexture: Nullable<BaseTexture>;
  118055. /**
  118056. * AKA Specular texture in other nomenclature.
  118057. */
  118058. protected _reflectivityTexture: Nullable<BaseTexture>;
  118059. /**
  118060. * Used to switch from specular/glossiness to metallic/roughness workflow.
  118061. */
  118062. protected _metallicTexture: Nullable<BaseTexture>;
  118063. /**
  118064. * Specifies the metallic scalar of the metallic/roughness workflow.
  118065. * Can also be used to scale the metalness values of the metallic texture.
  118066. */
  118067. protected _metallic: Nullable<number>;
  118068. /**
  118069. * Specifies the roughness scalar of the metallic/roughness workflow.
  118070. * Can also be used to scale the roughness values of the metallic texture.
  118071. */
  118072. protected _roughness: Nullable<number>;
  118073. /**
  118074. * Specifies the an F0 factor to help configuring the material F0.
  118075. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  118076. * to 0.5 the previously hard coded value stays the same.
  118077. * Can also be used to scale the F0 values of the metallic texture.
  118078. */
  118079. protected _metallicF0Factor: number;
  118080. /**
  118081. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  118082. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  118083. * your expectation as it multiplies with the texture data.
  118084. */
  118085. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  118086. /**
  118087. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  118088. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  118089. */
  118090. protected _microSurfaceTexture: Nullable<BaseTexture>;
  118091. /**
  118092. * Stores surface normal data used to displace a mesh in a texture.
  118093. */
  118094. protected _bumpTexture: Nullable<BaseTexture>;
  118095. /**
  118096. * Stores the pre-calculated light information of a mesh in a texture.
  118097. */
  118098. protected _lightmapTexture: Nullable<BaseTexture>;
  118099. /**
  118100. * The color of a material in ambient lighting.
  118101. */
  118102. protected _ambientColor: Color3;
  118103. /**
  118104. * AKA Diffuse Color in other nomenclature.
  118105. */
  118106. protected _albedoColor: Color3;
  118107. /**
  118108. * AKA Specular Color in other nomenclature.
  118109. */
  118110. protected _reflectivityColor: Color3;
  118111. /**
  118112. * The color applied when light is reflected from a material.
  118113. */
  118114. protected _reflectionColor: Color3;
  118115. /**
  118116. * The color applied when light is emitted from a material.
  118117. */
  118118. protected _emissiveColor: Color3;
  118119. /**
  118120. * AKA Glossiness in other nomenclature.
  118121. */
  118122. protected _microSurface: number;
  118123. /**
  118124. * Specifies that the material will use the light map as a show map.
  118125. */
  118126. protected _useLightmapAsShadowmap: boolean;
  118127. /**
  118128. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  118129. * makes the reflect vector face the model (under horizon).
  118130. */
  118131. protected _useHorizonOcclusion: boolean;
  118132. /**
  118133. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  118134. * too much the area relying on ambient texture to define their ambient occlusion.
  118135. */
  118136. protected _useRadianceOcclusion: boolean;
  118137. /**
  118138. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  118139. */
  118140. protected _useAlphaFromAlbedoTexture: boolean;
  118141. /**
  118142. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  118143. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  118144. */
  118145. protected _useSpecularOverAlpha: boolean;
  118146. /**
  118147. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  118148. */
  118149. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  118150. /**
  118151. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  118152. */
  118153. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  118154. /**
  118155. * Specifies if the metallic texture contains the roughness information in its green channel.
  118156. */
  118157. protected _useRoughnessFromMetallicTextureGreen: boolean;
  118158. /**
  118159. * Specifies if the metallic texture contains the metallness information in its blue channel.
  118160. */
  118161. protected _useMetallnessFromMetallicTextureBlue: boolean;
  118162. /**
  118163. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  118164. */
  118165. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  118166. /**
  118167. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  118168. */
  118169. protected _useAmbientInGrayScale: boolean;
  118170. /**
  118171. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  118172. * The material will try to infer what glossiness each pixel should be.
  118173. */
  118174. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  118175. /**
  118176. * Defines the falloff type used in this material.
  118177. * It by default is Physical.
  118178. */
  118179. protected _lightFalloff: number;
  118180. /**
  118181. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  118182. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  118183. */
  118184. protected _useRadianceOverAlpha: boolean;
  118185. /**
  118186. * Allows using an object space normal map (instead of tangent space).
  118187. */
  118188. protected _useObjectSpaceNormalMap: boolean;
  118189. /**
  118190. * Allows using the bump map in parallax mode.
  118191. */
  118192. protected _useParallax: boolean;
  118193. /**
  118194. * Allows using the bump map in parallax occlusion mode.
  118195. */
  118196. protected _useParallaxOcclusion: boolean;
  118197. /**
  118198. * Controls the scale bias of the parallax mode.
  118199. */
  118200. protected _parallaxScaleBias: number;
  118201. /**
  118202. * If sets to true, disables all the lights affecting the material.
  118203. */
  118204. protected _disableLighting: boolean;
  118205. /**
  118206. * Number of Simultaneous lights allowed on the material.
  118207. */
  118208. protected _maxSimultaneousLights: number;
  118209. /**
  118210. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  118211. */
  118212. protected _invertNormalMapX: boolean;
  118213. /**
  118214. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  118215. */
  118216. protected _invertNormalMapY: boolean;
  118217. /**
  118218. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  118219. */
  118220. protected _twoSidedLighting: boolean;
  118221. /**
  118222. * Defines the alpha limits in alpha test mode.
  118223. */
  118224. protected _alphaCutOff: number;
  118225. /**
  118226. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  118227. */
  118228. protected _forceAlphaTest: boolean;
  118229. /**
  118230. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  118231. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  118232. */
  118233. protected _useAlphaFresnel: boolean;
  118234. /**
  118235. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  118236. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  118237. */
  118238. protected _useLinearAlphaFresnel: boolean;
  118239. /**
  118240. * The transparency mode of the material.
  118241. */
  118242. protected _transparencyMode: Nullable<number>;
  118243. /**
  118244. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  118245. * from cos thetav and roughness:
  118246. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  118247. */
  118248. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  118249. /**
  118250. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  118251. */
  118252. protected _forceIrradianceInFragment: boolean;
  118253. /**
  118254. * Force normal to face away from face.
  118255. */
  118256. protected _forceNormalForward: boolean;
  118257. /**
  118258. * Enables specular anti aliasing in the PBR shader.
  118259. * It will both interacts on the Geometry for analytical and IBL lighting.
  118260. * It also prefilter the roughness map based on the bump values.
  118261. */
  118262. protected _enableSpecularAntiAliasing: boolean;
  118263. /**
  118264. * Default configuration related to image processing available in the PBR Material.
  118265. */
  118266. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  118267. /**
  118268. * Keep track of the image processing observer to allow dispose and replace.
  118269. */
  118270. private _imageProcessingObserver;
  118271. /**
  118272. * Attaches a new image processing configuration to the PBR Material.
  118273. * @param configuration
  118274. */
  118275. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  118276. /**
  118277. * Stores the available render targets.
  118278. */
  118279. private _renderTargets;
  118280. /**
  118281. * Sets the global ambient color for the material used in lighting calculations.
  118282. */
  118283. private _globalAmbientColor;
  118284. /**
  118285. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  118286. */
  118287. private _useLogarithmicDepth;
  118288. /**
  118289. * If set to true, no lighting calculations will be applied.
  118290. */
  118291. private _unlit;
  118292. private _debugMode;
  118293. /**
  118294. * @hidden
  118295. * This is reserved for the inspector.
  118296. * Defines the material debug mode.
  118297. * It helps seeing only some components of the material while troubleshooting.
  118298. */
  118299. debugMode: number;
  118300. /**
  118301. * @hidden
  118302. * This is reserved for the inspector.
  118303. * Specify from where on screen the debug mode should start.
  118304. * The value goes from -1 (full screen) to 1 (not visible)
  118305. * It helps with side by side comparison against the final render
  118306. * This defaults to -1
  118307. */
  118308. private debugLimit;
  118309. /**
  118310. * @hidden
  118311. * This is reserved for the inspector.
  118312. * As the default viewing range might not be enough (if the ambient is really small for instance)
  118313. * You can use the factor to better multiply the final value.
  118314. */
  118315. private debugFactor;
  118316. /**
  118317. * Defines the clear coat layer parameters for the material.
  118318. */
  118319. readonly clearCoat: PBRClearCoatConfiguration;
  118320. /**
  118321. * Defines the anisotropic parameters for the material.
  118322. */
  118323. readonly anisotropy: PBRAnisotropicConfiguration;
  118324. /**
  118325. * Defines the BRDF parameters for the material.
  118326. */
  118327. readonly brdf: PBRBRDFConfiguration;
  118328. /**
  118329. * Defines the Sheen parameters for the material.
  118330. */
  118331. readonly sheen: PBRSheenConfiguration;
  118332. /**
  118333. * Defines the SubSurface parameters for the material.
  118334. */
  118335. readonly subSurface: PBRSubSurfaceConfiguration;
  118336. /**
  118337. * Custom callback helping to override the default shader used in the material.
  118338. */
  118339. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  118340. protected _rebuildInParallel: boolean;
  118341. /**
  118342. * Instantiates a new PBRMaterial instance.
  118343. *
  118344. * @param name The material name
  118345. * @param scene The scene the material will be use in.
  118346. */
  118347. constructor(name: string, scene: Scene);
  118348. /**
  118349. * Gets a boolean indicating that current material needs to register RTT
  118350. */
  118351. readonly hasRenderTargetTextures: boolean;
  118352. /**
  118353. * Gets the name of the material class.
  118354. */
  118355. getClassName(): string;
  118356. /**
  118357. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  118358. */
  118359. /**
  118360. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  118361. */
  118362. useLogarithmicDepth: boolean;
  118363. /**
  118364. * Gets the current transparency mode.
  118365. */
  118366. /**
  118367. * Sets the transparency mode of the material.
  118368. *
  118369. * | Value | Type | Description |
  118370. * | ----- | ----------------------------------- | ----------- |
  118371. * | 0 | OPAQUE | |
  118372. * | 1 | ALPHATEST | |
  118373. * | 2 | ALPHABLEND | |
  118374. * | 3 | ALPHATESTANDBLEND | |
  118375. *
  118376. */
  118377. transparencyMode: Nullable<number>;
  118378. /**
  118379. * Returns true if alpha blending should be disabled.
  118380. */
  118381. private readonly _disableAlphaBlending;
  118382. /**
  118383. * Specifies whether or not this material should be rendered in alpha blend mode.
  118384. */
  118385. needAlphaBlending(): boolean;
  118386. /**
  118387. * Specifies if the mesh will require alpha blending.
  118388. * @param mesh - BJS mesh.
  118389. */
  118390. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  118391. /**
  118392. * Specifies whether or not this material should be rendered in alpha test mode.
  118393. */
  118394. needAlphaTesting(): boolean;
  118395. /**
  118396. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  118397. */
  118398. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  118399. /**
  118400. * Gets the texture used for the alpha test.
  118401. */
  118402. getAlphaTestTexture(): Nullable<BaseTexture>;
  118403. /**
  118404. * Specifies that the submesh is ready to be used.
  118405. * @param mesh - BJS mesh.
  118406. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  118407. * @param useInstances - Specifies that instances should be used.
  118408. * @returns - boolean indicating that the submesh is ready or not.
  118409. */
  118410. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  118411. /**
  118412. * Specifies if the material uses metallic roughness workflow.
  118413. * @returns boolean specifiying if the material uses metallic roughness workflow.
  118414. */
  118415. isMetallicWorkflow(): boolean;
  118416. private _prepareEffect;
  118417. private _prepareDefines;
  118418. /**
  118419. * Force shader compilation
  118420. */
  118421. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  118422. /**
  118423. * Initializes the uniform buffer layout for the shader.
  118424. */
  118425. buildUniformLayout(): void;
  118426. /**
  118427. * Unbinds the material from the mesh
  118428. */
  118429. unbind(): void;
  118430. /**
  118431. * Binds the submesh data.
  118432. * @param world - The world matrix.
  118433. * @param mesh - The BJS mesh.
  118434. * @param subMesh - A submesh of the BJS mesh.
  118435. */
  118436. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  118437. /**
  118438. * Returns the animatable textures.
  118439. * @returns - Array of animatable textures.
  118440. */
  118441. getAnimatables(): IAnimatable[];
  118442. /**
  118443. * Returns the texture used for reflections.
  118444. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  118445. */
  118446. private _getReflectionTexture;
  118447. /**
  118448. * Returns an array of the actively used textures.
  118449. * @returns - Array of BaseTextures
  118450. */
  118451. getActiveTextures(): BaseTexture[];
  118452. /**
  118453. * Checks to see if a texture is used in the material.
  118454. * @param texture - Base texture to use.
  118455. * @returns - Boolean specifying if a texture is used in the material.
  118456. */
  118457. hasTexture(texture: BaseTexture): boolean;
  118458. /**
  118459. * Disposes the resources of the material.
  118460. * @param forceDisposeEffect - Forces the disposal of effects.
  118461. * @param forceDisposeTextures - Forces the disposal of all textures.
  118462. */
  118463. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  118464. }
  118465. }
  118466. declare module BABYLON {
  118467. /**
  118468. * The Physically based material of BJS.
  118469. *
  118470. * This offers the main features of a standard PBR material.
  118471. * For more information, please refer to the documentation :
  118472. * https://doc.babylonjs.com/how_to/physically_based_rendering
  118473. */
  118474. export class PBRMaterial extends PBRBaseMaterial {
  118475. /**
  118476. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  118477. */
  118478. static readonly PBRMATERIAL_OPAQUE: number;
  118479. /**
  118480. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  118481. */
  118482. static readonly PBRMATERIAL_ALPHATEST: number;
  118483. /**
  118484. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  118485. */
  118486. static readonly PBRMATERIAL_ALPHABLEND: number;
  118487. /**
  118488. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  118489. * They are also discarded below the alpha cutoff threshold to improve performances.
  118490. */
  118491. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  118492. /**
  118493. * Defines the default value of how much AO map is occluding the analytical lights
  118494. * (point spot...).
  118495. */
  118496. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  118497. /**
  118498. * Intensity of the direct lights e.g. the four lights available in your scene.
  118499. * This impacts both the direct diffuse and specular highlights.
  118500. */
  118501. directIntensity: number;
  118502. /**
  118503. * Intensity of the emissive part of the material.
  118504. * This helps controlling the emissive effect without modifying the emissive color.
  118505. */
  118506. emissiveIntensity: number;
  118507. /**
  118508. * Intensity of the environment e.g. how much the environment will light the object
  118509. * either through harmonics for rough material or through the refelction for shiny ones.
  118510. */
  118511. environmentIntensity: number;
  118512. /**
  118513. * This is a special control allowing the reduction of the specular highlights coming from the
  118514. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  118515. */
  118516. specularIntensity: number;
  118517. /**
  118518. * Debug Control allowing disabling the bump map on this material.
  118519. */
  118520. disableBumpMap: boolean;
  118521. /**
  118522. * AKA Diffuse Texture in standard nomenclature.
  118523. */
  118524. albedoTexture: BaseTexture;
  118525. /**
  118526. * AKA Occlusion Texture in other nomenclature.
  118527. */
  118528. ambientTexture: BaseTexture;
  118529. /**
  118530. * AKA Occlusion Texture Intensity in other nomenclature.
  118531. */
  118532. ambientTextureStrength: number;
  118533. /**
  118534. * Defines how much the AO map is occluding the analytical lights (point spot...).
  118535. * 1 means it completely occludes it
  118536. * 0 mean it has no impact
  118537. */
  118538. ambientTextureImpactOnAnalyticalLights: number;
  118539. /**
  118540. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  118541. */
  118542. opacityTexture: BaseTexture;
  118543. /**
  118544. * Stores the reflection values in a texture.
  118545. */
  118546. reflectionTexture: Nullable<BaseTexture>;
  118547. /**
  118548. * Stores the emissive values in a texture.
  118549. */
  118550. emissiveTexture: BaseTexture;
  118551. /**
  118552. * AKA Specular texture in other nomenclature.
  118553. */
  118554. reflectivityTexture: BaseTexture;
  118555. /**
  118556. * Used to switch from specular/glossiness to metallic/roughness workflow.
  118557. */
  118558. metallicTexture: BaseTexture;
  118559. /**
  118560. * Specifies the metallic scalar of the metallic/roughness workflow.
  118561. * Can also be used to scale the metalness values of the metallic texture.
  118562. */
  118563. metallic: Nullable<number>;
  118564. /**
  118565. * Specifies the roughness scalar of the metallic/roughness workflow.
  118566. * Can also be used to scale the roughness values of the metallic texture.
  118567. */
  118568. roughness: Nullable<number>;
  118569. /**
  118570. * Specifies the an F0 factor to help configuring the material F0.
  118571. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  118572. * to 0.5 the previously hard coded value stays the same.
  118573. * Can also be used to scale the F0 values of the metallic texture.
  118574. */
  118575. metallicF0Factor: number;
  118576. /**
  118577. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  118578. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  118579. * your expectation as it multiplies with the texture data.
  118580. */
  118581. useMetallicF0FactorFromMetallicTexture: boolean;
  118582. /**
  118583. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  118584. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  118585. */
  118586. microSurfaceTexture: BaseTexture;
  118587. /**
  118588. * Stores surface normal data used to displace a mesh in a texture.
  118589. */
  118590. bumpTexture: BaseTexture;
  118591. /**
  118592. * Stores the pre-calculated light information of a mesh in a texture.
  118593. */
  118594. lightmapTexture: BaseTexture;
  118595. /**
  118596. * Stores the refracted light information in a texture.
  118597. */
  118598. refractionTexture: Nullable<BaseTexture>;
  118599. /**
  118600. * The color of a material in ambient lighting.
  118601. */
  118602. ambientColor: Color3;
  118603. /**
  118604. * AKA Diffuse Color in other nomenclature.
  118605. */
  118606. albedoColor: Color3;
  118607. /**
  118608. * AKA Specular Color in other nomenclature.
  118609. */
  118610. reflectivityColor: Color3;
  118611. /**
  118612. * The color reflected from the material.
  118613. */
  118614. reflectionColor: Color3;
  118615. /**
  118616. * The color emitted from the material.
  118617. */
  118618. emissiveColor: Color3;
  118619. /**
  118620. * AKA Glossiness in other nomenclature.
  118621. */
  118622. microSurface: number;
  118623. /**
  118624. * source material index of refraction (IOR)' / 'destination material IOR.
  118625. */
  118626. indexOfRefraction: number;
  118627. /**
  118628. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  118629. */
  118630. invertRefractionY: boolean;
  118631. /**
  118632. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  118633. * Materials half opaque for instance using refraction could benefit from this control.
  118634. */
  118635. linkRefractionWithTransparency: boolean;
  118636. /**
  118637. * If true, the light map contains occlusion information instead of lighting info.
  118638. */
  118639. useLightmapAsShadowmap: boolean;
  118640. /**
  118641. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  118642. */
  118643. useAlphaFromAlbedoTexture: boolean;
  118644. /**
  118645. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  118646. */
  118647. forceAlphaTest: boolean;
  118648. /**
  118649. * Defines the alpha limits in alpha test mode.
  118650. */
  118651. alphaCutOff: number;
  118652. /**
  118653. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  118654. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  118655. */
  118656. useSpecularOverAlpha: boolean;
  118657. /**
  118658. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  118659. */
  118660. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  118661. /**
  118662. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  118663. */
  118664. useRoughnessFromMetallicTextureAlpha: boolean;
  118665. /**
  118666. * Specifies if the metallic texture contains the roughness information in its green channel.
  118667. */
  118668. useRoughnessFromMetallicTextureGreen: boolean;
  118669. /**
  118670. * Specifies if the metallic texture contains the metallness information in its blue channel.
  118671. */
  118672. useMetallnessFromMetallicTextureBlue: boolean;
  118673. /**
  118674. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  118675. */
  118676. useAmbientOcclusionFromMetallicTextureRed: boolean;
  118677. /**
  118678. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  118679. */
  118680. useAmbientInGrayScale: boolean;
  118681. /**
  118682. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  118683. * The material will try to infer what glossiness each pixel should be.
  118684. */
  118685. useAutoMicroSurfaceFromReflectivityMap: boolean;
  118686. /**
  118687. * BJS is using an harcoded light falloff based on a manually sets up range.
  118688. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  118689. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  118690. */
  118691. /**
  118692. * BJS is using an harcoded light falloff based on a manually sets up range.
  118693. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  118694. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  118695. */
  118696. usePhysicalLightFalloff: boolean;
  118697. /**
  118698. * In order to support the falloff compatibility with gltf, a special mode has been added
  118699. * to reproduce the gltf light falloff.
  118700. */
  118701. /**
  118702. * In order to support the falloff compatibility with gltf, a special mode has been added
  118703. * to reproduce the gltf light falloff.
  118704. */
  118705. useGLTFLightFalloff: boolean;
  118706. /**
  118707. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  118708. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  118709. */
  118710. useRadianceOverAlpha: boolean;
  118711. /**
  118712. * Allows using an object space normal map (instead of tangent space).
  118713. */
  118714. useObjectSpaceNormalMap: boolean;
  118715. /**
  118716. * Allows using the bump map in parallax mode.
  118717. */
  118718. useParallax: boolean;
  118719. /**
  118720. * Allows using the bump map in parallax occlusion mode.
  118721. */
  118722. useParallaxOcclusion: boolean;
  118723. /**
  118724. * Controls the scale bias of the parallax mode.
  118725. */
  118726. parallaxScaleBias: number;
  118727. /**
  118728. * If sets to true, disables all the lights affecting the material.
  118729. */
  118730. disableLighting: boolean;
  118731. /**
  118732. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  118733. */
  118734. forceIrradianceInFragment: boolean;
  118735. /**
  118736. * Number of Simultaneous lights allowed on the material.
  118737. */
  118738. maxSimultaneousLights: number;
  118739. /**
  118740. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  118741. */
  118742. invertNormalMapX: boolean;
  118743. /**
  118744. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  118745. */
  118746. invertNormalMapY: boolean;
  118747. /**
  118748. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  118749. */
  118750. twoSidedLighting: boolean;
  118751. /**
  118752. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  118753. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  118754. */
  118755. useAlphaFresnel: boolean;
  118756. /**
  118757. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  118758. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  118759. */
  118760. useLinearAlphaFresnel: boolean;
  118761. /**
  118762. * Let user defines the brdf lookup texture used for IBL.
  118763. * A default 8bit version is embedded but you could point at :
  118764. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  118765. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  118766. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  118767. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  118768. */
  118769. environmentBRDFTexture: Nullable<BaseTexture>;
  118770. /**
  118771. * Force normal to face away from face.
  118772. */
  118773. forceNormalForward: boolean;
  118774. /**
  118775. * Enables specular anti aliasing in the PBR shader.
  118776. * It will both interacts on the Geometry for analytical and IBL lighting.
  118777. * It also prefilter the roughness map based on the bump values.
  118778. */
  118779. enableSpecularAntiAliasing: boolean;
  118780. /**
  118781. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  118782. * makes the reflect vector face the model (under horizon).
  118783. */
  118784. useHorizonOcclusion: boolean;
  118785. /**
  118786. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  118787. * too much the area relying on ambient texture to define their ambient occlusion.
  118788. */
  118789. useRadianceOcclusion: boolean;
  118790. /**
  118791. * If set to true, no lighting calculations will be applied.
  118792. */
  118793. unlit: boolean;
  118794. /**
  118795. * Gets the image processing configuration used either in this material.
  118796. */
  118797. /**
  118798. * Sets the Default image processing configuration used either in the this material.
  118799. *
  118800. * If sets to null, the scene one is in use.
  118801. */
  118802. imageProcessingConfiguration: ImageProcessingConfiguration;
  118803. /**
  118804. * Gets wether the color curves effect is enabled.
  118805. */
  118806. /**
  118807. * Sets wether the color curves effect is enabled.
  118808. */
  118809. cameraColorCurvesEnabled: boolean;
  118810. /**
  118811. * Gets wether the color grading effect is enabled.
  118812. */
  118813. /**
  118814. * Gets wether the color grading effect is enabled.
  118815. */
  118816. cameraColorGradingEnabled: boolean;
  118817. /**
  118818. * Gets wether tonemapping is enabled or not.
  118819. */
  118820. /**
  118821. * Sets wether tonemapping is enabled or not
  118822. */
  118823. cameraToneMappingEnabled: boolean;
  118824. /**
  118825. * The camera exposure used on this material.
  118826. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  118827. * This corresponds to a photographic exposure.
  118828. */
  118829. /**
  118830. * The camera exposure used on this material.
  118831. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  118832. * This corresponds to a photographic exposure.
  118833. */
  118834. cameraExposure: number;
  118835. /**
  118836. * Gets The camera contrast used on this material.
  118837. */
  118838. /**
  118839. * Sets The camera contrast used on this material.
  118840. */
  118841. cameraContrast: number;
  118842. /**
  118843. * Gets the Color Grading 2D Lookup Texture.
  118844. */
  118845. /**
  118846. * Sets the Color Grading 2D Lookup Texture.
  118847. */
  118848. cameraColorGradingTexture: Nullable<BaseTexture>;
  118849. /**
  118850. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  118851. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  118852. * 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;
  118853. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  118854. */
  118855. /**
  118856. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  118857. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  118858. * 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;
  118859. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  118860. */
  118861. cameraColorCurves: Nullable<ColorCurves>;
  118862. /**
  118863. * Instantiates a new PBRMaterial instance.
  118864. *
  118865. * @param name The material name
  118866. * @param scene The scene the material will be use in.
  118867. */
  118868. constructor(name: string, scene: Scene);
  118869. /**
  118870. * Returns the name of this material class.
  118871. */
  118872. getClassName(): string;
  118873. /**
  118874. * Makes a duplicate of the current material.
  118875. * @param name - name to use for the new material.
  118876. */
  118877. clone(name: string): PBRMaterial;
  118878. /**
  118879. * Serializes this PBR Material.
  118880. * @returns - An object with the serialized material.
  118881. */
  118882. serialize(): any;
  118883. /**
  118884. * Parses a PBR Material from a serialized object.
  118885. * @param source - Serialized object.
  118886. * @param scene - BJS scene instance.
  118887. * @param rootUrl - url for the scene object
  118888. * @returns - PBRMaterial
  118889. */
  118890. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  118891. }
  118892. }
  118893. declare module BABYLON {
  118894. /**
  118895. * Direct draw surface info
  118896. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  118897. */
  118898. export interface DDSInfo {
  118899. /**
  118900. * Width of the texture
  118901. */
  118902. width: number;
  118903. /**
  118904. * Width of the texture
  118905. */
  118906. height: number;
  118907. /**
  118908. * Number of Mipmaps for the texture
  118909. * @see https://en.wikipedia.org/wiki/Mipmap
  118910. */
  118911. mipmapCount: number;
  118912. /**
  118913. * If the textures format is a known fourCC format
  118914. * @see https://www.fourcc.org/
  118915. */
  118916. isFourCC: boolean;
  118917. /**
  118918. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  118919. */
  118920. isRGB: boolean;
  118921. /**
  118922. * If the texture is a lumincance format
  118923. */
  118924. isLuminance: boolean;
  118925. /**
  118926. * If this is a cube texture
  118927. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  118928. */
  118929. isCube: boolean;
  118930. /**
  118931. * If the texture is a compressed format eg. FOURCC_DXT1
  118932. */
  118933. isCompressed: boolean;
  118934. /**
  118935. * The dxgiFormat of the texture
  118936. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  118937. */
  118938. dxgiFormat: number;
  118939. /**
  118940. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  118941. */
  118942. textureType: number;
  118943. /**
  118944. * Sphericle polynomial created for the dds texture
  118945. */
  118946. sphericalPolynomial?: SphericalPolynomial;
  118947. }
  118948. /**
  118949. * Class used to provide DDS decompression tools
  118950. */
  118951. export class DDSTools {
  118952. /**
  118953. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  118954. */
  118955. static StoreLODInAlphaChannel: boolean;
  118956. /**
  118957. * Gets DDS information from an array buffer
  118958. * @param arrayBuffer defines the array buffer to read data from
  118959. * @returns the DDS information
  118960. */
  118961. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  118962. private static _FloatView;
  118963. private static _Int32View;
  118964. private static _ToHalfFloat;
  118965. private static _FromHalfFloat;
  118966. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  118967. private static _GetHalfFloatRGBAArrayBuffer;
  118968. private static _GetFloatRGBAArrayBuffer;
  118969. private static _GetFloatAsUIntRGBAArrayBuffer;
  118970. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  118971. private static _GetRGBAArrayBuffer;
  118972. private static _ExtractLongWordOrder;
  118973. private static _GetRGBArrayBuffer;
  118974. private static _GetLuminanceArrayBuffer;
  118975. /**
  118976. * Uploads DDS Levels to a Babylon Texture
  118977. * @hidden
  118978. */
  118979. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  118980. }
  118981. interface ThinEngine {
  118982. /**
  118983. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  118984. * @param rootUrl defines the url where the file to load is located
  118985. * @param scene defines the current scene
  118986. * @param lodScale defines scale to apply to the mip map selection
  118987. * @param lodOffset defines offset to apply to the mip map selection
  118988. * @param onLoad defines an optional callback raised when the texture is loaded
  118989. * @param onError defines an optional callback raised if there is an issue to load the texture
  118990. * @param format defines the format of the data
  118991. * @param forcedExtension defines the extension to use to pick the right loader
  118992. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  118993. * @returns the cube texture as an InternalTexture
  118994. */
  118995. 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;
  118996. }
  118997. }
  118998. declare module BABYLON {
  118999. /**
  119000. * Implementation of the DDS Texture Loader.
  119001. * @hidden
  119002. */
  119003. export class _DDSTextureLoader implements IInternalTextureLoader {
  119004. /**
  119005. * Defines wether the loader supports cascade loading the different faces.
  119006. */
  119007. readonly supportCascades: boolean;
  119008. /**
  119009. * This returns if the loader support the current file information.
  119010. * @param extension defines the file extension of the file being loaded
  119011. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119012. * @param fallback defines the fallback internal texture if any
  119013. * @param isBase64 defines whether the texture is encoded as a base64
  119014. * @param isBuffer defines whether the texture data are stored as a buffer
  119015. * @returns true if the loader can load the specified file
  119016. */
  119017. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  119018. /**
  119019. * Transform the url before loading if required.
  119020. * @param rootUrl the url of the texture
  119021. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119022. * @returns the transformed texture
  119023. */
  119024. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  119025. /**
  119026. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  119027. * @param rootUrl the url of the texture
  119028. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119029. * @returns the fallback texture
  119030. */
  119031. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  119032. /**
  119033. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  119034. * @param data contains the texture data
  119035. * @param texture defines the BabylonJS internal texture
  119036. * @param createPolynomials will be true if polynomials have been requested
  119037. * @param onLoad defines the callback to trigger once the texture is ready
  119038. * @param onError defines the callback to trigger in case of error
  119039. */
  119040. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  119041. /**
  119042. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  119043. * @param data contains the texture data
  119044. * @param texture defines the BabylonJS internal texture
  119045. * @param callback defines the method to call once ready to upload
  119046. */
  119047. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  119048. }
  119049. }
  119050. declare module BABYLON {
  119051. /**
  119052. * Implementation of the ENV Texture Loader.
  119053. * @hidden
  119054. */
  119055. export class _ENVTextureLoader implements IInternalTextureLoader {
  119056. /**
  119057. * Defines wether the loader supports cascade loading the different faces.
  119058. */
  119059. readonly supportCascades: boolean;
  119060. /**
  119061. * This returns if the loader support the current file information.
  119062. * @param extension defines the file extension of the file being loaded
  119063. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119064. * @param fallback defines the fallback internal texture if any
  119065. * @param isBase64 defines whether the texture is encoded as a base64
  119066. * @param isBuffer defines whether the texture data are stored as a buffer
  119067. * @returns true if the loader can load the specified file
  119068. */
  119069. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  119070. /**
  119071. * Transform the url before loading if required.
  119072. * @param rootUrl the url of the texture
  119073. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119074. * @returns the transformed texture
  119075. */
  119076. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  119077. /**
  119078. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  119079. * @param rootUrl the url of the texture
  119080. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119081. * @returns the fallback texture
  119082. */
  119083. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  119084. /**
  119085. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  119086. * @param data contains the texture data
  119087. * @param texture defines the BabylonJS internal texture
  119088. * @param createPolynomials will be true if polynomials have been requested
  119089. * @param onLoad defines the callback to trigger once the texture is ready
  119090. * @param onError defines the callback to trigger in case of error
  119091. */
  119092. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  119093. /**
  119094. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  119095. * @param data contains the texture data
  119096. * @param texture defines the BabylonJS internal texture
  119097. * @param callback defines the method to call once ready to upload
  119098. */
  119099. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  119100. }
  119101. }
  119102. declare module BABYLON {
  119103. /**
  119104. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  119105. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  119106. */
  119107. export class KhronosTextureContainer {
  119108. /** contents of the KTX container file */
  119109. arrayBuffer: any;
  119110. private static HEADER_LEN;
  119111. private static COMPRESSED_2D;
  119112. private static COMPRESSED_3D;
  119113. private static TEX_2D;
  119114. private static TEX_3D;
  119115. /**
  119116. * Gets the openGL type
  119117. */
  119118. glType: number;
  119119. /**
  119120. * Gets the openGL type size
  119121. */
  119122. glTypeSize: number;
  119123. /**
  119124. * Gets the openGL format
  119125. */
  119126. glFormat: number;
  119127. /**
  119128. * Gets the openGL internal format
  119129. */
  119130. glInternalFormat: number;
  119131. /**
  119132. * Gets the base internal format
  119133. */
  119134. glBaseInternalFormat: number;
  119135. /**
  119136. * Gets image width in pixel
  119137. */
  119138. pixelWidth: number;
  119139. /**
  119140. * Gets image height in pixel
  119141. */
  119142. pixelHeight: number;
  119143. /**
  119144. * Gets image depth in pixels
  119145. */
  119146. pixelDepth: number;
  119147. /**
  119148. * Gets the number of array elements
  119149. */
  119150. numberOfArrayElements: number;
  119151. /**
  119152. * Gets the number of faces
  119153. */
  119154. numberOfFaces: number;
  119155. /**
  119156. * Gets the number of mipmap levels
  119157. */
  119158. numberOfMipmapLevels: number;
  119159. /**
  119160. * Gets the bytes of key value data
  119161. */
  119162. bytesOfKeyValueData: number;
  119163. /**
  119164. * Gets the load type
  119165. */
  119166. loadType: number;
  119167. /**
  119168. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  119169. */
  119170. isInvalid: boolean;
  119171. /**
  119172. * Creates a new KhronosTextureContainer
  119173. * @param arrayBuffer contents of the KTX container file
  119174. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  119175. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  119176. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  119177. */
  119178. constructor(
  119179. /** contents of the KTX container file */
  119180. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  119181. /**
  119182. * Uploads KTX content to a Babylon Texture.
  119183. * It is assumed that the texture has already been created & is currently bound
  119184. * @hidden
  119185. */
  119186. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  119187. private _upload2DCompressedLevels;
  119188. }
  119189. }
  119190. declare module BABYLON {
  119191. /**
  119192. * Implementation of the KTX Texture Loader.
  119193. * @hidden
  119194. */
  119195. export class _KTXTextureLoader implements IInternalTextureLoader {
  119196. /**
  119197. * Defines wether the loader supports cascade loading the different faces.
  119198. */
  119199. readonly supportCascades: boolean;
  119200. /**
  119201. * This returns if the loader support the current file information.
  119202. * @param extension defines the file extension of the file being loaded
  119203. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119204. * @param fallback defines the fallback internal texture if any
  119205. * @param isBase64 defines whether the texture is encoded as a base64
  119206. * @param isBuffer defines whether the texture data are stored as a buffer
  119207. * @returns true if the loader can load the specified file
  119208. */
  119209. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  119210. /**
  119211. * Transform the url before loading if required.
  119212. * @param rootUrl the url of the texture
  119213. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119214. * @returns the transformed texture
  119215. */
  119216. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  119217. /**
  119218. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  119219. * @param rootUrl the url of the texture
  119220. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119221. * @returns the fallback texture
  119222. */
  119223. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  119224. /**
  119225. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  119226. * @param data contains the texture data
  119227. * @param texture defines the BabylonJS internal texture
  119228. * @param createPolynomials will be true if polynomials have been requested
  119229. * @param onLoad defines the callback to trigger once the texture is ready
  119230. * @param onError defines the callback to trigger in case of error
  119231. */
  119232. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  119233. /**
  119234. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  119235. * @param data contains the texture data
  119236. * @param texture defines the BabylonJS internal texture
  119237. * @param callback defines the method to call once ready to upload
  119238. */
  119239. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  119240. }
  119241. }
  119242. declare module BABYLON {
  119243. /** @hidden */
  119244. export var _forceSceneHelpersToBundle: boolean;
  119245. interface Scene {
  119246. /**
  119247. * Creates a default light for the scene.
  119248. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  119249. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  119250. */
  119251. createDefaultLight(replace?: boolean): void;
  119252. /**
  119253. * Creates a default camera for the scene.
  119254. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  119255. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  119256. * @param replace has default false, when true replaces the active camera in the scene
  119257. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  119258. */
  119259. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  119260. /**
  119261. * Creates a default camera and a default light.
  119262. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  119263. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  119264. * @param replace has the default false, when true replaces the active camera/light in the scene
  119265. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  119266. */
  119267. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  119268. /**
  119269. * Creates a new sky box
  119270. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  119271. * @param environmentTexture defines the texture to use as environment texture
  119272. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  119273. * @param scale defines the overall scale of the skybox
  119274. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  119275. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  119276. * @returns a new mesh holding the sky box
  119277. */
  119278. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  119279. /**
  119280. * Creates a new environment
  119281. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  119282. * @param options defines the options you can use to configure the environment
  119283. * @returns the new EnvironmentHelper
  119284. */
  119285. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  119286. /**
  119287. * Creates a new VREXperienceHelper
  119288. * @see http://doc.babylonjs.com/how_to/webvr_helper
  119289. * @param webVROptions defines the options used to create the new VREXperienceHelper
  119290. * @returns a new VREXperienceHelper
  119291. */
  119292. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  119293. /**
  119294. * Creates a new WebXRDefaultExperience
  119295. * @see http://doc.babylonjs.com/how_to/webxr
  119296. * @param options experience options
  119297. * @returns a promise for a new WebXRDefaultExperience
  119298. */
  119299. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  119300. }
  119301. }
  119302. declare module BABYLON {
  119303. /**
  119304. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  119305. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  119306. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  119307. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  119308. */
  119309. export class VideoDome extends TransformNode {
  119310. /**
  119311. * Define the video source as a Monoscopic panoramic 360 video.
  119312. */
  119313. static readonly MODE_MONOSCOPIC: number;
  119314. /**
  119315. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  119316. */
  119317. static readonly MODE_TOPBOTTOM: number;
  119318. /**
  119319. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  119320. */
  119321. static readonly MODE_SIDEBYSIDE: number;
  119322. private _halfDome;
  119323. private _useDirectMapping;
  119324. /**
  119325. * The video texture being displayed on the sphere
  119326. */
  119327. protected _videoTexture: VideoTexture;
  119328. /**
  119329. * Gets the video texture being displayed on the sphere
  119330. */
  119331. readonly videoTexture: VideoTexture;
  119332. /**
  119333. * The skybox material
  119334. */
  119335. protected _material: BackgroundMaterial;
  119336. /**
  119337. * The surface used for the skybox
  119338. */
  119339. protected _mesh: Mesh;
  119340. /**
  119341. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  119342. */
  119343. private _halfDomeMask;
  119344. /**
  119345. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  119346. * Also see the options.resolution property.
  119347. */
  119348. fovMultiplier: number;
  119349. private _videoMode;
  119350. /**
  119351. * Gets or set the current video mode for the video. It can be:
  119352. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  119353. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  119354. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  119355. */
  119356. videoMode: number;
  119357. /**
  119358. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  119359. *
  119360. */
  119361. /**
  119362. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  119363. */
  119364. halfDome: boolean;
  119365. /**
  119366. * Oberserver used in Stereoscopic VR Mode.
  119367. */
  119368. private _onBeforeCameraRenderObserver;
  119369. /**
  119370. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  119371. * @param name Element's name, child elements will append suffixes for their own names.
  119372. * @param urlsOrVideo defines the url(s) or the video element to use
  119373. * @param options An object containing optional or exposed sub element properties
  119374. */
  119375. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  119376. resolution?: number;
  119377. clickToPlay?: boolean;
  119378. autoPlay?: boolean;
  119379. loop?: boolean;
  119380. size?: number;
  119381. poster?: string;
  119382. faceForward?: boolean;
  119383. useDirectMapping?: boolean;
  119384. halfDomeMode?: boolean;
  119385. }, scene: Scene);
  119386. private _changeVideoMode;
  119387. /**
  119388. * Releases resources associated with this node.
  119389. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  119390. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  119391. */
  119392. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  119393. }
  119394. }
  119395. declare module BABYLON {
  119396. /**
  119397. * This class can be used to get instrumentation data from a Babylon engine
  119398. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  119399. */
  119400. export class EngineInstrumentation implements IDisposable {
  119401. /**
  119402. * Define the instrumented engine.
  119403. */
  119404. engine: Engine;
  119405. private _captureGPUFrameTime;
  119406. private _gpuFrameTimeToken;
  119407. private _gpuFrameTime;
  119408. private _captureShaderCompilationTime;
  119409. private _shaderCompilationTime;
  119410. private _onBeginFrameObserver;
  119411. private _onEndFrameObserver;
  119412. private _onBeforeShaderCompilationObserver;
  119413. private _onAfterShaderCompilationObserver;
  119414. /**
  119415. * Gets the perf counter used for GPU frame time
  119416. */
  119417. readonly gpuFrameTimeCounter: PerfCounter;
  119418. /**
  119419. * Gets the GPU frame time capture status
  119420. */
  119421. /**
  119422. * Enable or disable the GPU frame time capture
  119423. */
  119424. captureGPUFrameTime: boolean;
  119425. /**
  119426. * Gets the perf counter used for shader compilation time
  119427. */
  119428. readonly shaderCompilationTimeCounter: PerfCounter;
  119429. /**
  119430. * Gets the shader compilation time capture status
  119431. */
  119432. /**
  119433. * Enable or disable the shader compilation time capture
  119434. */
  119435. captureShaderCompilationTime: boolean;
  119436. /**
  119437. * Instantiates a new engine instrumentation.
  119438. * This class can be used to get instrumentation data from a Babylon engine
  119439. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  119440. * @param engine Defines the engine to instrument
  119441. */
  119442. constructor(
  119443. /**
  119444. * Define the instrumented engine.
  119445. */
  119446. engine: Engine);
  119447. /**
  119448. * Dispose and release associated resources.
  119449. */
  119450. dispose(): void;
  119451. }
  119452. }
  119453. declare module BABYLON {
  119454. /**
  119455. * This class can be used to get instrumentation data from a Babylon engine
  119456. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  119457. */
  119458. export class SceneInstrumentation implements IDisposable {
  119459. /**
  119460. * Defines the scene to instrument
  119461. */
  119462. scene: Scene;
  119463. private _captureActiveMeshesEvaluationTime;
  119464. private _activeMeshesEvaluationTime;
  119465. private _captureRenderTargetsRenderTime;
  119466. private _renderTargetsRenderTime;
  119467. private _captureFrameTime;
  119468. private _frameTime;
  119469. private _captureRenderTime;
  119470. private _renderTime;
  119471. private _captureInterFrameTime;
  119472. private _interFrameTime;
  119473. private _captureParticlesRenderTime;
  119474. private _particlesRenderTime;
  119475. private _captureSpritesRenderTime;
  119476. private _spritesRenderTime;
  119477. private _capturePhysicsTime;
  119478. private _physicsTime;
  119479. private _captureAnimationsTime;
  119480. private _animationsTime;
  119481. private _captureCameraRenderTime;
  119482. private _cameraRenderTime;
  119483. private _onBeforeActiveMeshesEvaluationObserver;
  119484. private _onAfterActiveMeshesEvaluationObserver;
  119485. private _onBeforeRenderTargetsRenderObserver;
  119486. private _onAfterRenderTargetsRenderObserver;
  119487. private _onAfterRenderObserver;
  119488. private _onBeforeDrawPhaseObserver;
  119489. private _onAfterDrawPhaseObserver;
  119490. private _onBeforeAnimationsObserver;
  119491. private _onBeforeParticlesRenderingObserver;
  119492. private _onAfterParticlesRenderingObserver;
  119493. private _onBeforeSpritesRenderingObserver;
  119494. private _onAfterSpritesRenderingObserver;
  119495. private _onBeforePhysicsObserver;
  119496. private _onAfterPhysicsObserver;
  119497. private _onAfterAnimationsObserver;
  119498. private _onBeforeCameraRenderObserver;
  119499. private _onAfterCameraRenderObserver;
  119500. /**
  119501. * Gets the perf counter used for active meshes evaluation time
  119502. */
  119503. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  119504. /**
  119505. * Gets the active meshes evaluation time capture status
  119506. */
  119507. /**
  119508. * Enable or disable the active meshes evaluation time capture
  119509. */
  119510. captureActiveMeshesEvaluationTime: boolean;
  119511. /**
  119512. * Gets the perf counter used for render targets render time
  119513. */
  119514. readonly renderTargetsRenderTimeCounter: PerfCounter;
  119515. /**
  119516. * Gets the render targets render time capture status
  119517. */
  119518. /**
  119519. * Enable or disable the render targets render time capture
  119520. */
  119521. captureRenderTargetsRenderTime: boolean;
  119522. /**
  119523. * Gets the perf counter used for particles render time
  119524. */
  119525. readonly particlesRenderTimeCounter: PerfCounter;
  119526. /**
  119527. * Gets the particles render time capture status
  119528. */
  119529. /**
  119530. * Enable or disable the particles render time capture
  119531. */
  119532. captureParticlesRenderTime: boolean;
  119533. /**
  119534. * Gets the perf counter used for sprites render time
  119535. */
  119536. readonly spritesRenderTimeCounter: PerfCounter;
  119537. /**
  119538. * Gets the sprites render time capture status
  119539. */
  119540. /**
  119541. * Enable or disable the sprites render time capture
  119542. */
  119543. captureSpritesRenderTime: boolean;
  119544. /**
  119545. * Gets the perf counter used for physics time
  119546. */
  119547. readonly physicsTimeCounter: PerfCounter;
  119548. /**
  119549. * Gets the physics time capture status
  119550. */
  119551. /**
  119552. * Enable or disable the physics time capture
  119553. */
  119554. capturePhysicsTime: boolean;
  119555. /**
  119556. * Gets the perf counter used for animations time
  119557. */
  119558. readonly animationsTimeCounter: PerfCounter;
  119559. /**
  119560. * Gets the animations time capture status
  119561. */
  119562. /**
  119563. * Enable or disable the animations time capture
  119564. */
  119565. captureAnimationsTime: boolean;
  119566. /**
  119567. * Gets the perf counter used for frame time capture
  119568. */
  119569. readonly frameTimeCounter: PerfCounter;
  119570. /**
  119571. * Gets the frame time capture status
  119572. */
  119573. /**
  119574. * Enable or disable the frame time capture
  119575. */
  119576. captureFrameTime: boolean;
  119577. /**
  119578. * Gets the perf counter used for inter-frames time capture
  119579. */
  119580. readonly interFrameTimeCounter: PerfCounter;
  119581. /**
  119582. * Gets the inter-frames time capture status
  119583. */
  119584. /**
  119585. * Enable or disable the inter-frames time capture
  119586. */
  119587. captureInterFrameTime: boolean;
  119588. /**
  119589. * Gets the perf counter used for render time capture
  119590. */
  119591. readonly renderTimeCounter: PerfCounter;
  119592. /**
  119593. * Gets the render time capture status
  119594. */
  119595. /**
  119596. * Enable or disable the render time capture
  119597. */
  119598. captureRenderTime: boolean;
  119599. /**
  119600. * Gets the perf counter used for camera render time capture
  119601. */
  119602. readonly cameraRenderTimeCounter: PerfCounter;
  119603. /**
  119604. * Gets the camera render time capture status
  119605. */
  119606. /**
  119607. * Enable or disable the camera render time capture
  119608. */
  119609. captureCameraRenderTime: boolean;
  119610. /**
  119611. * Gets the perf counter used for draw calls
  119612. */
  119613. readonly drawCallsCounter: PerfCounter;
  119614. /**
  119615. * Instantiates a new scene instrumentation.
  119616. * This class can be used to get instrumentation data from a Babylon engine
  119617. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  119618. * @param scene Defines the scene to instrument
  119619. */
  119620. constructor(
  119621. /**
  119622. * Defines the scene to instrument
  119623. */
  119624. scene: Scene);
  119625. /**
  119626. * Dispose and release associated resources.
  119627. */
  119628. dispose(): void;
  119629. }
  119630. }
  119631. declare module BABYLON {
  119632. /** @hidden */
  119633. export var glowMapGenerationPixelShader: {
  119634. name: string;
  119635. shader: string;
  119636. };
  119637. }
  119638. declare module BABYLON {
  119639. /** @hidden */
  119640. export var glowMapGenerationVertexShader: {
  119641. name: string;
  119642. shader: string;
  119643. };
  119644. }
  119645. declare module BABYLON {
  119646. /**
  119647. * Effect layer options. This helps customizing the behaviour
  119648. * of the effect layer.
  119649. */
  119650. export interface IEffectLayerOptions {
  119651. /**
  119652. * Multiplication factor apply to the canvas size to compute the render target size
  119653. * used to generated the objects (the smaller the faster).
  119654. */
  119655. mainTextureRatio: number;
  119656. /**
  119657. * Enforces a fixed size texture to ensure effect stability across devices.
  119658. */
  119659. mainTextureFixedSize?: number;
  119660. /**
  119661. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  119662. */
  119663. alphaBlendingMode: number;
  119664. /**
  119665. * The camera attached to the layer.
  119666. */
  119667. camera: Nullable<Camera>;
  119668. /**
  119669. * The rendering group to draw the layer in.
  119670. */
  119671. renderingGroupId: number;
  119672. }
  119673. /**
  119674. * The effect layer Helps adding post process effect blended with the main pass.
  119675. *
  119676. * This can be for instance use to generate glow or higlight effects on the scene.
  119677. *
  119678. * The effect layer class can not be used directly and is intented to inherited from to be
  119679. * customized per effects.
  119680. */
  119681. export abstract class EffectLayer {
  119682. private _vertexBuffers;
  119683. private _indexBuffer;
  119684. private _cachedDefines;
  119685. private _effectLayerMapGenerationEffect;
  119686. private _effectLayerOptions;
  119687. private _mergeEffect;
  119688. protected _scene: Scene;
  119689. protected _engine: Engine;
  119690. protected _maxSize: number;
  119691. protected _mainTextureDesiredSize: ISize;
  119692. protected _mainTexture: RenderTargetTexture;
  119693. protected _shouldRender: boolean;
  119694. protected _postProcesses: PostProcess[];
  119695. protected _textures: BaseTexture[];
  119696. protected _emissiveTextureAndColor: {
  119697. texture: Nullable<BaseTexture>;
  119698. color: Color4;
  119699. };
  119700. /**
  119701. * The name of the layer
  119702. */
  119703. name: string;
  119704. /**
  119705. * The clear color of the texture used to generate the glow map.
  119706. */
  119707. neutralColor: Color4;
  119708. /**
  119709. * Specifies wether the highlight layer is enabled or not.
  119710. */
  119711. isEnabled: boolean;
  119712. /**
  119713. * Gets the camera attached to the layer.
  119714. */
  119715. readonly camera: Nullable<Camera>;
  119716. /**
  119717. * Gets the rendering group id the layer should render in.
  119718. */
  119719. renderingGroupId: number;
  119720. /**
  119721. * An event triggered when the effect layer has been disposed.
  119722. */
  119723. onDisposeObservable: Observable<EffectLayer>;
  119724. /**
  119725. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  119726. */
  119727. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  119728. /**
  119729. * An event triggered when the generated texture is being merged in the scene.
  119730. */
  119731. onBeforeComposeObservable: Observable<EffectLayer>;
  119732. /**
  119733. * An event triggered when the mesh is rendered into the effect render target.
  119734. */
  119735. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  119736. /**
  119737. * An event triggered after the mesh has been rendered into the effect render target.
  119738. */
  119739. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  119740. /**
  119741. * An event triggered when the generated texture has been merged in the scene.
  119742. */
  119743. onAfterComposeObservable: Observable<EffectLayer>;
  119744. /**
  119745. * An event triggered when the efffect layer changes its size.
  119746. */
  119747. onSizeChangedObservable: Observable<EffectLayer>;
  119748. /** @hidden */
  119749. static _SceneComponentInitialization: (scene: Scene) => void;
  119750. /**
  119751. * Instantiates a new effect Layer and references it in the scene.
  119752. * @param name The name of the layer
  119753. * @param scene The scene to use the layer in
  119754. */
  119755. constructor(
  119756. /** The Friendly of the effect in the scene */
  119757. name: string, scene: Scene);
  119758. /**
  119759. * Get the effect name of the layer.
  119760. * @return The effect name
  119761. */
  119762. abstract getEffectName(): string;
  119763. /**
  119764. * Checks for the readiness of the element composing the layer.
  119765. * @param subMesh the mesh to check for
  119766. * @param useInstances specify wether or not to use instances to render the mesh
  119767. * @return true if ready otherwise, false
  119768. */
  119769. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  119770. /**
  119771. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  119772. * @returns true if the effect requires stencil during the main canvas render pass.
  119773. */
  119774. abstract needStencil(): boolean;
  119775. /**
  119776. * Create the merge effect. This is the shader use to blit the information back
  119777. * to the main canvas at the end of the scene rendering.
  119778. * @returns The effect containing the shader used to merge the effect on the main canvas
  119779. */
  119780. protected abstract _createMergeEffect(): Effect;
  119781. /**
  119782. * Creates the render target textures and post processes used in the effect layer.
  119783. */
  119784. protected abstract _createTextureAndPostProcesses(): void;
  119785. /**
  119786. * Implementation specific of rendering the generating effect on the main canvas.
  119787. * @param effect The effect used to render through
  119788. */
  119789. protected abstract _internalRender(effect: Effect): void;
  119790. /**
  119791. * Sets the required values for both the emissive texture and and the main color.
  119792. */
  119793. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  119794. /**
  119795. * Free any resources and references associated to a mesh.
  119796. * Internal use
  119797. * @param mesh The mesh to free.
  119798. */
  119799. abstract _disposeMesh(mesh: Mesh): void;
  119800. /**
  119801. * Serializes this layer (Glow or Highlight for example)
  119802. * @returns a serialized layer object
  119803. */
  119804. abstract serialize?(): any;
  119805. /**
  119806. * Initializes the effect layer with the required options.
  119807. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  119808. */
  119809. protected _init(options: Partial<IEffectLayerOptions>): void;
  119810. /**
  119811. * Generates the index buffer of the full screen quad blending to the main canvas.
  119812. */
  119813. private _generateIndexBuffer;
  119814. /**
  119815. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  119816. */
  119817. private _generateVertexBuffer;
  119818. /**
  119819. * Sets the main texture desired size which is the closest power of two
  119820. * of the engine canvas size.
  119821. */
  119822. private _setMainTextureSize;
  119823. /**
  119824. * Creates the main texture for the effect layer.
  119825. */
  119826. protected _createMainTexture(): void;
  119827. /**
  119828. * Adds specific effects defines.
  119829. * @param defines The defines to add specifics to.
  119830. */
  119831. protected _addCustomEffectDefines(defines: string[]): void;
  119832. /**
  119833. * Checks for the readiness of the element composing the layer.
  119834. * @param subMesh the mesh to check for
  119835. * @param useInstances specify wether or not to use instances to render the mesh
  119836. * @param emissiveTexture the associated emissive texture used to generate the glow
  119837. * @return true if ready otherwise, false
  119838. */
  119839. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  119840. /**
  119841. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  119842. */
  119843. render(): void;
  119844. /**
  119845. * Determine if a given mesh will be used in the current effect.
  119846. * @param mesh mesh to test
  119847. * @returns true if the mesh will be used
  119848. */
  119849. hasMesh(mesh: AbstractMesh): boolean;
  119850. /**
  119851. * Returns true if the layer contains information to display, otherwise false.
  119852. * @returns true if the glow layer should be rendered
  119853. */
  119854. shouldRender(): boolean;
  119855. /**
  119856. * Returns true if the mesh should render, otherwise false.
  119857. * @param mesh The mesh to render
  119858. * @returns true if it should render otherwise false
  119859. */
  119860. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  119861. /**
  119862. * Returns true if the mesh can be rendered, otherwise false.
  119863. * @param mesh The mesh to render
  119864. * @param material The material used on the mesh
  119865. * @returns true if it can be rendered otherwise false
  119866. */
  119867. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  119868. /**
  119869. * Returns true if the mesh should render, otherwise false.
  119870. * @param mesh The mesh to render
  119871. * @returns true if it should render otherwise false
  119872. */
  119873. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  119874. /**
  119875. * Renders the submesh passed in parameter to the generation map.
  119876. */
  119877. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  119878. /**
  119879. * Defines wether the current material of the mesh should be use to render the effect.
  119880. * @param mesh defines the current mesh to render
  119881. */
  119882. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  119883. /**
  119884. * Rebuild the required buffers.
  119885. * @hidden Internal use only.
  119886. */
  119887. _rebuild(): void;
  119888. /**
  119889. * Dispose only the render target textures and post process.
  119890. */
  119891. private _disposeTextureAndPostProcesses;
  119892. /**
  119893. * Dispose the highlight layer and free resources.
  119894. */
  119895. dispose(): void;
  119896. /**
  119897. * Gets the class name of the effect layer
  119898. * @returns the string with the class name of the effect layer
  119899. */
  119900. getClassName(): string;
  119901. /**
  119902. * Creates an effect layer from parsed effect layer data
  119903. * @param parsedEffectLayer defines effect layer data
  119904. * @param scene defines the current scene
  119905. * @param rootUrl defines the root URL containing the effect layer information
  119906. * @returns a parsed effect Layer
  119907. */
  119908. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  119909. }
  119910. }
  119911. declare module BABYLON {
  119912. interface AbstractScene {
  119913. /**
  119914. * The list of effect layers (highlights/glow) added to the scene
  119915. * @see http://doc.babylonjs.com/how_to/highlight_layer
  119916. * @see http://doc.babylonjs.com/how_to/glow_layer
  119917. */
  119918. effectLayers: Array<EffectLayer>;
  119919. /**
  119920. * Removes the given effect layer from this scene.
  119921. * @param toRemove defines the effect layer to remove
  119922. * @returns the index of the removed effect layer
  119923. */
  119924. removeEffectLayer(toRemove: EffectLayer): number;
  119925. /**
  119926. * Adds the given effect layer to this scene
  119927. * @param newEffectLayer defines the effect layer to add
  119928. */
  119929. addEffectLayer(newEffectLayer: EffectLayer): void;
  119930. }
  119931. /**
  119932. * Defines the layer scene component responsible to manage any effect layers
  119933. * in a given scene.
  119934. */
  119935. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  119936. /**
  119937. * The component name helpfull to identify the component in the list of scene components.
  119938. */
  119939. readonly name: string;
  119940. /**
  119941. * The scene the component belongs to.
  119942. */
  119943. scene: Scene;
  119944. private _engine;
  119945. private _renderEffects;
  119946. private _needStencil;
  119947. private _previousStencilState;
  119948. /**
  119949. * Creates a new instance of the component for the given scene
  119950. * @param scene Defines the scene to register the component in
  119951. */
  119952. constructor(scene: Scene);
  119953. /**
  119954. * Registers the component in a given scene
  119955. */
  119956. register(): void;
  119957. /**
  119958. * Rebuilds the elements related to this component in case of
  119959. * context lost for instance.
  119960. */
  119961. rebuild(): void;
  119962. /**
  119963. * Serializes the component data to the specified json object
  119964. * @param serializationObject The object to serialize to
  119965. */
  119966. serialize(serializationObject: any): void;
  119967. /**
  119968. * Adds all the elements from the container to the scene
  119969. * @param container the container holding the elements
  119970. */
  119971. addFromContainer(container: AbstractScene): void;
  119972. /**
  119973. * Removes all the elements in the container from the scene
  119974. * @param container contains the elements to remove
  119975. * @param dispose if the removed element should be disposed (default: false)
  119976. */
  119977. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  119978. /**
  119979. * Disposes the component and the associated ressources.
  119980. */
  119981. dispose(): void;
  119982. private _isReadyForMesh;
  119983. private _renderMainTexture;
  119984. private _setStencil;
  119985. private _setStencilBack;
  119986. private _draw;
  119987. private _drawCamera;
  119988. private _drawRenderingGroup;
  119989. }
  119990. }
  119991. declare module BABYLON {
  119992. /** @hidden */
  119993. export var glowMapMergePixelShader: {
  119994. name: string;
  119995. shader: string;
  119996. };
  119997. }
  119998. declare module BABYLON {
  119999. /** @hidden */
  120000. export var glowMapMergeVertexShader: {
  120001. name: string;
  120002. shader: string;
  120003. };
  120004. }
  120005. declare module BABYLON {
  120006. interface AbstractScene {
  120007. /**
  120008. * Return a the first highlight layer of the scene with a given name.
  120009. * @param name The name of the highlight layer to look for.
  120010. * @return The highlight layer if found otherwise null.
  120011. */
  120012. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  120013. }
  120014. /**
  120015. * Glow layer options. This helps customizing the behaviour
  120016. * of the glow layer.
  120017. */
  120018. export interface IGlowLayerOptions {
  120019. /**
  120020. * Multiplication factor apply to the canvas size to compute the render target size
  120021. * used to generated the glowing objects (the smaller the faster).
  120022. */
  120023. mainTextureRatio: number;
  120024. /**
  120025. * Enforces a fixed size texture to ensure resize independant blur.
  120026. */
  120027. mainTextureFixedSize?: number;
  120028. /**
  120029. * How big is the kernel of the blur texture.
  120030. */
  120031. blurKernelSize: number;
  120032. /**
  120033. * The camera attached to the layer.
  120034. */
  120035. camera: Nullable<Camera>;
  120036. /**
  120037. * Enable MSAA by chosing the number of samples.
  120038. */
  120039. mainTextureSamples?: number;
  120040. /**
  120041. * The rendering group to draw the layer in.
  120042. */
  120043. renderingGroupId: number;
  120044. }
  120045. /**
  120046. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  120047. *
  120048. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  120049. *
  120050. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  120051. */
  120052. export class GlowLayer extends EffectLayer {
  120053. /**
  120054. * Effect Name of the layer.
  120055. */
  120056. static readonly EffectName: string;
  120057. /**
  120058. * The default blur kernel size used for the glow.
  120059. */
  120060. static DefaultBlurKernelSize: number;
  120061. /**
  120062. * The default texture size ratio used for the glow.
  120063. */
  120064. static DefaultTextureRatio: number;
  120065. /**
  120066. * Sets the kernel size of the blur.
  120067. */
  120068. /**
  120069. * Gets the kernel size of the blur.
  120070. */
  120071. blurKernelSize: number;
  120072. /**
  120073. * Sets the glow intensity.
  120074. */
  120075. /**
  120076. * Gets the glow intensity.
  120077. */
  120078. intensity: number;
  120079. private _options;
  120080. private _intensity;
  120081. private _horizontalBlurPostprocess1;
  120082. private _verticalBlurPostprocess1;
  120083. private _horizontalBlurPostprocess2;
  120084. private _verticalBlurPostprocess2;
  120085. private _blurTexture1;
  120086. private _blurTexture2;
  120087. private _postProcesses1;
  120088. private _postProcesses2;
  120089. private _includedOnlyMeshes;
  120090. private _excludedMeshes;
  120091. private _meshesUsingTheirOwnMaterials;
  120092. /**
  120093. * Callback used to let the user override the color selection on a per mesh basis
  120094. */
  120095. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  120096. /**
  120097. * Callback used to let the user override the texture selection on a per mesh basis
  120098. */
  120099. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  120100. /**
  120101. * Instantiates a new glow Layer and references it to the scene.
  120102. * @param name The name of the layer
  120103. * @param scene The scene to use the layer in
  120104. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  120105. */
  120106. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  120107. /**
  120108. * Get the effect name of the layer.
  120109. * @return The effect name
  120110. */
  120111. getEffectName(): string;
  120112. /**
  120113. * Create the merge effect. This is the shader use to blit the information back
  120114. * to the main canvas at the end of the scene rendering.
  120115. */
  120116. protected _createMergeEffect(): Effect;
  120117. /**
  120118. * Creates the render target textures and post processes used in the glow layer.
  120119. */
  120120. protected _createTextureAndPostProcesses(): void;
  120121. /**
  120122. * Checks for the readiness of the element composing the layer.
  120123. * @param subMesh the mesh to check for
  120124. * @param useInstances specify wether or not to use instances to render the mesh
  120125. * @param emissiveTexture the associated emissive texture used to generate the glow
  120126. * @return true if ready otherwise, false
  120127. */
  120128. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  120129. /**
  120130. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  120131. */
  120132. needStencil(): boolean;
  120133. /**
  120134. * Returns true if the mesh can be rendered, otherwise false.
  120135. * @param mesh The mesh to render
  120136. * @param material The material used on the mesh
  120137. * @returns true if it can be rendered otherwise false
  120138. */
  120139. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  120140. /**
  120141. * Implementation specific of rendering the generating effect on the main canvas.
  120142. * @param effect The effect used to render through
  120143. */
  120144. protected _internalRender(effect: Effect): void;
  120145. /**
  120146. * Sets the required values for both the emissive texture and and the main color.
  120147. */
  120148. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  120149. /**
  120150. * Returns true if the mesh should render, otherwise false.
  120151. * @param mesh The mesh to render
  120152. * @returns true if it should render otherwise false
  120153. */
  120154. protected _shouldRenderMesh(mesh: Mesh): boolean;
  120155. /**
  120156. * Adds specific effects defines.
  120157. * @param defines The defines to add specifics to.
  120158. */
  120159. protected _addCustomEffectDefines(defines: string[]): void;
  120160. /**
  120161. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  120162. * @param mesh The mesh to exclude from the glow layer
  120163. */
  120164. addExcludedMesh(mesh: Mesh): void;
  120165. /**
  120166. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  120167. * @param mesh The mesh to remove
  120168. */
  120169. removeExcludedMesh(mesh: Mesh): void;
  120170. /**
  120171. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  120172. * @param mesh The mesh to include in the glow layer
  120173. */
  120174. addIncludedOnlyMesh(mesh: Mesh): void;
  120175. /**
  120176. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  120177. * @param mesh The mesh to remove
  120178. */
  120179. removeIncludedOnlyMesh(mesh: Mesh): void;
  120180. /**
  120181. * Determine if a given mesh will be used in the glow layer
  120182. * @param mesh The mesh to test
  120183. * @returns true if the mesh will be highlighted by the current glow layer
  120184. */
  120185. hasMesh(mesh: AbstractMesh): boolean;
  120186. /**
  120187. * Defines wether the current material of the mesh should be use to render the effect.
  120188. * @param mesh defines the current mesh to render
  120189. */
  120190. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  120191. /**
  120192. * Add a mesh to be rendered through its own material and not with emissive only.
  120193. * @param mesh The mesh for which we need to use its material
  120194. */
  120195. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  120196. /**
  120197. * Remove a mesh from being rendered through its own material and not with emissive only.
  120198. * @param mesh The mesh for which we need to not use its material
  120199. */
  120200. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  120201. /**
  120202. * Free any resources and references associated to a mesh.
  120203. * Internal use
  120204. * @param mesh The mesh to free.
  120205. * @hidden
  120206. */
  120207. _disposeMesh(mesh: Mesh): void;
  120208. /**
  120209. * Gets the class name of the effect layer
  120210. * @returns the string with the class name of the effect layer
  120211. */
  120212. getClassName(): string;
  120213. /**
  120214. * Serializes this glow layer
  120215. * @returns a serialized glow layer object
  120216. */
  120217. serialize(): any;
  120218. /**
  120219. * Creates a Glow Layer from parsed glow layer data
  120220. * @param parsedGlowLayer defines glow layer data
  120221. * @param scene defines the current scene
  120222. * @param rootUrl defines the root URL containing the glow layer information
  120223. * @returns a parsed Glow Layer
  120224. */
  120225. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  120226. }
  120227. }
  120228. declare module BABYLON {
  120229. /** @hidden */
  120230. export var glowBlurPostProcessPixelShader: {
  120231. name: string;
  120232. shader: string;
  120233. };
  120234. }
  120235. declare module BABYLON {
  120236. interface AbstractScene {
  120237. /**
  120238. * Return a the first highlight layer of the scene with a given name.
  120239. * @param name The name of the highlight layer to look for.
  120240. * @return The highlight layer if found otherwise null.
  120241. */
  120242. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  120243. }
  120244. /**
  120245. * Highlight layer options. This helps customizing the behaviour
  120246. * of the highlight layer.
  120247. */
  120248. export interface IHighlightLayerOptions {
  120249. /**
  120250. * Multiplication factor apply to the canvas size to compute the render target size
  120251. * used to generated the glowing objects (the smaller the faster).
  120252. */
  120253. mainTextureRatio: number;
  120254. /**
  120255. * Enforces a fixed size texture to ensure resize independant blur.
  120256. */
  120257. mainTextureFixedSize?: number;
  120258. /**
  120259. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  120260. * of the picture to blur (the smaller the faster).
  120261. */
  120262. blurTextureSizeRatio: number;
  120263. /**
  120264. * How big in texel of the blur texture is the vertical blur.
  120265. */
  120266. blurVerticalSize: number;
  120267. /**
  120268. * How big in texel of the blur texture is the horizontal blur.
  120269. */
  120270. blurHorizontalSize: number;
  120271. /**
  120272. * Alpha blending mode used to apply the blur. Default is combine.
  120273. */
  120274. alphaBlendingMode: number;
  120275. /**
  120276. * The camera attached to the layer.
  120277. */
  120278. camera: Nullable<Camera>;
  120279. /**
  120280. * Should we display highlight as a solid stroke?
  120281. */
  120282. isStroke?: boolean;
  120283. /**
  120284. * The rendering group to draw the layer in.
  120285. */
  120286. renderingGroupId: number;
  120287. }
  120288. /**
  120289. * The highlight layer Helps adding a glow effect around a mesh.
  120290. *
  120291. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  120292. * glowy meshes to your scene.
  120293. *
  120294. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  120295. */
  120296. export class HighlightLayer extends EffectLayer {
  120297. name: string;
  120298. /**
  120299. * Effect Name of the highlight layer.
  120300. */
  120301. static readonly EffectName: string;
  120302. /**
  120303. * The neutral color used during the preparation of the glow effect.
  120304. * This is black by default as the blend operation is a blend operation.
  120305. */
  120306. static NeutralColor: Color4;
  120307. /**
  120308. * Stencil value used for glowing meshes.
  120309. */
  120310. static GlowingMeshStencilReference: number;
  120311. /**
  120312. * Stencil value used for the other meshes in the scene.
  120313. */
  120314. static NormalMeshStencilReference: number;
  120315. /**
  120316. * Specifies whether or not the inner glow is ACTIVE in the layer.
  120317. */
  120318. innerGlow: boolean;
  120319. /**
  120320. * Specifies whether or not the outer glow is ACTIVE in the layer.
  120321. */
  120322. outerGlow: boolean;
  120323. /**
  120324. * Specifies the horizontal size of the blur.
  120325. */
  120326. /**
  120327. * Gets the horizontal size of the blur.
  120328. */
  120329. blurHorizontalSize: number;
  120330. /**
  120331. * Specifies the vertical size of the blur.
  120332. */
  120333. /**
  120334. * Gets the vertical size of the blur.
  120335. */
  120336. blurVerticalSize: number;
  120337. /**
  120338. * An event triggered when the highlight layer is being blurred.
  120339. */
  120340. onBeforeBlurObservable: Observable<HighlightLayer>;
  120341. /**
  120342. * An event triggered when the highlight layer has been blurred.
  120343. */
  120344. onAfterBlurObservable: Observable<HighlightLayer>;
  120345. private _instanceGlowingMeshStencilReference;
  120346. private _options;
  120347. private _downSamplePostprocess;
  120348. private _horizontalBlurPostprocess;
  120349. private _verticalBlurPostprocess;
  120350. private _blurTexture;
  120351. private _meshes;
  120352. private _excludedMeshes;
  120353. /**
  120354. * Instantiates a new highlight Layer and references it to the scene..
  120355. * @param name The name of the layer
  120356. * @param scene The scene to use the layer in
  120357. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  120358. */
  120359. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  120360. /**
  120361. * Get the effect name of the layer.
  120362. * @return The effect name
  120363. */
  120364. getEffectName(): string;
  120365. /**
  120366. * Create the merge effect. This is the shader use to blit the information back
  120367. * to the main canvas at the end of the scene rendering.
  120368. */
  120369. protected _createMergeEffect(): Effect;
  120370. /**
  120371. * Creates the render target textures and post processes used in the highlight layer.
  120372. */
  120373. protected _createTextureAndPostProcesses(): void;
  120374. /**
  120375. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  120376. */
  120377. needStencil(): boolean;
  120378. /**
  120379. * Checks for the readiness of the element composing the layer.
  120380. * @param subMesh the mesh to check for
  120381. * @param useInstances specify wether or not to use instances to render the mesh
  120382. * @param emissiveTexture the associated emissive texture used to generate the glow
  120383. * @return true if ready otherwise, false
  120384. */
  120385. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  120386. /**
  120387. * Implementation specific of rendering the generating effect on the main canvas.
  120388. * @param effect The effect used to render through
  120389. */
  120390. protected _internalRender(effect: Effect): void;
  120391. /**
  120392. * Returns true if the layer contains information to display, otherwise false.
  120393. */
  120394. shouldRender(): boolean;
  120395. /**
  120396. * Returns true if the mesh should render, otherwise false.
  120397. * @param mesh The mesh to render
  120398. * @returns true if it should render otherwise false
  120399. */
  120400. protected _shouldRenderMesh(mesh: Mesh): boolean;
  120401. /**
  120402. * Sets the required values for both the emissive texture and and the main color.
  120403. */
  120404. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  120405. /**
  120406. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  120407. * @param mesh The mesh to exclude from the highlight layer
  120408. */
  120409. addExcludedMesh(mesh: Mesh): void;
  120410. /**
  120411. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  120412. * @param mesh The mesh to highlight
  120413. */
  120414. removeExcludedMesh(mesh: Mesh): void;
  120415. /**
  120416. * Determine if a given mesh will be highlighted by the current HighlightLayer
  120417. * @param mesh mesh to test
  120418. * @returns true if the mesh will be highlighted by the current HighlightLayer
  120419. */
  120420. hasMesh(mesh: AbstractMesh): boolean;
  120421. /**
  120422. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  120423. * @param mesh The mesh to highlight
  120424. * @param color The color of the highlight
  120425. * @param glowEmissiveOnly Extract the glow from the emissive texture
  120426. */
  120427. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  120428. /**
  120429. * Remove a mesh from the highlight layer in order to make it stop glowing.
  120430. * @param mesh The mesh to highlight
  120431. */
  120432. removeMesh(mesh: Mesh): void;
  120433. /**
  120434. * Force the stencil to the normal expected value for none glowing parts
  120435. */
  120436. private _defaultStencilReference;
  120437. /**
  120438. * Free any resources and references associated to a mesh.
  120439. * Internal use
  120440. * @param mesh The mesh to free.
  120441. * @hidden
  120442. */
  120443. _disposeMesh(mesh: Mesh): void;
  120444. /**
  120445. * Dispose the highlight layer and free resources.
  120446. */
  120447. dispose(): void;
  120448. /**
  120449. * Gets the class name of the effect layer
  120450. * @returns the string with the class name of the effect layer
  120451. */
  120452. getClassName(): string;
  120453. /**
  120454. * Serializes this Highlight layer
  120455. * @returns a serialized Highlight layer object
  120456. */
  120457. serialize(): any;
  120458. /**
  120459. * Creates a Highlight layer from parsed Highlight layer data
  120460. * @param parsedHightlightLayer defines the Highlight layer data
  120461. * @param scene defines the current scene
  120462. * @param rootUrl defines the root URL containing the Highlight layer information
  120463. * @returns a parsed Highlight layer
  120464. */
  120465. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  120466. }
  120467. }
  120468. declare module BABYLON {
  120469. interface AbstractScene {
  120470. /**
  120471. * The list of layers (background and foreground) of the scene
  120472. */
  120473. layers: Array<Layer>;
  120474. }
  120475. /**
  120476. * Defines the layer scene component responsible to manage any layers
  120477. * in a given scene.
  120478. */
  120479. export class LayerSceneComponent implements ISceneComponent {
  120480. /**
  120481. * The component name helpfull to identify the component in the list of scene components.
  120482. */
  120483. readonly name: string;
  120484. /**
  120485. * The scene the component belongs to.
  120486. */
  120487. scene: Scene;
  120488. private _engine;
  120489. /**
  120490. * Creates a new instance of the component for the given scene
  120491. * @param scene Defines the scene to register the component in
  120492. */
  120493. constructor(scene: Scene);
  120494. /**
  120495. * Registers the component in a given scene
  120496. */
  120497. register(): void;
  120498. /**
  120499. * Rebuilds the elements related to this component in case of
  120500. * context lost for instance.
  120501. */
  120502. rebuild(): void;
  120503. /**
  120504. * Disposes the component and the associated ressources.
  120505. */
  120506. dispose(): void;
  120507. private _draw;
  120508. private _drawCameraPredicate;
  120509. private _drawCameraBackground;
  120510. private _drawCameraForeground;
  120511. private _drawRenderTargetPredicate;
  120512. private _drawRenderTargetBackground;
  120513. private _drawRenderTargetForeground;
  120514. /**
  120515. * Adds all the elements from the container to the scene
  120516. * @param container the container holding the elements
  120517. */
  120518. addFromContainer(container: AbstractScene): void;
  120519. /**
  120520. * Removes all the elements in the container from the scene
  120521. * @param container contains the elements to remove
  120522. * @param dispose if the removed element should be disposed (default: false)
  120523. */
  120524. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  120525. }
  120526. }
  120527. declare module BABYLON {
  120528. /** @hidden */
  120529. export var layerPixelShader: {
  120530. name: string;
  120531. shader: string;
  120532. };
  120533. }
  120534. declare module BABYLON {
  120535. /** @hidden */
  120536. export var layerVertexShader: {
  120537. name: string;
  120538. shader: string;
  120539. };
  120540. }
  120541. declare module BABYLON {
  120542. /**
  120543. * This represents a full screen 2d layer.
  120544. * This can be useful to display a picture in the background of your scene for instance.
  120545. * @see https://www.babylonjs-playground.com/#08A2BS#1
  120546. */
  120547. export class Layer {
  120548. /**
  120549. * Define the name of the layer.
  120550. */
  120551. name: string;
  120552. /**
  120553. * Define the texture the layer should display.
  120554. */
  120555. texture: Nullable<Texture>;
  120556. /**
  120557. * Is the layer in background or foreground.
  120558. */
  120559. isBackground: boolean;
  120560. /**
  120561. * Define the color of the layer (instead of texture).
  120562. */
  120563. color: Color4;
  120564. /**
  120565. * Define the scale of the layer in order to zoom in out of the texture.
  120566. */
  120567. scale: Vector2;
  120568. /**
  120569. * Define an offset for the layer in order to shift the texture.
  120570. */
  120571. offset: Vector2;
  120572. /**
  120573. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  120574. */
  120575. alphaBlendingMode: number;
  120576. /**
  120577. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  120578. * Alpha test will not mix with the background color in case of transparency.
  120579. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  120580. */
  120581. alphaTest: boolean;
  120582. /**
  120583. * Define a mask to restrict the layer to only some of the scene cameras.
  120584. */
  120585. layerMask: number;
  120586. /**
  120587. * Define the list of render target the layer is visible into.
  120588. */
  120589. renderTargetTextures: RenderTargetTexture[];
  120590. /**
  120591. * Define if the layer is only used in renderTarget or if it also
  120592. * renders in the main frame buffer of the canvas.
  120593. */
  120594. renderOnlyInRenderTargetTextures: boolean;
  120595. private _scene;
  120596. private _vertexBuffers;
  120597. private _indexBuffer;
  120598. private _effect;
  120599. private _previousDefines;
  120600. /**
  120601. * An event triggered when the layer is disposed.
  120602. */
  120603. onDisposeObservable: Observable<Layer>;
  120604. private _onDisposeObserver;
  120605. /**
  120606. * Back compatibility with callback before the onDisposeObservable existed.
  120607. * The set callback will be triggered when the layer has been disposed.
  120608. */
  120609. onDispose: () => void;
  120610. /**
  120611. * An event triggered before rendering the scene
  120612. */
  120613. onBeforeRenderObservable: Observable<Layer>;
  120614. private _onBeforeRenderObserver;
  120615. /**
  120616. * Back compatibility with callback before the onBeforeRenderObservable existed.
  120617. * The set callback will be triggered just before rendering the layer.
  120618. */
  120619. onBeforeRender: () => void;
  120620. /**
  120621. * An event triggered after rendering the scene
  120622. */
  120623. onAfterRenderObservable: Observable<Layer>;
  120624. private _onAfterRenderObserver;
  120625. /**
  120626. * Back compatibility with callback before the onAfterRenderObservable existed.
  120627. * The set callback will be triggered just after rendering the layer.
  120628. */
  120629. onAfterRender: () => void;
  120630. /**
  120631. * Instantiates a new layer.
  120632. * This represents a full screen 2d layer.
  120633. * This can be useful to display a picture in the background of your scene for instance.
  120634. * @see https://www.babylonjs-playground.com/#08A2BS#1
  120635. * @param name Define the name of the layer in the scene
  120636. * @param imgUrl Define the url of the texture to display in the layer
  120637. * @param scene Define the scene the layer belongs to
  120638. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  120639. * @param color Defines a color for the layer
  120640. */
  120641. constructor(
  120642. /**
  120643. * Define the name of the layer.
  120644. */
  120645. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  120646. private _createIndexBuffer;
  120647. /** @hidden */
  120648. _rebuild(): void;
  120649. /**
  120650. * Renders the layer in the scene.
  120651. */
  120652. render(): void;
  120653. /**
  120654. * Disposes and releases the associated ressources.
  120655. */
  120656. dispose(): void;
  120657. }
  120658. }
  120659. declare module BABYLON {
  120660. /** @hidden */
  120661. export var lensFlarePixelShader: {
  120662. name: string;
  120663. shader: string;
  120664. };
  120665. }
  120666. declare module BABYLON {
  120667. /** @hidden */
  120668. export var lensFlareVertexShader: {
  120669. name: string;
  120670. shader: string;
  120671. };
  120672. }
  120673. declare module BABYLON {
  120674. /**
  120675. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  120676. * It is usually composed of several `lensFlare`.
  120677. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  120678. */
  120679. export class LensFlareSystem {
  120680. /**
  120681. * Define the name of the lens flare system
  120682. */
  120683. name: string;
  120684. /**
  120685. * List of lens flares used in this system.
  120686. */
  120687. lensFlares: LensFlare[];
  120688. /**
  120689. * Define a limit from the border the lens flare can be visible.
  120690. */
  120691. borderLimit: number;
  120692. /**
  120693. * Define a viewport border we do not want to see the lens flare in.
  120694. */
  120695. viewportBorder: number;
  120696. /**
  120697. * Define a predicate which could limit the list of meshes able to occlude the effect.
  120698. */
  120699. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  120700. /**
  120701. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  120702. */
  120703. layerMask: number;
  120704. /**
  120705. * Define the id of the lens flare system in the scene.
  120706. * (equal to name by default)
  120707. */
  120708. id: string;
  120709. private _scene;
  120710. private _emitter;
  120711. private _vertexBuffers;
  120712. private _indexBuffer;
  120713. private _effect;
  120714. private _positionX;
  120715. private _positionY;
  120716. private _isEnabled;
  120717. /** @hidden */
  120718. static _SceneComponentInitialization: (scene: Scene) => void;
  120719. /**
  120720. * Instantiates a lens flare system.
  120721. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  120722. * It is usually composed of several `lensFlare`.
  120723. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  120724. * @param name Define the name of the lens flare system in the scene
  120725. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  120726. * @param scene Define the scene the lens flare system belongs to
  120727. */
  120728. constructor(
  120729. /**
  120730. * Define the name of the lens flare system
  120731. */
  120732. name: string, emitter: any, scene: Scene);
  120733. /**
  120734. * Define if the lens flare system is enabled.
  120735. */
  120736. isEnabled: boolean;
  120737. /**
  120738. * Get the scene the effects belongs to.
  120739. * @returns the scene holding the lens flare system
  120740. */
  120741. getScene(): Scene;
  120742. /**
  120743. * Get the emitter of the lens flare system.
  120744. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  120745. * @returns the emitter of the lens flare system
  120746. */
  120747. getEmitter(): any;
  120748. /**
  120749. * Set the emitter of the lens flare system.
  120750. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  120751. * @param newEmitter Define the new emitter of the system
  120752. */
  120753. setEmitter(newEmitter: any): void;
  120754. /**
  120755. * Get the lens flare system emitter position.
  120756. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  120757. * @returns the position
  120758. */
  120759. getEmitterPosition(): Vector3;
  120760. /**
  120761. * @hidden
  120762. */
  120763. computeEffectivePosition(globalViewport: Viewport): boolean;
  120764. /** @hidden */
  120765. _isVisible(): boolean;
  120766. /**
  120767. * @hidden
  120768. */
  120769. render(): boolean;
  120770. /**
  120771. * Dispose and release the lens flare with its associated resources.
  120772. */
  120773. dispose(): void;
  120774. /**
  120775. * Parse a lens flare system from a JSON repressentation
  120776. * @param parsedLensFlareSystem Define the JSON to parse
  120777. * @param scene Define the scene the parsed system should be instantiated in
  120778. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  120779. * @returns the parsed system
  120780. */
  120781. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  120782. /**
  120783. * Serialize the current Lens Flare System into a JSON representation.
  120784. * @returns the serialized JSON
  120785. */
  120786. serialize(): any;
  120787. }
  120788. }
  120789. declare module BABYLON {
  120790. /**
  120791. * This represents one of the lens effect in a `lensFlareSystem`.
  120792. * It controls one of the indiviual texture used in the effect.
  120793. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  120794. */
  120795. export class LensFlare {
  120796. /**
  120797. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  120798. */
  120799. size: number;
  120800. /**
  120801. * 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.
  120802. */
  120803. position: number;
  120804. /**
  120805. * Define the lens color.
  120806. */
  120807. color: Color3;
  120808. /**
  120809. * Define the lens texture.
  120810. */
  120811. texture: Nullable<Texture>;
  120812. /**
  120813. * Define the alpha mode to render this particular lens.
  120814. */
  120815. alphaMode: number;
  120816. private _system;
  120817. /**
  120818. * Creates a new Lens Flare.
  120819. * This represents one of the lens effect in a `lensFlareSystem`.
  120820. * It controls one of the indiviual texture used in the effect.
  120821. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  120822. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  120823. * @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.
  120824. * @param color Define the lens color
  120825. * @param imgUrl Define the lens texture url
  120826. * @param system Define the `lensFlareSystem` this flare is part of
  120827. * @returns The newly created Lens Flare
  120828. */
  120829. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  120830. /**
  120831. * Instantiates a new Lens Flare.
  120832. * This represents one of the lens effect in a `lensFlareSystem`.
  120833. * It controls one of the indiviual texture used in the effect.
  120834. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  120835. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  120836. * @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.
  120837. * @param color Define the lens color
  120838. * @param imgUrl Define the lens texture url
  120839. * @param system Define the `lensFlareSystem` this flare is part of
  120840. */
  120841. constructor(
  120842. /**
  120843. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  120844. */
  120845. size: number,
  120846. /**
  120847. * 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.
  120848. */
  120849. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  120850. /**
  120851. * Dispose and release the lens flare with its associated resources.
  120852. */
  120853. dispose(): void;
  120854. }
  120855. }
  120856. declare module BABYLON {
  120857. interface AbstractScene {
  120858. /**
  120859. * The list of lens flare system added to the scene
  120860. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  120861. */
  120862. lensFlareSystems: Array<LensFlareSystem>;
  120863. /**
  120864. * Removes the given lens flare system from this scene.
  120865. * @param toRemove The lens flare system to remove
  120866. * @returns The index of the removed lens flare system
  120867. */
  120868. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  120869. /**
  120870. * Adds the given lens flare system to this scene
  120871. * @param newLensFlareSystem The lens flare system to add
  120872. */
  120873. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  120874. /**
  120875. * Gets a lens flare system using its name
  120876. * @param name defines the name to look for
  120877. * @returns the lens flare system or null if not found
  120878. */
  120879. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  120880. /**
  120881. * Gets a lens flare system using its id
  120882. * @param id defines the id to look for
  120883. * @returns the lens flare system or null if not found
  120884. */
  120885. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  120886. }
  120887. /**
  120888. * Defines the lens flare scene component responsible to manage any lens flares
  120889. * in a given scene.
  120890. */
  120891. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  120892. /**
  120893. * The component name helpfull to identify the component in the list of scene components.
  120894. */
  120895. readonly name: string;
  120896. /**
  120897. * The scene the component belongs to.
  120898. */
  120899. scene: Scene;
  120900. /**
  120901. * Creates a new instance of the component for the given scene
  120902. * @param scene Defines the scene to register the component in
  120903. */
  120904. constructor(scene: Scene);
  120905. /**
  120906. * Registers the component in a given scene
  120907. */
  120908. register(): void;
  120909. /**
  120910. * Rebuilds the elements related to this component in case of
  120911. * context lost for instance.
  120912. */
  120913. rebuild(): void;
  120914. /**
  120915. * Adds all the elements from the container to the scene
  120916. * @param container the container holding the elements
  120917. */
  120918. addFromContainer(container: AbstractScene): void;
  120919. /**
  120920. * Removes all the elements in the container from the scene
  120921. * @param container contains the elements to remove
  120922. * @param dispose if the removed element should be disposed (default: false)
  120923. */
  120924. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  120925. /**
  120926. * Serializes the component data to the specified json object
  120927. * @param serializationObject The object to serialize to
  120928. */
  120929. serialize(serializationObject: any): void;
  120930. /**
  120931. * Disposes the component and the associated ressources.
  120932. */
  120933. dispose(): void;
  120934. private _draw;
  120935. }
  120936. }
  120937. declare module BABYLON {
  120938. /**
  120939. * Defines the shadow generator component responsible to manage any shadow generators
  120940. * in a given scene.
  120941. */
  120942. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  120943. /**
  120944. * The component name helpfull to identify the component in the list of scene components.
  120945. */
  120946. readonly name: string;
  120947. /**
  120948. * The scene the component belongs to.
  120949. */
  120950. scene: Scene;
  120951. /**
  120952. * Creates a new instance of the component for the given scene
  120953. * @param scene Defines the scene to register the component in
  120954. */
  120955. constructor(scene: Scene);
  120956. /**
  120957. * Registers the component in a given scene
  120958. */
  120959. register(): void;
  120960. /**
  120961. * Rebuilds the elements related to this component in case of
  120962. * context lost for instance.
  120963. */
  120964. rebuild(): void;
  120965. /**
  120966. * Serializes the component data to the specified json object
  120967. * @param serializationObject The object to serialize to
  120968. */
  120969. serialize(serializationObject: any): void;
  120970. /**
  120971. * Adds all the elements from the container to the scene
  120972. * @param container the container holding the elements
  120973. */
  120974. addFromContainer(container: AbstractScene): void;
  120975. /**
  120976. * Removes all the elements in the container from the scene
  120977. * @param container contains the elements to remove
  120978. * @param dispose if the removed element should be disposed (default: false)
  120979. */
  120980. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  120981. /**
  120982. * Rebuilds the elements related to this component in case of
  120983. * context lost for instance.
  120984. */
  120985. dispose(): void;
  120986. private _gatherRenderTargets;
  120987. }
  120988. }
  120989. declare module BABYLON {
  120990. /**
  120991. * A point light is a light defined by an unique point in world space.
  120992. * The light is emitted in every direction from this point.
  120993. * A good example of a point light is a standard light bulb.
  120994. * Documentation: https://doc.babylonjs.com/babylon101/lights
  120995. */
  120996. export class PointLight extends ShadowLight {
  120997. private _shadowAngle;
  120998. /**
  120999. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  121000. * This specifies what angle the shadow will use to be created.
  121001. *
  121002. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  121003. */
  121004. /**
  121005. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  121006. * This specifies what angle the shadow will use to be created.
  121007. *
  121008. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  121009. */
  121010. shadowAngle: number;
  121011. /**
  121012. * Gets the direction if it has been set.
  121013. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  121014. */
  121015. /**
  121016. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  121017. */
  121018. direction: Vector3;
  121019. /**
  121020. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  121021. * A PointLight emits the light in every direction.
  121022. * It can cast shadows.
  121023. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  121024. * ```javascript
  121025. * var pointLight = new PointLight("pl", camera.position, scene);
  121026. * ```
  121027. * Documentation : https://doc.babylonjs.com/babylon101/lights
  121028. * @param name The light friendly name
  121029. * @param position The position of the point light in the scene
  121030. * @param scene The scene the lights belongs to
  121031. */
  121032. constructor(name: string, position: Vector3, scene: Scene);
  121033. /**
  121034. * Returns the string "PointLight"
  121035. * @returns the class name
  121036. */
  121037. getClassName(): string;
  121038. /**
  121039. * Returns the integer 0.
  121040. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  121041. */
  121042. getTypeID(): number;
  121043. /**
  121044. * Specifies wether or not the shadowmap should be a cube texture.
  121045. * @returns true if the shadowmap needs to be a cube texture.
  121046. */
  121047. needCube(): boolean;
  121048. /**
  121049. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  121050. * @param faceIndex The index of the face we are computed the direction to generate shadow
  121051. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  121052. */
  121053. getShadowDirection(faceIndex?: number): Vector3;
  121054. /**
  121055. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  121056. * - fov = PI / 2
  121057. * - aspect ratio : 1.0
  121058. * - z-near and far equal to the active camera minZ and maxZ.
  121059. * Returns the PointLight.
  121060. */
  121061. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  121062. protected _buildUniformLayout(): void;
  121063. /**
  121064. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  121065. * @param effect The effect to update
  121066. * @param lightIndex The index of the light in the effect to update
  121067. * @returns The point light
  121068. */
  121069. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  121070. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  121071. /**
  121072. * Prepares the list of defines specific to the light type.
  121073. * @param defines the list of defines
  121074. * @param lightIndex defines the index of the light for the effect
  121075. */
  121076. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  121077. }
  121078. }
  121079. declare module BABYLON {
  121080. /**
  121081. * Header information of HDR texture files.
  121082. */
  121083. export interface HDRInfo {
  121084. /**
  121085. * The height of the texture in pixels.
  121086. */
  121087. height: number;
  121088. /**
  121089. * The width of the texture in pixels.
  121090. */
  121091. width: number;
  121092. /**
  121093. * The index of the beginning of the data in the binary file.
  121094. */
  121095. dataPosition: number;
  121096. }
  121097. /**
  121098. * This groups tools to convert HDR texture to native colors array.
  121099. */
  121100. export class HDRTools {
  121101. private static Ldexp;
  121102. private static Rgbe2float;
  121103. private static readStringLine;
  121104. /**
  121105. * Reads header information from an RGBE texture stored in a native array.
  121106. * More information on this format are available here:
  121107. * https://en.wikipedia.org/wiki/RGBE_image_format
  121108. *
  121109. * @param uint8array The binary file stored in native array.
  121110. * @return The header information.
  121111. */
  121112. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  121113. /**
  121114. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  121115. * This RGBE texture needs to store the information as a panorama.
  121116. *
  121117. * More information on this format are available here:
  121118. * https://en.wikipedia.org/wiki/RGBE_image_format
  121119. *
  121120. * @param buffer The binary file stored in an array buffer.
  121121. * @param size The expected size of the extracted cubemap.
  121122. * @return The Cube Map information.
  121123. */
  121124. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  121125. /**
  121126. * Returns the pixels data extracted from an RGBE texture.
  121127. * This pixels will be stored left to right up to down in the R G B order in one array.
  121128. *
  121129. * More information on this format are available here:
  121130. * https://en.wikipedia.org/wiki/RGBE_image_format
  121131. *
  121132. * @param uint8array The binary file stored in an array buffer.
  121133. * @param hdrInfo The header information of the file.
  121134. * @return The pixels data in RGB right to left up to down order.
  121135. */
  121136. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  121137. private static RGBE_ReadPixels_RLE;
  121138. }
  121139. }
  121140. declare module BABYLON {
  121141. /**
  121142. * This represents a texture coming from an HDR input.
  121143. *
  121144. * The only supported format is currently panorama picture stored in RGBE format.
  121145. * Example of such files can be found on HDRLib: http://hdrlib.com/
  121146. */
  121147. export class HDRCubeTexture extends BaseTexture {
  121148. private static _facesMapping;
  121149. private _generateHarmonics;
  121150. private _noMipmap;
  121151. private _textureMatrix;
  121152. private _size;
  121153. private _onLoad;
  121154. private _onError;
  121155. /**
  121156. * The texture URL.
  121157. */
  121158. url: string;
  121159. /**
  121160. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  121161. */
  121162. coordinatesMode: number;
  121163. protected _isBlocking: boolean;
  121164. /**
  121165. * Sets wether or not the texture is blocking during loading.
  121166. */
  121167. /**
  121168. * Gets wether or not the texture is blocking during loading.
  121169. */
  121170. isBlocking: boolean;
  121171. protected _rotationY: number;
  121172. /**
  121173. * Sets texture matrix rotation angle around Y axis in radians.
  121174. */
  121175. /**
  121176. * Gets texture matrix rotation angle around Y axis radians.
  121177. */
  121178. rotationY: number;
  121179. /**
  121180. * Gets or sets the center of the bounding box associated with the cube texture
  121181. * It must define where the camera used to render the texture was set
  121182. */
  121183. boundingBoxPosition: Vector3;
  121184. private _boundingBoxSize;
  121185. /**
  121186. * Gets or sets the size of the bounding box associated with the cube texture
  121187. * When defined, the cubemap will switch to local mode
  121188. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  121189. * @example https://www.babylonjs-playground.com/#RNASML
  121190. */
  121191. boundingBoxSize: Vector3;
  121192. /**
  121193. * Instantiates an HDRTexture from the following parameters.
  121194. *
  121195. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  121196. * @param scene The scene the texture will be used in
  121197. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  121198. * @param noMipmap Forces to not generate the mipmap if true
  121199. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  121200. * @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)
  121201. * @param reserved Reserved flag for internal use.
  121202. */
  121203. 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>);
  121204. /**
  121205. * Get the current class name of the texture useful for serialization or dynamic coding.
  121206. * @returns "HDRCubeTexture"
  121207. */
  121208. getClassName(): string;
  121209. /**
  121210. * Occurs when the file is raw .hdr file.
  121211. */
  121212. private loadTexture;
  121213. clone(): HDRCubeTexture;
  121214. delayLoad(): void;
  121215. /**
  121216. * Get the texture reflection matrix used to rotate/transform the reflection.
  121217. * @returns the reflection matrix
  121218. */
  121219. getReflectionTextureMatrix(): Matrix;
  121220. /**
  121221. * Set the texture reflection matrix used to rotate/transform the reflection.
  121222. * @param value Define the reflection matrix to set
  121223. */
  121224. setReflectionTextureMatrix(value: Matrix): void;
  121225. /**
  121226. * Parses a JSON representation of an HDR Texture in order to create the texture
  121227. * @param parsedTexture Define the JSON representation
  121228. * @param scene Define the scene the texture should be created in
  121229. * @param rootUrl Define the root url in case we need to load relative dependencies
  121230. * @returns the newly created texture after parsing
  121231. */
  121232. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  121233. serialize(): any;
  121234. }
  121235. }
  121236. declare module BABYLON {
  121237. /**
  121238. * Class used to control physics engine
  121239. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  121240. */
  121241. export class PhysicsEngine implements IPhysicsEngine {
  121242. private _physicsPlugin;
  121243. /**
  121244. * Global value used to control the smallest number supported by the simulation
  121245. */
  121246. static Epsilon: number;
  121247. private _impostors;
  121248. private _joints;
  121249. private _subTimeStep;
  121250. /**
  121251. * Gets the gravity vector used by the simulation
  121252. */
  121253. gravity: Vector3;
  121254. /**
  121255. * Factory used to create the default physics plugin.
  121256. * @returns The default physics plugin
  121257. */
  121258. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  121259. /**
  121260. * Creates a new Physics Engine
  121261. * @param gravity defines the gravity vector used by the simulation
  121262. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  121263. */
  121264. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  121265. /**
  121266. * Sets the gravity vector used by the simulation
  121267. * @param gravity defines the gravity vector to use
  121268. */
  121269. setGravity(gravity: Vector3): void;
  121270. /**
  121271. * Set the time step of the physics engine.
  121272. * Default is 1/60.
  121273. * To slow it down, enter 1/600 for example.
  121274. * To speed it up, 1/30
  121275. * @param newTimeStep defines the new timestep to apply to this world.
  121276. */
  121277. setTimeStep(newTimeStep?: number): void;
  121278. /**
  121279. * Get the time step of the physics engine.
  121280. * @returns the current time step
  121281. */
  121282. getTimeStep(): number;
  121283. /**
  121284. * Set the sub time step of the physics engine.
  121285. * Default is 0 meaning there is no sub steps
  121286. * To increase physics resolution precision, set a small value (like 1 ms)
  121287. * @param subTimeStep defines the new sub timestep used for physics resolution.
  121288. */
  121289. setSubTimeStep(subTimeStep?: number): void;
  121290. /**
  121291. * Get the sub time step of the physics engine.
  121292. * @returns the current sub time step
  121293. */
  121294. getSubTimeStep(): number;
  121295. /**
  121296. * Release all resources
  121297. */
  121298. dispose(): void;
  121299. /**
  121300. * Gets the name of the current physics plugin
  121301. * @returns the name of the plugin
  121302. */
  121303. getPhysicsPluginName(): string;
  121304. /**
  121305. * Adding a new impostor for the impostor tracking.
  121306. * This will be done by the impostor itself.
  121307. * @param impostor the impostor to add
  121308. */
  121309. addImpostor(impostor: PhysicsImpostor): void;
  121310. /**
  121311. * Remove an impostor from the engine.
  121312. * This impostor and its mesh will not longer be updated by the physics engine.
  121313. * @param impostor the impostor to remove
  121314. */
  121315. removeImpostor(impostor: PhysicsImpostor): void;
  121316. /**
  121317. * Add a joint to the physics engine
  121318. * @param mainImpostor defines the main impostor to which the joint is added.
  121319. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  121320. * @param joint defines the joint that will connect both impostors.
  121321. */
  121322. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  121323. /**
  121324. * Removes a joint from the simulation
  121325. * @param mainImpostor defines the impostor used with the joint
  121326. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  121327. * @param joint defines the joint to remove
  121328. */
  121329. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  121330. /**
  121331. * Called by the scene. No need to call it.
  121332. * @param delta defines the timespam between frames
  121333. */
  121334. _step(delta: number): void;
  121335. /**
  121336. * Gets the current plugin used to run the simulation
  121337. * @returns current plugin
  121338. */
  121339. getPhysicsPlugin(): IPhysicsEnginePlugin;
  121340. /**
  121341. * Gets the list of physic impostors
  121342. * @returns an array of PhysicsImpostor
  121343. */
  121344. getImpostors(): Array<PhysicsImpostor>;
  121345. /**
  121346. * Gets the impostor for a physics enabled object
  121347. * @param object defines the object impersonated by the impostor
  121348. * @returns the PhysicsImpostor or null if not found
  121349. */
  121350. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  121351. /**
  121352. * Gets the impostor for a physics body object
  121353. * @param body defines physics body used by the impostor
  121354. * @returns the PhysicsImpostor or null if not found
  121355. */
  121356. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  121357. /**
  121358. * Does a raycast in the physics world
  121359. * @param from when should the ray start?
  121360. * @param to when should the ray end?
  121361. * @returns PhysicsRaycastResult
  121362. */
  121363. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  121364. }
  121365. }
  121366. declare module BABYLON {
  121367. /** @hidden */
  121368. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  121369. private _useDeltaForWorldStep;
  121370. world: any;
  121371. name: string;
  121372. private _physicsMaterials;
  121373. private _fixedTimeStep;
  121374. private _cannonRaycastResult;
  121375. private _raycastResult;
  121376. private _physicsBodysToRemoveAfterStep;
  121377. BJSCANNON: any;
  121378. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  121379. setGravity(gravity: Vector3): void;
  121380. setTimeStep(timeStep: number): void;
  121381. getTimeStep(): number;
  121382. executeStep(delta: number): void;
  121383. private _removeMarkedPhysicsBodiesFromWorld;
  121384. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  121385. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  121386. generatePhysicsBody(impostor: PhysicsImpostor): void;
  121387. private _processChildMeshes;
  121388. removePhysicsBody(impostor: PhysicsImpostor): void;
  121389. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  121390. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  121391. private _addMaterial;
  121392. private _checkWithEpsilon;
  121393. private _createShape;
  121394. private _createHeightmap;
  121395. private _minus90X;
  121396. private _plus90X;
  121397. private _tmpPosition;
  121398. private _tmpDeltaPosition;
  121399. private _tmpUnityRotation;
  121400. private _updatePhysicsBodyTransformation;
  121401. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  121402. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  121403. isSupported(): boolean;
  121404. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  121405. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  121406. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  121407. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  121408. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  121409. getBodyMass(impostor: PhysicsImpostor): number;
  121410. getBodyFriction(impostor: PhysicsImpostor): number;
  121411. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  121412. getBodyRestitution(impostor: PhysicsImpostor): number;
  121413. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  121414. sleepBody(impostor: PhysicsImpostor): void;
  121415. wakeUpBody(impostor: PhysicsImpostor): void;
  121416. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  121417. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  121418. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  121419. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  121420. getRadius(impostor: PhysicsImpostor): number;
  121421. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  121422. dispose(): void;
  121423. private _extendNamespace;
  121424. /**
  121425. * Does a raycast in the physics world
  121426. * @param from when should the ray start?
  121427. * @param to when should the ray end?
  121428. * @returns PhysicsRaycastResult
  121429. */
  121430. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  121431. }
  121432. }
  121433. declare module BABYLON {
  121434. /** @hidden */
  121435. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  121436. world: any;
  121437. name: string;
  121438. BJSOIMO: any;
  121439. private _raycastResult;
  121440. constructor(iterations?: number, oimoInjection?: any);
  121441. setGravity(gravity: Vector3): void;
  121442. setTimeStep(timeStep: number): void;
  121443. getTimeStep(): number;
  121444. private _tmpImpostorsArray;
  121445. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  121446. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  121447. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  121448. generatePhysicsBody(impostor: PhysicsImpostor): void;
  121449. private _tmpPositionVector;
  121450. removePhysicsBody(impostor: PhysicsImpostor): void;
  121451. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  121452. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  121453. isSupported(): boolean;
  121454. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  121455. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  121456. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  121457. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  121458. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  121459. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  121460. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  121461. getBodyMass(impostor: PhysicsImpostor): number;
  121462. getBodyFriction(impostor: PhysicsImpostor): number;
  121463. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  121464. getBodyRestitution(impostor: PhysicsImpostor): number;
  121465. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  121466. sleepBody(impostor: PhysicsImpostor): void;
  121467. wakeUpBody(impostor: PhysicsImpostor): void;
  121468. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  121469. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  121470. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  121471. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  121472. getRadius(impostor: PhysicsImpostor): number;
  121473. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  121474. dispose(): void;
  121475. /**
  121476. * Does a raycast in the physics world
  121477. * @param from when should the ray start?
  121478. * @param to when should the ray end?
  121479. * @returns PhysicsRaycastResult
  121480. */
  121481. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  121482. }
  121483. }
  121484. declare module BABYLON {
  121485. /**
  121486. * Class containing static functions to help procedurally build meshes
  121487. */
  121488. export class RibbonBuilder {
  121489. /**
  121490. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  121491. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  121492. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  121493. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  121494. * * 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
  121495. * * 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
  121496. * * 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
  121497. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121498. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121499. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121500. * * 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
  121501. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  121502. * * 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
  121503. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  121504. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121505. * @param name defines the name of the mesh
  121506. * @param options defines the options used to create the mesh
  121507. * @param scene defines the hosting scene
  121508. * @returns the ribbon mesh
  121509. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  121510. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121511. */
  121512. static CreateRibbon(name: string, options: {
  121513. pathArray: Vector3[][];
  121514. closeArray?: boolean;
  121515. closePath?: boolean;
  121516. offset?: number;
  121517. updatable?: boolean;
  121518. sideOrientation?: number;
  121519. frontUVs?: Vector4;
  121520. backUVs?: Vector4;
  121521. instance?: Mesh;
  121522. invertUV?: boolean;
  121523. uvs?: Vector2[];
  121524. colors?: Color4[];
  121525. }, scene?: Nullable<Scene>): Mesh;
  121526. }
  121527. }
  121528. declare module BABYLON {
  121529. /**
  121530. * Class containing static functions to help procedurally build meshes
  121531. */
  121532. export class ShapeBuilder {
  121533. /**
  121534. * 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.
  121535. * * 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.
  121536. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  121537. * * 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.
  121538. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  121539. * * 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
  121540. * * 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
  121541. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  121542. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121543. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121544. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  121545. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121546. * @param name defines the name of the mesh
  121547. * @param options defines the options used to create the mesh
  121548. * @param scene defines the hosting scene
  121549. * @returns the extruded shape mesh
  121550. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121551. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  121552. */
  121553. static ExtrudeShape(name: string, options: {
  121554. shape: Vector3[];
  121555. path: Vector3[];
  121556. scale?: number;
  121557. rotation?: number;
  121558. cap?: number;
  121559. updatable?: boolean;
  121560. sideOrientation?: number;
  121561. frontUVs?: Vector4;
  121562. backUVs?: Vector4;
  121563. instance?: Mesh;
  121564. invertUV?: boolean;
  121565. }, scene?: Nullable<Scene>): Mesh;
  121566. /**
  121567. * Creates an custom extruded shape mesh.
  121568. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  121569. * * 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.
  121570. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  121571. * * 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
  121572. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  121573. * * 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
  121574. * * It must returns a float value that will be the scale value applied to the shape on each path point
  121575. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  121576. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  121577. * * 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
  121578. * * 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
  121579. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  121580. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121581. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121582. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121583. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121584. * @param name defines the name of the mesh
  121585. * @param options defines the options used to create the mesh
  121586. * @param scene defines the hosting scene
  121587. * @returns the custom extruded shape mesh
  121588. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  121589. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121590. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  121591. */
  121592. static ExtrudeShapeCustom(name: string, options: {
  121593. shape: Vector3[];
  121594. path: Vector3[];
  121595. scaleFunction?: any;
  121596. rotationFunction?: any;
  121597. ribbonCloseArray?: boolean;
  121598. ribbonClosePath?: boolean;
  121599. cap?: number;
  121600. updatable?: boolean;
  121601. sideOrientation?: number;
  121602. frontUVs?: Vector4;
  121603. backUVs?: Vector4;
  121604. instance?: Mesh;
  121605. invertUV?: boolean;
  121606. }, scene?: Nullable<Scene>): Mesh;
  121607. private static _ExtrudeShapeGeneric;
  121608. }
  121609. }
  121610. declare module BABYLON {
  121611. /**
  121612. * AmmoJS Physics plugin
  121613. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  121614. * @see https://github.com/kripken/ammo.js/
  121615. */
  121616. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  121617. private _useDeltaForWorldStep;
  121618. /**
  121619. * Reference to the Ammo library
  121620. */
  121621. bjsAMMO: any;
  121622. /**
  121623. * Created ammoJS world which physics bodies are added to
  121624. */
  121625. world: any;
  121626. /**
  121627. * Name of the plugin
  121628. */
  121629. name: string;
  121630. private _timeStep;
  121631. private _fixedTimeStep;
  121632. private _maxSteps;
  121633. private _tmpQuaternion;
  121634. private _tmpAmmoTransform;
  121635. private _tmpAmmoQuaternion;
  121636. private _tmpAmmoConcreteContactResultCallback;
  121637. private _collisionConfiguration;
  121638. private _dispatcher;
  121639. private _overlappingPairCache;
  121640. private _solver;
  121641. private _softBodySolver;
  121642. private _tmpAmmoVectorA;
  121643. private _tmpAmmoVectorB;
  121644. private _tmpAmmoVectorC;
  121645. private _tmpAmmoVectorD;
  121646. private _tmpContactCallbackResult;
  121647. private _tmpAmmoVectorRCA;
  121648. private _tmpAmmoVectorRCB;
  121649. private _raycastResult;
  121650. private static readonly DISABLE_COLLISION_FLAG;
  121651. private static readonly KINEMATIC_FLAG;
  121652. private static readonly DISABLE_DEACTIVATION_FLAG;
  121653. /**
  121654. * Initializes the ammoJS plugin
  121655. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  121656. * @param ammoInjection can be used to inject your own ammo reference
  121657. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  121658. */
  121659. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  121660. /**
  121661. * Sets the gravity of the physics world (m/(s^2))
  121662. * @param gravity Gravity to set
  121663. */
  121664. setGravity(gravity: Vector3): void;
  121665. /**
  121666. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  121667. * @param timeStep timestep to use in seconds
  121668. */
  121669. setTimeStep(timeStep: number): void;
  121670. /**
  121671. * 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)
  121672. * @param fixedTimeStep fixedTimeStep to use in seconds
  121673. */
  121674. setFixedTimeStep(fixedTimeStep: number): void;
  121675. /**
  121676. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  121677. * @param maxSteps the maximum number of steps by the physics engine per frame
  121678. */
  121679. setMaxSteps(maxSteps: number): void;
  121680. /**
  121681. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  121682. * @returns the current timestep in seconds
  121683. */
  121684. getTimeStep(): number;
  121685. /**
  121686. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  121687. */
  121688. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  121689. private _isImpostorInContact;
  121690. private _isImpostorPairInContact;
  121691. private _stepSimulation;
  121692. /**
  121693. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  121694. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  121695. * After the step the babylon meshes are set to the position of the physics imposters
  121696. * @param delta amount of time to step forward
  121697. * @param impostors array of imposters to update before/after the step
  121698. */
  121699. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  121700. /**
  121701. * Update babylon mesh to match physics world object
  121702. * @param impostor imposter to match
  121703. */
  121704. private _afterSoftStep;
  121705. /**
  121706. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  121707. * @param impostor imposter to match
  121708. */
  121709. private _ropeStep;
  121710. /**
  121711. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  121712. * @param impostor imposter to match
  121713. */
  121714. private _softbodyOrClothStep;
  121715. private _tmpVector;
  121716. private _tmpMatrix;
  121717. /**
  121718. * Applies an impulse on the imposter
  121719. * @param impostor imposter to apply impulse to
  121720. * @param force amount of force to be applied to the imposter
  121721. * @param contactPoint the location to apply the impulse on the imposter
  121722. */
  121723. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  121724. /**
  121725. * Applies a force on the imposter
  121726. * @param impostor imposter to apply force
  121727. * @param force amount of force to be applied to the imposter
  121728. * @param contactPoint the location to apply the force on the imposter
  121729. */
  121730. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  121731. /**
  121732. * Creates a physics body using the plugin
  121733. * @param impostor the imposter to create the physics body on
  121734. */
  121735. generatePhysicsBody(impostor: PhysicsImpostor): void;
  121736. /**
  121737. * Removes the physics body from the imposter and disposes of the body's memory
  121738. * @param impostor imposter to remove the physics body from
  121739. */
  121740. removePhysicsBody(impostor: PhysicsImpostor): void;
  121741. /**
  121742. * Generates a joint
  121743. * @param impostorJoint the imposter joint to create the joint with
  121744. */
  121745. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  121746. /**
  121747. * Removes a joint
  121748. * @param impostorJoint the imposter joint to remove the joint from
  121749. */
  121750. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  121751. private _addMeshVerts;
  121752. /**
  121753. * Initialise the soft body vertices to match its object's (mesh) vertices
  121754. * Softbody vertices (nodes) are in world space and to match this
  121755. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  121756. * @param impostor to create the softbody for
  121757. */
  121758. private _softVertexData;
  121759. /**
  121760. * Create an impostor's soft body
  121761. * @param impostor to create the softbody for
  121762. */
  121763. private _createSoftbody;
  121764. /**
  121765. * Create cloth for an impostor
  121766. * @param impostor to create the softbody for
  121767. */
  121768. private _createCloth;
  121769. /**
  121770. * Create rope for an impostor
  121771. * @param impostor to create the softbody for
  121772. */
  121773. private _createRope;
  121774. /**
  121775. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  121776. * @param impostor to create the custom physics shape for
  121777. */
  121778. private _createCustom;
  121779. private _addHullVerts;
  121780. private _createShape;
  121781. /**
  121782. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  121783. * @param impostor imposter containing the physics body and babylon object
  121784. */
  121785. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  121786. /**
  121787. * Sets the babylon object's position/rotation from the physics body's position/rotation
  121788. * @param impostor imposter containing the physics body and babylon object
  121789. * @param newPosition new position
  121790. * @param newRotation new rotation
  121791. */
  121792. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  121793. /**
  121794. * If this plugin is supported
  121795. * @returns true if its supported
  121796. */
  121797. isSupported(): boolean;
  121798. /**
  121799. * Sets the linear velocity of the physics body
  121800. * @param impostor imposter to set the velocity on
  121801. * @param velocity velocity to set
  121802. */
  121803. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  121804. /**
  121805. * Sets the angular velocity of the physics body
  121806. * @param impostor imposter to set the velocity on
  121807. * @param velocity velocity to set
  121808. */
  121809. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  121810. /**
  121811. * gets the linear velocity
  121812. * @param impostor imposter to get linear velocity from
  121813. * @returns linear velocity
  121814. */
  121815. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  121816. /**
  121817. * gets the angular velocity
  121818. * @param impostor imposter to get angular velocity from
  121819. * @returns angular velocity
  121820. */
  121821. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  121822. /**
  121823. * Sets the mass of physics body
  121824. * @param impostor imposter to set the mass on
  121825. * @param mass mass to set
  121826. */
  121827. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  121828. /**
  121829. * Gets the mass of the physics body
  121830. * @param impostor imposter to get the mass from
  121831. * @returns mass
  121832. */
  121833. getBodyMass(impostor: PhysicsImpostor): number;
  121834. /**
  121835. * Gets friction of the impostor
  121836. * @param impostor impostor to get friction from
  121837. * @returns friction value
  121838. */
  121839. getBodyFriction(impostor: PhysicsImpostor): number;
  121840. /**
  121841. * Sets friction of the impostor
  121842. * @param impostor impostor to set friction on
  121843. * @param friction friction value
  121844. */
  121845. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  121846. /**
  121847. * Gets restitution of the impostor
  121848. * @param impostor impostor to get restitution from
  121849. * @returns restitution value
  121850. */
  121851. getBodyRestitution(impostor: PhysicsImpostor): number;
  121852. /**
  121853. * Sets resitution of the impostor
  121854. * @param impostor impostor to set resitution on
  121855. * @param restitution resitution value
  121856. */
  121857. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  121858. /**
  121859. * Gets pressure inside the impostor
  121860. * @param impostor impostor to get pressure from
  121861. * @returns pressure value
  121862. */
  121863. getBodyPressure(impostor: PhysicsImpostor): number;
  121864. /**
  121865. * Sets pressure inside a soft body impostor
  121866. * Cloth and rope must remain 0 pressure
  121867. * @param impostor impostor to set pressure on
  121868. * @param pressure pressure value
  121869. */
  121870. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  121871. /**
  121872. * Gets stiffness of the impostor
  121873. * @param impostor impostor to get stiffness from
  121874. * @returns pressure value
  121875. */
  121876. getBodyStiffness(impostor: PhysicsImpostor): number;
  121877. /**
  121878. * Sets stiffness of the impostor
  121879. * @param impostor impostor to set stiffness on
  121880. * @param stiffness stiffness value from 0 to 1
  121881. */
  121882. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  121883. /**
  121884. * Gets velocityIterations of the impostor
  121885. * @param impostor impostor to get velocity iterations from
  121886. * @returns velocityIterations value
  121887. */
  121888. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  121889. /**
  121890. * Sets velocityIterations of the impostor
  121891. * @param impostor impostor to set velocity iterations on
  121892. * @param velocityIterations velocityIterations value
  121893. */
  121894. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  121895. /**
  121896. * Gets positionIterations of the impostor
  121897. * @param impostor impostor to get position iterations from
  121898. * @returns positionIterations value
  121899. */
  121900. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  121901. /**
  121902. * Sets positionIterations of the impostor
  121903. * @param impostor impostor to set position on
  121904. * @param positionIterations positionIterations value
  121905. */
  121906. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  121907. /**
  121908. * Append an anchor to a cloth object
  121909. * @param impostor is the cloth impostor to add anchor to
  121910. * @param otherImpostor is the rigid impostor to anchor to
  121911. * @param width ratio across width from 0 to 1
  121912. * @param height ratio up height from 0 to 1
  121913. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  121914. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  121915. */
  121916. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  121917. /**
  121918. * Append an hook to a rope object
  121919. * @param impostor is the rope impostor to add hook to
  121920. * @param otherImpostor is the rigid impostor to hook to
  121921. * @param length ratio along the rope from 0 to 1
  121922. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  121923. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  121924. */
  121925. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  121926. /**
  121927. * Sleeps the physics body and stops it from being active
  121928. * @param impostor impostor to sleep
  121929. */
  121930. sleepBody(impostor: PhysicsImpostor): void;
  121931. /**
  121932. * Activates the physics body
  121933. * @param impostor impostor to activate
  121934. */
  121935. wakeUpBody(impostor: PhysicsImpostor): void;
  121936. /**
  121937. * Updates the distance parameters of the joint
  121938. * @param joint joint to update
  121939. * @param maxDistance maximum distance of the joint
  121940. * @param minDistance minimum distance of the joint
  121941. */
  121942. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  121943. /**
  121944. * Sets a motor on the joint
  121945. * @param joint joint to set motor on
  121946. * @param speed speed of the motor
  121947. * @param maxForce maximum force of the motor
  121948. * @param motorIndex index of the motor
  121949. */
  121950. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  121951. /**
  121952. * Sets the motors limit
  121953. * @param joint joint to set limit on
  121954. * @param upperLimit upper limit
  121955. * @param lowerLimit lower limit
  121956. */
  121957. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  121958. /**
  121959. * Syncs the position and rotation of a mesh with the impostor
  121960. * @param mesh mesh to sync
  121961. * @param impostor impostor to update the mesh with
  121962. */
  121963. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  121964. /**
  121965. * Gets the radius of the impostor
  121966. * @param impostor impostor to get radius from
  121967. * @returns the radius
  121968. */
  121969. getRadius(impostor: PhysicsImpostor): number;
  121970. /**
  121971. * Gets the box size of the impostor
  121972. * @param impostor impostor to get box size from
  121973. * @param result the resulting box size
  121974. */
  121975. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  121976. /**
  121977. * Disposes of the impostor
  121978. */
  121979. dispose(): void;
  121980. /**
  121981. * Does a raycast in the physics world
  121982. * @param from when should the ray start?
  121983. * @param to when should the ray end?
  121984. * @returns PhysicsRaycastResult
  121985. */
  121986. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  121987. }
  121988. }
  121989. declare module BABYLON {
  121990. interface AbstractScene {
  121991. /**
  121992. * The list of reflection probes added to the scene
  121993. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  121994. */
  121995. reflectionProbes: Array<ReflectionProbe>;
  121996. /**
  121997. * Removes the given reflection probe from this scene.
  121998. * @param toRemove The reflection probe to remove
  121999. * @returns The index of the removed reflection probe
  122000. */
  122001. removeReflectionProbe(toRemove: ReflectionProbe): number;
  122002. /**
  122003. * Adds the given reflection probe to this scene.
  122004. * @param newReflectionProbe The reflection probe to add
  122005. */
  122006. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  122007. }
  122008. /**
  122009. * Class used to generate realtime reflection / refraction cube textures
  122010. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  122011. */
  122012. export class ReflectionProbe {
  122013. /** defines the name of the probe */
  122014. name: string;
  122015. private _scene;
  122016. private _renderTargetTexture;
  122017. private _projectionMatrix;
  122018. private _viewMatrix;
  122019. private _target;
  122020. private _add;
  122021. private _attachedMesh;
  122022. private _invertYAxis;
  122023. /** Gets or sets probe position (center of the cube map) */
  122024. position: Vector3;
  122025. /**
  122026. * Creates a new reflection probe
  122027. * @param name defines the name of the probe
  122028. * @param size defines the texture resolution (for each face)
  122029. * @param scene defines the hosting scene
  122030. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  122031. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  122032. */
  122033. constructor(
  122034. /** defines the name of the probe */
  122035. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  122036. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  122037. samples: number;
  122038. /** Gets or sets the refresh rate to use (on every frame by default) */
  122039. refreshRate: number;
  122040. /**
  122041. * Gets the hosting scene
  122042. * @returns a Scene
  122043. */
  122044. getScene(): Scene;
  122045. /** Gets the internal CubeTexture used to render to */
  122046. readonly cubeTexture: RenderTargetTexture;
  122047. /** Gets the list of meshes to render */
  122048. readonly renderList: Nullable<AbstractMesh[]>;
  122049. /**
  122050. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  122051. * @param mesh defines the mesh to attach to
  122052. */
  122053. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  122054. /**
  122055. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  122056. * @param renderingGroupId The rendering group id corresponding to its index
  122057. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  122058. */
  122059. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  122060. /**
  122061. * Clean all associated resources
  122062. */
  122063. dispose(): void;
  122064. /**
  122065. * Converts the reflection probe information to a readable string for debug purpose.
  122066. * @param fullDetails Supports for multiple levels of logging within scene loading
  122067. * @returns the human readable reflection probe info
  122068. */
  122069. toString(fullDetails?: boolean): string;
  122070. /**
  122071. * Get the class name of the relfection probe.
  122072. * @returns "ReflectionProbe"
  122073. */
  122074. getClassName(): string;
  122075. /**
  122076. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  122077. * @returns The JSON representation of the texture
  122078. */
  122079. serialize(): any;
  122080. /**
  122081. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  122082. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  122083. * @param scene Define the scene the parsed reflection probe should be instantiated in
  122084. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  122085. * @returns The parsed reflection probe if successful
  122086. */
  122087. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  122088. }
  122089. }
  122090. declare module BABYLON {
  122091. /** @hidden */
  122092. export var _BabylonLoaderRegistered: boolean;
  122093. /**
  122094. * Helps setting up some configuration for the babylon file loader.
  122095. */
  122096. export class BabylonFileLoaderConfiguration {
  122097. /**
  122098. * The loader does not allow injecting custom physix engine into the plugins.
  122099. * Unfortunately in ES6, we need to manually inject them into the plugin.
  122100. * So you could set this variable to your engine import to make it work.
  122101. */
  122102. static LoaderInjectedPhysicsEngine: any;
  122103. }
  122104. }
  122105. declare module BABYLON {
  122106. /**
  122107. * The Physically based simple base material of BJS.
  122108. *
  122109. * This enables better naming and convention enforcements on top of the pbrMaterial.
  122110. * It is used as the base class for both the specGloss and metalRough conventions.
  122111. */
  122112. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  122113. /**
  122114. * Number of Simultaneous lights allowed on the material.
  122115. */
  122116. maxSimultaneousLights: number;
  122117. /**
  122118. * If sets to true, disables all the lights affecting the material.
  122119. */
  122120. disableLighting: boolean;
  122121. /**
  122122. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  122123. */
  122124. environmentTexture: BaseTexture;
  122125. /**
  122126. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  122127. */
  122128. invertNormalMapX: boolean;
  122129. /**
  122130. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  122131. */
  122132. invertNormalMapY: boolean;
  122133. /**
  122134. * Normal map used in the model.
  122135. */
  122136. normalTexture: BaseTexture;
  122137. /**
  122138. * Emissivie color used to self-illuminate the model.
  122139. */
  122140. emissiveColor: Color3;
  122141. /**
  122142. * Emissivie texture used to self-illuminate the model.
  122143. */
  122144. emissiveTexture: BaseTexture;
  122145. /**
  122146. * Occlusion Channel Strenght.
  122147. */
  122148. occlusionStrength: number;
  122149. /**
  122150. * Occlusion Texture of the material (adding extra occlusion effects).
  122151. */
  122152. occlusionTexture: BaseTexture;
  122153. /**
  122154. * Defines the alpha limits in alpha test mode.
  122155. */
  122156. alphaCutOff: number;
  122157. /**
  122158. * Gets the current double sided mode.
  122159. */
  122160. /**
  122161. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  122162. */
  122163. doubleSided: boolean;
  122164. /**
  122165. * Stores the pre-calculated light information of a mesh in a texture.
  122166. */
  122167. lightmapTexture: BaseTexture;
  122168. /**
  122169. * If true, the light map contains occlusion information instead of lighting info.
  122170. */
  122171. useLightmapAsShadowmap: boolean;
  122172. /**
  122173. * Instantiates a new PBRMaterial instance.
  122174. *
  122175. * @param name The material name
  122176. * @param scene The scene the material will be use in.
  122177. */
  122178. constructor(name: string, scene: Scene);
  122179. getClassName(): string;
  122180. }
  122181. }
  122182. declare module BABYLON {
  122183. /**
  122184. * The PBR material of BJS following the metal roughness convention.
  122185. *
  122186. * This fits to the PBR convention in the GLTF definition:
  122187. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  122188. */
  122189. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  122190. /**
  122191. * The base color has two different interpretations depending on the value of metalness.
  122192. * When the material is a metal, the base color is the specific measured reflectance value
  122193. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  122194. * of the material.
  122195. */
  122196. baseColor: Color3;
  122197. /**
  122198. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  122199. * well as opacity information in the alpha channel.
  122200. */
  122201. baseTexture: BaseTexture;
  122202. /**
  122203. * Specifies the metallic scalar value of the material.
  122204. * Can also be used to scale the metalness values of the metallic texture.
  122205. */
  122206. metallic: number;
  122207. /**
  122208. * Specifies the roughness scalar value of the material.
  122209. * Can also be used to scale the roughness values of the metallic texture.
  122210. */
  122211. roughness: number;
  122212. /**
  122213. * Texture containing both the metallic value in the B channel and the
  122214. * roughness value in the G channel to keep better precision.
  122215. */
  122216. metallicRoughnessTexture: BaseTexture;
  122217. /**
  122218. * Instantiates a new PBRMetalRoughnessMaterial instance.
  122219. *
  122220. * @param name The material name
  122221. * @param scene The scene the material will be use in.
  122222. */
  122223. constructor(name: string, scene: Scene);
  122224. /**
  122225. * Return the currrent class name of the material.
  122226. */
  122227. getClassName(): string;
  122228. /**
  122229. * Makes a duplicate of the current material.
  122230. * @param name - name to use for the new material.
  122231. */
  122232. clone(name: string): PBRMetallicRoughnessMaterial;
  122233. /**
  122234. * Serialize the material to a parsable JSON object.
  122235. */
  122236. serialize(): any;
  122237. /**
  122238. * Parses a JSON object correponding to the serialize function.
  122239. */
  122240. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  122241. }
  122242. }
  122243. declare module BABYLON {
  122244. /**
  122245. * The PBR material of BJS following the specular glossiness convention.
  122246. *
  122247. * This fits to the PBR convention in the GLTF definition:
  122248. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  122249. */
  122250. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  122251. /**
  122252. * Specifies the diffuse color of the material.
  122253. */
  122254. diffuseColor: Color3;
  122255. /**
  122256. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  122257. * channel.
  122258. */
  122259. diffuseTexture: BaseTexture;
  122260. /**
  122261. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  122262. */
  122263. specularColor: Color3;
  122264. /**
  122265. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  122266. */
  122267. glossiness: number;
  122268. /**
  122269. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  122270. */
  122271. specularGlossinessTexture: BaseTexture;
  122272. /**
  122273. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  122274. *
  122275. * @param name The material name
  122276. * @param scene The scene the material will be use in.
  122277. */
  122278. constructor(name: string, scene: Scene);
  122279. /**
  122280. * Return the currrent class name of the material.
  122281. */
  122282. getClassName(): string;
  122283. /**
  122284. * Makes a duplicate of the current material.
  122285. * @param name - name to use for the new material.
  122286. */
  122287. clone(name: string): PBRSpecularGlossinessMaterial;
  122288. /**
  122289. * Serialize the material to a parsable JSON object.
  122290. */
  122291. serialize(): any;
  122292. /**
  122293. * Parses a JSON object correponding to the serialize function.
  122294. */
  122295. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  122296. }
  122297. }
  122298. declare module BABYLON {
  122299. /**
  122300. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  122301. * It can help converting any input color in a desired output one. This can then be used to create effects
  122302. * from sepia, black and white to sixties or futuristic rendering...
  122303. *
  122304. * The only supported format is currently 3dl.
  122305. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  122306. */
  122307. export class ColorGradingTexture extends BaseTexture {
  122308. /**
  122309. * The current texture matrix. (will always be identity in color grading texture)
  122310. */
  122311. private _textureMatrix;
  122312. /**
  122313. * The texture URL.
  122314. */
  122315. url: string;
  122316. /**
  122317. * Empty line regex stored for GC.
  122318. */
  122319. private static _noneEmptyLineRegex;
  122320. private _engine;
  122321. /**
  122322. * Instantiates a ColorGradingTexture from the following parameters.
  122323. *
  122324. * @param url The location of the color gradind data (currently only supporting 3dl)
  122325. * @param scene The scene the texture will be used in
  122326. */
  122327. constructor(url: string, scene: Scene);
  122328. /**
  122329. * Returns the texture matrix used in most of the material.
  122330. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  122331. */
  122332. getTextureMatrix(): Matrix;
  122333. /**
  122334. * Occurs when the file being loaded is a .3dl LUT file.
  122335. */
  122336. private load3dlTexture;
  122337. /**
  122338. * Starts the loading process of the texture.
  122339. */
  122340. private loadTexture;
  122341. /**
  122342. * Clones the color gradind texture.
  122343. */
  122344. clone(): ColorGradingTexture;
  122345. /**
  122346. * Called during delayed load for textures.
  122347. */
  122348. delayLoad(): void;
  122349. /**
  122350. * Parses a color grading texture serialized by Babylon.
  122351. * @param parsedTexture The texture information being parsedTexture
  122352. * @param scene The scene to load the texture in
  122353. * @param rootUrl The root url of the data assets to load
  122354. * @return A color gradind texture
  122355. */
  122356. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  122357. /**
  122358. * Serializes the LUT texture to json format.
  122359. */
  122360. serialize(): any;
  122361. }
  122362. }
  122363. declare module BABYLON {
  122364. /**
  122365. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  122366. */
  122367. export class EquiRectangularCubeTexture extends BaseTexture {
  122368. /** The six faces of the cube. */
  122369. private static _FacesMapping;
  122370. private _noMipmap;
  122371. private _onLoad;
  122372. private _onError;
  122373. /** The size of the cubemap. */
  122374. private _size;
  122375. /** The buffer of the image. */
  122376. private _buffer;
  122377. /** The width of the input image. */
  122378. private _width;
  122379. /** The height of the input image. */
  122380. private _height;
  122381. /** The URL to the image. */
  122382. url: string;
  122383. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  122384. coordinatesMode: number;
  122385. /**
  122386. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  122387. * @param url The location of the image
  122388. * @param scene The scene the texture will be used in
  122389. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  122390. * @param noMipmap Forces to not generate the mipmap if true
  122391. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  122392. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  122393. * @param onLoad — defines a callback called when texture is loaded
  122394. * @param onError — defines a callback called if there is an error
  122395. */
  122396. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  122397. /**
  122398. * Load the image data, by putting the image on a canvas and extracting its buffer.
  122399. */
  122400. private loadImage;
  122401. /**
  122402. * Convert the image buffer into a cubemap and create a CubeTexture.
  122403. */
  122404. private loadTexture;
  122405. /**
  122406. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  122407. * @param buffer The ArrayBuffer that should be converted.
  122408. * @returns The buffer as Float32Array.
  122409. */
  122410. private getFloat32ArrayFromArrayBuffer;
  122411. /**
  122412. * Get the current class name of the texture useful for serialization or dynamic coding.
  122413. * @returns "EquiRectangularCubeTexture"
  122414. */
  122415. getClassName(): string;
  122416. /**
  122417. * Create a clone of the current EquiRectangularCubeTexture and return it.
  122418. * @returns A clone of the current EquiRectangularCubeTexture.
  122419. */
  122420. clone(): EquiRectangularCubeTexture;
  122421. }
  122422. }
  122423. declare module BABYLON {
  122424. /**
  122425. * Based on jsTGALoader - Javascript loader for TGA file
  122426. * By Vincent Thibault
  122427. * @see http://blog.robrowser.com/javascript-tga-loader.html
  122428. */
  122429. export class TGATools {
  122430. private static _TYPE_INDEXED;
  122431. private static _TYPE_RGB;
  122432. private static _TYPE_GREY;
  122433. private static _TYPE_RLE_INDEXED;
  122434. private static _TYPE_RLE_RGB;
  122435. private static _TYPE_RLE_GREY;
  122436. private static _ORIGIN_MASK;
  122437. private static _ORIGIN_SHIFT;
  122438. private static _ORIGIN_BL;
  122439. private static _ORIGIN_BR;
  122440. private static _ORIGIN_UL;
  122441. private static _ORIGIN_UR;
  122442. /**
  122443. * Gets the header of a TGA file
  122444. * @param data defines the TGA data
  122445. * @returns the header
  122446. */
  122447. static GetTGAHeader(data: Uint8Array): any;
  122448. /**
  122449. * Uploads TGA content to a Babylon Texture
  122450. * @hidden
  122451. */
  122452. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  122453. /** @hidden */
  122454. 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;
  122455. /** @hidden */
  122456. 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;
  122457. /** @hidden */
  122458. 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;
  122459. /** @hidden */
  122460. 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;
  122461. /** @hidden */
  122462. 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;
  122463. /** @hidden */
  122464. 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;
  122465. }
  122466. }
  122467. declare module BABYLON {
  122468. /**
  122469. * Implementation of the TGA Texture Loader.
  122470. * @hidden
  122471. */
  122472. export class _TGATextureLoader implements IInternalTextureLoader {
  122473. /**
  122474. * Defines wether the loader supports cascade loading the different faces.
  122475. */
  122476. readonly supportCascades: boolean;
  122477. /**
  122478. * This returns if the loader support the current file information.
  122479. * @param extension defines the file extension of the file being loaded
  122480. * @param textureFormatInUse defines the current compressed format in use iun the engine
  122481. * @param fallback defines the fallback internal texture if any
  122482. * @param isBase64 defines whether the texture is encoded as a base64
  122483. * @param isBuffer defines whether the texture data are stored as a buffer
  122484. * @returns true if the loader can load the specified file
  122485. */
  122486. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  122487. /**
  122488. * Transform the url before loading if required.
  122489. * @param rootUrl the url of the texture
  122490. * @param textureFormatInUse defines the current compressed format in use iun the engine
  122491. * @returns the transformed texture
  122492. */
  122493. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  122494. /**
  122495. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  122496. * @param rootUrl the url of the texture
  122497. * @param textureFormatInUse defines the current compressed format in use iun the engine
  122498. * @returns the fallback texture
  122499. */
  122500. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  122501. /**
  122502. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  122503. * @param data contains the texture data
  122504. * @param texture defines the BabylonJS internal texture
  122505. * @param createPolynomials will be true if polynomials have been requested
  122506. * @param onLoad defines the callback to trigger once the texture is ready
  122507. * @param onError defines the callback to trigger in case of error
  122508. */
  122509. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  122510. /**
  122511. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  122512. * @param data contains the texture data
  122513. * @param texture defines the BabylonJS internal texture
  122514. * @param callback defines the method to call once ready to upload
  122515. */
  122516. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  122517. }
  122518. }
  122519. declare module BABYLON {
  122520. /**
  122521. * Info about the .basis files
  122522. */
  122523. class BasisFileInfo {
  122524. /**
  122525. * If the file has alpha
  122526. */
  122527. hasAlpha: boolean;
  122528. /**
  122529. * Info about each image of the basis file
  122530. */
  122531. images: Array<{
  122532. levels: Array<{
  122533. width: number;
  122534. height: number;
  122535. transcodedPixels: ArrayBufferView;
  122536. }>;
  122537. }>;
  122538. }
  122539. /**
  122540. * Result of transcoding a basis file
  122541. */
  122542. class TranscodeResult {
  122543. /**
  122544. * Info about the .basis file
  122545. */
  122546. fileInfo: BasisFileInfo;
  122547. /**
  122548. * Format to use when loading the file
  122549. */
  122550. format: number;
  122551. }
  122552. /**
  122553. * Configuration options for the Basis transcoder
  122554. */
  122555. export class BasisTranscodeConfiguration {
  122556. /**
  122557. * Supported compression formats used to determine the supported output format of the transcoder
  122558. */
  122559. supportedCompressionFormats?: {
  122560. /**
  122561. * etc1 compression format
  122562. */
  122563. etc1?: boolean;
  122564. /**
  122565. * s3tc compression format
  122566. */
  122567. s3tc?: boolean;
  122568. /**
  122569. * pvrtc compression format
  122570. */
  122571. pvrtc?: boolean;
  122572. /**
  122573. * etc2 compression format
  122574. */
  122575. etc2?: boolean;
  122576. };
  122577. /**
  122578. * If mipmap levels should be loaded for transcoded images (Default: true)
  122579. */
  122580. loadMipmapLevels?: boolean;
  122581. /**
  122582. * Index of a single image to load (Default: all images)
  122583. */
  122584. loadSingleImage?: number;
  122585. }
  122586. /**
  122587. * Used to load .Basis files
  122588. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  122589. */
  122590. export class BasisTools {
  122591. private static _IgnoreSupportedFormats;
  122592. /**
  122593. * URL to use when loading the basis transcoder
  122594. */
  122595. static JSModuleURL: string;
  122596. /**
  122597. * URL to use when loading the wasm module for the transcoder
  122598. */
  122599. static WasmModuleURL: string;
  122600. /**
  122601. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  122602. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  122603. * @returns internal format corresponding to the Basis format
  122604. */
  122605. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  122606. private static _WorkerPromise;
  122607. private static _Worker;
  122608. private static _actionId;
  122609. private static _CreateWorkerAsync;
  122610. /**
  122611. * Transcodes a loaded image file to compressed pixel data
  122612. * @param imageData image data to transcode
  122613. * @param config configuration options for the transcoding
  122614. * @returns a promise resulting in the transcoded image
  122615. */
  122616. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  122617. /**
  122618. * Loads a texture from the transcode result
  122619. * @param texture texture load to
  122620. * @param transcodeResult the result of transcoding the basis file to load from
  122621. */
  122622. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  122623. }
  122624. }
  122625. declare module BABYLON {
  122626. /**
  122627. * Loader for .basis file format
  122628. */
  122629. export class _BasisTextureLoader implements IInternalTextureLoader {
  122630. /**
  122631. * Defines whether the loader supports cascade loading the different faces.
  122632. */
  122633. readonly supportCascades: boolean;
  122634. /**
  122635. * This returns if the loader support the current file information.
  122636. * @param extension defines the file extension of the file being loaded
  122637. * @param textureFormatInUse defines the current compressed format in use iun the engine
  122638. * @param fallback defines the fallback internal texture if any
  122639. * @param isBase64 defines whether the texture is encoded as a base64
  122640. * @param isBuffer defines whether the texture data are stored as a buffer
  122641. * @returns true if the loader can load the specified file
  122642. */
  122643. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  122644. /**
  122645. * Transform the url before loading if required.
  122646. * @param rootUrl the url of the texture
  122647. * @param textureFormatInUse defines the current compressed format in use iun the engine
  122648. * @returns the transformed texture
  122649. */
  122650. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  122651. /**
  122652. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  122653. * @param rootUrl the url of the texture
  122654. * @param textureFormatInUse defines the current compressed format in use iun the engine
  122655. * @returns the fallback texture
  122656. */
  122657. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  122658. /**
  122659. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  122660. * @param data contains the texture data
  122661. * @param texture defines the BabylonJS internal texture
  122662. * @param createPolynomials will be true if polynomials have been requested
  122663. * @param onLoad defines the callback to trigger once the texture is ready
  122664. * @param onError defines the callback to trigger in case of error
  122665. */
  122666. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  122667. /**
  122668. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  122669. * @param data contains the texture data
  122670. * @param texture defines the BabylonJS internal texture
  122671. * @param callback defines the method to call once ready to upload
  122672. */
  122673. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  122674. }
  122675. }
  122676. declare module BABYLON {
  122677. /**
  122678. * 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.
  122679. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  122680. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  122681. */
  122682. export class CustomProceduralTexture extends ProceduralTexture {
  122683. private _animate;
  122684. private _time;
  122685. private _config;
  122686. private _texturePath;
  122687. /**
  122688. * Instantiates a new Custom Procedural Texture.
  122689. * 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.
  122690. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  122691. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  122692. * @param name Define the name of the texture
  122693. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  122694. * @param size Define the size of the texture to create
  122695. * @param scene Define the scene the texture belongs to
  122696. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  122697. * @param generateMipMaps Define if the texture should creates mip maps or not
  122698. */
  122699. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  122700. private _loadJson;
  122701. /**
  122702. * Is the texture ready to be used ? (rendered at least once)
  122703. * @returns true if ready, otherwise, false.
  122704. */
  122705. isReady(): boolean;
  122706. /**
  122707. * Render the texture to its associated render target.
  122708. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  122709. */
  122710. render(useCameraPostProcess?: boolean): void;
  122711. /**
  122712. * Update the list of dependant textures samplers in the shader.
  122713. */
  122714. updateTextures(): void;
  122715. /**
  122716. * Update the uniform values of the procedural texture in the shader.
  122717. */
  122718. updateShaderUniforms(): void;
  122719. /**
  122720. * Define if the texture animates or not.
  122721. */
  122722. animate: boolean;
  122723. }
  122724. }
  122725. declare module BABYLON {
  122726. /** @hidden */
  122727. export var noisePixelShader: {
  122728. name: string;
  122729. shader: string;
  122730. };
  122731. }
  122732. declare module BABYLON {
  122733. /**
  122734. * Class used to generate noise procedural textures
  122735. */
  122736. export class NoiseProceduralTexture extends ProceduralTexture {
  122737. private _time;
  122738. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  122739. brightness: number;
  122740. /** Defines the number of octaves to process */
  122741. octaves: number;
  122742. /** Defines the level of persistence (0.8 by default) */
  122743. persistence: number;
  122744. /** Gets or sets animation speed factor (default is 1) */
  122745. animationSpeedFactor: number;
  122746. /**
  122747. * Creates a new NoiseProceduralTexture
  122748. * @param name defines the name fo the texture
  122749. * @param size defines the size of the texture (default is 256)
  122750. * @param scene defines the hosting scene
  122751. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  122752. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  122753. */
  122754. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  122755. private _updateShaderUniforms;
  122756. protected _getDefines(): string;
  122757. /** Generate the current state of the procedural texture */
  122758. render(useCameraPostProcess?: boolean): void;
  122759. /**
  122760. * Serializes this noise procedural texture
  122761. * @returns a serialized noise procedural texture object
  122762. */
  122763. serialize(): any;
  122764. /**
  122765. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  122766. * @param parsedTexture defines parsed texture data
  122767. * @param scene defines the current scene
  122768. * @param rootUrl defines the root URL containing noise procedural texture information
  122769. * @returns a parsed NoiseProceduralTexture
  122770. */
  122771. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  122772. }
  122773. }
  122774. declare module BABYLON {
  122775. /**
  122776. * Raw cube texture where the raw buffers are passed in
  122777. */
  122778. export class RawCubeTexture extends CubeTexture {
  122779. /**
  122780. * Creates a cube texture where the raw buffers are passed in.
  122781. * @param scene defines the scene the texture is attached to
  122782. * @param data defines the array of data to use to create each face
  122783. * @param size defines the size of the textures
  122784. * @param format defines the format of the data
  122785. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  122786. * @param generateMipMaps defines if the engine should generate the mip levels
  122787. * @param invertY defines if data must be stored with Y axis inverted
  122788. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  122789. * @param compression defines the compression used (null by default)
  122790. */
  122791. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  122792. /**
  122793. * Updates the raw cube texture.
  122794. * @param data defines the data to store
  122795. * @param format defines the data format
  122796. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  122797. * @param invertY defines if data must be stored with Y axis inverted
  122798. * @param compression defines the compression used (null by default)
  122799. * @param level defines which level of the texture to update
  122800. */
  122801. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  122802. /**
  122803. * Updates a raw cube texture with RGBD encoded data.
  122804. * @param data defines the array of data [mipmap][face] to use to create each face
  122805. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  122806. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  122807. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  122808. * @returns a promsie that resolves when the operation is complete
  122809. */
  122810. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  122811. /**
  122812. * Clones the raw cube texture.
  122813. * @return a new cube texture
  122814. */
  122815. clone(): CubeTexture;
  122816. /** @hidden */
  122817. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  122818. }
  122819. }
  122820. declare module BABYLON {
  122821. /**
  122822. * Class used to store 3D textures containing user data
  122823. */
  122824. export class RawTexture3D extends Texture {
  122825. /** Gets or sets the texture format to use */
  122826. format: number;
  122827. private _engine;
  122828. /**
  122829. * Create a new RawTexture3D
  122830. * @param data defines the data of the texture
  122831. * @param width defines the width of the texture
  122832. * @param height defines the height of the texture
  122833. * @param depth defines the depth of the texture
  122834. * @param format defines the texture format to use
  122835. * @param scene defines the hosting scene
  122836. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  122837. * @param invertY defines if texture must be stored with Y axis inverted
  122838. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  122839. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  122840. */
  122841. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  122842. /** Gets or sets the texture format to use */
  122843. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  122844. /**
  122845. * Update the texture with new data
  122846. * @param data defines the data to store in the texture
  122847. */
  122848. update(data: ArrayBufferView): void;
  122849. }
  122850. }
  122851. declare module BABYLON {
  122852. /**
  122853. * Class used to store 2D array textures containing user data
  122854. */
  122855. export class RawTexture2DArray extends Texture {
  122856. /** Gets or sets the texture format to use */
  122857. format: number;
  122858. private _engine;
  122859. /**
  122860. * Create a new RawTexture2DArray
  122861. * @param data defines the data of the texture
  122862. * @param width defines the width of the texture
  122863. * @param height defines the height of the texture
  122864. * @param depth defines the number of layers of the texture
  122865. * @param format defines the texture format to use
  122866. * @param scene defines the hosting scene
  122867. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  122868. * @param invertY defines if texture must be stored with Y axis inverted
  122869. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  122870. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  122871. */
  122872. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  122873. /** Gets or sets the texture format to use */
  122874. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  122875. /**
  122876. * Update the texture with new data
  122877. * @param data defines the data to store in the texture
  122878. */
  122879. update(data: ArrayBufferView): void;
  122880. }
  122881. }
  122882. declare module BABYLON {
  122883. /**
  122884. * Creates a refraction texture used by refraction channel of the standard material.
  122885. * It is like a mirror but to see through a material.
  122886. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  122887. */
  122888. export class RefractionTexture extends RenderTargetTexture {
  122889. /**
  122890. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  122891. * 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.
  122892. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  122893. */
  122894. refractionPlane: Plane;
  122895. /**
  122896. * Define how deep under the surface we should see.
  122897. */
  122898. depth: number;
  122899. /**
  122900. * Creates a refraction texture used by refraction channel of the standard material.
  122901. * It is like a mirror but to see through a material.
  122902. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  122903. * @param name Define the texture name
  122904. * @param size Define the size of the underlying texture
  122905. * @param scene Define the scene the refraction belongs to
  122906. * @param generateMipMaps Define if we need to generate mips level for the refraction
  122907. */
  122908. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  122909. /**
  122910. * Clone the refraction texture.
  122911. * @returns the cloned texture
  122912. */
  122913. clone(): RefractionTexture;
  122914. /**
  122915. * Serialize the texture to a JSON representation you could use in Parse later on
  122916. * @returns the serialized JSON representation
  122917. */
  122918. serialize(): any;
  122919. }
  122920. }
  122921. declare module BABYLON {
  122922. /**
  122923. * Defines the options related to the creation of an HtmlElementTexture
  122924. */
  122925. export interface IHtmlElementTextureOptions {
  122926. /**
  122927. * Defines wether mip maps should be created or not.
  122928. */
  122929. generateMipMaps?: boolean;
  122930. /**
  122931. * Defines the sampling mode of the texture.
  122932. */
  122933. samplingMode?: number;
  122934. /**
  122935. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  122936. */
  122937. engine: Nullable<ThinEngine>;
  122938. /**
  122939. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  122940. */
  122941. scene: Nullable<Scene>;
  122942. }
  122943. /**
  122944. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  122945. * To be as efficient as possible depending on your constraints nothing aside the first upload
  122946. * is automatically managed.
  122947. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  122948. * in your application.
  122949. *
  122950. * As the update is not automatic, you need to call them manually.
  122951. */
  122952. export class HtmlElementTexture extends BaseTexture {
  122953. /**
  122954. * The texture URL.
  122955. */
  122956. element: HTMLVideoElement | HTMLCanvasElement;
  122957. private static readonly DefaultOptions;
  122958. private _textureMatrix;
  122959. private _engine;
  122960. private _isVideo;
  122961. private _generateMipMaps;
  122962. private _samplingMode;
  122963. /**
  122964. * Instantiates a HtmlElementTexture from the following parameters.
  122965. *
  122966. * @param name Defines the name of the texture
  122967. * @param element Defines the video or canvas the texture is filled with
  122968. * @param options Defines the other none mandatory texture creation options
  122969. */
  122970. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  122971. private _createInternalTexture;
  122972. /**
  122973. * Returns the texture matrix used in most of the material.
  122974. */
  122975. getTextureMatrix(): Matrix;
  122976. /**
  122977. * Updates the content of the texture.
  122978. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  122979. */
  122980. update(invertY?: Nullable<boolean>): void;
  122981. }
  122982. }
  122983. declare module BABYLON {
  122984. /**
  122985. * Enum used to define the target of a block
  122986. */
  122987. export enum NodeMaterialBlockTargets {
  122988. /** Vertex shader */
  122989. Vertex = 1,
  122990. /** Fragment shader */
  122991. Fragment = 2,
  122992. /** Neutral */
  122993. Neutral = 4,
  122994. /** Vertex and Fragment */
  122995. VertexAndFragment = 3
  122996. }
  122997. }
  122998. declare module BABYLON {
  122999. /**
  123000. * Defines the kind of connection point for node based material
  123001. */
  123002. export enum NodeMaterialBlockConnectionPointTypes {
  123003. /** Float */
  123004. Float = 1,
  123005. /** Int */
  123006. Int = 2,
  123007. /** Vector2 */
  123008. Vector2 = 4,
  123009. /** Vector3 */
  123010. Vector3 = 8,
  123011. /** Vector4 */
  123012. Vector4 = 16,
  123013. /** Color3 */
  123014. Color3 = 32,
  123015. /** Color4 */
  123016. Color4 = 64,
  123017. /** Matrix */
  123018. Matrix = 128,
  123019. /** Detect type based on connection */
  123020. AutoDetect = 1024,
  123021. /** Output type that will be defined by input type */
  123022. BasedOnInput = 2048
  123023. }
  123024. }
  123025. declare module BABYLON {
  123026. /**
  123027. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  123028. */
  123029. export enum NodeMaterialBlockConnectionPointMode {
  123030. /** Value is an uniform */
  123031. Uniform = 0,
  123032. /** Value is a mesh attribute */
  123033. Attribute = 1,
  123034. /** Value is a varying between vertex and fragment shaders */
  123035. Varying = 2,
  123036. /** Mode is undefined */
  123037. Undefined = 3
  123038. }
  123039. }
  123040. declare module BABYLON {
  123041. /**
  123042. * Enum used to define system values e.g. values automatically provided by the system
  123043. */
  123044. export enum NodeMaterialSystemValues {
  123045. /** World */
  123046. World = 1,
  123047. /** View */
  123048. View = 2,
  123049. /** Projection */
  123050. Projection = 3,
  123051. /** ViewProjection */
  123052. ViewProjection = 4,
  123053. /** WorldView */
  123054. WorldView = 5,
  123055. /** WorldViewProjection */
  123056. WorldViewProjection = 6,
  123057. /** CameraPosition */
  123058. CameraPosition = 7,
  123059. /** Fog Color */
  123060. FogColor = 8,
  123061. /** Delta time */
  123062. DeltaTime = 9
  123063. }
  123064. }
  123065. declare module BABYLON {
  123066. /**
  123067. * Root class for all node material optimizers
  123068. */
  123069. export class NodeMaterialOptimizer {
  123070. /**
  123071. * Function used to optimize a NodeMaterial graph
  123072. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  123073. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  123074. */
  123075. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  123076. }
  123077. }
  123078. declare module BABYLON {
  123079. /**
  123080. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  123081. */
  123082. export class TransformBlock extends NodeMaterialBlock {
  123083. /**
  123084. * Defines the value to use to complement W value to transform it to a Vector4
  123085. */
  123086. complementW: number;
  123087. /**
  123088. * Defines the value to use to complement z value to transform it to a Vector4
  123089. */
  123090. complementZ: number;
  123091. /**
  123092. * Creates a new TransformBlock
  123093. * @param name defines the block name
  123094. */
  123095. constructor(name: string);
  123096. /**
  123097. * Gets the current class name
  123098. * @returns the class name
  123099. */
  123100. getClassName(): string;
  123101. /**
  123102. * Gets the vector input
  123103. */
  123104. readonly vector: NodeMaterialConnectionPoint;
  123105. /**
  123106. * Gets the output component
  123107. */
  123108. readonly output: NodeMaterialConnectionPoint;
  123109. /**
  123110. * Gets the matrix transform input
  123111. */
  123112. readonly transform: NodeMaterialConnectionPoint;
  123113. protected _buildBlock(state: NodeMaterialBuildState): this;
  123114. serialize(): any;
  123115. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123116. protected _dumpPropertiesCode(): string;
  123117. }
  123118. }
  123119. declare module BABYLON {
  123120. /**
  123121. * Block used to output the vertex position
  123122. */
  123123. export class VertexOutputBlock extends NodeMaterialBlock {
  123124. /**
  123125. * Creates a new VertexOutputBlock
  123126. * @param name defines the block name
  123127. */
  123128. constructor(name: string);
  123129. /**
  123130. * Gets the current class name
  123131. * @returns the class name
  123132. */
  123133. getClassName(): string;
  123134. /**
  123135. * Gets the vector input component
  123136. */
  123137. readonly vector: NodeMaterialConnectionPoint;
  123138. protected _buildBlock(state: NodeMaterialBuildState): this;
  123139. }
  123140. }
  123141. declare module BABYLON {
  123142. /**
  123143. * Block used to output the final color
  123144. */
  123145. export class FragmentOutputBlock extends NodeMaterialBlock {
  123146. /**
  123147. * Create a new FragmentOutputBlock
  123148. * @param name defines the block name
  123149. */
  123150. constructor(name: string);
  123151. /**
  123152. * Gets the current class name
  123153. * @returns the class name
  123154. */
  123155. getClassName(): string;
  123156. /**
  123157. * Gets the rgba input component
  123158. */
  123159. readonly rgba: NodeMaterialConnectionPoint;
  123160. /**
  123161. * Gets the rgb input component
  123162. */
  123163. readonly rgb: NodeMaterialConnectionPoint;
  123164. /**
  123165. * Gets the a input component
  123166. */
  123167. readonly a: NodeMaterialConnectionPoint;
  123168. protected _buildBlock(state: NodeMaterialBuildState): this;
  123169. }
  123170. }
  123171. declare module BABYLON {
  123172. /**
  123173. * Block used to read a reflection texture from a sampler
  123174. */
  123175. export class ReflectionTextureBlock extends NodeMaterialBlock {
  123176. private _define3DName;
  123177. private _defineCubicName;
  123178. private _defineExplicitName;
  123179. private _defineProjectionName;
  123180. private _defineLocalCubicName;
  123181. private _defineSphericalName;
  123182. private _definePlanarName;
  123183. private _defineEquirectangularName;
  123184. private _defineMirroredEquirectangularFixedName;
  123185. private _defineEquirectangularFixedName;
  123186. private _defineSkyboxName;
  123187. private _cubeSamplerName;
  123188. private _2DSamplerName;
  123189. private _positionUVWName;
  123190. private _directionWName;
  123191. private _reflectionCoordsName;
  123192. private _reflection2DCoordsName;
  123193. private _reflectionColorName;
  123194. private _reflectionMatrixName;
  123195. /**
  123196. * Gets or sets the texture associated with the node
  123197. */
  123198. texture: Nullable<BaseTexture>;
  123199. /**
  123200. * Create a new TextureBlock
  123201. * @param name defines the block name
  123202. */
  123203. constructor(name: string);
  123204. /**
  123205. * Gets the current class name
  123206. * @returns the class name
  123207. */
  123208. getClassName(): string;
  123209. /**
  123210. * Gets the world position input component
  123211. */
  123212. readonly position: NodeMaterialConnectionPoint;
  123213. /**
  123214. * Gets the world position input component
  123215. */
  123216. readonly worldPosition: NodeMaterialConnectionPoint;
  123217. /**
  123218. * Gets the world normal input component
  123219. */
  123220. readonly worldNormal: NodeMaterialConnectionPoint;
  123221. /**
  123222. * Gets the world input component
  123223. */
  123224. readonly world: NodeMaterialConnectionPoint;
  123225. /**
  123226. * Gets the camera (or eye) position component
  123227. */
  123228. readonly cameraPosition: NodeMaterialConnectionPoint;
  123229. /**
  123230. * Gets the view input component
  123231. */
  123232. readonly view: NodeMaterialConnectionPoint;
  123233. /**
  123234. * Gets the rgb output component
  123235. */
  123236. readonly rgb: NodeMaterialConnectionPoint;
  123237. /**
  123238. * Gets the r output component
  123239. */
  123240. readonly r: NodeMaterialConnectionPoint;
  123241. /**
  123242. * Gets the g output component
  123243. */
  123244. readonly g: NodeMaterialConnectionPoint;
  123245. /**
  123246. * Gets the b output component
  123247. */
  123248. readonly b: NodeMaterialConnectionPoint;
  123249. autoConfigure(material: NodeMaterial): void;
  123250. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  123251. isReady(): boolean;
  123252. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  123253. private _injectVertexCode;
  123254. private _writeOutput;
  123255. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  123256. protected _dumpPropertiesCode(): string;
  123257. serialize(): any;
  123258. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123259. }
  123260. }
  123261. declare module BABYLON {
  123262. /**
  123263. * Interface used to configure the node material editor
  123264. */
  123265. export interface INodeMaterialEditorOptions {
  123266. /** Define the URl to load node editor script */
  123267. editorURL?: string;
  123268. }
  123269. /** @hidden */
  123270. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  123271. /** BONES */
  123272. NUM_BONE_INFLUENCERS: number;
  123273. BonesPerMesh: number;
  123274. BONETEXTURE: boolean;
  123275. /** MORPH TARGETS */
  123276. MORPHTARGETS: boolean;
  123277. MORPHTARGETS_NORMAL: boolean;
  123278. MORPHTARGETS_TANGENT: boolean;
  123279. MORPHTARGETS_UV: boolean;
  123280. NUM_MORPH_INFLUENCERS: number;
  123281. /** IMAGE PROCESSING */
  123282. IMAGEPROCESSING: boolean;
  123283. VIGNETTE: boolean;
  123284. VIGNETTEBLENDMODEMULTIPLY: boolean;
  123285. VIGNETTEBLENDMODEOPAQUE: boolean;
  123286. TONEMAPPING: boolean;
  123287. TONEMAPPING_ACES: boolean;
  123288. CONTRAST: boolean;
  123289. EXPOSURE: boolean;
  123290. COLORCURVES: boolean;
  123291. COLORGRADING: boolean;
  123292. COLORGRADING3D: boolean;
  123293. SAMPLER3DGREENDEPTH: boolean;
  123294. SAMPLER3DBGRMAP: boolean;
  123295. IMAGEPROCESSINGPOSTPROCESS: boolean;
  123296. /** MISC. */
  123297. BUMPDIRECTUV: number;
  123298. constructor();
  123299. setValue(name: string, value: boolean): void;
  123300. }
  123301. /**
  123302. * Class used to configure NodeMaterial
  123303. */
  123304. export interface INodeMaterialOptions {
  123305. /**
  123306. * Defines if blocks should emit comments
  123307. */
  123308. emitComments: boolean;
  123309. }
  123310. /**
  123311. * Class used to create a node based material built by assembling shader blocks
  123312. */
  123313. export class NodeMaterial extends PushMaterial {
  123314. private static _BuildIdGenerator;
  123315. private _options;
  123316. private _vertexCompilationState;
  123317. private _fragmentCompilationState;
  123318. private _sharedData;
  123319. private _buildId;
  123320. private _buildWasSuccessful;
  123321. private _cachedWorldViewMatrix;
  123322. private _cachedWorldViewProjectionMatrix;
  123323. private _optimizers;
  123324. private _animationFrame;
  123325. /** Define the URl to load node editor script */
  123326. static EditorURL: string;
  123327. private BJSNODEMATERIALEDITOR;
  123328. /** Get the inspector from bundle or global */
  123329. private _getGlobalNodeMaterialEditor;
  123330. /**
  123331. * Gets or sets data used by visual editor
  123332. * @see https://nme.babylonjs.com
  123333. */
  123334. editorData: any;
  123335. /**
  123336. * Gets or sets a boolean indicating that alpha value must be ignored (This will turn alpha blending off even if an alpha value is produced by the material)
  123337. */
  123338. ignoreAlpha: boolean;
  123339. /**
  123340. * Defines the maximum number of lights that can be used in the material
  123341. */
  123342. maxSimultaneousLights: number;
  123343. /**
  123344. * Observable raised when the material is built
  123345. */
  123346. onBuildObservable: Observable<NodeMaterial>;
  123347. /**
  123348. * Gets or sets the root nodes of the material vertex shader
  123349. */
  123350. _vertexOutputNodes: NodeMaterialBlock[];
  123351. /**
  123352. * Gets or sets the root nodes of the material fragment (pixel) shader
  123353. */
  123354. _fragmentOutputNodes: NodeMaterialBlock[];
  123355. /** Gets or sets options to control the node material overall behavior */
  123356. options: INodeMaterialOptions;
  123357. /**
  123358. * Default configuration related to image processing available in the standard Material.
  123359. */
  123360. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  123361. /**
  123362. * Gets the image processing configuration used either in this material.
  123363. */
  123364. /**
  123365. * Sets the Default image processing configuration used either in the this material.
  123366. *
  123367. * If sets to null, the scene one is in use.
  123368. */
  123369. imageProcessingConfiguration: ImageProcessingConfiguration;
  123370. /**
  123371. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  123372. */
  123373. attachedBlocks: NodeMaterialBlock[];
  123374. /**
  123375. * Create a new node based material
  123376. * @param name defines the material name
  123377. * @param scene defines the hosting scene
  123378. * @param options defines creation option
  123379. */
  123380. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  123381. /**
  123382. * Gets the current class name of the material e.g. "NodeMaterial"
  123383. * @returns the class name
  123384. */
  123385. getClassName(): string;
  123386. /**
  123387. * Keep track of the image processing observer to allow dispose and replace.
  123388. */
  123389. private _imageProcessingObserver;
  123390. /**
  123391. * Attaches a new image processing configuration to the Standard Material.
  123392. * @param configuration
  123393. */
  123394. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  123395. /**
  123396. * Get a block by its name
  123397. * @param name defines the name of the block to retrieve
  123398. * @returns the required block or null if not found
  123399. */
  123400. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  123401. /**
  123402. * Get a block by its name
  123403. * @param predicate defines the predicate used to find the good candidate
  123404. * @returns the required block or null if not found
  123405. */
  123406. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  123407. /**
  123408. * Get an input block by its name
  123409. * @param predicate defines the predicate used to find the good candidate
  123410. * @returns the required input block or null if not found
  123411. */
  123412. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  123413. /**
  123414. * Gets the list of input blocks attached to this material
  123415. * @returns an array of InputBlocks
  123416. */
  123417. getInputBlocks(): InputBlock[];
  123418. /**
  123419. * Adds a new optimizer to the list of optimizers
  123420. * @param optimizer defines the optimizers to add
  123421. * @returns the current material
  123422. */
  123423. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  123424. /**
  123425. * Remove an optimizer from the list of optimizers
  123426. * @param optimizer defines the optimizers to remove
  123427. * @returns the current material
  123428. */
  123429. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  123430. /**
  123431. * Add a new block to the list of output nodes
  123432. * @param node defines the node to add
  123433. * @returns the current material
  123434. */
  123435. addOutputNode(node: NodeMaterialBlock): this;
  123436. /**
  123437. * Remove a block from the list of root nodes
  123438. * @param node defines the node to remove
  123439. * @returns the current material
  123440. */
  123441. removeOutputNode(node: NodeMaterialBlock): this;
  123442. private _addVertexOutputNode;
  123443. private _removeVertexOutputNode;
  123444. private _addFragmentOutputNode;
  123445. private _removeFragmentOutputNode;
  123446. /**
  123447. * Specifies if the material will require alpha blending
  123448. * @returns a boolean specifying if alpha blending is needed
  123449. */
  123450. needAlphaBlending(): boolean;
  123451. /**
  123452. * Specifies if this material should be rendered in alpha test mode
  123453. * @returns a boolean specifying if an alpha test is needed.
  123454. */
  123455. needAlphaTesting(): boolean;
  123456. private _initializeBlock;
  123457. private _resetDualBlocks;
  123458. /**
  123459. * Remove a block from the current node material
  123460. * @param block defines the block to remove
  123461. */
  123462. removeBlock(block: NodeMaterialBlock): void;
  123463. /**
  123464. * Build the material and generates the inner effect
  123465. * @param verbose defines if the build should log activity
  123466. */
  123467. build(verbose?: boolean): void;
  123468. /**
  123469. * Runs an otpimization phase to try to improve the shader code
  123470. */
  123471. optimize(): void;
  123472. private _prepareDefinesForAttributes;
  123473. /**
  123474. * Get if the submesh is ready to be used and all its information available.
  123475. * Child classes can use it to update shaders
  123476. * @param mesh defines the mesh to check
  123477. * @param subMesh defines which submesh to check
  123478. * @param useInstances specifies that instances should be used
  123479. * @returns a boolean indicating that the submesh is ready or not
  123480. */
  123481. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  123482. /**
  123483. * Get a string representing the shaders built by the current node graph
  123484. */
  123485. readonly compiledShaders: string;
  123486. /**
  123487. * Binds the world matrix to the material
  123488. * @param world defines the world transformation matrix
  123489. */
  123490. bindOnlyWorldMatrix(world: Matrix): void;
  123491. /**
  123492. * Binds the submesh to this material by preparing the effect and shader to draw
  123493. * @param world defines the world transformation matrix
  123494. * @param mesh defines the mesh containing the submesh
  123495. * @param subMesh defines the submesh to bind the material to
  123496. */
  123497. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  123498. /**
  123499. * Gets the active textures from the material
  123500. * @returns an array of textures
  123501. */
  123502. getActiveTextures(): BaseTexture[];
  123503. /**
  123504. * Gets the list of texture blocks
  123505. * @returns an array of texture blocks
  123506. */
  123507. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  123508. /**
  123509. * Specifies if the material uses a texture
  123510. * @param texture defines the texture to check against the material
  123511. * @returns a boolean specifying if the material uses the texture
  123512. */
  123513. hasTexture(texture: BaseTexture): boolean;
  123514. /**
  123515. * Disposes the material
  123516. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  123517. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  123518. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  123519. */
  123520. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  123521. /** Creates the node editor window. */
  123522. private _createNodeEditor;
  123523. /**
  123524. * Launch the node material editor
  123525. * @param config Define the configuration of the editor
  123526. * @return a promise fulfilled when the node editor is visible
  123527. */
  123528. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  123529. /**
  123530. * Clear the current material
  123531. */
  123532. clear(): void;
  123533. /**
  123534. * Clear the current material and set it to a default state
  123535. */
  123536. setToDefault(): void;
  123537. /**
  123538. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  123539. * @param url defines the url to load from
  123540. * @returns a promise that will fullfil when the material is fully loaded
  123541. */
  123542. loadAsync(url: string): Promise<void>;
  123543. private _gatherBlocks;
  123544. /**
  123545. * Generate a string containing the code declaration required to create an equivalent of this material
  123546. * @returns a string
  123547. */
  123548. generateCode(): string;
  123549. /**
  123550. * Serializes this material in a JSON representation
  123551. * @returns the serialized material object
  123552. */
  123553. serialize(): any;
  123554. private _restoreConnections;
  123555. /**
  123556. * Clear the current graph and load a new one from a serialization object
  123557. * @param source defines the JSON representation of the material
  123558. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  123559. */
  123560. loadFromSerialization(source: any, rootUrl?: string): void;
  123561. /**
  123562. * Creates a node material from parsed material data
  123563. * @param source defines the JSON representation of the material
  123564. * @param scene defines the hosting scene
  123565. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  123566. * @returns a new node material
  123567. */
  123568. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  123569. /**
  123570. * Creates a new node material set to default basic configuration
  123571. * @param name defines the name of the material
  123572. * @param scene defines the hosting scene
  123573. * @returns a new NodeMaterial
  123574. */
  123575. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  123576. }
  123577. }
  123578. declare module BABYLON {
  123579. /**
  123580. * Block used to read a texture from a sampler
  123581. */
  123582. export class TextureBlock extends NodeMaterialBlock {
  123583. private _defineName;
  123584. private _linearDefineName;
  123585. private _tempTextureRead;
  123586. private _samplerName;
  123587. private _transformedUVName;
  123588. private _textureTransformName;
  123589. private _textureInfoName;
  123590. private _mainUVName;
  123591. private _mainUVDefineName;
  123592. /**
  123593. * Gets or sets the texture associated with the node
  123594. */
  123595. texture: Nullable<Texture>;
  123596. /**
  123597. * Create a new TextureBlock
  123598. * @param name defines the block name
  123599. */
  123600. constructor(name: string);
  123601. /**
  123602. * Gets the current class name
  123603. * @returns the class name
  123604. */
  123605. getClassName(): string;
  123606. /**
  123607. * Gets the uv input component
  123608. */
  123609. readonly uv: NodeMaterialConnectionPoint;
  123610. /**
  123611. * Gets the rgba output component
  123612. */
  123613. readonly rgba: NodeMaterialConnectionPoint;
  123614. /**
  123615. * Gets the rgb output component
  123616. */
  123617. readonly rgb: NodeMaterialConnectionPoint;
  123618. /**
  123619. * Gets the r output component
  123620. */
  123621. readonly r: NodeMaterialConnectionPoint;
  123622. /**
  123623. * Gets the g output component
  123624. */
  123625. readonly g: NodeMaterialConnectionPoint;
  123626. /**
  123627. * Gets the b output component
  123628. */
  123629. readonly b: NodeMaterialConnectionPoint;
  123630. /**
  123631. * Gets the a output component
  123632. */
  123633. readonly a: NodeMaterialConnectionPoint;
  123634. readonly target: NodeMaterialBlockTargets;
  123635. autoConfigure(material: NodeMaterial): void;
  123636. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  123637. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  123638. private _getTextureBase;
  123639. isReady(): boolean;
  123640. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  123641. private readonly _isMixed;
  123642. private _injectVertexCode;
  123643. private _writeTextureRead;
  123644. private _writeOutput;
  123645. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  123646. protected _dumpPropertiesCode(): string;
  123647. serialize(): any;
  123648. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123649. }
  123650. }
  123651. declare module BABYLON {
  123652. /**
  123653. * Class used to store shared data between 2 NodeMaterialBuildState
  123654. */
  123655. export class NodeMaterialBuildStateSharedData {
  123656. /**
  123657. * Gets the list of emitted varyings
  123658. */
  123659. temps: string[];
  123660. /**
  123661. * Gets the list of emitted varyings
  123662. */
  123663. varyings: string[];
  123664. /**
  123665. * Gets the varying declaration string
  123666. */
  123667. varyingDeclaration: string;
  123668. /**
  123669. * Input blocks
  123670. */
  123671. inputBlocks: InputBlock[];
  123672. /**
  123673. * Input blocks
  123674. */
  123675. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  123676. /**
  123677. * Bindable blocks (Blocks that need to set data to the effect)
  123678. */
  123679. bindableBlocks: NodeMaterialBlock[];
  123680. /**
  123681. * List of blocks that can provide a compilation fallback
  123682. */
  123683. blocksWithFallbacks: NodeMaterialBlock[];
  123684. /**
  123685. * List of blocks that can provide a define update
  123686. */
  123687. blocksWithDefines: NodeMaterialBlock[];
  123688. /**
  123689. * List of blocks that can provide a repeatable content
  123690. */
  123691. repeatableContentBlocks: NodeMaterialBlock[];
  123692. /**
  123693. * List of blocks that can provide a dynamic list of uniforms
  123694. */
  123695. dynamicUniformBlocks: NodeMaterialBlock[];
  123696. /**
  123697. * List of blocks that can block the isReady function for the material
  123698. */
  123699. blockingBlocks: NodeMaterialBlock[];
  123700. /**
  123701. * Gets the list of animated inputs
  123702. */
  123703. animatedInputs: InputBlock[];
  123704. /**
  123705. * Build Id used to avoid multiple recompilations
  123706. */
  123707. buildId: number;
  123708. /** List of emitted variables */
  123709. variableNames: {
  123710. [key: string]: number;
  123711. };
  123712. /** List of emitted defines */
  123713. defineNames: {
  123714. [key: string]: number;
  123715. };
  123716. /** Should emit comments? */
  123717. emitComments: boolean;
  123718. /** Emit build activity */
  123719. verbose: boolean;
  123720. /** Gets or sets the hosting scene */
  123721. scene: Scene;
  123722. /**
  123723. * Gets the compilation hints emitted at compilation time
  123724. */
  123725. hints: {
  123726. needWorldViewMatrix: boolean;
  123727. needWorldViewProjectionMatrix: boolean;
  123728. needAlphaBlending: boolean;
  123729. needAlphaTesting: boolean;
  123730. };
  123731. /**
  123732. * List of compilation checks
  123733. */
  123734. checks: {
  123735. emitVertex: boolean;
  123736. emitFragment: boolean;
  123737. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  123738. };
  123739. /** Creates a new shared data */
  123740. constructor();
  123741. /**
  123742. * Emits console errors and exceptions if there is a failing check
  123743. */
  123744. emitErrors(): void;
  123745. }
  123746. }
  123747. declare module BABYLON {
  123748. /**
  123749. * Class used to store node based material build state
  123750. */
  123751. export class NodeMaterialBuildState {
  123752. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  123753. supportUniformBuffers: boolean;
  123754. /**
  123755. * Gets the list of emitted attributes
  123756. */
  123757. attributes: string[];
  123758. /**
  123759. * Gets the list of emitted uniforms
  123760. */
  123761. uniforms: string[];
  123762. /**
  123763. * Gets the list of emitted constants
  123764. */
  123765. constants: string[];
  123766. /**
  123767. * Gets the list of emitted samplers
  123768. */
  123769. samplers: string[];
  123770. /**
  123771. * Gets the list of emitted functions
  123772. */
  123773. functions: {
  123774. [key: string]: string;
  123775. };
  123776. /**
  123777. * Gets the list of emitted extensions
  123778. */
  123779. extensions: {
  123780. [key: string]: string;
  123781. };
  123782. /**
  123783. * Gets the target of the compilation state
  123784. */
  123785. target: NodeMaterialBlockTargets;
  123786. /**
  123787. * Gets the list of emitted counters
  123788. */
  123789. counters: {
  123790. [key: string]: number;
  123791. };
  123792. /**
  123793. * Shared data between multiple NodeMaterialBuildState instances
  123794. */
  123795. sharedData: NodeMaterialBuildStateSharedData;
  123796. /** @hidden */
  123797. _vertexState: NodeMaterialBuildState;
  123798. /** @hidden */
  123799. _attributeDeclaration: string;
  123800. /** @hidden */
  123801. _uniformDeclaration: string;
  123802. /** @hidden */
  123803. _constantDeclaration: string;
  123804. /** @hidden */
  123805. _samplerDeclaration: string;
  123806. /** @hidden */
  123807. _varyingTransfer: string;
  123808. private _repeatableContentAnchorIndex;
  123809. /** @hidden */
  123810. _builtCompilationString: string;
  123811. /**
  123812. * Gets the emitted compilation strings
  123813. */
  123814. compilationString: string;
  123815. /**
  123816. * Finalize the compilation strings
  123817. * @param state defines the current compilation state
  123818. */
  123819. finalize(state: NodeMaterialBuildState): void;
  123820. /** @hidden */
  123821. readonly _repeatableContentAnchor: string;
  123822. /** @hidden */
  123823. _getFreeVariableName(prefix: string): string;
  123824. /** @hidden */
  123825. _getFreeDefineName(prefix: string): string;
  123826. /** @hidden */
  123827. _excludeVariableName(name: string): void;
  123828. /** @hidden */
  123829. _emit2DSampler(name: string): void;
  123830. /** @hidden */
  123831. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  123832. /** @hidden */
  123833. _emitExtension(name: string, extension: string): void;
  123834. /** @hidden */
  123835. _emitFunction(name: string, code: string, comments: string): void;
  123836. /** @hidden */
  123837. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  123838. replaceStrings?: {
  123839. search: RegExp;
  123840. replace: string;
  123841. }[];
  123842. repeatKey?: string;
  123843. }): string;
  123844. /** @hidden */
  123845. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  123846. repeatKey?: string;
  123847. removeAttributes?: boolean;
  123848. removeUniforms?: boolean;
  123849. removeVaryings?: boolean;
  123850. removeIfDef?: boolean;
  123851. replaceStrings?: {
  123852. search: RegExp;
  123853. replace: string;
  123854. }[];
  123855. }, storeKey?: string): void;
  123856. /** @hidden */
  123857. _registerTempVariable(name: string): boolean;
  123858. /** @hidden */
  123859. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  123860. /** @hidden */
  123861. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  123862. /** @hidden */
  123863. _emitFloat(value: number): string;
  123864. }
  123865. }
  123866. declare module BABYLON {
  123867. /**
  123868. * Defines a block that can be used inside a node based material
  123869. */
  123870. export class NodeMaterialBlock {
  123871. private _buildId;
  123872. private _buildTarget;
  123873. private _target;
  123874. private _isFinalMerger;
  123875. private _isInput;
  123876. protected _isUnique: boolean;
  123877. /** @hidden */
  123878. _codeVariableName: string;
  123879. /** @hidden */
  123880. _inputs: NodeMaterialConnectionPoint[];
  123881. /** @hidden */
  123882. _outputs: NodeMaterialConnectionPoint[];
  123883. /** @hidden */
  123884. _preparationId: number;
  123885. /**
  123886. * Gets or sets the name of the block
  123887. */
  123888. name: string;
  123889. /**
  123890. * Gets or sets the unique id of the node
  123891. */
  123892. uniqueId: number;
  123893. /**
  123894. * Gets or sets the comments associated with this block
  123895. */
  123896. comments: string;
  123897. /**
  123898. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  123899. */
  123900. readonly isUnique: boolean;
  123901. /**
  123902. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  123903. */
  123904. readonly isFinalMerger: boolean;
  123905. /**
  123906. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  123907. */
  123908. readonly isInput: boolean;
  123909. /**
  123910. * Gets or sets the build Id
  123911. */
  123912. buildId: number;
  123913. /**
  123914. * Gets or sets the target of the block
  123915. */
  123916. target: NodeMaterialBlockTargets;
  123917. /**
  123918. * Gets the list of input points
  123919. */
  123920. readonly inputs: NodeMaterialConnectionPoint[];
  123921. /** Gets the list of output points */
  123922. readonly outputs: NodeMaterialConnectionPoint[];
  123923. /**
  123924. * Find an input by its name
  123925. * @param name defines the name of the input to look for
  123926. * @returns the input or null if not found
  123927. */
  123928. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  123929. /**
  123930. * Find an output by its name
  123931. * @param name defines the name of the outputto look for
  123932. * @returns the output or null if not found
  123933. */
  123934. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  123935. /**
  123936. * Creates a new NodeMaterialBlock
  123937. * @param name defines the block name
  123938. * @param target defines the target of that block (Vertex by default)
  123939. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  123940. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  123941. */
  123942. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  123943. /**
  123944. * Initialize the block and prepare the context for build
  123945. * @param state defines the state that will be used for the build
  123946. */
  123947. initialize(state: NodeMaterialBuildState): void;
  123948. /**
  123949. * Bind data to effect. Will only be called for blocks with isBindable === true
  123950. * @param effect defines the effect to bind data to
  123951. * @param nodeMaterial defines the hosting NodeMaterial
  123952. * @param mesh defines the mesh that will be rendered
  123953. */
  123954. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  123955. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  123956. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  123957. protected _writeFloat(value: number): string;
  123958. /**
  123959. * Gets the current class name e.g. "NodeMaterialBlock"
  123960. * @returns the class name
  123961. */
  123962. getClassName(): string;
  123963. /**
  123964. * Register a new input. Must be called inside a block constructor
  123965. * @param name defines the connection point name
  123966. * @param type defines the connection point type
  123967. * @param isOptional defines a boolean indicating that this input can be omitted
  123968. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  123969. * @returns the current block
  123970. */
  123971. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  123972. /**
  123973. * Register a new output. Must be called inside a block constructor
  123974. * @param name defines the connection point name
  123975. * @param type defines the connection point type
  123976. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  123977. * @returns the current block
  123978. */
  123979. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  123980. /**
  123981. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  123982. * @param forOutput defines an optional connection point to check compatibility with
  123983. * @returns the first available input or null
  123984. */
  123985. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  123986. /**
  123987. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  123988. * @param forBlock defines an optional block to check compatibility with
  123989. * @returns the first available input or null
  123990. */
  123991. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  123992. /**
  123993. * Gets the sibling of the given output
  123994. * @param current defines the current output
  123995. * @returns the next output in the list or null
  123996. */
  123997. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  123998. /**
  123999. * Connect current block with another block
  124000. * @param other defines the block to connect with
  124001. * @param options define the various options to help pick the right connections
  124002. * @returns the current block
  124003. */
  124004. connectTo(other: NodeMaterialBlock, options?: {
  124005. input?: string;
  124006. output?: string;
  124007. outputSwizzle?: string;
  124008. }): this | undefined;
  124009. protected _buildBlock(state: NodeMaterialBuildState): void;
  124010. /**
  124011. * Add uniforms, samplers and uniform buffers at compilation time
  124012. * @param state defines the state to update
  124013. * @param nodeMaterial defines the node material requesting the update
  124014. * @param defines defines the material defines to update
  124015. * @param uniformBuffers defines the list of uniform buffer names
  124016. */
  124017. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  124018. /**
  124019. * Add potential fallbacks if shader compilation fails
  124020. * @param mesh defines the mesh to be rendered
  124021. * @param fallbacks defines the current prioritized list of fallbacks
  124022. */
  124023. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  124024. /**
  124025. * Initialize defines for shader compilation
  124026. * @param mesh defines the mesh to be rendered
  124027. * @param nodeMaterial defines the node material requesting the update
  124028. * @param defines defines the material defines to update
  124029. * @param useInstances specifies that instances should be used
  124030. */
  124031. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  124032. /**
  124033. * Update defines for shader compilation
  124034. * @param mesh defines the mesh to be rendered
  124035. * @param nodeMaterial defines the node material requesting the update
  124036. * @param defines defines the material defines to update
  124037. * @param useInstances specifies that instances should be used
  124038. */
  124039. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  124040. /**
  124041. * Lets the block try to connect some inputs automatically
  124042. * @param material defines the hosting NodeMaterial
  124043. */
  124044. autoConfigure(material: NodeMaterial): void;
  124045. /**
  124046. * Function called when a block is declared as repeatable content generator
  124047. * @param vertexShaderState defines the current compilation state for the vertex shader
  124048. * @param fragmentShaderState defines the current compilation state for the fragment shader
  124049. * @param mesh defines the mesh to be rendered
  124050. * @param defines defines the material defines to update
  124051. */
  124052. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  124053. /**
  124054. * Checks if the block is ready
  124055. * @param mesh defines the mesh to be rendered
  124056. * @param nodeMaterial defines the node material requesting the update
  124057. * @param defines defines the material defines to update
  124058. * @param useInstances specifies that instances should be used
  124059. * @returns true if the block is ready
  124060. */
  124061. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  124062. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  124063. private _processBuild;
  124064. /**
  124065. * Compile the current node and generate the shader code
  124066. * @param state defines the current compilation state (uniforms, samplers, current string)
  124067. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  124068. * @returns true if already built
  124069. */
  124070. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  124071. protected _inputRename(name: string): string;
  124072. protected _outputRename(name: string): string;
  124073. protected _dumpPropertiesCode(): string;
  124074. /** @hidden */
  124075. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  124076. /** @hidden */
  124077. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  124078. /**
  124079. * Clone the current block to a new identical block
  124080. * @param scene defines the hosting scene
  124081. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  124082. * @returns a copy of the current block
  124083. */
  124084. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  124085. /**
  124086. * Serializes this block in a JSON representation
  124087. * @returns the serialized block object
  124088. */
  124089. serialize(): any;
  124090. /** @hidden */
  124091. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124092. /**
  124093. * Release resources
  124094. */
  124095. dispose(): void;
  124096. }
  124097. }
  124098. declare module BABYLON {
  124099. /**
  124100. * Enum defining the type of animations supported by InputBlock
  124101. */
  124102. export enum AnimatedInputBlockTypes {
  124103. /** No animation */
  124104. None = 0,
  124105. /** Time based animation. Will only work for floats */
  124106. Time = 1
  124107. }
  124108. }
  124109. declare module BABYLON {
  124110. /**
  124111. * Block used to expose an input value
  124112. */
  124113. export class InputBlock extends NodeMaterialBlock {
  124114. private _mode;
  124115. private _associatedVariableName;
  124116. private _storedValue;
  124117. private _valueCallback;
  124118. private _type;
  124119. private _animationType;
  124120. /** Gets or set a value used to limit the range of float values */
  124121. min: number;
  124122. /** Gets or set a value used to limit the range of float values */
  124123. max: number;
  124124. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  124125. matrixMode: number;
  124126. /** @hidden */
  124127. _systemValue: Nullable<NodeMaterialSystemValues>;
  124128. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  124129. visibleInInspector: boolean;
  124130. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  124131. isConstant: boolean;
  124132. /** Gets or sets the group to use to display this block in the Inspector */
  124133. groupInInspector: string;
  124134. /**
  124135. * Gets or sets the connection point type (default is float)
  124136. */
  124137. readonly type: NodeMaterialBlockConnectionPointTypes;
  124138. /**
  124139. * Creates a new InputBlock
  124140. * @param name defines the block name
  124141. * @param target defines the target of that block (Vertex by default)
  124142. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  124143. */
  124144. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  124145. /**
  124146. * Gets the output component
  124147. */
  124148. readonly output: NodeMaterialConnectionPoint;
  124149. /**
  124150. * Set the source of this connection point to a vertex attribute
  124151. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  124152. * @returns the current connection point
  124153. */
  124154. setAsAttribute(attributeName?: string): InputBlock;
  124155. /**
  124156. * Set the source of this connection point to a system value
  124157. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  124158. * @returns the current connection point
  124159. */
  124160. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  124161. /**
  124162. * Gets or sets the value of that point.
  124163. * Please note that this value will be ignored if valueCallback is defined
  124164. */
  124165. value: any;
  124166. /**
  124167. * Gets or sets a callback used to get the value of that point.
  124168. * Please note that setting this value will force the connection point to ignore the value property
  124169. */
  124170. valueCallback: () => any;
  124171. /**
  124172. * Gets or sets the associated variable name in the shader
  124173. */
  124174. associatedVariableName: string;
  124175. /** Gets or sets the type of animation applied to the input */
  124176. animationType: AnimatedInputBlockTypes;
  124177. /**
  124178. * Gets a boolean indicating that this connection point not defined yet
  124179. */
  124180. readonly isUndefined: boolean;
  124181. /**
  124182. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  124183. * In this case the connection point name must be the name of the uniform to use.
  124184. * Can only be set on inputs
  124185. */
  124186. isUniform: boolean;
  124187. /**
  124188. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  124189. * In this case the connection point name must be the name of the attribute to use
  124190. * Can only be set on inputs
  124191. */
  124192. isAttribute: boolean;
  124193. /**
  124194. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  124195. * Can only be set on exit points
  124196. */
  124197. isVarying: boolean;
  124198. /**
  124199. * Gets a boolean indicating that the current connection point is a system value
  124200. */
  124201. readonly isSystemValue: boolean;
  124202. /**
  124203. * Gets or sets the current well known value or null if not defined as a system value
  124204. */
  124205. systemValue: Nullable<NodeMaterialSystemValues>;
  124206. /**
  124207. * Gets the current class name
  124208. * @returns the class name
  124209. */
  124210. getClassName(): string;
  124211. /**
  124212. * Animate the input if animationType !== None
  124213. * @param scene defines the rendering scene
  124214. */
  124215. animate(scene: Scene): void;
  124216. private _emitDefine;
  124217. initialize(state: NodeMaterialBuildState): void;
  124218. /**
  124219. * Set the input block to its default value (based on its type)
  124220. */
  124221. setDefaultValue(): void;
  124222. private _emitConstant;
  124223. private _emit;
  124224. /** @hidden */
  124225. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  124226. /** @hidden */
  124227. _transmit(effect: Effect, scene: Scene): void;
  124228. protected _buildBlock(state: NodeMaterialBuildState): void;
  124229. protected _dumpPropertiesCode(): string;
  124230. serialize(): any;
  124231. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124232. }
  124233. }
  124234. declare module BABYLON {
  124235. /**
  124236. * Enum used to define the compatibility state between two connection points
  124237. */
  124238. export enum NodeMaterialConnectionPointCompatibilityStates {
  124239. /** Points are compatibles */
  124240. Compatible = 0,
  124241. /** Points are incompatible because of their types */
  124242. TypeIncompatible = 1,
  124243. /** Points are incompatible because of their targets (vertex vs fragment) */
  124244. TargetIncompatible = 2
  124245. }
  124246. /**
  124247. * Defines the direction of a connection point
  124248. */
  124249. export enum NodeMaterialConnectionPointDirection {
  124250. /** Input */
  124251. Input = 0,
  124252. /** Output */
  124253. Output = 1
  124254. }
  124255. /**
  124256. * Defines a connection point for a block
  124257. */
  124258. export class NodeMaterialConnectionPoint {
  124259. /** @hidden */
  124260. _ownerBlock: NodeMaterialBlock;
  124261. /** @hidden */
  124262. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  124263. private _endpoints;
  124264. private _associatedVariableName;
  124265. private _direction;
  124266. /** @hidden */
  124267. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  124268. /** @hidden */
  124269. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  124270. private _type;
  124271. /** @hidden */
  124272. _enforceAssociatedVariableName: boolean;
  124273. /** Gets the direction of the point */
  124274. readonly direction: NodeMaterialConnectionPointDirection;
  124275. /**
  124276. * Gets or sets the additional types supported by this connection point
  124277. */
  124278. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  124279. /**
  124280. * Gets or sets the additional types excluded by this connection point
  124281. */
  124282. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  124283. /**
  124284. * Observable triggered when this point is connected
  124285. */
  124286. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  124287. /**
  124288. * Gets or sets the associated variable name in the shader
  124289. */
  124290. associatedVariableName: string;
  124291. /**
  124292. * Gets or sets the connection point type (default is float)
  124293. */
  124294. type: NodeMaterialBlockConnectionPointTypes;
  124295. /**
  124296. * Gets or sets the connection point name
  124297. */
  124298. name: string;
  124299. /**
  124300. * Gets or sets a boolean indicating that this connection point can be omitted
  124301. */
  124302. isOptional: boolean;
  124303. /**
  124304. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  124305. */
  124306. define: string;
  124307. /** @hidden */
  124308. _prioritizeVertex: boolean;
  124309. private _target;
  124310. /** Gets or sets the target of that connection point */
  124311. target: NodeMaterialBlockTargets;
  124312. /**
  124313. * Gets a boolean indicating that the current point is connected
  124314. */
  124315. readonly isConnected: boolean;
  124316. /**
  124317. * Gets a boolean indicating that the current point is connected to an input block
  124318. */
  124319. readonly isConnectedToInputBlock: boolean;
  124320. /**
  124321. * Gets a the connected input block (if any)
  124322. */
  124323. readonly connectInputBlock: Nullable<InputBlock>;
  124324. /** Get the other side of the connection (if any) */
  124325. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  124326. /** Get the block that owns this connection point */
  124327. readonly ownerBlock: NodeMaterialBlock;
  124328. /** Get the block connected on the other side of this connection (if any) */
  124329. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  124330. /** Get the block connected on the endpoints of this connection (if any) */
  124331. readonly connectedBlocks: Array<NodeMaterialBlock>;
  124332. /** Gets the list of connected endpoints */
  124333. readonly endpoints: NodeMaterialConnectionPoint[];
  124334. /** Gets a boolean indicating if that output point is connected to at least one input */
  124335. readonly hasEndpoints: boolean;
  124336. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  124337. readonly isConnectedInVertexShader: boolean;
  124338. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  124339. readonly isConnectedInFragmentShader: boolean;
  124340. /**
  124341. * Creates a new connection point
  124342. * @param name defines the connection point name
  124343. * @param ownerBlock defines the block hosting this connection point
  124344. * @param direction defines the direction of the connection point
  124345. */
  124346. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  124347. /**
  124348. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  124349. * @returns the class name
  124350. */
  124351. getClassName(): string;
  124352. /**
  124353. * Gets a boolean indicating if the current point can be connected to another point
  124354. * @param connectionPoint defines the other connection point
  124355. * @returns a boolean
  124356. */
  124357. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  124358. /**
  124359. * Gets a number indicating if the current point can be connected to another point
  124360. * @param connectionPoint defines the other connection point
  124361. * @returns a number defining the compatibility state
  124362. */
  124363. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  124364. /**
  124365. * Connect this point to another connection point
  124366. * @param connectionPoint defines the other connection point
  124367. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  124368. * @returns the current connection point
  124369. */
  124370. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  124371. /**
  124372. * Disconnect this point from one of his endpoint
  124373. * @param endpoint defines the other connection point
  124374. * @returns the current connection point
  124375. */
  124376. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  124377. /**
  124378. * Serializes this point in a JSON representation
  124379. * @returns the serialized point object
  124380. */
  124381. serialize(): any;
  124382. /**
  124383. * Release resources
  124384. */
  124385. dispose(): void;
  124386. }
  124387. }
  124388. declare module BABYLON {
  124389. /**
  124390. * Block used to add support for vertex skinning (bones)
  124391. */
  124392. export class BonesBlock extends NodeMaterialBlock {
  124393. /**
  124394. * Creates a new BonesBlock
  124395. * @param name defines the block name
  124396. */
  124397. constructor(name: string);
  124398. /**
  124399. * Initialize the block and prepare the context for build
  124400. * @param state defines the state that will be used for the build
  124401. */
  124402. initialize(state: NodeMaterialBuildState): void;
  124403. /**
  124404. * Gets the current class name
  124405. * @returns the class name
  124406. */
  124407. getClassName(): string;
  124408. /**
  124409. * Gets the matrix indices input component
  124410. */
  124411. readonly matricesIndices: NodeMaterialConnectionPoint;
  124412. /**
  124413. * Gets the matrix weights input component
  124414. */
  124415. readonly matricesWeights: NodeMaterialConnectionPoint;
  124416. /**
  124417. * Gets the extra matrix indices input component
  124418. */
  124419. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  124420. /**
  124421. * Gets the extra matrix weights input component
  124422. */
  124423. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  124424. /**
  124425. * Gets the world input component
  124426. */
  124427. readonly world: NodeMaterialConnectionPoint;
  124428. /**
  124429. * Gets the output component
  124430. */
  124431. readonly output: NodeMaterialConnectionPoint;
  124432. autoConfigure(material: NodeMaterial): void;
  124433. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  124434. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  124435. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  124436. protected _buildBlock(state: NodeMaterialBuildState): this;
  124437. }
  124438. }
  124439. declare module BABYLON {
  124440. /**
  124441. * Block used to add support for instances
  124442. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  124443. */
  124444. export class InstancesBlock extends NodeMaterialBlock {
  124445. /**
  124446. * Creates a new InstancesBlock
  124447. * @param name defines the block name
  124448. */
  124449. constructor(name: string);
  124450. /**
  124451. * Gets the current class name
  124452. * @returns the class name
  124453. */
  124454. getClassName(): string;
  124455. /**
  124456. * Gets the first world row input component
  124457. */
  124458. readonly world0: NodeMaterialConnectionPoint;
  124459. /**
  124460. * Gets the second world row input component
  124461. */
  124462. readonly world1: NodeMaterialConnectionPoint;
  124463. /**
  124464. * Gets the third world row input component
  124465. */
  124466. readonly world2: NodeMaterialConnectionPoint;
  124467. /**
  124468. * Gets the forth world row input component
  124469. */
  124470. readonly world3: NodeMaterialConnectionPoint;
  124471. /**
  124472. * Gets the world input component
  124473. */
  124474. readonly world: NodeMaterialConnectionPoint;
  124475. /**
  124476. * Gets the output component
  124477. */
  124478. readonly output: NodeMaterialConnectionPoint;
  124479. autoConfigure(material: NodeMaterial): void;
  124480. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  124481. protected _buildBlock(state: NodeMaterialBuildState): this;
  124482. }
  124483. }
  124484. declare module BABYLON {
  124485. /**
  124486. * Block used to add morph targets support to vertex shader
  124487. */
  124488. export class MorphTargetsBlock extends NodeMaterialBlock {
  124489. private _repeatableContentAnchor;
  124490. private _repeatebleContentGenerated;
  124491. /**
  124492. * Create a new MorphTargetsBlock
  124493. * @param name defines the block name
  124494. */
  124495. constructor(name: string);
  124496. /**
  124497. * Gets the current class name
  124498. * @returns the class name
  124499. */
  124500. getClassName(): string;
  124501. /**
  124502. * Gets the position input component
  124503. */
  124504. readonly position: NodeMaterialConnectionPoint;
  124505. /**
  124506. * Gets the normal input component
  124507. */
  124508. readonly normal: NodeMaterialConnectionPoint;
  124509. /**
  124510. * Gets the tangent input component
  124511. */
  124512. readonly tangent: NodeMaterialConnectionPoint;
  124513. /**
  124514. * Gets the tangent input component
  124515. */
  124516. readonly uv: NodeMaterialConnectionPoint;
  124517. /**
  124518. * Gets the position output component
  124519. */
  124520. readonly positionOutput: NodeMaterialConnectionPoint;
  124521. /**
  124522. * Gets the normal output component
  124523. */
  124524. readonly normalOutput: NodeMaterialConnectionPoint;
  124525. /**
  124526. * Gets the tangent output component
  124527. */
  124528. readonly tangentOutput: NodeMaterialConnectionPoint;
  124529. /**
  124530. * Gets the tangent output component
  124531. */
  124532. readonly uvOutput: NodeMaterialConnectionPoint;
  124533. initialize(state: NodeMaterialBuildState): void;
  124534. autoConfigure(material: NodeMaterial): void;
  124535. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  124536. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  124537. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  124538. protected _buildBlock(state: NodeMaterialBuildState): this;
  124539. }
  124540. }
  124541. declare module BABYLON {
  124542. /**
  124543. * Block used to get data information from a light
  124544. */
  124545. export class LightInformationBlock extends NodeMaterialBlock {
  124546. private _lightDataUniformName;
  124547. private _lightColorUniformName;
  124548. private _lightTypeDefineName;
  124549. /**
  124550. * Gets or sets the light associated with this block
  124551. */
  124552. light: Nullable<Light>;
  124553. /**
  124554. * Creates a new LightInformationBlock
  124555. * @param name defines the block name
  124556. */
  124557. constructor(name: string);
  124558. /**
  124559. * Gets the current class name
  124560. * @returns the class name
  124561. */
  124562. getClassName(): string;
  124563. /**
  124564. * Gets the world position input component
  124565. */
  124566. readonly worldPosition: NodeMaterialConnectionPoint;
  124567. /**
  124568. * Gets the direction output component
  124569. */
  124570. readonly direction: NodeMaterialConnectionPoint;
  124571. /**
  124572. * Gets the direction output component
  124573. */
  124574. readonly color: NodeMaterialConnectionPoint;
  124575. /**
  124576. * Gets the direction output component
  124577. */
  124578. readonly intensity: NodeMaterialConnectionPoint;
  124579. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  124580. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  124581. protected _buildBlock(state: NodeMaterialBuildState): this;
  124582. serialize(): any;
  124583. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124584. }
  124585. }
  124586. declare module BABYLON {
  124587. /**
  124588. * Block used to add image processing support to fragment shader
  124589. */
  124590. export class ImageProcessingBlock extends NodeMaterialBlock {
  124591. /**
  124592. * Create a new ImageProcessingBlock
  124593. * @param name defines the block name
  124594. */
  124595. constructor(name: string);
  124596. /**
  124597. * Gets the current class name
  124598. * @returns the class name
  124599. */
  124600. getClassName(): string;
  124601. /**
  124602. * Gets the color input component
  124603. */
  124604. readonly color: NodeMaterialConnectionPoint;
  124605. /**
  124606. * Gets the output component
  124607. */
  124608. readonly output: NodeMaterialConnectionPoint;
  124609. /**
  124610. * Initialize the block and prepare the context for build
  124611. * @param state defines the state that will be used for the build
  124612. */
  124613. initialize(state: NodeMaterialBuildState): void;
  124614. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  124615. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  124616. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  124617. protected _buildBlock(state: NodeMaterialBuildState): this;
  124618. }
  124619. }
  124620. declare module BABYLON {
  124621. /**
  124622. * Block used to pertub normals based on a normal map
  124623. */
  124624. export class PerturbNormalBlock extends NodeMaterialBlock {
  124625. private _tangentSpaceParameterName;
  124626. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  124627. invertX: boolean;
  124628. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  124629. invertY: boolean;
  124630. /**
  124631. * Create a new PerturbNormalBlock
  124632. * @param name defines the block name
  124633. */
  124634. constructor(name: string);
  124635. /**
  124636. * Gets the current class name
  124637. * @returns the class name
  124638. */
  124639. getClassName(): string;
  124640. /**
  124641. * Gets the world position input component
  124642. */
  124643. readonly worldPosition: NodeMaterialConnectionPoint;
  124644. /**
  124645. * Gets the world normal input component
  124646. */
  124647. readonly worldNormal: NodeMaterialConnectionPoint;
  124648. /**
  124649. * Gets the uv input component
  124650. */
  124651. readonly uv: NodeMaterialConnectionPoint;
  124652. /**
  124653. * Gets the normal map color input component
  124654. */
  124655. readonly normalMapColor: NodeMaterialConnectionPoint;
  124656. /**
  124657. * Gets the strength input component
  124658. */
  124659. readonly strength: NodeMaterialConnectionPoint;
  124660. /**
  124661. * Gets the output component
  124662. */
  124663. readonly output: NodeMaterialConnectionPoint;
  124664. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  124665. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  124666. autoConfigure(material: NodeMaterial): void;
  124667. protected _buildBlock(state: NodeMaterialBuildState): this;
  124668. protected _dumpPropertiesCode(): string;
  124669. serialize(): any;
  124670. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124671. }
  124672. }
  124673. declare module BABYLON {
  124674. /**
  124675. * Block used to discard a pixel if a value is smaller than a cutoff
  124676. */
  124677. export class DiscardBlock extends NodeMaterialBlock {
  124678. /**
  124679. * Create a new DiscardBlock
  124680. * @param name defines the block name
  124681. */
  124682. constructor(name: string);
  124683. /**
  124684. * Gets the current class name
  124685. * @returns the class name
  124686. */
  124687. getClassName(): string;
  124688. /**
  124689. * Gets the color input component
  124690. */
  124691. readonly value: NodeMaterialConnectionPoint;
  124692. /**
  124693. * Gets the cutoff input component
  124694. */
  124695. readonly cutoff: NodeMaterialConnectionPoint;
  124696. protected _buildBlock(state: NodeMaterialBuildState): this;
  124697. }
  124698. }
  124699. declare module BABYLON {
  124700. /**
  124701. * Block used to test if the fragment shader is front facing
  124702. */
  124703. export class FrontFacingBlock extends NodeMaterialBlock {
  124704. /**
  124705. * Creates a new FrontFacingBlock
  124706. * @param name defines the block name
  124707. */
  124708. constructor(name: string);
  124709. /**
  124710. * Gets the current class name
  124711. * @returns the class name
  124712. */
  124713. getClassName(): string;
  124714. /**
  124715. * Gets the output component
  124716. */
  124717. readonly output: NodeMaterialConnectionPoint;
  124718. protected _buildBlock(state: NodeMaterialBuildState): this;
  124719. }
  124720. }
  124721. declare module BABYLON {
  124722. /**
  124723. * Block used to get the derivative value on x and y of a given input
  124724. */
  124725. export class DerivativeBlock extends NodeMaterialBlock {
  124726. /**
  124727. * Create a new DerivativeBlock
  124728. * @param name defines the block name
  124729. */
  124730. constructor(name: string);
  124731. /**
  124732. * Gets the current class name
  124733. * @returns the class name
  124734. */
  124735. getClassName(): string;
  124736. /**
  124737. * Gets the input component
  124738. */
  124739. readonly input: NodeMaterialConnectionPoint;
  124740. /**
  124741. * Gets the derivative output on x
  124742. */
  124743. readonly dx: NodeMaterialConnectionPoint;
  124744. /**
  124745. * Gets the derivative output on y
  124746. */
  124747. readonly dy: NodeMaterialConnectionPoint;
  124748. protected _buildBlock(state: NodeMaterialBuildState): this;
  124749. }
  124750. }
  124751. declare module BABYLON {
  124752. /**
  124753. * Block used to add support for scene fog
  124754. */
  124755. export class FogBlock extends NodeMaterialBlock {
  124756. private _fogDistanceName;
  124757. private _fogParameters;
  124758. /**
  124759. * Create a new FogBlock
  124760. * @param name defines the block name
  124761. */
  124762. constructor(name: string);
  124763. /**
  124764. * Gets the current class name
  124765. * @returns the class name
  124766. */
  124767. getClassName(): string;
  124768. /**
  124769. * Gets the world position input component
  124770. */
  124771. readonly worldPosition: NodeMaterialConnectionPoint;
  124772. /**
  124773. * Gets the view input component
  124774. */
  124775. readonly view: NodeMaterialConnectionPoint;
  124776. /**
  124777. * Gets the color input component
  124778. */
  124779. readonly input: NodeMaterialConnectionPoint;
  124780. /**
  124781. * Gets the fog color input component
  124782. */
  124783. readonly fogColor: NodeMaterialConnectionPoint;
  124784. /**
  124785. * Gets the output component
  124786. */
  124787. readonly output: NodeMaterialConnectionPoint;
  124788. autoConfigure(material: NodeMaterial): void;
  124789. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  124790. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  124791. protected _buildBlock(state: NodeMaterialBuildState): this;
  124792. }
  124793. }
  124794. declare module BABYLON {
  124795. /**
  124796. * Block used to add light in the fragment shader
  124797. */
  124798. export class LightBlock extends NodeMaterialBlock {
  124799. private _lightId;
  124800. /**
  124801. * Gets or sets the light associated with this block
  124802. */
  124803. light: Nullable<Light>;
  124804. /**
  124805. * Create a new LightBlock
  124806. * @param name defines the block name
  124807. */
  124808. constructor(name: string);
  124809. /**
  124810. * Gets the current class name
  124811. * @returns the class name
  124812. */
  124813. getClassName(): string;
  124814. /**
  124815. * Gets the world position input component
  124816. */
  124817. readonly worldPosition: NodeMaterialConnectionPoint;
  124818. /**
  124819. * Gets the world normal input component
  124820. */
  124821. readonly worldNormal: NodeMaterialConnectionPoint;
  124822. /**
  124823. * Gets the camera (or eye) position component
  124824. */
  124825. readonly cameraPosition: NodeMaterialConnectionPoint;
  124826. /**
  124827. * Gets the glossiness component
  124828. */
  124829. readonly glossiness: NodeMaterialConnectionPoint;
  124830. /**
  124831. * Gets the glossinness power component
  124832. */
  124833. readonly glossPower: NodeMaterialConnectionPoint;
  124834. /**
  124835. * Gets the diffuse color component
  124836. */
  124837. readonly diffuseColor: NodeMaterialConnectionPoint;
  124838. /**
  124839. * Gets the specular color component
  124840. */
  124841. readonly specularColor: NodeMaterialConnectionPoint;
  124842. /**
  124843. * Gets the diffuse output component
  124844. */
  124845. readonly diffuseOutput: NodeMaterialConnectionPoint;
  124846. /**
  124847. * Gets the specular output component
  124848. */
  124849. readonly specularOutput: NodeMaterialConnectionPoint;
  124850. autoConfigure(material: NodeMaterial): void;
  124851. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  124852. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  124853. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  124854. private _injectVertexCode;
  124855. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  124856. serialize(): any;
  124857. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124858. }
  124859. }
  124860. declare module BABYLON {
  124861. /**
  124862. * Block used to multiply 2 values
  124863. */
  124864. export class MultiplyBlock extends NodeMaterialBlock {
  124865. /**
  124866. * Creates a new MultiplyBlock
  124867. * @param name defines the block name
  124868. */
  124869. constructor(name: string);
  124870. /**
  124871. * Gets the current class name
  124872. * @returns the class name
  124873. */
  124874. getClassName(): string;
  124875. /**
  124876. * Gets the left operand input component
  124877. */
  124878. readonly left: NodeMaterialConnectionPoint;
  124879. /**
  124880. * Gets the right operand input component
  124881. */
  124882. readonly right: NodeMaterialConnectionPoint;
  124883. /**
  124884. * Gets the output component
  124885. */
  124886. readonly output: NodeMaterialConnectionPoint;
  124887. protected _buildBlock(state: NodeMaterialBuildState): this;
  124888. }
  124889. }
  124890. declare module BABYLON {
  124891. /**
  124892. * Block used to add 2 vectors
  124893. */
  124894. export class AddBlock extends NodeMaterialBlock {
  124895. /**
  124896. * Creates a new AddBlock
  124897. * @param name defines the block name
  124898. */
  124899. constructor(name: string);
  124900. /**
  124901. * Gets the current class name
  124902. * @returns the class name
  124903. */
  124904. getClassName(): string;
  124905. /**
  124906. * Gets the left operand input component
  124907. */
  124908. readonly left: NodeMaterialConnectionPoint;
  124909. /**
  124910. * Gets the right operand input component
  124911. */
  124912. readonly right: NodeMaterialConnectionPoint;
  124913. /**
  124914. * Gets the output component
  124915. */
  124916. readonly output: NodeMaterialConnectionPoint;
  124917. protected _buildBlock(state: NodeMaterialBuildState): this;
  124918. }
  124919. }
  124920. declare module BABYLON {
  124921. /**
  124922. * Block used to scale a vector by a float
  124923. */
  124924. export class ScaleBlock extends NodeMaterialBlock {
  124925. /**
  124926. * Creates a new ScaleBlock
  124927. * @param name defines the block name
  124928. */
  124929. constructor(name: string);
  124930. /**
  124931. * Gets the current class name
  124932. * @returns the class name
  124933. */
  124934. getClassName(): string;
  124935. /**
  124936. * Gets the input component
  124937. */
  124938. readonly input: NodeMaterialConnectionPoint;
  124939. /**
  124940. * Gets the factor input component
  124941. */
  124942. readonly factor: NodeMaterialConnectionPoint;
  124943. /**
  124944. * Gets the output component
  124945. */
  124946. readonly output: NodeMaterialConnectionPoint;
  124947. protected _buildBlock(state: NodeMaterialBuildState): this;
  124948. }
  124949. }
  124950. declare module BABYLON {
  124951. /**
  124952. * Block used to clamp a float
  124953. */
  124954. export class ClampBlock extends NodeMaterialBlock {
  124955. /** Gets or sets the minimum range */
  124956. minimum: number;
  124957. /** Gets or sets the maximum range */
  124958. maximum: number;
  124959. /**
  124960. * Creates a new ClampBlock
  124961. * @param name defines the block name
  124962. */
  124963. constructor(name: string);
  124964. /**
  124965. * Gets the current class name
  124966. * @returns the class name
  124967. */
  124968. getClassName(): string;
  124969. /**
  124970. * Gets the value input component
  124971. */
  124972. readonly value: NodeMaterialConnectionPoint;
  124973. /**
  124974. * Gets the output component
  124975. */
  124976. readonly output: NodeMaterialConnectionPoint;
  124977. protected _buildBlock(state: NodeMaterialBuildState): this;
  124978. protected _dumpPropertiesCode(): string;
  124979. serialize(): any;
  124980. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124981. }
  124982. }
  124983. declare module BABYLON {
  124984. /**
  124985. * Block used to apply a cross product between 2 vectors
  124986. */
  124987. export class CrossBlock extends NodeMaterialBlock {
  124988. /**
  124989. * Creates a new CrossBlock
  124990. * @param name defines the block name
  124991. */
  124992. constructor(name: string);
  124993. /**
  124994. * Gets the current class name
  124995. * @returns the class name
  124996. */
  124997. getClassName(): string;
  124998. /**
  124999. * Gets the left operand input component
  125000. */
  125001. readonly left: NodeMaterialConnectionPoint;
  125002. /**
  125003. * Gets the right operand input component
  125004. */
  125005. readonly right: NodeMaterialConnectionPoint;
  125006. /**
  125007. * Gets the output component
  125008. */
  125009. readonly output: NodeMaterialConnectionPoint;
  125010. protected _buildBlock(state: NodeMaterialBuildState): this;
  125011. }
  125012. }
  125013. declare module BABYLON {
  125014. /**
  125015. * Block used to apply a dot product between 2 vectors
  125016. */
  125017. export class DotBlock extends NodeMaterialBlock {
  125018. /**
  125019. * Creates a new DotBlock
  125020. * @param name defines the block name
  125021. */
  125022. constructor(name: string);
  125023. /**
  125024. * Gets the current class name
  125025. * @returns the class name
  125026. */
  125027. getClassName(): string;
  125028. /**
  125029. * Gets the left operand input component
  125030. */
  125031. readonly left: NodeMaterialConnectionPoint;
  125032. /**
  125033. * Gets the right operand input component
  125034. */
  125035. readonly right: NodeMaterialConnectionPoint;
  125036. /**
  125037. * Gets the output component
  125038. */
  125039. readonly output: NodeMaterialConnectionPoint;
  125040. protected _buildBlock(state: NodeMaterialBuildState): this;
  125041. }
  125042. }
  125043. declare module BABYLON {
  125044. /**
  125045. * Block used to remap a float from a range to a new one
  125046. */
  125047. export class RemapBlock extends NodeMaterialBlock {
  125048. /**
  125049. * Gets or sets the source range
  125050. */
  125051. sourceRange: Vector2;
  125052. /**
  125053. * Gets or sets the target range
  125054. */
  125055. targetRange: Vector2;
  125056. /**
  125057. * Creates a new RemapBlock
  125058. * @param name defines the block name
  125059. */
  125060. constructor(name: string);
  125061. /**
  125062. * Gets the current class name
  125063. * @returns the class name
  125064. */
  125065. getClassName(): string;
  125066. /**
  125067. * Gets the input component
  125068. */
  125069. readonly input: NodeMaterialConnectionPoint;
  125070. /**
  125071. * Gets the source min input component
  125072. */
  125073. readonly sourceMin: NodeMaterialConnectionPoint;
  125074. /**
  125075. * Gets the source max input component
  125076. */
  125077. readonly sourceMax: NodeMaterialConnectionPoint;
  125078. /**
  125079. * Gets the target min input component
  125080. */
  125081. readonly targetMin: NodeMaterialConnectionPoint;
  125082. /**
  125083. * Gets the target max input component
  125084. */
  125085. readonly targetMax: NodeMaterialConnectionPoint;
  125086. /**
  125087. * Gets the output component
  125088. */
  125089. readonly output: NodeMaterialConnectionPoint;
  125090. protected _buildBlock(state: NodeMaterialBuildState): this;
  125091. protected _dumpPropertiesCode(): string;
  125092. serialize(): any;
  125093. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  125094. }
  125095. }
  125096. declare module BABYLON {
  125097. /**
  125098. * Block used to normalize a vector
  125099. */
  125100. export class NormalizeBlock extends NodeMaterialBlock {
  125101. /**
  125102. * Creates a new NormalizeBlock
  125103. * @param name defines the block name
  125104. */
  125105. constructor(name: string);
  125106. /**
  125107. * Gets the current class name
  125108. * @returns the class name
  125109. */
  125110. getClassName(): string;
  125111. /**
  125112. * Gets the input component
  125113. */
  125114. readonly input: NodeMaterialConnectionPoint;
  125115. /**
  125116. * Gets the output component
  125117. */
  125118. readonly output: NodeMaterialConnectionPoint;
  125119. protected _buildBlock(state: NodeMaterialBuildState): this;
  125120. }
  125121. }
  125122. declare module BABYLON {
  125123. /**
  125124. * Operations supported by the Trigonometry block
  125125. */
  125126. export enum TrigonometryBlockOperations {
  125127. /** Cos */
  125128. Cos = 0,
  125129. /** Sin */
  125130. Sin = 1,
  125131. /** Abs */
  125132. Abs = 2,
  125133. /** Exp */
  125134. Exp = 3,
  125135. /** Exp2 */
  125136. Exp2 = 4,
  125137. /** Round */
  125138. Round = 5,
  125139. /** Floor */
  125140. Floor = 6,
  125141. /** Ceiling */
  125142. Ceiling = 7,
  125143. /** Square root */
  125144. Sqrt = 8,
  125145. /** Log */
  125146. Log = 9,
  125147. /** Tangent */
  125148. Tan = 10,
  125149. /** Arc tangent */
  125150. ArcTan = 11,
  125151. /** Arc cosinus */
  125152. ArcCos = 12,
  125153. /** Arc sinus */
  125154. ArcSin = 13,
  125155. /** Fraction */
  125156. Fract = 14,
  125157. /** Sign */
  125158. Sign = 15,
  125159. /** To radians (from degrees) */
  125160. Radians = 16,
  125161. /** To degrees (from radians) */
  125162. Degrees = 17
  125163. }
  125164. /**
  125165. * Block used to apply trigonometry operation to floats
  125166. */
  125167. export class TrigonometryBlock extends NodeMaterialBlock {
  125168. /**
  125169. * Gets or sets the operation applied by the block
  125170. */
  125171. operation: TrigonometryBlockOperations;
  125172. /**
  125173. * Creates a new TrigonometryBlock
  125174. * @param name defines the block name
  125175. */
  125176. constructor(name: string);
  125177. /**
  125178. * Gets the current class name
  125179. * @returns the class name
  125180. */
  125181. getClassName(): string;
  125182. /**
  125183. * Gets the input component
  125184. */
  125185. readonly input: NodeMaterialConnectionPoint;
  125186. /**
  125187. * Gets the output component
  125188. */
  125189. readonly output: NodeMaterialConnectionPoint;
  125190. protected _buildBlock(state: NodeMaterialBuildState): this;
  125191. serialize(): any;
  125192. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  125193. protected _dumpPropertiesCode(): string;
  125194. }
  125195. }
  125196. declare module BABYLON {
  125197. /**
  125198. * Block used to create a Color3/4 out of individual inputs (one for each component)
  125199. */
  125200. export class ColorMergerBlock extends NodeMaterialBlock {
  125201. /**
  125202. * Create a new ColorMergerBlock
  125203. * @param name defines the block name
  125204. */
  125205. constructor(name: string);
  125206. /**
  125207. * Gets the current class name
  125208. * @returns the class name
  125209. */
  125210. getClassName(): string;
  125211. /**
  125212. * Gets the rgb component (input)
  125213. */
  125214. readonly rgbIn: NodeMaterialConnectionPoint;
  125215. /**
  125216. * Gets the r component (input)
  125217. */
  125218. readonly r: NodeMaterialConnectionPoint;
  125219. /**
  125220. * Gets the g component (input)
  125221. */
  125222. readonly g: NodeMaterialConnectionPoint;
  125223. /**
  125224. * Gets the b component (input)
  125225. */
  125226. readonly b: NodeMaterialConnectionPoint;
  125227. /**
  125228. * Gets the a component (input)
  125229. */
  125230. readonly a: NodeMaterialConnectionPoint;
  125231. /**
  125232. * Gets the rgba component (output)
  125233. */
  125234. readonly rgba: NodeMaterialConnectionPoint;
  125235. /**
  125236. * Gets the rgb component (output)
  125237. */
  125238. readonly rgbOut: NodeMaterialConnectionPoint;
  125239. /**
  125240. * Gets the rgb component (output)
  125241. * @deprecated Please use rgbOut instead.
  125242. */
  125243. readonly rgb: NodeMaterialConnectionPoint;
  125244. protected _buildBlock(state: NodeMaterialBuildState): this;
  125245. }
  125246. }
  125247. declare module BABYLON {
  125248. /**
  125249. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  125250. */
  125251. export class VectorMergerBlock extends NodeMaterialBlock {
  125252. /**
  125253. * Create a new VectorMergerBlock
  125254. * @param name defines the block name
  125255. */
  125256. constructor(name: string);
  125257. /**
  125258. * Gets the current class name
  125259. * @returns the class name
  125260. */
  125261. getClassName(): string;
  125262. /**
  125263. * Gets the xyz component (input)
  125264. */
  125265. readonly xyzIn: NodeMaterialConnectionPoint;
  125266. /**
  125267. * Gets the xy component (input)
  125268. */
  125269. readonly xyIn: NodeMaterialConnectionPoint;
  125270. /**
  125271. * Gets the x component (input)
  125272. */
  125273. readonly x: NodeMaterialConnectionPoint;
  125274. /**
  125275. * Gets the y component (input)
  125276. */
  125277. readonly y: NodeMaterialConnectionPoint;
  125278. /**
  125279. * Gets the z component (input)
  125280. */
  125281. readonly z: NodeMaterialConnectionPoint;
  125282. /**
  125283. * Gets the w component (input)
  125284. */
  125285. readonly w: NodeMaterialConnectionPoint;
  125286. /**
  125287. * Gets the xyzw component (output)
  125288. */
  125289. readonly xyzw: NodeMaterialConnectionPoint;
  125290. /**
  125291. * Gets the xyz component (output)
  125292. */
  125293. readonly xyzOut: NodeMaterialConnectionPoint;
  125294. /**
  125295. * Gets the xy component (output)
  125296. */
  125297. readonly xyOut: NodeMaterialConnectionPoint;
  125298. /**
  125299. * Gets the xy component (output)
  125300. * @deprecated Please use xyOut instead.
  125301. */
  125302. readonly xy: NodeMaterialConnectionPoint;
  125303. /**
  125304. * Gets the xyz component (output)
  125305. * @deprecated Please use xyzOut instead.
  125306. */
  125307. readonly xyz: NodeMaterialConnectionPoint;
  125308. protected _buildBlock(state: NodeMaterialBuildState): this;
  125309. }
  125310. }
  125311. declare module BABYLON {
  125312. /**
  125313. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  125314. */
  125315. export class ColorSplitterBlock extends NodeMaterialBlock {
  125316. /**
  125317. * Create a new ColorSplitterBlock
  125318. * @param name defines the block name
  125319. */
  125320. constructor(name: string);
  125321. /**
  125322. * Gets the current class name
  125323. * @returns the class name
  125324. */
  125325. getClassName(): string;
  125326. /**
  125327. * Gets the rgba component (input)
  125328. */
  125329. readonly rgba: NodeMaterialConnectionPoint;
  125330. /**
  125331. * Gets the rgb component (input)
  125332. */
  125333. readonly rgbIn: NodeMaterialConnectionPoint;
  125334. /**
  125335. * Gets the rgb component (output)
  125336. */
  125337. readonly rgbOut: NodeMaterialConnectionPoint;
  125338. /**
  125339. * Gets the r component (output)
  125340. */
  125341. readonly r: NodeMaterialConnectionPoint;
  125342. /**
  125343. * Gets the g component (output)
  125344. */
  125345. readonly g: NodeMaterialConnectionPoint;
  125346. /**
  125347. * Gets the b component (output)
  125348. */
  125349. readonly b: NodeMaterialConnectionPoint;
  125350. /**
  125351. * Gets the a component (output)
  125352. */
  125353. readonly a: NodeMaterialConnectionPoint;
  125354. protected _inputRename(name: string): string;
  125355. protected _outputRename(name: string): string;
  125356. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  125357. }
  125358. }
  125359. declare module BABYLON {
  125360. /**
  125361. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  125362. */
  125363. export class VectorSplitterBlock extends NodeMaterialBlock {
  125364. /**
  125365. * Create a new VectorSplitterBlock
  125366. * @param name defines the block name
  125367. */
  125368. constructor(name: string);
  125369. /**
  125370. * Gets the current class name
  125371. * @returns the class name
  125372. */
  125373. getClassName(): string;
  125374. /**
  125375. * Gets the xyzw component (input)
  125376. */
  125377. readonly xyzw: NodeMaterialConnectionPoint;
  125378. /**
  125379. * Gets the xyz component (input)
  125380. */
  125381. readonly xyzIn: NodeMaterialConnectionPoint;
  125382. /**
  125383. * Gets the xy component (input)
  125384. */
  125385. readonly xyIn: NodeMaterialConnectionPoint;
  125386. /**
  125387. * Gets the xyz component (output)
  125388. */
  125389. readonly xyzOut: NodeMaterialConnectionPoint;
  125390. /**
  125391. * Gets the xy component (output)
  125392. */
  125393. readonly xyOut: NodeMaterialConnectionPoint;
  125394. /**
  125395. * Gets the x component (output)
  125396. */
  125397. readonly x: NodeMaterialConnectionPoint;
  125398. /**
  125399. * Gets the y component (output)
  125400. */
  125401. readonly y: NodeMaterialConnectionPoint;
  125402. /**
  125403. * Gets the z component (output)
  125404. */
  125405. readonly z: NodeMaterialConnectionPoint;
  125406. /**
  125407. * Gets the w component (output)
  125408. */
  125409. readonly w: NodeMaterialConnectionPoint;
  125410. protected _inputRename(name: string): string;
  125411. protected _outputRename(name: string): string;
  125412. protected _buildBlock(state: NodeMaterialBuildState): this;
  125413. }
  125414. }
  125415. declare module BABYLON {
  125416. /**
  125417. * Block used to lerp between 2 values
  125418. */
  125419. export class LerpBlock extends NodeMaterialBlock {
  125420. /**
  125421. * Creates a new LerpBlock
  125422. * @param name defines the block name
  125423. */
  125424. constructor(name: string);
  125425. /**
  125426. * Gets the current class name
  125427. * @returns the class name
  125428. */
  125429. getClassName(): string;
  125430. /**
  125431. * Gets the left operand input component
  125432. */
  125433. readonly left: NodeMaterialConnectionPoint;
  125434. /**
  125435. * Gets the right operand input component
  125436. */
  125437. readonly right: NodeMaterialConnectionPoint;
  125438. /**
  125439. * Gets the gradient operand input component
  125440. */
  125441. readonly gradient: NodeMaterialConnectionPoint;
  125442. /**
  125443. * Gets the output component
  125444. */
  125445. readonly output: NodeMaterialConnectionPoint;
  125446. protected _buildBlock(state: NodeMaterialBuildState): this;
  125447. }
  125448. }
  125449. declare module BABYLON {
  125450. /**
  125451. * Block used to divide 2 vectors
  125452. */
  125453. export class DivideBlock extends NodeMaterialBlock {
  125454. /**
  125455. * Creates a new DivideBlock
  125456. * @param name defines the block name
  125457. */
  125458. constructor(name: string);
  125459. /**
  125460. * Gets the current class name
  125461. * @returns the class name
  125462. */
  125463. getClassName(): string;
  125464. /**
  125465. * Gets the left operand input component
  125466. */
  125467. readonly left: NodeMaterialConnectionPoint;
  125468. /**
  125469. * Gets the right operand input component
  125470. */
  125471. readonly right: NodeMaterialConnectionPoint;
  125472. /**
  125473. * Gets the output component
  125474. */
  125475. readonly output: NodeMaterialConnectionPoint;
  125476. protected _buildBlock(state: NodeMaterialBuildState): this;
  125477. }
  125478. }
  125479. declare module BABYLON {
  125480. /**
  125481. * Block used to subtract 2 vectors
  125482. */
  125483. export class SubtractBlock extends NodeMaterialBlock {
  125484. /**
  125485. * Creates a new SubtractBlock
  125486. * @param name defines the block name
  125487. */
  125488. constructor(name: string);
  125489. /**
  125490. * Gets the current class name
  125491. * @returns the class name
  125492. */
  125493. getClassName(): string;
  125494. /**
  125495. * Gets the left operand input component
  125496. */
  125497. readonly left: NodeMaterialConnectionPoint;
  125498. /**
  125499. * Gets the right operand input component
  125500. */
  125501. readonly right: NodeMaterialConnectionPoint;
  125502. /**
  125503. * Gets the output component
  125504. */
  125505. readonly output: NodeMaterialConnectionPoint;
  125506. protected _buildBlock(state: NodeMaterialBuildState): this;
  125507. }
  125508. }
  125509. declare module BABYLON {
  125510. /**
  125511. * Block used to step a value
  125512. */
  125513. export class StepBlock extends NodeMaterialBlock {
  125514. /**
  125515. * Creates a new StepBlock
  125516. * @param name defines the block name
  125517. */
  125518. constructor(name: string);
  125519. /**
  125520. * Gets the current class name
  125521. * @returns the class name
  125522. */
  125523. getClassName(): string;
  125524. /**
  125525. * Gets the value operand input component
  125526. */
  125527. readonly value: NodeMaterialConnectionPoint;
  125528. /**
  125529. * Gets the edge operand input component
  125530. */
  125531. readonly edge: NodeMaterialConnectionPoint;
  125532. /**
  125533. * Gets the output component
  125534. */
  125535. readonly output: NodeMaterialConnectionPoint;
  125536. protected _buildBlock(state: NodeMaterialBuildState): this;
  125537. }
  125538. }
  125539. declare module BABYLON {
  125540. /**
  125541. * Block used to get the opposite (1 - x) of a value
  125542. */
  125543. export class OneMinusBlock extends NodeMaterialBlock {
  125544. /**
  125545. * Creates a new OneMinusBlock
  125546. * @param name defines the block name
  125547. */
  125548. constructor(name: string);
  125549. /**
  125550. * Gets the current class name
  125551. * @returns the class name
  125552. */
  125553. getClassName(): string;
  125554. /**
  125555. * Gets the input component
  125556. */
  125557. readonly input: NodeMaterialConnectionPoint;
  125558. /**
  125559. * Gets the output component
  125560. */
  125561. readonly output: NodeMaterialConnectionPoint;
  125562. protected _buildBlock(state: NodeMaterialBuildState): this;
  125563. }
  125564. }
  125565. declare module BABYLON {
  125566. /**
  125567. * Block used to get the view direction
  125568. */
  125569. export class ViewDirectionBlock extends NodeMaterialBlock {
  125570. /**
  125571. * Creates a new ViewDirectionBlock
  125572. * @param name defines the block name
  125573. */
  125574. constructor(name: string);
  125575. /**
  125576. * Gets the current class name
  125577. * @returns the class name
  125578. */
  125579. getClassName(): string;
  125580. /**
  125581. * Gets the world position component
  125582. */
  125583. readonly worldPosition: NodeMaterialConnectionPoint;
  125584. /**
  125585. * Gets the camera position component
  125586. */
  125587. readonly cameraPosition: NodeMaterialConnectionPoint;
  125588. /**
  125589. * Gets the output component
  125590. */
  125591. readonly output: NodeMaterialConnectionPoint;
  125592. autoConfigure(material: NodeMaterial): void;
  125593. protected _buildBlock(state: NodeMaterialBuildState): this;
  125594. }
  125595. }
  125596. declare module BABYLON {
  125597. /**
  125598. * Block used to compute fresnel value
  125599. */
  125600. export class FresnelBlock extends NodeMaterialBlock {
  125601. /**
  125602. * Create a new FresnelBlock
  125603. * @param name defines the block name
  125604. */
  125605. constructor(name: string);
  125606. /**
  125607. * Gets the current class name
  125608. * @returns the class name
  125609. */
  125610. getClassName(): string;
  125611. /**
  125612. * Gets the world normal input component
  125613. */
  125614. readonly worldNormal: NodeMaterialConnectionPoint;
  125615. /**
  125616. * Gets the view direction input component
  125617. */
  125618. readonly viewDirection: NodeMaterialConnectionPoint;
  125619. /**
  125620. * Gets the bias input component
  125621. */
  125622. readonly bias: NodeMaterialConnectionPoint;
  125623. /**
  125624. * Gets the camera (or eye) position component
  125625. */
  125626. readonly power: NodeMaterialConnectionPoint;
  125627. /**
  125628. * Gets the fresnel output component
  125629. */
  125630. readonly fresnel: NodeMaterialConnectionPoint;
  125631. autoConfigure(material: NodeMaterial): void;
  125632. protected _buildBlock(state: NodeMaterialBuildState): this;
  125633. }
  125634. }
  125635. declare module BABYLON {
  125636. /**
  125637. * Block used to get the max of 2 values
  125638. */
  125639. export class MaxBlock extends NodeMaterialBlock {
  125640. /**
  125641. * Creates a new MaxBlock
  125642. * @param name defines the block name
  125643. */
  125644. constructor(name: string);
  125645. /**
  125646. * Gets the current class name
  125647. * @returns the class name
  125648. */
  125649. getClassName(): string;
  125650. /**
  125651. * Gets the left operand input component
  125652. */
  125653. readonly left: NodeMaterialConnectionPoint;
  125654. /**
  125655. * Gets the right operand input component
  125656. */
  125657. readonly right: NodeMaterialConnectionPoint;
  125658. /**
  125659. * Gets the output component
  125660. */
  125661. readonly output: NodeMaterialConnectionPoint;
  125662. protected _buildBlock(state: NodeMaterialBuildState): this;
  125663. }
  125664. }
  125665. declare module BABYLON {
  125666. /**
  125667. * Block used to get the min of 2 values
  125668. */
  125669. export class MinBlock extends NodeMaterialBlock {
  125670. /**
  125671. * Creates a new MinBlock
  125672. * @param name defines the block name
  125673. */
  125674. constructor(name: string);
  125675. /**
  125676. * Gets the current class name
  125677. * @returns the class name
  125678. */
  125679. getClassName(): string;
  125680. /**
  125681. * Gets the left operand input component
  125682. */
  125683. readonly left: NodeMaterialConnectionPoint;
  125684. /**
  125685. * Gets the right operand input component
  125686. */
  125687. readonly right: NodeMaterialConnectionPoint;
  125688. /**
  125689. * Gets the output component
  125690. */
  125691. readonly output: NodeMaterialConnectionPoint;
  125692. protected _buildBlock(state: NodeMaterialBuildState): this;
  125693. }
  125694. }
  125695. declare module BABYLON {
  125696. /**
  125697. * Block used to get the distance between 2 values
  125698. */
  125699. export class DistanceBlock extends NodeMaterialBlock {
  125700. /**
  125701. * Creates a new DistanceBlock
  125702. * @param name defines the block name
  125703. */
  125704. constructor(name: string);
  125705. /**
  125706. * Gets the current class name
  125707. * @returns the class name
  125708. */
  125709. getClassName(): string;
  125710. /**
  125711. * Gets the left operand input component
  125712. */
  125713. readonly left: NodeMaterialConnectionPoint;
  125714. /**
  125715. * Gets the right operand input component
  125716. */
  125717. readonly right: NodeMaterialConnectionPoint;
  125718. /**
  125719. * Gets the output component
  125720. */
  125721. readonly output: NodeMaterialConnectionPoint;
  125722. protected _buildBlock(state: NodeMaterialBuildState): this;
  125723. }
  125724. }
  125725. declare module BABYLON {
  125726. /**
  125727. * Block used to get the length of a vector
  125728. */
  125729. export class LengthBlock extends NodeMaterialBlock {
  125730. /**
  125731. * Creates a new LengthBlock
  125732. * @param name defines the block name
  125733. */
  125734. constructor(name: string);
  125735. /**
  125736. * Gets the current class name
  125737. * @returns the class name
  125738. */
  125739. getClassName(): string;
  125740. /**
  125741. * Gets the value input component
  125742. */
  125743. readonly value: NodeMaterialConnectionPoint;
  125744. /**
  125745. * Gets the output component
  125746. */
  125747. readonly output: NodeMaterialConnectionPoint;
  125748. protected _buildBlock(state: NodeMaterialBuildState): this;
  125749. }
  125750. }
  125751. declare module BABYLON {
  125752. /**
  125753. * Block used to get negative version of a value (i.e. x * -1)
  125754. */
  125755. export class NegateBlock extends NodeMaterialBlock {
  125756. /**
  125757. * Creates a new NegateBlock
  125758. * @param name defines the block name
  125759. */
  125760. constructor(name: string);
  125761. /**
  125762. * Gets the current class name
  125763. * @returns the class name
  125764. */
  125765. getClassName(): string;
  125766. /**
  125767. * Gets the value input component
  125768. */
  125769. readonly value: NodeMaterialConnectionPoint;
  125770. /**
  125771. * Gets the output component
  125772. */
  125773. readonly output: NodeMaterialConnectionPoint;
  125774. protected _buildBlock(state: NodeMaterialBuildState): this;
  125775. }
  125776. }
  125777. declare module BABYLON {
  125778. /**
  125779. * Block used to get the value of the first parameter raised to the power of the second
  125780. */
  125781. export class PowBlock extends NodeMaterialBlock {
  125782. /**
  125783. * Creates a new PowBlock
  125784. * @param name defines the block name
  125785. */
  125786. constructor(name: string);
  125787. /**
  125788. * Gets the current class name
  125789. * @returns the class name
  125790. */
  125791. getClassName(): string;
  125792. /**
  125793. * Gets the value operand input component
  125794. */
  125795. readonly value: NodeMaterialConnectionPoint;
  125796. /**
  125797. * Gets the power operand input component
  125798. */
  125799. readonly power: NodeMaterialConnectionPoint;
  125800. /**
  125801. * Gets the output component
  125802. */
  125803. readonly output: NodeMaterialConnectionPoint;
  125804. protected _buildBlock(state: NodeMaterialBuildState): this;
  125805. }
  125806. }
  125807. declare module BABYLON {
  125808. /**
  125809. * Block used to get a random number
  125810. */
  125811. export class RandomNumberBlock extends NodeMaterialBlock {
  125812. /**
  125813. * Creates a new RandomNumberBlock
  125814. * @param name defines the block name
  125815. */
  125816. constructor(name: string);
  125817. /**
  125818. * Gets the current class name
  125819. * @returns the class name
  125820. */
  125821. getClassName(): string;
  125822. /**
  125823. * Gets the seed input component
  125824. */
  125825. readonly seed: NodeMaterialConnectionPoint;
  125826. /**
  125827. * Gets the output component
  125828. */
  125829. readonly output: NodeMaterialConnectionPoint;
  125830. protected _buildBlock(state: NodeMaterialBuildState): this;
  125831. }
  125832. }
  125833. declare module BABYLON {
  125834. /**
  125835. * Block used to compute arc tangent of 2 values
  125836. */
  125837. export class ArcTan2Block extends NodeMaterialBlock {
  125838. /**
  125839. * Creates a new ArcTan2Block
  125840. * @param name defines the block name
  125841. */
  125842. constructor(name: string);
  125843. /**
  125844. * Gets the current class name
  125845. * @returns the class name
  125846. */
  125847. getClassName(): string;
  125848. /**
  125849. * Gets the x operand input component
  125850. */
  125851. readonly x: NodeMaterialConnectionPoint;
  125852. /**
  125853. * Gets the y operand input component
  125854. */
  125855. readonly y: NodeMaterialConnectionPoint;
  125856. /**
  125857. * Gets the output component
  125858. */
  125859. readonly output: NodeMaterialConnectionPoint;
  125860. protected _buildBlock(state: NodeMaterialBuildState): this;
  125861. }
  125862. }
  125863. declare module BABYLON {
  125864. /**
  125865. * Block used to smooth step a value
  125866. */
  125867. export class SmoothStepBlock extends NodeMaterialBlock {
  125868. /**
  125869. * Creates a new SmoothStepBlock
  125870. * @param name defines the block name
  125871. */
  125872. constructor(name: string);
  125873. /**
  125874. * Gets the current class name
  125875. * @returns the class name
  125876. */
  125877. getClassName(): string;
  125878. /**
  125879. * Gets the value operand input component
  125880. */
  125881. readonly value: NodeMaterialConnectionPoint;
  125882. /**
  125883. * Gets the first edge operand input component
  125884. */
  125885. readonly edge0: NodeMaterialConnectionPoint;
  125886. /**
  125887. * Gets the second edge operand input component
  125888. */
  125889. readonly edge1: NodeMaterialConnectionPoint;
  125890. /**
  125891. * Gets the output component
  125892. */
  125893. readonly output: NodeMaterialConnectionPoint;
  125894. protected _buildBlock(state: NodeMaterialBuildState): this;
  125895. }
  125896. }
  125897. declare module BABYLON {
  125898. /**
  125899. * Block used to get the reciprocal (1 / x) of a value
  125900. */
  125901. export class ReciprocalBlock extends NodeMaterialBlock {
  125902. /**
  125903. * Creates a new ReciprocalBlock
  125904. * @param name defines the block name
  125905. */
  125906. constructor(name: string);
  125907. /**
  125908. * Gets the current class name
  125909. * @returns the class name
  125910. */
  125911. getClassName(): string;
  125912. /**
  125913. * Gets the input component
  125914. */
  125915. readonly input: NodeMaterialConnectionPoint;
  125916. /**
  125917. * Gets the output component
  125918. */
  125919. readonly output: NodeMaterialConnectionPoint;
  125920. protected _buildBlock(state: NodeMaterialBuildState): this;
  125921. }
  125922. }
  125923. declare module BABYLON {
  125924. /**
  125925. * Block used to replace a color by another one
  125926. */
  125927. export class ReplaceColorBlock extends NodeMaterialBlock {
  125928. /**
  125929. * Creates a new ReplaceColorBlock
  125930. * @param name defines the block name
  125931. */
  125932. constructor(name: string);
  125933. /**
  125934. * Gets the current class name
  125935. * @returns the class name
  125936. */
  125937. getClassName(): string;
  125938. /**
  125939. * Gets the value input component
  125940. */
  125941. readonly value: NodeMaterialConnectionPoint;
  125942. /**
  125943. * Gets the reference input component
  125944. */
  125945. readonly reference: NodeMaterialConnectionPoint;
  125946. /**
  125947. * Gets the distance input component
  125948. */
  125949. readonly distance: NodeMaterialConnectionPoint;
  125950. /**
  125951. * Gets the replacement input component
  125952. */
  125953. readonly replacement: NodeMaterialConnectionPoint;
  125954. /**
  125955. * Gets the output component
  125956. */
  125957. readonly output: NodeMaterialConnectionPoint;
  125958. protected _buildBlock(state: NodeMaterialBuildState): this;
  125959. }
  125960. }
  125961. declare module BABYLON {
  125962. /**
  125963. * Block used to posterize a value
  125964. * @see https://en.wikipedia.org/wiki/Posterization
  125965. */
  125966. export class PosterizeBlock extends NodeMaterialBlock {
  125967. /**
  125968. * Creates a new PosterizeBlock
  125969. * @param name defines the block name
  125970. */
  125971. constructor(name: string);
  125972. /**
  125973. * Gets the current class name
  125974. * @returns the class name
  125975. */
  125976. getClassName(): string;
  125977. /**
  125978. * Gets the value input component
  125979. */
  125980. readonly value: NodeMaterialConnectionPoint;
  125981. /**
  125982. * Gets the steps input component
  125983. */
  125984. readonly steps: NodeMaterialConnectionPoint;
  125985. /**
  125986. * Gets the output component
  125987. */
  125988. readonly output: NodeMaterialConnectionPoint;
  125989. protected _buildBlock(state: NodeMaterialBuildState): this;
  125990. }
  125991. }
  125992. declare module BABYLON {
  125993. /**
  125994. * Operations supported by the Wave block
  125995. */
  125996. export enum WaveBlockKind {
  125997. /** SawTooth */
  125998. SawTooth = 0,
  125999. /** Square */
  126000. Square = 1,
  126001. /** Triangle */
  126002. Triangle = 2
  126003. }
  126004. /**
  126005. * Block used to apply wave operation to floats
  126006. */
  126007. export class WaveBlock extends NodeMaterialBlock {
  126008. /**
  126009. * Gets or sets the kibnd of wave to be applied by the block
  126010. */
  126011. kind: WaveBlockKind;
  126012. /**
  126013. * Creates a new WaveBlock
  126014. * @param name defines the block name
  126015. */
  126016. constructor(name: string);
  126017. /**
  126018. * Gets the current class name
  126019. * @returns the class name
  126020. */
  126021. getClassName(): string;
  126022. /**
  126023. * Gets the input component
  126024. */
  126025. readonly input: NodeMaterialConnectionPoint;
  126026. /**
  126027. * Gets the output component
  126028. */
  126029. readonly output: NodeMaterialConnectionPoint;
  126030. protected _buildBlock(state: NodeMaterialBuildState): this;
  126031. serialize(): any;
  126032. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  126033. }
  126034. }
  126035. declare module BABYLON {
  126036. /**
  126037. * Class used to store a color step for the GradientBlock
  126038. */
  126039. export class GradientBlockColorStep {
  126040. /**
  126041. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  126042. */
  126043. step: number;
  126044. /**
  126045. * Gets or sets the color associated with this step
  126046. */
  126047. color: Color3;
  126048. /**
  126049. * Creates a new GradientBlockColorStep
  126050. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  126051. * @param color defines the color associated with this step
  126052. */
  126053. constructor(
  126054. /**
  126055. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  126056. */
  126057. step: number,
  126058. /**
  126059. * Gets or sets the color associated with this step
  126060. */
  126061. color: Color3);
  126062. }
  126063. /**
  126064. * Block used to return a color from a gradient based on an input value between 0 and 1
  126065. */
  126066. export class GradientBlock extends NodeMaterialBlock {
  126067. /**
  126068. * Gets or sets the list of color steps
  126069. */
  126070. colorSteps: GradientBlockColorStep[];
  126071. /**
  126072. * Creates a new GradientBlock
  126073. * @param name defines the block name
  126074. */
  126075. constructor(name: string);
  126076. /**
  126077. * Gets the current class name
  126078. * @returns the class name
  126079. */
  126080. getClassName(): string;
  126081. /**
  126082. * Gets the gradient input component
  126083. */
  126084. readonly gradient: NodeMaterialConnectionPoint;
  126085. /**
  126086. * Gets the output component
  126087. */
  126088. readonly output: NodeMaterialConnectionPoint;
  126089. private _writeColorConstant;
  126090. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  126091. serialize(): any;
  126092. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  126093. protected _dumpPropertiesCode(): string;
  126094. }
  126095. }
  126096. declare module BABYLON {
  126097. /**
  126098. * Block used to normalize lerp between 2 values
  126099. */
  126100. export class NLerpBlock extends NodeMaterialBlock {
  126101. /**
  126102. * Creates a new NLerpBlock
  126103. * @param name defines the block name
  126104. */
  126105. constructor(name: string);
  126106. /**
  126107. * Gets the current class name
  126108. * @returns the class name
  126109. */
  126110. getClassName(): string;
  126111. /**
  126112. * Gets the left operand input component
  126113. */
  126114. readonly left: NodeMaterialConnectionPoint;
  126115. /**
  126116. * Gets the right operand input component
  126117. */
  126118. readonly right: NodeMaterialConnectionPoint;
  126119. /**
  126120. * Gets the gradient operand input component
  126121. */
  126122. readonly gradient: NodeMaterialConnectionPoint;
  126123. /**
  126124. * Gets the output component
  126125. */
  126126. readonly output: NodeMaterialConnectionPoint;
  126127. protected _buildBlock(state: NodeMaterialBuildState): this;
  126128. }
  126129. }
  126130. declare module BABYLON {
  126131. /**
  126132. * block used to Generate a Worley Noise 3D Noise Pattern
  126133. */
  126134. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  126135. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  126136. manhattanDistance: boolean;
  126137. /**
  126138. * Creates a new WorleyNoise3DBlock
  126139. * @param name defines the block name
  126140. */
  126141. constructor(name: string);
  126142. /**
  126143. * Gets the current class name
  126144. * @returns the class name
  126145. */
  126146. getClassName(): string;
  126147. /**
  126148. * Gets the seed input component
  126149. */
  126150. readonly seed: NodeMaterialConnectionPoint;
  126151. /**
  126152. * Gets the jitter input component
  126153. */
  126154. readonly jitter: NodeMaterialConnectionPoint;
  126155. /**
  126156. * Gets the output component
  126157. */
  126158. readonly output: NodeMaterialConnectionPoint;
  126159. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  126160. /**
  126161. * Exposes the properties to the UI?
  126162. */
  126163. protected _dumpPropertiesCode(): string;
  126164. /**
  126165. * Exposes the properties to the Seralize?
  126166. */
  126167. serialize(): any;
  126168. /**
  126169. * Exposes the properties to the deseralize?
  126170. */
  126171. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  126172. }
  126173. }
  126174. declare module BABYLON {
  126175. /**
  126176. * block used to Generate a Simplex Perlin 3d Noise Pattern
  126177. */
  126178. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  126179. /**
  126180. * Creates a new SimplexPerlin3DBlock
  126181. * @param name defines the block name
  126182. */
  126183. constructor(name: string);
  126184. /**
  126185. * Gets the current class name
  126186. * @returns the class name
  126187. */
  126188. getClassName(): string;
  126189. /**
  126190. * Gets the seed operand input component
  126191. */
  126192. readonly seed: NodeMaterialConnectionPoint;
  126193. /**
  126194. * Gets the output component
  126195. */
  126196. readonly output: NodeMaterialConnectionPoint;
  126197. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  126198. }
  126199. }
  126200. declare module BABYLON {
  126201. /**
  126202. * Block used to blend normals
  126203. */
  126204. export class NormalBlendBlock extends NodeMaterialBlock {
  126205. /**
  126206. * Creates a new NormalBlendBlock
  126207. * @param name defines the block name
  126208. */
  126209. constructor(name: string);
  126210. /**
  126211. * Gets the current class name
  126212. * @returns the class name
  126213. */
  126214. getClassName(): string;
  126215. /**
  126216. * Gets the first input component
  126217. */
  126218. readonly normalMap0: NodeMaterialConnectionPoint;
  126219. /**
  126220. * Gets the second input component
  126221. */
  126222. readonly normalMap1: NodeMaterialConnectionPoint;
  126223. /**
  126224. * Gets the output component
  126225. */
  126226. readonly output: NodeMaterialConnectionPoint;
  126227. protected _buildBlock(state: NodeMaterialBuildState): this;
  126228. }
  126229. }
  126230. declare module BABYLON {
  126231. /**
  126232. * Block used to rotate a 2d vector by a given angle
  126233. */
  126234. export class Rotate2dBlock extends NodeMaterialBlock {
  126235. /**
  126236. * Creates a new Rotate2dBlock
  126237. * @param name defines the block name
  126238. */
  126239. constructor(name: string);
  126240. /**
  126241. * Gets the current class name
  126242. * @returns the class name
  126243. */
  126244. getClassName(): string;
  126245. /**
  126246. * Gets the input vector
  126247. */
  126248. readonly input: NodeMaterialConnectionPoint;
  126249. /**
  126250. * Gets the input angle
  126251. */
  126252. readonly angle: NodeMaterialConnectionPoint;
  126253. /**
  126254. * Gets the output component
  126255. */
  126256. readonly output: NodeMaterialConnectionPoint;
  126257. autoConfigure(material: NodeMaterial): void;
  126258. protected _buildBlock(state: NodeMaterialBuildState): this;
  126259. }
  126260. }
  126261. declare module BABYLON {
  126262. /**
  126263. * Block used to get the reflected vector from a direction and a normal
  126264. */
  126265. export class ReflectBlock extends NodeMaterialBlock {
  126266. /**
  126267. * Creates a new ReflectBlock
  126268. * @param name defines the block name
  126269. */
  126270. constructor(name: string);
  126271. /**
  126272. * Gets the current class name
  126273. * @returns the class name
  126274. */
  126275. getClassName(): string;
  126276. /**
  126277. * Gets the incident component
  126278. */
  126279. readonly incident: NodeMaterialConnectionPoint;
  126280. /**
  126281. * Gets the normal component
  126282. */
  126283. readonly normal: NodeMaterialConnectionPoint;
  126284. /**
  126285. * Gets the output component
  126286. */
  126287. readonly output: NodeMaterialConnectionPoint;
  126288. protected _buildBlock(state: NodeMaterialBuildState): this;
  126289. }
  126290. }
  126291. declare module BABYLON {
  126292. /**
  126293. * Block used to get the refracted vector from a direction and a normal
  126294. */
  126295. export class RefractBlock extends NodeMaterialBlock {
  126296. /**
  126297. * Creates a new RefractBlock
  126298. * @param name defines the block name
  126299. */
  126300. constructor(name: string);
  126301. /**
  126302. * Gets the current class name
  126303. * @returns the class name
  126304. */
  126305. getClassName(): string;
  126306. /**
  126307. * Gets the incident component
  126308. */
  126309. readonly incident: NodeMaterialConnectionPoint;
  126310. /**
  126311. * Gets the normal component
  126312. */
  126313. readonly normal: NodeMaterialConnectionPoint;
  126314. /**
  126315. * Gets the index of refraction component
  126316. */
  126317. readonly ior: NodeMaterialConnectionPoint;
  126318. /**
  126319. * Gets the output component
  126320. */
  126321. readonly output: NodeMaterialConnectionPoint;
  126322. protected _buildBlock(state: NodeMaterialBuildState): this;
  126323. }
  126324. }
  126325. declare module BABYLON {
  126326. /**
  126327. * Block used to desaturate a color
  126328. */
  126329. export class DesaturateBlock extends NodeMaterialBlock {
  126330. /**
  126331. * Creates a new DesaturateBlock
  126332. * @param name defines the block name
  126333. */
  126334. constructor(name: string);
  126335. /**
  126336. * Gets the current class name
  126337. * @returns the class name
  126338. */
  126339. getClassName(): string;
  126340. /**
  126341. * Gets the color operand input component
  126342. */
  126343. readonly color: NodeMaterialConnectionPoint;
  126344. /**
  126345. * Gets the level operand input component
  126346. */
  126347. readonly level: NodeMaterialConnectionPoint;
  126348. /**
  126349. * Gets the output component
  126350. */
  126351. readonly output: NodeMaterialConnectionPoint;
  126352. protected _buildBlock(state: NodeMaterialBuildState): this;
  126353. }
  126354. }
  126355. declare module BABYLON {
  126356. /**
  126357. * Effect Render Options
  126358. */
  126359. export interface IEffectRendererOptions {
  126360. /**
  126361. * Defines the vertices positions.
  126362. */
  126363. positions?: number[];
  126364. /**
  126365. * Defines the indices.
  126366. */
  126367. indices?: number[];
  126368. }
  126369. /**
  126370. * Helper class to render one or more effects
  126371. */
  126372. export class EffectRenderer {
  126373. private engine;
  126374. private static _DefaultOptions;
  126375. private _vertexBuffers;
  126376. private _indexBuffer;
  126377. private _ringBufferIndex;
  126378. private _ringScreenBuffer;
  126379. private _fullscreenViewport;
  126380. private _getNextFrameBuffer;
  126381. /**
  126382. * Creates an effect renderer
  126383. * @param engine the engine to use for rendering
  126384. * @param options defines the options of the effect renderer
  126385. */
  126386. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  126387. /**
  126388. * Sets the current viewport in normalized coordinates 0-1
  126389. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  126390. */
  126391. setViewport(viewport?: Viewport): void;
  126392. /**
  126393. * Binds the embedded attributes buffer to the effect.
  126394. * @param effect Defines the effect to bind the attributes for
  126395. */
  126396. bindBuffers(effect: Effect): void;
  126397. /**
  126398. * Sets the current effect wrapper to use during draw.
  126399. * The effect needs to be ready before calling this api.
  126400. * This also sets the default full screen position attribute.
  126401. * @param effectWrapper Defines the effect to draw with
  126402. */
  126403. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  126404. /**
  126405. * Draws a full screen quad.
  126406. */
  126407. draw(): void;
  126408. /**
  126409. * renders one or more effects to a specified texture
  126410. * @param effectWrappers list of effects to renderer
  126411. * @param outputTexture texture to draw to, if null it will render to the screen
  126412. */
  126413. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  126414. /**
  126415. * Disposes of the effect renderer
  126416. */
  126417. dispose(): void;
  126418. }
  126419. /**
  126420. * Options to create an EffectWrapper
  126421. */
  126422. interface EffectWrapperCreationOptions {
  126423. /**
  126424. * Engine to use to create the effect
  126425. */
  126426. engine: ThinEngine;
  126427. /**
  126428. * Fragment shader for the effect
  126429. */
  126430. fragmentShader: string;
  126431. /**
  126432. * Vertex shader for the effect
  126433. */
  126434. vertexShader?: string;
  126435. /**
  126436. * Attributes to use in the shader
  126437. */
  126438. attributeNames?: Array<string>;
  126439. /**
  126440. * Uniforms to use in the shader
  126441. */
  126442. uniformNames?: Array<string>;
  126443. /**
  126444. * Texture sampler names to use in the shader
  126445. */
  126446. samplerNames?: Array<string>;
  126447. /**
  126448. * The friendly name of the effect displayed in Spector.
  126449. */
  126450. name?: string;
  126451. }
  126452. /**
  126453. * Wraps an effect to be used for rendering
  126454. */
  126455. export class EffectWrapper {
  126456. /**
  126457. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  126458. */
  126459. onApplyObservable: Observable<{}>;
  126460. /**
  126461. * The underlying effect
  126462. */
  126463. effect: Effect;
  126464. /**
  126465. * Creates an effect to be renderer
  126466. * @param creationOptions options to create the effect
  126467. */
  126468. constructor(creationOptions: EffectWrapperCreationOptions);
  126469. /**
  126470. * Disposes of the effect wrapper
  126471. */
  126472. dispose(): void;
  126473. }
  126474. }
  126475. declare module BABYLON {
  126476. /**
  126477. * Helper class to push actions to a pool of workers.
  126478. */
  126479. export class WorkerPool implements IDisposable {
  126480. private _workerInfos;
  126481. private _pendingActions;
  126482. /**
  126483. * Constructor
  126484. * @param workers Array of workers to use for actions
  126485. */
  126486. constructor(workers: Array<Worker>);
  126487. /**
  126488. * Terminates all workers and clears any pending actions.
  126489. */
  126490. dispose(): void;
  126491. /**
  126492. * Pushes an action to the worker pool. If all the workers are active, the action will be
  126493. * pended until a worker has completed its action.
  126494. * @param action The action to perform. Call onComplete when the action is complete.
  126495. */
  126496. push(action: (worker: Worker, onComplete: () => void) => void): void;
  126497. private _execute;
  126498. }
  126499. }
  126500. declare module BABYLON {
  126501. /**
  126502. * Configuration for Draco compression
  126503. */
  126504. export interface IDracoCompressionConfiguration {
  126505. /**
  126506. * Configuration for the decoder.
  126507. */
  126508. decoder: {
  126509. /**
  126510. * The url to the WebAssembly module.
  126511. */
  126512. wasmUrl?: string;
  126513. /**
  126514. * The url to the WebAssembly binary.
  126515. */
  126516. wasmBinaryUrl?: string;
  126517. /**
  126518. * The url to the fallback JavaScript module.
  126519. */
  126520. fallbackUrl?: string;
  126521. };
  126522. }
  126523. /**
  126524. * Draco compression (https://google.github.io/draco/)
  126525. *
  126526. * This class wraps the Draco module.
  126527. *
  126528. * **Encoder**
  126529. *
  126530. * The encoder is not currently implemented.
  126531. *
  126532. * **Decoder**
  126533. *
  126534. * 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.
  126535. *
  126536. * To update the configuration, use the following code:
  126537. * ```javascript
  126538. * DracoCompression.Configuration = {
  126539. * decoder: {
  126540. * wasmUrl: "<url to the WebAssembly library>",
  126541. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  126542. * fallbackUrl: "<url to the fallback JavaScript library>",
  126543. * }
  126544. * };
  126545. * ```
  126546. *
  126547. * 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.
  126548. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  126549. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  126550. *
  126551. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  126552. * ```javascript
  126553. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  126554. * ```
  126555. *
  126556. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  126557. */
  126558. export class DracoCompression implements IDisposable {
  126559. private _workerPoolPromise?;
  126560. private _decoderModulePromise?;
  126561. /**
  126562. * The configuration. Defaults to the following urls:
  126563. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  126564. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  126565. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  126566. */
  126567. static Configuration: IDracoCompressionConfiguration;
  126568. /**
  126569. * Returns true if the decoder configuration is available.
  126570. */
  126571. static readonly DecoderAvailable: boolean;
  126572. /**
  126573. * Default number of workers to create when creating the draco compression object.
  126574. */
  126575. static DefaultNumWorkers: number;
  126576. private static GetDefaultNumWorkers;
  126577. private static _Default;
  126578. /**
  126579. * Default instance for the draco compression object.
  126580. */
  126581. static readonly Default: DracoCompression;
  126582. /**
  126583. * Constructor
  126584. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  126585. */
  126586. constructor(numWorkers?: number);
  126587. /**
  126588. * Stop all async operations and release resources.
  126589. */
  126590. dispose(): void;
  126591. /**
  126592. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  126593. * @returns a promise that resolves when ready
  126594. */
  126595. whenReadyAsync(): Promise<void>;
  126596. /**
  126597. * Decode Draco compressed mesh data to vertex data.
  126598. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  126599. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  126600. * @returns A promise that resolves with the decoded vertex data
  126601. */
  126602. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  126603. [kind: string]: number;
  126604. }): Promise<VertexData>;
  126605. }
  126606. }
  126607. declare module BABYLON {
  126608. /**
  126609. * Class for building Constructive Solid Geometry
  126610. */
  126611. export class CSG {
  126612. private polygons;
  126613. /**
  126614. * The world matrix
  126615. */
  126616. matrix: Matrix;
  126617. /**
  126618. * Stores the position
  126619. */
  126620. position: Vector3;
  126621. /**
  126622. * Stores the rotation
  126623. */
  126624. rotation: Vector3;
  126625. /**
  126626. * Stores the rotation quaternion
  126627. */
  126628. rotationQuaternion: Nullable<Quaternion>;
  126629. /**
  126630. * Stores the scaling vector
  126631. */
  126632. scaling: Vector3;
  126633. /**
  126634. * Convert the Mesh to CSG
  126635. * @param mesh The Mesh to convert to CSG
  126636. * @returns A new CSG from the Mesh
  126637. */
  126638. static FromMesh(mesh: Mesh): CSG;
  126639. /**
  126640. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  126641. * @param polygons Polygons used to construct a CSG solid
  126642. */
  126643. private static FromPolygons;
  126644. /**
  126645. * Clones, or makes a deep copy, of the CSG
  126646. * @returns A new CSG
  126647. */
  126648. clone(): CSG;
  126649. /**
  126650. * Unions this CSG with another CSG
  126651. * @param csg The CSG to union against this CSG
  126652. * @returns The unioned CSG
  126653. */
  126654. union(csg: CSG): CSG;
  126655. /**
  126656. * Unions this CSG with another CSG in place
  126657. * @param csg The CSG to union against this CSG
  126658. */
  126659. unionInPlace(csg: CSG): void;
  126660. /**
  126661. * Subtracts this CSG with another CSG
  126662. * @param csg The CSG to subtract against this CSG
  126663. * @returns A new CSG
  126664. */
  126665. subtract(csg: CSG): CSG;
  126666. /**
  126667. * Subtracts this CSG with another CSG in place
  126668. * @param csg The CSG to subtact against this CSG
  126669. */
  126670. subtractInPlace(csg: CSG): void;
  126671. /**
  126672. * Intersect this CSG with another CSG
  126673. * @param csg The CSG to intersect against this CSG
  126674. * @returns A new CSG
  126675. */
  126676. intersect(csg: CSG): CSG;
  126677. /**
  126678. * Intersects this CSG with another CSG in place
  126679. * @param csg The CSG to intersect against this CSG
  126680. */
  126681. intersectInPlace(csg: CSG): void;
  126682. /**
  126683. * Return a new CSG solid with solid and empty space switched. This solid is
  126684. * not modified.
  126685. * @returns A new CSG solid with solid and empty space switched
  126686. */
  126687. inverse(): CSG;
  126688. /**
  126689. * Inverses the CSG in place
  126690. */
  126691. inverseInPlace(): void;
  126692. /**
  126693. * This is used to keep meshes transformations so they can be restored
  126694. * when we build back a Babylon Mesh
  126695. * NB : All CSG operations are performed in world coordinates
  126696. * @param csg The CSG to copy the transform attributes from
  126697. * @returns This CSG
  126698. */
  126699. copyTransformAttributes(csg: CSG): CSG;
  126700. /**
  126701. * Build Raw mesh from CSG
  126702. * Coordinates here are in world space
  126703. * @param name The name of the mesh geometry
  126704. * @param scene The Scene
  126705. * @param keepSubMeshes Specifies if the submeshes should be kept
  126706. * @returns A new Mesh
  126707. */
  126708. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  126709. /**
  126710. * Build Mesh from CSG taking material and transforms into account
  126711. * @param name The name of the Mesh
  126712. * @param material The material of the Mesh
  126713. * @param scene The Scene
  126714. * @param keepSubMeshes Specifies if submeshes should be kept
  126715. * @returns The new Mesh
  126716. */
  126717. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  126718. }
  126719. }
  126720. declare module BABYLON {
  126721. /**
  126722. * Class used to create a trail following a mesh
  126723. */
  126724. export class TrailMesh extends Mesh {
  126725. private _generator;
  126726. private _autoStart;
  126727. private _running;
  126728. private _diameter;
  126729. private _length;
  126730. private _sectionPolygonPointsCount;
  126731. private _sectionVectors;
  126732. private _sectionNormalVectors;
  126733. private _beforeRenderObserver;
  126734. /**
  126735. * @constructor
  126736. * @param name The value used by scene.getMeshByName() to do a lookup.
  126737. * @param generator The mesh to generate a trail.
  126738. * @param scene The scene to add this mesh to.
  126739. * @param diameter Diameter of trailing mesh. Default is 1.
  126740. * @param length Length of trailing mesh. Default is 60.
  126741. * @param autoStart Automatically start trailing mesh. Default true.
  126742. */
  126743. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  126744. /**
  126745. * "TrailMesh"
  126746. * @returns "TrailMesh"
  126747. */
  126748. getClassName(): string;
  126749. private _createMesh;
  126750. /**
  126751. * Start trailing mesh.
  126752. */
  126753. start(): void;
  126754. /**
  126755. * Stop trailing mesh.
  126756. */
  126757. stop(): void;
  126758. /**
  126759. * Update trailing mesh geometry.
  126760. */
  126761. update(): void;
  126762. /**
  126763. * Returns a new TrailMesh object.
  126764. * @param name is a string, the name given to the new mesh
  126765. * @param newGenerator use new generator object for cloned trail mesh
  126766. * @returns a new mesh
  126767. */
  126768. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  126769. /**
  126770. * Serializes this trail mesh
  126771. * @param serializationObject object to write serialization to
  126772. */
  126773. serialize(serializationObject: any): void;
  126774. /**
  126775. * Parses a serialized trail mesh
  126776. * @param parsedMesh the serialized mesh
  126777. * @param scene the scene to create the trail mesh in
  126778. * @returns the created trail mesh
  126779. */
  126780. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  126781. }
  126782. }
  126783. declare module BABYLON {
  126784. /**
  126785. * Class containing static functions to help procedurally build meshes
  126786. */
  126787. export class TiledBoxBuilder {
  126788. /**
  126789. * Creates a box mesh
  126790. * 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)
  126791. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  126792. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126793. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126794. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126795. * @param name defines the name of the mesh
  126796. * @param options defines the options used to create the mesh
  126797. * @param scene defines the hosting scene
  126798. * @returns the box mesh
  126799. */
  126800. static CreateTiledBox(name: string, options: {
  126801. pattern?: number;
  126802. width?: number;
  126803. height?: number;
  126804. depth?: number;
  126805. tileSize?: number;
  126806. tileWidth?: number;
  126807. tileHeight?: number;
  126808. alignHorizontal?: number;
  126809. alignVertical?: number;
  126810. faceUV?: Vector4[];
  126811. faceColors?: Color4[];
  126812. sideOrientation?: number;
  126813. updatable?: boolean;
  126814. }, scene?: Nullable<Scene>): Mesh;
  126815. }
  126816. }
  126817. declare module BABYLON {
  126818. /**
  126819. * Class containing static functions to help procedurally build meshes
  126820. */
  126821. export class TorusKnotBuilder {
  126822. /**
  126823. * Creates a torus knot mesh
  126824. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  126825. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  126826. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  126827. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  126828. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126829. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126830. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  126831. * @param name defines the name of the mesh
  126832. * @param options defines the options used to create the mesh
  126833. * @param scene defines the hosting scene
  126834. * @returns the torus knot mesh
  126835. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  126836. */
  126837. static CreateTorusKnot(name: string, options: {
  126838. radius?: number;
  126839. tube?: number;
  126840. radialSegments?: number;
  126841. tubularSegments?: number;
  126842. p?: number;
  126843. q?: number;
  126844. updatable?: boolean;
  126845. sideOrientation?: number;
  126846. frontUVs?: Vector4;
  126847. backUVs?: Vector4;
  126848. }, scene: any): Mesh;
  126849. }
  126850. }
  126851. declare module BABYLON {
  126852. /**
  126853. * Polygon
  126854. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  126855. */
  126856. export class Polygon {
  126857. /**
  126858. * Creates a rectangle
  126859. * @param xmin bottom X coord
  126860. * @param ymin bottom Y coord
  126861. * @param xmax top X coord
  126862. * @param ymax top Y coord
  126863. * @returns points that make the resulting rectation
  126864. */
  126865. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  126866. /**
  126867. * Creates a circle
  126868. * @param radius radius of circle
  126869. * @param cx scale in x
  126870. * @param cy scale in y
  126871. * @param numberOfSides number of sides that make up the circle
  126872. * @returns points that make the resulting circle
  126873. */
  126874. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  126875. /**
  126876. * Creates a polygon from input string
  126877. * @param input Input polygon data
  126878. * @returns the parsed points
  126879. */
  126880. static Parse(input: string): Vector2[];
  126881. /**
  126882. * Starts building a polygon from x and y coordinates
  126883. * @param x x coordinate
  126884. * @param y y coordinate
  126885. * @returns the started path2
  126886. */
  126887. static StartingAt(x: number, y: number): Path2;
  126888. }
  126889. /**
  126890. * Builds a polygon
  126891. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  126892. */
  126893. export class PolygonMeshBuilder {
  126894. private _points;
  126895. private _outlinepoints;
  126896. private _holes;
  126897. private _name;
  126898. private _scene;
  126899. private _epoints;
  126900. private _eholes;
  126901. private _addToepoint;
  126902. /**
  126903. * Babylon reference to the earcut plugin.
  126904. */
  126905. bjsEarcut: any;
  126906. /**
  126907. * Creates a PolygonMeshBuilder
  126908. * @param name name of the builder
  126909. * @param contours Path of the polygon
  126910. * @param scene scene to add to when creating the mesh
  126911. * @param earcutInjection can be used to inject your own earcut reference
  126912. */
  126913. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  126914. /**
  126915. * Adds a whole within the polygon
  126916. * @param hole Array of points defining the hole
  126917. * @returns this
  126918. */
  126919. addHole(hole: Vector2[]): PolygonMeshBuilder;
  126920. /**
  126921. * Creates the polygon
  126922. * @param updatable If the mesh should be updatable
  126923. * @param depth The depth of the mesh created
  126924. * @returns the created mesh
  126925. */
  126926. build(updatable?: boolean, depth?: number): Mesh;
  126927. /**
  126928. * Creates the polygon
  126929. * @param depth The depth of the mesh created
  126930. * @returns the created VertexData
  126931. */
  126932. buildVertexData(depth?: number): VertexData;
  126933. /**
  126934. * Adds a side to the polygon
  126935. * @param positions points that make the polygon
  126936. * @param normals normals of the polygon
  126937. * @param uvs uvs of the polygon
  126938. * @param indices indices of the polygon
  126939. * @param bounds bounds of the polygon
  126940. * @param points points of the polygon
  126941. * @param depth depth of the polygon
  126942. * @param flip flip of the polygon
  126943. */
  126944. private addSide;
  126945. }
  126946. }
  126947. declare module BABYLON {
  126948. /**
  126949. * Class containing static functions to help procedurally build meshes
  126950. */
  126951. export class PolygonBuilder {
  126952. /**
  126953. * Creates a polygon mesh
  126954. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  126955. * * 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
  126956. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  126957. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126958. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  126959. * * Remember you can only change the shape positions, not their number when updating a polygon
  126960. * @param name defines the name of the mesh
  126961. * @param options defines the options used to create the mesh
  126962. * @param scene defines the hosting scene
  126963. * @param earcutInjection can be used to inject your own earcut reference
  126964. * @returns the polygon mesh
  126965. */
  126966. static CreatePolygon(name: string, options: {
  126967. shape: Vector3[];
  126968. holes?: Vector3[][];
  126969. depth?: number;
  126970. faceUV?: Vector4[];
  126971. faceColors?: Color4[];
  126972. updatable?: boolean;
  126973. sideOrientation?: number;
  126974. frontUVs?: Vector4;
  126975. backUVs?: Vector4;
  126976. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  126977. /**
  126978. * Creates an extruded polygon mesh, with depth in the Y direction.
  126979. * * 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)
  126980. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  126981. * @param name defines the name of the mesh
  126982. * @param options defines the options used to create the mesh
  126983. * @param scene defines the hosting scene
  126984. * @param earcutInjection can be used to inject your own earcut reference
  126985. * @returns the polygon mesh
  126986. */
  126987. static ExtrudePolygon(name: string, options: {
  126988. shape: Vector3[];
  126989. holes?: Vector3[][];
  126990. depth?: number;
  126991. faceUV?: Vector4[];
  126992. faceColors?: Color4[];
  126993. updatable?: boolean;
  126994. sideOrientation?: number;
  126995. frontUVs?: Vector4;
  126996. backUVs?: Vector4;
  126997. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  126998. }
  126999. }
  127000. declare module BABYLON {
  127001. /**
  127002. * Class containing static functions to help procedurally build meshes
  127003. */
  127004. export class LatheBuilder {
  127005. /**
  127006. * Creates lathe mesh.
  127007. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  127008. * * 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
  127009. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  127010. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  127011. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  127012. * * 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
  127013. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  127014. * * 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
  127015. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127016. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127017. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  127018. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127019. * @param name defines the name of the mesh
  127020. * @param options defines the options used to create the mesh
  127021. * @param scene defines the hosting scene
  127022. * @returns the lathe mesh
  127023. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  127024. */
  127025. static CreateLathe(name: string, options: {
  127026. shape: Vector3[];
  127027. radius?: number;
  127028. tessellation?: number;
  127029. clip?: number;
  127030. arc?: number;
  127031. closed?: boolean;
  127032. updatable?: boolean;
  127033. sideOrientation?: number;
  127034. frontUVs?: Vector4;
  127035. backUVs?: Vector4;
  127036. cap?: number;
  127037. invertUV?: boolean;
  127038. }, scene?: Nullable<Scene>): Mesh;
  127039. }
  127040. }
  127041. declare module BABYLON {
  127042. /**
  127043. * Class containing static functions to help procedurally build meshes
  127044. */
  127045. export class TiledPlaneBuilder {
  127046. /**
  127047. * Creates a tiled plane mesh
  127048. * * The parameter `pattern` will, depending on value, do nothing or
  127049. * * * flip (reflect about central vertical) alternate tiles across and up
  127050. * * * flip every tile on alternate rows
  127051. * * * rotate (180 degs) alternate tiles across and up
  127052. * * * rotate every tile on alternate rows
  127053. * * * flip and rotate alternate tiles across and up
  127054. * * * flip and rotate every tile on alternate rows
  127055. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  127056. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  127057. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127058. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  127059. * * 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)
  127060. * * 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)
  127061. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  127062. * @param name defines the name of the mesh
  127063. * @param options defines the options used to create the mesh
  127064. * @param scene defines the hosting scene
  127065. * @returns the box mesh
  127066. */
  127067. static CreateTiledPlane(name: string, options: {
  127068. pattern?: number;
  127069. tileSize?: number;
  127070. tileWidth?: number;
  127071. tileHeight?: number;
  127072. size?: number;
  127073. width?: number;
  127074. height?: number;
  127075. alignHorizontal?: number;
  127076. alignVertical?: number;
  127077. sideOrientation?: number;
  127078. frontUVs?: Vector4;
  127079. backUVs?: Vector4;
  127080. updatable?: boolean;
  127081. }, scene?: Nullable<Scene>): Mesh;
  127082. }
  127083. }
  127084. declare module BABYLON {
  127085. /**
  127086. * Class containing static functions to help procedurally build meshes
  127087. */
  127088. export class TubeBuilder {
  127089. /**
  127090. * Creates a tube mesh.
  127091. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  127092. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  127093. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  127094. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  127095. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  127096. * * 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)
  127097. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  127098. * * 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
  127099. * * 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
  127100. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127101. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127102. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  127103. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127104. * @param name defines the name of the mesh
  127105. * @param options defines the options used to create the mesh
  127106. * @param scene defines the hosting scene
  127107. * @returns the tube mesh
  127108. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  127109. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  127110. */
  127111. static CreateTube(name: string, options: {
  127112. path: Vector3[];
  127113. radius?: number;
  127114. tessellation?: number;
  127115. radiusFunction?: {
  127116. (i: number, distance: number): number;
  127117. };
  127118. cap?: number;
  127119. arc?: number;
  127120. updatable?: boolean;
  127121. sideOrientation?: number;
  127122. frontUVs?: Vector4;
  127123. backUVs?: Vector4;
  127124. instance?: Mesh;
  127125. invertUV?: boolean;
  127126. }, scene?: Nullable<Scene>): Mesh;
  127127. }
  127128. }
  127129. declare module BABYLON {
  127130. /**
  127131. * Class containing static functions to help procedurally build meshes
  127132. */
  127133. export class IcoSphereBuilder {
  127134. /**
  127135. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  127136. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  127137. * * 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`)
  127138. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  127139. * * 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
  127140. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127141. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127142. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127143. * @param name defines the name of the mesh
  127144. * @param options defines the options used to create the mesh
  127145. * @param scene defines the hosting scene
  127146. * @returns the icosahedron mesh
  127147. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  127148. */
  127149. static CreateIcoSphere(name: string, options: {
  127150. radius?: number;
  127151. radiusX?: number;
  127152. radiusY?: number;
  127153. radiusZ?: number;
  127154. flat?: boolean;
  127155. subdivisions?: number;
  127156. sideOrientation?: number;
  127157. frontUVs?: Vector4;
  127158. backUVs?: Vector4;
  127159. updatable?: boolean;
  127160. }, scene?: Nullable<Scene>): Mesh;
  127161. }
  127162. }
  127163. declare module BABYLON {
  127164. /**
  127165. * Class containing static functions to help procedurally build meshes
  127166. */
  127167. export class DecalBuilder {
  127168. /**
  127169. * Creates a decal mesh.
  127170. * 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
  127171. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  127172. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  127173. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  127174. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  127175. * @param name defines the name of the mesh
  127176. * @param sourceMesh defines the mesh where the decal must be applied
  127177. * @param options defines the options used to create the mesh
  127178. * @param scene defines the hosting scene
  127179. * @returns the decal mesh
  127180. * @see https://doc.babylonjs.com/how_to/decals
  127181. */
  127182. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  127183. position?: Vector3;
  127184. normal?: Vector3;
  127185. size?: Vector3;
  127186. angle?: number;
  127187. }): Mesh;
  127188. }
  127189. }
  127190. declare module BABYLON {
  127191. /**
  127192. * Class containing static functions to help procedurally build meshes
  127193. */
  127194. export class MeshBuilder {
  127195. /**
  127196. * Creates a box mesh
  127197. * * The parameter `size` sets the size (float) of each box side (default 1)
  127198. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  127199. * * 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)
  127200. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  127201. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127202. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127203. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127204. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  127205. * @param name defines the name of the mesh
  127206. * @param options defines the options used to create the mesh
  127207. * @param scene defines the hosting scene
  127208. * @returns the box mesh
  127209. */
  127210. static CreateBox(name: string, options: {
  127211. size?: number;
  127212. width?: number;
  127213. height?: number;
  127214. depth?: number;
  127215. faceUV?: Vector4[];
  127216. faceColors?: Color4[];
  127217. sideOrientation?: number;
  127218. frontUVs?: Vector4;
  127219. backUVs?: Vector4;
  127220. updatable?: boolean;
  127221. }, scene?: Nullable<Scene>): Mesh;
  127222. /**
  127223. * Creates a tiled box mesh
  127224. * * faceTiles sets the pattern, tile size and number of tiles for a face
  127225. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127226. * @param name defines the name of the mesh
  127227. * @param options defines the options used to create the mesh
  127228. * @param scene defines the hosting scene
  127229. * @returns the tiled box mesh
  127230. */
  127231. static CreateTiledBox(name: string, options: {
  127232. pattern?: number;
  127233. size?: number;
  127234. width?: number;
  127235. height?: number;
  127236. depth: number;
  127237. tileSize?: number;
  127238. tileWidth?: number;
  127239. tileHeight?: number;
  127240. faceUV?: Vector4[];
  127241. faceColors?: Color4[];
  127242. alignHorizontal?: number;
  127243. alignVertical?: number;
  127244. sideOrientation?: number;
  127245. updatable?: boolean;
  127246. }, scene?: Nullable<Scene>): Mesh;
  127247. /**
  127248. * Creates a sphere mesh
  127249. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  127250. * * 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`)
  127251. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  127252. * * 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
  127253. * * 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)
  127254. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127255. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127256. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127257. * @param name defines the name of the mesh
  127258. * @param options defines the options used to create the mesh
  127259. * @param scene defines the hosting scene
  127260. * @returns the sphere mesh
  127261. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  127262. */
  127263. static CreateSphere(name: string, options: {
  127264. segments?: number;
  127265. diameter?: number;
  127266. diameterX?: number;
  127267. diameterY?: number;
  127268. diameterZ?: number;
  127269. arc?: number;
  127270. slice?: number;
  127271. sideOrientation?: number;
  127272. frontUVs?: Vector4;
  127273. backUVs?: Vector4;
  127274. updatable?: boolean;
  127275. }, scene?: Nullable<Scene>): Mesh;
  127276. /**
  127277. * Creates a plane polygonal mesh. By default, this is a disc
  127278. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  127279. * * 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
  127280. * * 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
  127281. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127282. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127283. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127284. * @param name defines the name of the mesh
  127285. * @param options defines the options used to create the mesh
  127286. * @param scene defines the hosting scene
  127287. * @returns the plane polygonal mesh
  127288. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  127289. */
  127290. static CreateDisc(name: string, options: {
  127291. radius?: number;
  127292. tessellation?: number;
  127293. arc?: number;
  127294. updatable?: boolean;
  127295. sideOrientation?: number;
  127296. frontUVs?: Vector4;
  127297. backUVs?: Vector4;
  127298. }, scene?: Nullable<Scene>): Mesh;
  127299. /**
  127300. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  127301. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  127302. * * 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`)
  127303. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  127304. * * 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
  127305. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127306. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127307. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127308. * @param name defines the name of the mesh
  127309. * @param options defines the options used to create the mesh
  127310. * @param scene defines the hosting scene
  127311. * @returns the icosahedron mesh
  127312. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  127313. */
  127314. static CreateIcoSphere(name: string, options: {
  127315. radius?: number;
  127316. radiusX?: number;
  127317. radiusY?: number;
  127318. radiusZ?: number;
  127319. flat?: boolean;
  127320. subdivisions?: number;
  127321. sideOrientation?: number;
  127322. frontUVs?: Vector4;
  127323. backUVs?: Vector4;
  127324. updatable?: boolean;
  127325. }, scene?: Nullable<Scene>): Mesh;
  127326. /**
  127327. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  127328. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  127329. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  127330. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  127331. * * 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
  127332. * * 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
  127333. * * 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
  127334. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127335. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127336. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  127337. * * 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
  127338. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  127339. * * 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
  127340. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  127341. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127342. * @param name defines the name of the mesh
  127343. * @param options defines the options used to create the mesh
  127344. * @param scene defines the hosting scene
  127345. * @returns the ribbon mesh
  127346. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  127347. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  127348. */
  127349. static CreateRibbon(name: string, options: {
  127350. pathArray: Vector3[][];
  127351. closeArray?: boolean;
  127352. closePath?: boolean;
  127353. offset?: number;
  127354. updatable?: boolean;
  127355. sideOrientation?: number;
  127356. frontUVs?: Vector4;
  127357. backUVs?: Vector4;
  127358. instance?: Mesh;
  127359. invertUV?: boolean;
  127360. uvs?: Vector2[];
  127361. colors?: Color4[];
  127362. }, scene?: Nullable<Scene>): Mesh;
  127363. /**
  127364. * Creates a cylinder or a cone mesh
  127365. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  127366. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  127367. * * 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.
  127368. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  127369. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  127370. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  127371. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  127372. * * 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).
  127373. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  127374. * * 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).
  127375. * * 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
  127376. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  127377. * * 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
  127378. * * 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.
  127379. * * If `enclose` is false, a ring surface is one element.
  127380. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  127381. * * 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
  127382. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127383. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127384. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127385. * @param name defines the name of the mesh
  127386. * @param options defines the options used to create the mesh
  127387. * @param scene defines the hosting scene
  127388. * @returns the cylinder mesh
  127389. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  127390. */
  127391. static CreateCylinder(name: string, options: {
  127392. height?: number;
  127393. diameterTop?: number;
  127394. diameterBottom?: number;
  127395. diameter?: number;
  127396. tessellation?: number;
  127397. subdivisions?: number;
  127398. arc?: number;
  127399. faceColors?: Color4[];
  127400. faceUV?: Vector4[];
  127401. updatable?: boolean;
  127402. hasRings?: boolean;
  127403. enclose?: boolean;
  127404. cap?: number;
  127405. sideOrientation?: number;
  127406. frontUVs?: Vector4;
  127407. backUVs?: Vector4;
  127408. }, scene?: Nullable<Scene>): Mesh;
  127409. /**
  127410. * Creates a torus mesh
  127411. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  127412. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  127413. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  127414. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127415. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127416. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127417. * @param name defines the name of the mesh
  127418. * @param options defines the options used to create the mesh
  127419. * @param scene defines the hosting scene
  127420. * @returns the torus mesh
  127421. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  127422. */
  127423. static CreateTorus(name: string, options: {
  127424. diameter?: number;
  127425. thickness?: number;
  127426. tessellation?: number;
  127427. updatable?: boolean;
  127428. sideOrientation?: number;
  127429. frontUVs?: Vector4;
  127430. backUVs?: Vector4;
  127431. }, scene?: Nullable<Scene>): Mesh;
  127432. /**
  127433. * Creates a torus knot mesh
  127434. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  127435. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  127436. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  127437. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  127438. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127439. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127440. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127441. * @param name defines the name of the mesh
  127442. * @param options defines the options used to create the mesh
  127443. * @param scene defines the hosting scene
  127444. * @returns the torus knot mesh
  127445. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  127446. */
  127447. static CreateTorusKnot(name: string, options: {
  127448. radius?: number;
  127449. tube?: number;
  127450. radialSegments?: number;
  127451. tubularSegments?: number;
  127452. p?: number;
  127453. q?: number;
  127454. updatable?: boolean;
  127455. sideOrientation?: number;
  127456. frontUVs?: Vector4;
  127457. backUVs?: Vector4;
  127458. }, scene?: Nullable<Scene>): Mesh;
  127459. /**
  127460. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  127461. * * 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
  127462. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  127463. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  127464. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  127465. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  127466. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  127467. * * 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
  127468. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  127469. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127470. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  127471. * @param name defines the name of the new line system
  127472. * @param options defines the options used to create the line system
  127473. * @param scene defines the hosting scene
  127474. * @returns a new line system mesh
  127475. */
  127476. static CreateLineSystem(name: string, options: {
  127477. lines: Vector3[][];
  127478. updatable?: boolean;
  127479. instance?: Nullable<LinesMesh>;
  127480. colors?: Nullable<Color4[][]>;
  127481. useVertexAlpha?: boolean;
  127482. }, scene: Nullable<Scene>): LinesMesh;
  127483. /**
  127484. * Creates a line mesh
  127485. * 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
  127486. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  127487. * * The parameter `points` is an array successive Vector3
  127488. * * 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
  127489. * * The optional parameter `colors` is an array of successive Color4, one per line point
  127490. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  127491. * * When updating an instance, remember that only point positions can change, not the number of points
  127492. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127493. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  127494. * @param name defines the name of the new line system
  127495. * @param options defines the options used to create the line system
  127496. * @param scene defines the hosting scene
  127497. * @returns a new line mesh
  127498. */
  127499. static CreateLines(name: string, options: {
  127500. points: Vector3[];
  127501. updatable?: boolean;
  127502. instance?: Nullable<LinesMesh>;
  127503. colors?: Color4[];
  127504. useVertexAlpha?: boolean;
  127505. }, scene?: Nullable<Scene>): LinesMesh;
  127506. /**
  127507. * Creates a dashed line mesh
  127508. * * 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
  127509. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  127510. * * The parameter `points` is an array successive Vector3
  127511. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  127512. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  127513. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  127514. * * 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
  127515. * * When updating an instance, remember that only point positions can change, not the number of points
  127516. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127517. * @param name defines the name of the mesh
  127518. * @param options defines the options used to create the mesh
  127519. * @param scene defines the hosting scene
  127520. * @returns the dashed line mesh
  127521. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  127522. */
  127523. static CreateDashedLines(name: string, options: {
  127524. points: Vector3[];
  127525. dashSize?: number;
  127526. gapSize?: number;
  127527. dashNb?: number;
  127528. updatable?: boolean;
  127529. instance?: LinesMesh;
  127530. }, scene?: Nullable<Scene>): LinesMesh;
  127531. /**
  127532. * 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.
  127533. * * 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.
  127534. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  127535. * * 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.
  127536. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  127537. * * 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
  127538. * * 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
  127539. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  127540. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127541. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127542. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  127543. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127544. * @param name defines the name of the mesh
  127545. * @param options defines the options used to create the mesh
  127546. * @param scene defines the hosting scene
  127547. * @returns the extruded shape mesh
  127548. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  127549. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  127550. */
  127551. static ExtrudeShape(name: string, options: {
  127552. shape: Vector3[];
  127553. path: Vector3[];
  127554. scale?: number;
  127555. rotation?: number;
  127556. cap?: number;
  127557. updatable?: boolean;
  127558. sideOrientation?: number;
  127559. frontUVs?: Vector4;
  127560. backUVs?: Vector4;
  127561. instance?: Mesh;
  127562. invertUV?: boolean;
  127563. }, scene?: Nullable<Scene>): Mesh;
  127564. /**
  127565. * Creates an custom extruded shape mesh.
  127566. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  127567. * * 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.
  127568. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  127569. * * 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
  127570. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  127571. * * 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
  127572. * * It must returns a float value that will be the scale value applied to the shape on each path point
  127573. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  127574. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  127575. * * 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
  127576. * * 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
  127577. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  127578. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127579. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127580. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  127581. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127582. * @param name defines the name of the mesh
  127583. * @param options defines the options used to create the mesh
  127584. * @param scene defines the hosting scene
  127585. * @returns the custom extruded shape mesh
  127586. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  127587. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  127588. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  127589. */
  127590. static ExtrudeShapeCustom(name: string, options: {
  127591. shape: Vector3[];
  127592. path: Vector3[];
  127593. scaleFunction?: any;
  127594. rotationFunction?: any;
  127595. ribbonCloseArray?: boolean;
  127596. ribbonClosePath?: boolean;
  127597. cap?: number;
  127598. updatable?: boolean;
  127599. sideOrientation?: number;
  127600. frontUVs?: Vector4;
  127601. backUVs?: Vector4;
  127602. instance?: Mesh;
  127603. invertUV?: boolean;
  127604. }, scene?: Nullable<Scene>): Mesh;
  127605. /**
  127606. * Creates lathe mesh.
  127607. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  127608. * * 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
  127609. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  127610. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  127611. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  127612. * * 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
  127613. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  127614. * * 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
  127615. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127616. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127617. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  127618. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127619. * @param name defines the name of the mesh
  127620. * @param options defines the options used to create the mesh
  127621. * @param scene defines the hosting scene
  127622. * @returns the lathe mesh
  127623. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  127624. */
  127625. static CreateLathe(name: string, options: {
  127626. shape: Vector3[];
  127627. radius?: number;
  127628. tessellation?: number;
  127629. clip?: number;
  127630. arc?: number;
  127631. closed?: boolean;
  127632. updatable?: boolean;
  127633. sideOrientation?: number;
  127634. frontUVs?: Vector4;
  127635. backUVs?: Vector4;
  127636. cap?: number;
  127637. invertUV?: boolean;
  127638. }, scene?: Nullable<Scene>): Mesh;
  127639. /**
  127640. * Creates a tiled plane mesh
  127641. * * You can set a limited pattern arrangement with the tiles
  127642. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127643. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127644. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127645. * @param name defines the name of the mesh
  127646. * @param options defines the options used to create the mesh
  127647. * @param scene defines the hosting scene
  127648. * @returns the plane mesh
  127649. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  127650. */
  127651. static CreateTiledPlane(name: string, options: {
  127652. pattern?: number;
  127653. tileSize?: number;
  127654. tileWidth?: number;
  127655. tileHeight?: number;
  127656. size?: number;
  127657. width?: number;
  127658. height?: number;
  127659. alignHorizontal?: number;
  127660. alignVertical?: number;
  127661. sideOrientation?: number;
  127662. frontUVs?: Vector4;
  127663. backUVs?: Vector4;
  127664. updatable?: boolean;
  127665. }, scene?: Nullable<Scene>): Mesh;
  127666. /**
  127667. * Creates a plane mesh
  127668. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  127669. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  127670. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  127671. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127672. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127673. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127674. * @param name defines the name of the mesh
  127675. * @param options defines the options used to create the mesh
  127676. * @param scene defines the hosting scene
  127677. * @returns the plane mesh
  127678. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  127679. */
  127680. static CreatePlane(name: string, options: {
  127681. size?: number;
  127682. width?: number;
  127683. height?: number;
  127684. sideOrientation?: number;
  127685. frontUVs?: Vector4;
  127686. backUVs?: Vector4;
  127687. updatable?: boolean;
  127688. sourcePlane?: Plane;
  127689. }, scene?: Nullable<Scene>): Mesh;
  127690. /**
  127691. * Creates a ground mesh
  127692. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  127693. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  127694. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127695. * @param name defines the name of the mesh
  127696. * @param options defines the options used to create the mesh
  127697. * @param scene defines the hosting scene
  127698. * @returns the ground mesh
  127699. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  127700. */
  127701. static CreateGround(name: string, options: {
  127702. width?: number;
  127703. height?: number;
  127704. subdivisions?: number;
  127705. subdivisionsX?: number;
  127706. subdivisionsY?: number;
  127707. updatable?: boolean;
  127708. }, scene?: Nullable<Scene>): Mesh;
  127709. /**
  127710. * Creates a tiled ground mesh
  127711. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  127712. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  127713. * * 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
  127714. * * 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
  127715. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127716. * @param name defines the name of the mesh
  127717. * @param options defines the options used to create the mesh
  127718. * @param scene defines the hosting scene
  127719. * @returns the tiled ground mesh
  127720. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  127721. */
  127722. static CreateTiledGround(name: string, options: {
  127723. xmin: number;
  127724. zmin: number;
  127725. xmax: number;
  127726. zmax: number;
  127727. subdivisions?: {
  127728. w: number;
  127729. h: number;
  127730. };
  127731. precision?: {
  127732. w: number;
  127733. h: number;
  127734. };
  127735. updatable?: boolean;
  127736. }, scene?: Nullable<Scene>): Mesh;
  127737. /**
  127738. * Creates a ground mesh from a height map
  127739. * * The parameter `url` sets the URL of the height map image resource.
  127740. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  127741. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  127742. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  127743. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  127744. * * 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.
  127745. * * 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).
  127746. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  127747. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127748. * @param name defines the name of the mesh
  127749. * @param url defines the url to the height map
  127750. * @param options defines the options used to create the mesh
  127751. * @param scene defines the hosting scene
  127752. * @returns the ground mesh
  127753. * @see https://doc.babylonjs.com/babylon101/height_map
  127754. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  127755. */
  127756. static CreateGroundFromHeightMap(name: string, url: string, options: {
  127757. width?: number;
  127758. height?: number;
  127759. subdivisions?: number;
  127760. minHeight?: number;
  127761. maxHeight?: number;
  127762. colorFilter?: Color3;
  127763. alphaFilter?: number;
  127764. updatable?: boolean;
  127765. onReady?: (mesh: GroundMesh) => void;
  127766. }, scene?: Nullable<Scene>): GroundMesh;
  127767. /**
  127768. * Creates a polygon mesh
  127769. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  127770. * * 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
  127771. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  127772. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127773. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  127774. * * Remember you can only change the shape positions, not their number when updating a polygon
  127775. * @param name defines the name of the mesh
  127776. * @param options defines the options used to create the mesh
  127777. * @param scene defines the hosting scene
  127778. * @param earcutInjection can be used to inject your own earcut reference
  127779. * @returns the polygon mesh
  127780. */
  127781. static CreatePolygon(name: string, options: {
  127782. shape: Vector3[];
  127783. holes?: Vector3[][];
  127784. depth?: number;
  127785. faceUV?: Vector4[];
  127786. faceColors?: Color4[];
  127787. updatable?: boolean;
  127788. sideOrientation?: number;
  127789. frontUVs?: Vector4;
  127790. backUVs?: Vector4;
  127791. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  127792. /**
  127793. * Creates an extruded polygon mesh, with depth in the Y direction.
  127794. * * 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)
  127795. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  127796. * @param name defines the name of the mesh
  127797. * @param options defines the options used to create the mesh
  127798. * @param scene defines the hosting scene
  127799. * @param earcutInjection can be used to inject your own earcut reference
  127800. * @returns the polygon mesh
  127801. */
  127802. static ExtrudePolygon(name: string, options: {
  127803. shape: Vector3[];
  127804. holes?: Vector3[][];
  127805. depth?: number;
  127806. faceUV?: Vector4[];
  127807. faceColors?: Color4[];
  127808. updatable?: boolean;
  127809. sideOrientation?: number;
  127810. frontUVs?: Vector4;
  127811. backUVs?: Vector4;
  127812. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  127813. /**
  127814. * Creates a tube mesh.
  127815. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  127816. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  127817. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  127818. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  127819. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  127820. * * 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)
  127821. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  127822. * * 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
  127823. * * 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
  127824. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127825. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127826. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  127827. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127828. * @param name defines the name of the mesh
  127829. * @param options defines the options used to create the mesh
  127830. * @param scene defines the hosting scene
  127831. * @returns the tube mesh
  127832. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  127833. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  127834. */
  127835. static CreateTube(name: string, options: {
  127836. path: Vector3[];
  127837. radius?: number;
  127838. tessellation?: number;
  127839. radiusFunction?: {
  127840. (i: number, distance: number): number;
  127841. };
  127842. cap?: number;
  127843. arc?: number;
  127844. updatable?: boolean;
  127845. sideOrientation?: number;
  127846. frontUVs?: Vector4;
  127847. backUVs?: Vector4;
  127848. instance?: Mesh;
  127849. invertUV?: boolean;
  127850. }, scene?: Nullable<Scene>): Mesh;
  127851. /**
  127852. * Creates a polyhedron mesh
  127853. * * 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
  127854. * * The parameter `size` (positive float, default 1) sets the polygon size
  127855. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  127856. * * 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`
  127857. * * 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
  127858. * * 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)`)
  127859. * * 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
  127860. * * 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
  127861. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127862. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127863. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127864. * @param name defines the name of the mesh
  127865. * @param options defines the options used to create the mesh
  127866. * @param scene defines the hosting scene
  127867. * @returns the polyhedron mesh
  127868. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  127869. */
  127870. static CreatePolyhedron(name: string, options: {
  127871. type?: number;
  127872. size?: number;
  127873. sizeX?: number;
  127874. sizeY?: number;
  127875. sizeZ?: number;
  127876. custom?: any;
  127877. faceUV?: Vector4[];
  127878. faceColors?: Color4[];
  127879. flat?: boolean;
  127880. updatable?: boolean;
  127881. sideOrientation?: number;
  127882. frontUVs?: Vector4;
  127883. backUVs?: Vector4;
  127884. }, scene?: Nullable<Scene>): Mesh;
  127885. /**
  127886. * Creates a decal mesh.
  127887. * 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
  127888. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  127889. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  127890. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  127891. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  127892. * @param name defines the name of the mesh
  127893. * @param sourceMesh defines the mesh where the decal must be applied
  127894. * @param options defines the options used to create the mesh
  127895. * @param scene defines the hosting scene
  127896. * @returns the decal mesh
  127897. * @see https://doc.babylonjs.com/how_to/decals
  127898. */
  127899. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  127900. position?: Vector3;
  127901. normal?: Vector3;
  127902. size?: Vector3;
  127903. angle?: number;
  127904. }): Mesh;
  127905. }
  127906. }
  127907. declare module BABYLON {
  127908. /**
  127909. * A simplifier interface for future simplification implementations
  127910. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  127911. */
  127912. export interface ISimplifier {
  127913. /**
  127914. * Simplification of a given mesh according to the given settings.
  127915. * Since this requires computation, it is assumed that the function runs async.
  127916. * @param settings The settings of the simplification, including quality and distance
  127917. * @param successCallback A callback that will be called after the mesh was simplified.
  127918. * @param errorCallback in case of an error, this callback will be called. optional.
  127919. */
  127920. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  127921. }
  127922. /**
  127923. * Expected simplification settings.
  127924. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  127925. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  127926. */
  127927. export interface ISimplificationSettings {
  127928. /**
  127929. * Gets or sets the expected quality
  127930. */
  127931. quality: number;
  127932. /**
  127933. * Gets or sets the distance when this optimized version should be used
  127934. */
  127935. distance: number;
  127936. /**
  127937. * Gets an already optimized mesh
  127938. */
  127939. optimizeMesh?: boolean;
  127940. }
  127941. /**
  127942. * Class used to specify simplification options
  127943. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  127944. */
  127945. export class SimplificationSettings implements ISimplificationSettings {
  127946. /** expected quality */
  127947. quality: number;
  127948. /** distance when this optimized version should be used */
  127949. distance: number;
  127950. /** already optimized mesh */
  127951. optimizeMesh?: boolean | undefined;
  127952. /**
  127953. * Creates a SimplificationSettings
  127954. * @param quality expected quality
  127955. * @param distance distance when this optimized version should be used
  127956. * @param optimizeMesh already optimized mesh
  127957. */
  127958. constructor(
  127959. /** expected quality */
  127960. quality: number,
  127961. /** distance when this optimized version should be used */
  127962. distance: number,
  127963. /** already optimized mesh */
  127964. optimizeMesh?: boolean | undefined);
  127965. }
  127966. /**
  127967. * Interface used to define a simplification task
  127968. */
  127969. export interface ISimplificationTask {
  127970. /**
  127971. * Array of settings
  127972. */
  127973. settings: Array<ISimplificationSettings>;
  127974. /**
  127975. * Simplification type
  127976. */
  127977. simplificationType: SimplificationType;
  127978. /**
  127979. * Mesh to simplify
  127980. */
  127981. mesh: Mesh;
  127982. /**
  127983. * Callback called on success
  127984. */
  127985. successCallback?: () => void;
  127986. /**
  127987. * Defines if parallel processing can be used
  127988. */
  127989. parallelProcessing: boolean;
  127990. }
  127991. /**
  127992. * Queue used to order the simplification tasks
  127993. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  127994. */
  127995. export class SimplificationQueue {
  127996. private _simplificationArray;
  127997. /**
  127998. * Gets a boolean indicating that the process is still running
  127999. */
  128000. running: boolean;
  128001. /**
  128002. * Creates a new queue
  128003. */
  128004. constructor();
  128005. /**
  128006. * Adds a new simplification task
  128007. * @param task defines a task to add
  128008. */
  128009. addTask(task: ISimplificationTask): void;
  128010. /**
  128011. * Execute next task
  128012. */
  128013. executeNext(): void;
  128014. /**
  128015. * Execute a simplification task
  128016. * @param task defines the task to run
  128017. */
  128018. runSimplification(task: ISimplificationTask): void;
  128019. private getSimplifier;
  128020. }
  128021. /**
  128022. * The implemented types of simplification
  128023. * At the moment only Quadratic Error Decimation is implemented
  128024. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  128025. */
  128026. export enum SimplificationType {
  128027. /** Quadratic error decimation */
  128028. QUADRATIC = 0
  128029. }
  128030. }
  128031. declare module BABYLON {
  128032. interface Scene {
  128033. /** @hidden (Backing field) */
  128034. _simplificationQueue: SimplificationQueue;
  128035. /**
  128036. * Gets or sets the simplification queue attached to the scene
  128037. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  128038. */
  128039. simplificationQueue: SimplificationQueue;
  128040. }
  128041. interface Mesh {
  128042. /**
  128043. * Simplify the mesh according to the given array of settings.
  128044. * Function will return immediately and will simplify async
  128045. * @param settings a collection of simplification settings
  128046. * @param parallelProcessing should all levels calculate parallel or one after the other
  128047. * @param simplificationType the type of simplification to run
  128048. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  128049. * @returns the current mesh
  128050. */
  128051. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  128052. }
  128053. /**
  128054. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  128055. * created in a scene
  128056. */
  128057. export class SimplicationQueueSceneComponent implements ISceneComponent {
  128058. /**
  128059. * The component name helpfull to identify the component in the list of scene components.
  128060. */
  128061. readonly name: string;
  128062. /**
  128063. * The scene the component belongs to.
  128064. */
  128065. scene: Scene;
  128066. /**
  128067. * Creates a new instance of the component for the given scene
  128068. * @param scene Defines the scene to register the component in
  128069. */
  128070. constructor(scene: Scene);
  128071. /**
  128072. * Registers the component in a given scene
  128073. */
  128074. register(): void;
  128075. /**
  128076. * Rebuilds the elements related to this component in case of
  128077. * context lost for instance.
  128078. */
  128079. rebuild(): void;
  128080. /**
  128081. * Disposes the component and the associated ressources
  128082. */
  128083. dispose(): void;
  128084. private _beforeCameraUpdate;
  128085. }
  128086. }
  128087. declare module BABYLON {
  128088. /**
  128089. * Navigation plugin interface to add navigation constrained by a navigation mesh
  128090. */
  128091. export interface INavigationEnginePlugin {
  128092. /**
  128093. * plugin name
  128094. */
  128095. name: string;
  128096. /**
  128097. * Creates a navigation mesh
  128098. * @param meshes array of all the geometry used to compute the navigatio mesh
  128099. * @param parameters bunch of parameters used to filter geometry
  128100. */
  128101. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  128102. /**
  128103. * Create a navigation mesh debug mesh
  128104. * @param scene is where the mesh will be added
  128105. * @returns debug display mesh
  128106. */
  128107. createDebugNavMesh(scene: Scene): Mesh;
  128108. /**
  128109. * Get a navigation mesh constrained position, closest to the parameter position
  128110. * @param position world position
  128111. * @returns the closest point to position constrained by the navigation mesh
  128112. */
  128113. getClosestPoint(position: Vector3): Vector3;
  128114. /**
  128115. * Get a navigation mesh constrained position, within a particular radius
  128116. * @param position world position
  128117. * @param maxRadius the maximum distance to the constrained world position
  128118. * @returns the closest point to position constrained by the navigation mesh
  128119. */
  128120. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  128121. /**
  128122. * Compute the final position from a segment made of destination-position
  128123. * @param position world position
  128124. * @param destination world position
  128125. * @returns the resulting point along the navmesh
  128126. */
  128127. moveAlong(position: Vector3, destination: Vector3): Vector3;
  128128. /**
  128129. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  128130. * @param start world position
  128131. * @param end world position
  128132. * @returns array containing world position composing the path
  128133. */
  128134. computePath(start: Vector3, end: Vector3): Vector3[];
  128135. /**
  128136. * If this plugin is supported
  128137. * @returns true if plugin is supported
  128138. */
  128139. isSupported(): boolean;
  128140. /**
  128141. * Create a new Crowd so you can add agents
  128142. * @param maxAgents the maximum agent count in the crowd
  128143. * @param maxAgentRadius the maximum radius an agent can have
  128144. * @param scene to attach the crowd to
  128145. * @returns the crowd you can add agents to
  128146. */
  128147. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  128148. /**
  128149. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  128150. * The queries will try to find a solution within those bounds
  128151. * default is (1,1,1)
  128152. * @param extent x,y,z value that define the extent around the queries point of reference
  128153. */
  128154. setDefaultQueryExtent(extent: Vector3): void;
  128155. /**
  128156. * Get the Bounding box extent specified by setDefaultQueryExtent
  128157. * @returns the box extent values
  128158. */
  128159. getDefaultQueryExtent(): Vector3;
  128160. /**
  128161. * Release all resources
  128162. */
  128163. dispose(): void;
  128164. }
  128165. /**
  128166. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  128167. */
  128168. export interface ICrowd {
  128169. /**
  128170. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  128171. * You can attach anything to that node. The node position is updated in the scene update tick.
  128172. * @param pos world position that will be constrained by the navigation mesh
  128173. * @param parameters agent parameters
  128174. * @param transform hooked to the agent that will be update by the scene
  128175. * @returns agent index
  128176. */
  128177. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  128178. /**
  128179. * Returns the agent position in world space
  128180. * @param index agent index returned by addAgent
  128181. * @returns world space position
  128182. */
  128183. getAgentPosition(index: number): Vector3;
  128184. /**
  128185. * Gets the agent velocity in world space
  128186. * @param index agent index returned by addAgent
  128187. * @returns world space velocity
  128188. */
  128189. getAgentVelocity(index: number): Vector3;
  128190. /**
  128191. * remove a particular agent previously created
  128192. * @param index agent index returned by addAgent
  128193. */
  128194. removeAgent(index: number): void;
  128195. /**
  128196. * get the list of all agents attached to this crowd
  128197. * @returns list of agent indices
  128198. */
  128199. getAgents(): number[];
  128200. /**
  128201. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  128202. * @param deltaTime in seconds
  128203. */
  128204. update(deltaTime: number): void;
  128205. /**
  128206. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  128207. * @param index agent index returned by addAgent
  128208. * @param destination targeted world position
  128209. */
  128210. agentGoto(index: number, destination: Vector3): void;
  128211. /**
  128212. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  128213. * The queries will try to find a solution within those bounds
  128214. * default is (1,1,1)
  128215. * @param extent x,y,z value that define the extent around the queries point of reference
  128216. */
  128217. setDefaultQueryExtent(extent: Vector3): void;
  128218. /**
  128219. * Get the Bounding box extent specified by setDefaultQueryExtent
  128220. * @returns the box extent values
  128221. */
  128222. getDefaultQueryExtent(): Vector3;
  128223. /**
  128224. * Release all resources
  128225. */
  128226. dispose(): void;
  128227. }
  128228. /**
  128229. * Configures an agent
  128230. */
  128231. export interface IAgentParameters {
  128232. /**
  128233. * Agent radius. [Limit: >= 0]
  128234. */
  128235. radius: number;
  128236. /**
  128237. * Agent height. [Limit: > 0]
  128238. */
  128239. height: number;
  128240. /**
  128241. * Maximum allowed acceleration. [Limit: >= 0]
  128242. */
  128243. maxAcceleration: number;
  128244. /**
  128245. * Maximum allowed speed. [Limit: >= 0]
  128246. */
  128247. maxSpeed: number;
  128248. /**
  128249. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  128250. */
  128251. collisionQueryRange: number;
  128252. /**
  128253. * The path visibility optimization range. [Limit: > 0]
  128254. */
  128255. pathOptimizationRange: number;
  128256. /**
  128257. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  128258. */
  128259. separationWeight: number;
  128260. }
  128261. /**
  128262. * Configures the navigation mesh creation
  128263. */
  128264. export interface INavMeshParameters {
  128265. /**
  128266. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  128267. */
  128268. cs: number;
  128269. /**
  128270. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  128271. */
  128272. ch: number;
  128273. /**
  128274. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  128275. */
  128276. walkableSlopeAngle: number;
  128277. /**
  128278. * Minimum floor to 'ceiling' height that will still allow the floor area to
  128279. * be considered walkable. [Limit: >= 3] [Units: vx]
  128280. */
  128281. walkableHeight: number;
  128282. /**
  128283. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  128284. */
  128285. walkableClimb: number;
  128286. /**
  128287. * The distance to erode/shrink the walkable area of the heightfield away from
  128288. * obstructions. [Limit: >=0] [Units: vx]
  128289. */
  128290. walkableRadius: number;
  128291. /**
  128292. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  128293. */
  128294. maxEdgeLen: number;
  128295. /**
  128296. * The maximum distance a simplfied contour's border edges should deviate
  128297. * the original raw contour. [Limit: >=0] [Units: vx]
  128298. */
  128299. maxSimplificationError: number;
  128300. /**
  128301. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  128302. */
  128303. minRegionArea: number;
  128304. /**
  128305. * Any regions with a span count smaller than this value will, if possible,
  128306. * be merged with larger regions. [Limit: >=0] [Units: vx]
  128307. */
  128308. mergeRegionArea: number;
  128309. /**
  128310. * The maximum number of vertices allowed for polygons generated during the
  128311. * contour to polygon conversion process. [Limit: >= 3]
  128312. */
  128313. maxVertsPerPoly: number;
  128314. /**
  128315. * Sets the sampling distance to use when generating the detail mesh.
  128316. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  128317. */
  128318. detailSampleDist: number;
  128319. /**
  128320. * The maximum distance the detail mesh surface should deviate from heightfield
  128321. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  128322. */
  128323. detailSampleMaxError: number;
  128324. }
  128325. }
  128326. declare module BABYLON {
  128327. /**
  128328. * RecastJS navigation plugin
  128329. */
  128330. export class RecastJSPlugin implements INavigationEnginePlugin {
  128331. /**
  128332. * Reference to the Recast library
  128333. */
  128334. bjsRECAST: any;
  128335. /**
  128336. * plugin name
  128337. */
  128338. name: string;
  128339. /**
  128340. * the first navmesh created. We might extend this to support multiple navmeshes
  128341. */
  128342. navMesh: any;
  128343. /**
  128344. * Initializes the recastJS plugin
  128345. * @param recastInjection can be used to inject your own recast reference
  128346. */
  128347. constructor(recastInjection?: any);
  128348. /**
  128349. * Creates a navigation mesh
  128350. * @param meshes array of all the geometry used to compute the navigatio mesh
  128351. * @param parameters bunch of parameters used to filter geometry
  128352. */
  128353. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  128354. /**
  128355. * Create a navigation mesh debug mesh
  128356. * @param scene is where the mesh will be added
  128357. * @returns debug display mesh
  128358. */
  128359. createDebugNavMesh(scene: Scene): Mesh;
  128360. /**
  128361. * Get a navigation mesh constrained position, closest to the parameter position
  128362. * @param position world position
  128363. * @returns the closest point to position constrained by the navigation mesh
  128364. */
  128365. getClosestPoint(position: Vector3): Vector3;
  128366. /**
  128367. * Get a navigation mesh constrained position, within a particular radius
  128368. * @param position world position
  128369. * @param maxRadius the maximum distance to the constrained world position
  128370. * @returns the closest point to position constrained by the navigation mesh
  128371. */
  128372. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  128373. /**
  128374. * Compute the final position from a segment made of destination-position
  128375. * @param position world position
  128376. * @param destination world position
  128377. * @returns the resulting point along the navmesh
  128378. */
  128379. moveAlong(position: Vector3, destination: Vector3): Vector3;
  128380. /**
  128381. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  128382. * @param start world position
  128383. * @param end world position
  128384. * @returns array containing world position composing the path
  128385. */
  128386. computePath(start: Vector3, end: Vector3): Vector3[];
  128387. /**
  128388. * Create a new Crowd so you can add agents
  128389. * @param maxAgents the maximum agent count in the crowd
  128390. * @param maxAgentRadius the maximum radius an agent can have
  128391. * @param scene to attach the crowd to
  128392. * @returns the crowd you can add agents to
  128393. */
  128394. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  128395. /**
  128396. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  128397. * The queries will try to find a solution within those bounds
  128398. * default is (1,1,1)
  128399. * @param extent x,y,z value that define the extent around the queries point of reference
  128400. */
  128401. setDefaultQueryExtent(extent: Vector3): void;
  128402. /**
  128403. * Get the Bounding box extent specified by setDefaultQueryExtent
  128404. * @returns the box extent values
  128405. */
  128406. getDefaultQueryExtent(): Vector3;
  128407. /**
  128408. * Disposes
  128409. */
  128410. dispose(): void;
  128411. /**
  128412. * If this plugin is supported
  128413. * @returns true if plugin is supported
  128414. */
  128415. isSupported(): boolean;
  128416. }
  128417. /**
  128418. * Recast detour crowd implementation
  128419. */
  128420. export class RecastJSCrowd implements ICrowd {
  128421. /**
  128422. * Recast/detour plugin
  128423. */
  128424. bjsRECASTPlugin: RecastJSPlugin;
  128425. /**
  128426. * Link to the detour crowd
  128427. */
  128428. recastCrowd: any;
  128429. /**
  128430. * One transform per agent
  128431. */
  128432. transforms: TransformNode[];
  128433. /**
  128434. * All agents created
  128435. */
  128436. agents: number[];
  128437. /**
  128438. * Link to the scene is kept to unregister the crowd from the scene
  128439. */
  128440. private _scene;
  128441. /**
  128442. * Observer for crowd updates
  128443. */
  128444. private _onBeforeAnimationsObserver;
  128445. /**
  128446. * Constructor
  128447. * @param plugin recastJS plugin
  128448. * @param maxAgents the maximum agent count in the crowd
  128449. * @param maxAgentRadius the maximum radius an agent can have
  128450. * @param scene to attach the crowd to
  128451. * @returns the crowd you can add agents to
  128452. */
  128453. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  128454. /**
  128455. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  128456. * You can attach anything to that node. The node position is updated in the scene update tick.
  128457. * @param pos world position that will be constrained by the navigation mesh
  128458. * @param parameters agent parameters
  128459. * @param transform hooked to the agent that will be update by the scene
  128460. * @returns agent index
  128461. */
  128462. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  128463. /**
  128464. * Returns the agent position in world space
  128465. * @param index agent index returned by addAgent
  128466. * @returns world space position
  128467. */
  128468. getAgentPosition(index: number): Vector3;
  128469. /**
  128470. * Returns the agent velocity in world space
  128471. * @param index agent index returned by addAgent
  128472. * @returns world space velocity
  128473. */
  128474. getAgentVelocity(index: number): Vector3;
  128475. /**
  128476. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  128477. * @param index agent index returned by addAgent
  128478. * @param destination targeted world position
  128479. */
  128480. agentGoto(index: number, destination: Vector3): void;
  128481. /**
  128482. * remove a particular agent previously created
  128483. * @param index agent index returned by addAgent
  128484. */
  128485. removeAgent(index: number): void;
  128486. /**
  128487. * get the list of all agents attached to this crowd
  128488. * @returns list of agent indices
  128489. */
  128490. getAgents(): number[];
  128491. /**
  128492. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  128493. * @param deltaTime in seconds
  128494. */
  128495. update(deltaTime: number): void;
  128496. /**
  128497. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  128498. * The queries will try to find a solution within those bounds
  128499. * default is (1,1,1)
  128500. * @param extent x,y,z value that define the extent around the queries point of reference
  128501. */
  128502. setDefaultQueryExtent(extent: Vector3): void;
  128503. /**
  128504. * Get the Bounding box extent specified by setDefaultQueryExtent
  128505. * @returns the box extent values
  128506. */
  128507. getDefaultQueryExtent(): Vector3;
  128508. /**
  128509. * Release all resources
  128510. */
  128511. dispose(): void;
  128512. }
  128513. }
  128514. declare module BABYLON {
  128515. /**
  128516. * Class used to enable access to IndexedDB
  128517. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  128518. */
  128519. export class Database implements IOfflineProvider {
  128520. private _callbackManifestChecked;
  128521. private _currentSceneUrl;
  128522. private _db;
  128523. private _enableSceneOffline;
  128524. private _enableTexturesOffline;
  128525. private _manifestVersionFound;
  128526. private _mustUpdateRessources;
  128527. private _hasReachedQuota;
  128528. private _isSupported;
  128529. private _idbFactory;
  128530. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  128531. private static IsUASupportingBlobStorage;
  128532. /**
  128533. * Gets a boolean indicating if Database storate is enabled (off by default)
  128534. */
  128535. static IDBStorageEnabled: boolean;
  128536. /**
  128537. * Gets a boolean indicating if scene must be saved in the database
  128538. */
  128539. readonly enableSceneOffline: boolean;
  128540. /**
  128541. * Gets a boolean indicating if textures must be saved in the database
  128542. */
  128543. readonly enableTexturesOffline: boolean;
  128544. /**
  128545. * Creates a new Database
  128546. * @param urlToScene defines the url to load the scene
  128547. * @param callbackManifestChecked defines the callback to use when manifest is checked
  128548. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  128549. */
  128550. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  128551. private static _ParseURL;
  128552. private static _ReturnFullUrlLocation;
  128553. private _checkManifestFile;
  128554. /**
  128555. * Open the database and make it available
  128556. * @param successCallback defines the callback to call on success
  128557. * @param errorCallback defines the callback to call on error
  128558. */
  128559. open(successCallback: () => void, errorCallback: () => void): void;
  128560. /**
  128561. * Loads an image from the database
  128562. * @param url defines the url to load from
  128563. * @param image defines the target DOM image
  128564. */
  128565. loadImage(url: string, image: HTMLImageElement): void;
  128566. private _loadImageFromDBAsync;
  128567. private _saveImageIntoDBAsync;
  128568. private _checkVersionFromDB;
  128569. private _loadVersionFromDBAsync;
  128570. private _saveVersionIntoDBAsync;
  128571. /**
  128572. * Loads a file from database
  128573. * @param url defines the URL to load from
  128574. * @param sceneLoaded defines a callback to call on success
  128575. * @param progressCallBack defines a callback to call when progress changed
  128576. * @param errorCallback defines a callback to call on error
  128577. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  128578. */
  128579. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  128580. private _loadFileAsync;
  128581. private _saveFileAsync;
  128582. /**
  128583. * Validates if xhr data is correct
  128584. * @param xhr defines the request to validate
  128585. * @param dataType defines the expected data type
  128586. * @returns true if data is correct
  128587. */
  128588. private static _ValidateXHRData;
  128589. }
  128590. }
  128591. declare module BABYLON {
  128592. /** @hidden */
  128593. export var gpuUpdateParticlesPixelShader: {
  128594. name: string;
  128595. shader: string;
  128596. };
  128597. }
  128598. declare module BABYLON {
  128599. /** @hidden */
  128600. export var gpuUpdateParticlesVertexShader: {
  128601. name: string;
  128602. shader: string;
  128603. };
  128604. }
  128605. declare module BABYLON {
  128606. /** @hidden */
  128607. export var clipPlaneFragmentDeclaration2: {
  128608. name: string;
  128609. shader: string;
  128610. };
  128611. }
  128612. declare module BABYLON {
  128613. /** @hidden */
  128614. export var gpuRenderParticlesPixelShader: {
  128615. name: string;
  128616. shader: string;
  128617. };
  128618. }
  128619. declare module BABYLON {
  128620. /** @hidden */
  128621. export var clipPlaneVertexDeclaration2: {
  128622. name: string;
  128623. shader: string;
  128624. };
  128625. }
  128626. declare module BABYLON {
  128627. /** @hidden */
  128628. export var gpuRenderParticlesVertexShader: {
  128629. name: string;
  128630. shader: string;
  128631. };
  128632. }
  128633. declare module BABYLON {
  128634. /**
  128635. * This represents a GPU particle system in Babylon
  128636. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  128637. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  128638. */
  128639. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  128640. /**
  128641. * The layer mask we are rendering the particles through.
  128642. */
  128643. layerMask: number;
  128644. private _capacity;
  128645. private _activeCount;
  128646. private _currentActiveCount;
  128647. private _accumulatedCount;
  128648. private _renderEffect;
  128649. private _updateEffect;
  128650. private _buffer0;
  128651. private _buffer1;
  128652. private _spriteBuffer;
  128653. private _updateVAO;
  128654. private _renderVAO;
  128655. private _targetIndex;
  128656. private _sourceBuffer;
  128657. private _targetBuffer;
  128658. private _engine;
  128659. private _currentRenderId;
  128660. private _started;
  128661. private _stopped;
  128662. private _timeDelta;
  128663. private _randomTexture;
  128664. private _randomTexture2;
  128665. private _attributesStrideSize;
  128666. private _updateEffectOptions;
  128667. private _randomTextureSize;
  128668. private _actualFrame;
  128669. private readonly _rawTextureWidth;
  128670. /**
  128671. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  128672. */
  128673. static readonly IsSupported: boolean;
  128674. /**
  128675. * An event triggered when the system is disposed.
  128676. */
  128677. onDisposeObservable: Observable<GPUParticleSystem>;
  128678. /**
  128679. * Gets the maximum number of particles active at the same time.
  128680. * @returns The max number of active particles.
  128681. */
  128682. getCapacity(): number;
  128683. /**
  128684. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  128685. * to override the particles.
  128686. */
  128687. forceDepthWrite: boolean;
  128688. /**
  128689. * Gets or set the number of active particles
  128690. */
  128691. activeParticleCount: number;
  128692. private _preWarmDone;
  128693. /**
  128694. * Is this system ready to be used/rendered
  128695. * @return true if the system is ready
  128696. */
  128697. isReady(): boolean;
  128698. /**
  128699. * Gets if the system has been started. (Note: this will still be true after stop is called)
  128700. * @returns True if it has been started, otherwise false.
  128701. */
  128702. isStarted(): boolean;
  128703. /**
  128704. * Starts the particle system and begins to emit
  128705. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  128706. */
  128707. start(delay?: number): void;
  128708. /**
  128709. * Stops the particle system.
  128710. */
  128711. stop(): void;
  128712. /**
  128713. * Remove all active particles
  128714. */
  128715. reset(): void;
  128716. /**
  128717. * Returns the string "GPUParticleSystem"
  128718. * @returns a string containing the class name
  128719. */
  128720. getClassName(): string;
  128721. private _colorGradientsTexture;
  128722. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  128723. /**
  128724. * Adds a new color gradient
  128725. * @param gradient defines the gradient to use (between 0 and 1)
  128726. * @param color1 defines the color to affect to the specified gradient
  128727. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  128728. * @returns the current particle system
  128729. */
  128730. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  128731. /**
  128732. * Remove a specific color gradient
  128733. * @param gradient defines the gradient to remove
  128734. * @returns the current particle system
  128735. */
  128736. removeColorGradient(gradient: number): GPUParticleSystem;
  128737. private _angularSpeedGradientsTexture;
  128738. private _sizeGradientsTexture;
  128739. private _velocityGradientsTexture;
  128740. private _limitVelocityGradientsTexture;
  128741. private _dragGradientsTexture;
  128742. private _addFactorGradient;
  128743. /**
  128744. * Adds a new size gradient
  128745. * @param gradient defines the gradient to use (between 0 and 1)
  128746. * @param factor defines the size factor to affect to the specified gradient
  128747. * @returns the current particle system
  128748. */
  128749. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  128750. /**
  128751. * Remove a specific size gradient
  128752. * @param gradient defines the gradient to remove
  128753. * @returns the current particle system
  128754. */
  128755. removeSizeGradient(gradient: number): GPUParticleSystem;
  128756. /**
  128757. * Adds a new angular speed gradient
  128758. * @param gradient defines the gradient to use (between 0 and 1)
  128759. * @param factor defines the angular speed to affect to the specified gradient
  128760. * @returns the current particle system
  128761. */
  128762. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  128763. /**
  128764. * Remove a specific angular speed gradient
  128765. * @param gradient defines the gradient to remove
  128766. * @returns the current particle system
  128767. */
  128768. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  128769. /**
  128770. * Adds a new velocity gradient
  128771. * @param gradient defines the gradient to use (between 0 and 1)
  128772. * @param factor defines the velocity to affect to the specified gradient
  128773. * @returns the current particle system
  128774. */
  128775. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  128776. /**
  128777. * Remove a specific velocity gradient
  128778. * @param gradient defines the gradient to remove
  128779. * @returns the current particle system
  128780. */
  128781. removeVelocityGradient(gradient: number): GPUParticleSystem;
  128782. /**
  128783. * Adds a new limit velocity gradient
  128784. * @param gradient defines the gradient to use (between 0 and 1)
  128785. * @param factor defines the limit velocity value to affect to the specified gradient
  128786. * @returns the current particle system
  128787. */
  128788. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  128789. /**
  128790. * Remove a specific limit velocity gradient
  128791. * @param gradient defines the gradient to remove
  128792. * @returns the current particle system
  128793. */
  128794. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  128795. /**
  128796. * Adds a new drag gradient
  128797. * @param gradient defines the gradient to use (between 0 and 1)
  128798. * @param factor defines the drag value to affect to the specified gradient
  128799. * @returns the current particle system
  128800. */
  128801. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  128802. /**
  128803. * Remove a specific drag gradient
  128804. * @param gradient defines the gradient to remove
  128805. * @returns the current particle system
  128806. */
  128807. removeDragGradient(gradient: number): GPUParticleSystem;
  128808. /**
  128809. * Not supported by GPUParticleSystem
  128810. * @param gradient defines the gradient to use (between 0 and 1)
  128811. * @param factor defines the emit rate value to affect to the specified gradient
  128812. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  128813. * @returns the current particle system
  128814. */
  128815. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  128816. /**
  128817. * Not supported by GPUParticleSystem
  128818. * @param gradient defines the gradient to remove
  128819. * @returns the current particle system
  128820. */
  128821. removeEmitRateGradient(gradient: number): IParticleSystem;
  128822. /**
  128823. * Not supported by GPUParticleSystem
  128824. * @param gradient defines the gradient to use (between 0 and 1)
  128825. * @param factor defines the start size value to affect to the specified gradient
  128826. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  128827. * @returns the current particle system
  128828. */
  128829. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  128830. /**
  128831. * Not supported by GPUParticleSystem
  128832. * @param gradient defines the gradient to remove
  128833. * @returns the current particle system
  128834. */
  128835. removeStartSizeGradient(gradient: number): IParticleSystem;
  128836. /**
  128837. * Not supported by GPUParticleSystem
  128838. * @param gradient defines the gradient to use (between 0 and 1)
  128839. * @param min defines the color remap minimal range
  128840. * @param max defines the color remap maximal range
  128841. * @returns the current particle system
  128842. */
  128843. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  128844. /**
  128845. * Not supported by GPUParticleSystem
  128846. * @param gradient defines the gradient to remove
  128847. * @returns the current particle system
  128848. */
  128849. removeColorRemapGradient(): IParticleSystem;
  128850. /**
  128851. * Not supported by GPUParticleSystem
  128852. * @param gradient defines the gradient to use (between 0 and 1)
  128853. * @param min defines the alpha remap minimal range
  128854. * @param max defines the alpha remap maximal range
  128855. * @returns the current particle system
  128856. */
  128857. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  128858. /**
  128859. * Not supported by GPUParticleSystem
  128860. * @param gradient defines the gradient to remove
  128861. * @returns the current particle system
  128862. */
  128863. removeAlphaRemapGradient(): IParticleSystem;
  128864. /**
  128865. * Not supported by GPUParticleSystem
  128866. * @param gradient defines the gradient to use (between 0 and 1)
  128867. * @param color defines the color to affect to the specified gradient
  128868. * @returns the current particle system
  128869. */
  128870. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  128871. /**
  128872. * Not supported by GPUParticleSystem
  128873. * @param gradient defines the gradient to remove
  128874. * @returns the current particle system
  128875. */
  128876. removeRampGradient(): IParticleSystem;
  128877. /**
  128878. * Not supported by GPUParticleSystem
  128879. * @returns the list of ramp gradients
  128880. */
  128881. getRampGradients(): Nullable<Array<Color3Gradient>>;
  128882. /**
  128883. * Not supported by GPUParticleSystem
  128884. * Gets or sets a boolean indicating that ramp gradients must be used
  128885. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  128886. */
  128887. useRampGradients: boolean;
  128888. /**
  128889. * Not supported by GPUParticleSystem
  128890. * @param gradient defines the gradient to use (between 0 and 1)
  128891. * @param factor defines the life time factor to affect to the specified gradient
  128892. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  128893. * @returns the current particle system
  128894. */
  128895. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  128896. /**
  128897. * Not supported by GPUParticleSystem
  128898. * @param gradient defines the gradient to remove
  128899. * @returns the current particle system
  128900. */
  128901. removeLifeTimeGradient(gradient: number): IParticleSystem;
  128902. /**
  128903. * Instantiates a GPU particle system.
  128904. * 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.
  128905. * @param name The name of the particle system
  128906. * @param options The options used to create the system
  128907. * @param scene The scene the particle system belongs to
  128908. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  128909. */
  128910. constructor(name: string, options: Partial<{
  128911. capacity: number;
  128912. randomTextureSize: number;
  128913. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  128914. protected _reset(): void;
  128915. private _createUpdateVAO;
  128916. private _createRenderVAO;
  128917. private _initialize;
  128918. /** @hidden */
  128919. _recreateUpdateEffect(): void;
  128920. /** @hidden */
  128921. _recreateRenderEffect(): void;
  128922. /**
  128923. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  128924. * @param preWarm defines if we are in the pre-warmimg phase
  128925. */
  128926. animate(preWarm?: boolean): void;
  128927. private _createFactorGradientTexture;
  128928. private _createSizeGradientTexture;
  128929. private _createAngularSpeedGradientTexture;
  128930. private _createVelocityGradientTexture;
  128931. private _createLimitVelocityGradientTexture;
  128932. private _createDragGradientTexture;
  128933. private _createColorGradientTexture;
  128934. /**
  128935. * Renders the particle system in its current state
  128936. * @param preWarm defines if the system should only update the particles but not render them
  128937. * @returns the current number of particles
  128938. */
  128939. render(preWarm?: boolean): number;
  128940. /**
  128941. * Rebuilds the particle system
  128942. */
  128943. rebuild(): void;
  128944. private _releaseBuffers;
  128945. private _releaseVAOs;
  128946. /**
  128947. * Disposes the particle system and free the associated resources
  128948. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  128949. */
  128950. dispose(disposeTexture?: boolean): void;
  128951. /**
  128952. * Clones the particle system.
  128953. * @param name The name of the cloned object
  128954. * @param newEmitter The new emitter to use
  128955. * @returns the cloned particle system
  128956. */
  128957. clone(name: string, newEmitter: any): GPUParticleSystem;
  128958. /**
  128959. * Serializes the particle system to a JSON object.
  128960. * @returns the JSON object
  128961. */
  128962. serialize(): any;
  128963. /**
  128964. * Parses a JSON object to create a GPU particle system.
  128965. * @param parsedParticleSystem The JSON object to parse
  128966. * @param scene The scene to create the particle system in
  128967. * @param rootUrl The root url to use to load external dependencies like texture
  128968. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  128969. * @returns the parsed GPU particle system
  128970. */
  128971. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  128972. }
  128973. }
  128974. declare module BABYLON {
  128975. /**
  128976. * Represents a set of particle systems working together to create a specific effect
  128977. */
  128978. export class ParticleSystemSet implements IDisposable {
  128979. /**
  128980. * Gets or sets base Assets URL
  128981. */
  128982. static BaseAssetsUrl: string;
  128983. private _emitterCreationOptions;
  128984. private _emitterNode;
  128985. /**
  128986. * Gets the particle system list
  128987. */
  128988. systems: IParticleSystem[];
  128989. /**
  128990. * Gets the emitter node used with this set
  128991. */
  128992. readonly emitterNode: Nullable<TransformNode>;
  128993. /**
  128994. * Creates a new emitter mesh as a sphere
  128995. * @param options defines the options used to create the sphere
  128996. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  128997. * @param scene defines the hosting scene
  128998. */
  128999. setEmitterAsSphere(options: {
  129000. diameter: number;
  129001. segments: number;
  129002. color: Color3;
  129003. }, renderingGroupId: number, scene: Scene): void;
  129004. /**
  129005. * Starts all particle systems of the set
  129006. * @param emitter defines an optional mesh to use as emitter for the particle systems
  129007. */
  129008. start(emitter?: AbstractMesh): void;
  129009. /**
  129010. * Release all associated resources
  129011. */
  129012. dispose(): void;
  129013. /**
  129014. * Serialize the set into a JSON compatible object
  129015. * @returns a JSON compatible representation of the set
  129016. */
  129017. serialize(): any;
  129018. /**
  129019. * Parse a new ParticleSystemSet from a serialized source
  129020. * @param data defines a JSON compatible representation of the set
  129021. * @param scene defines the hosting scene
  129022. * @param gpu defines if we want GPU particles or CPU particles
  129023. * @returns a new ParticleSystemSet
  129024. */
  129025. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  129026. }
  129027. }
  129028. declare module BABYLON {
  129029. /**
  129030. * This class is made for on one-liner static method to help creating particle system set.
  129031. */
  129032. export class ParticleHelper {
  129033. /**
  129034. * Gets or sets base Assets URL
  129035. */
  129036. static BaseAssetsUrl: string;
  129037. /**
  129038. * Create a default particle system that you can tweak
  129039. * @param emitter defines the emitter to use
  129040. * @param capacity defines the system capacity (default is 500 particles)
  129041. * @param scene defines the hosting scene
  129042. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  129043. * @returns the new Particle system
  129044. */
  129045. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  129046. /**
  129047. * This is the main static method (one-liner) of this helper to create different particle systems
  129048. * @param type This string represents the type to the particle system to create
  129049. * @param scene The scene where the particle system should live
  129050. * @param gpu If the system will use gpu
  129051. * @returns the ParticleSystemSet created
  129052. */
  129053. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  129054. /**
  129055. * Static function used to export a particle system to a ParticleSystemSet variable.
  129056. * Please note that the emitter shape is not exported
  129057. * @param systems defines the particle systems to export
  129058. * @returns the created particle system set
  129059. */
  129060. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  129061. }
  129062. }
  129063. declare module BABYLON {
  129064. interface Engine {
  129065. /**
  129066. * Create an effect to use with particle systems.
  129067. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  129068. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  129069. * @param uniformsNames defines a list of attribute names
  129070. * @param samplers defines an array of string used to represent textures
  129071. * @param defines defines the string containing the defines to use to compile the shaders
  129072. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  129073. * @param onCompiled defines a function to call when the effect creation is successful
  129074. * @param onError defines a function to call when the effect creation has failed
  129075. * @returns the new Effect
  129076. */
  129077. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  129078. }
  129079. interface Mesh {
  129080. /**
  129081. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  129082. * @returns an array of IParticleSystem
  129083. */
  129084. getEmittedParticleSystems(): IParticleSystem[];
  129085. /**
  129086. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  129087. * @returns an array of IParticleSystem
  129088. */
  129089. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  129090. }
  129091. /**
  129092. * @hidden
  129093. */
  129094. export var _IDoNeedToBeInTheBuild: number;
  129095. }
  129096. declare module BABYLON {
  129097. /** Defines the 4 color options */
  129098. export enum PointColor {
  129099. /** color value */
  129100. Color = 2,
  129101. /** uv value */
  129102. UV = 1,
  129103. /** random value */
  129104. Random = 0,
  129105. /** stated value */
  129106. Stated = 3
  129107. }
  129108. /**
  129109. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  129110. * As it is just a mesh, the PointCloudSystem has all the same properties as any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  129111. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  129112. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  129113. *
  129114. * Full documentation here : TO BE ENTERED
  129115. */
  129116. export class PointsCloudSystem implements IDisposable {
  129117. /**
  129118. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  129119. * Example : var p = SPS.particles[i];
  129120. */
  129121. particles: CloudPoint[];
  129122. /**
  129123. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  129124. */
  129125. nbParticles: number;
  129126. /**
  129127. * This a counter for your own usage. It's not set by any SPS functions.
  129128. */
  129129. counter: number;
  129130. /**
  129131. * The PCS name. This name is also given to the underlying mesh.
  129132. */
  129133. name: string;
  129134. /**
  129135. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  129136. */
  129137. mesh: Mesh;
  129138. /**
  129139. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  129140. * Please read :
  129141. */
  129142. vars: any;
  129143. /**
  129144. * @hidden
  129145. */
  129146. _size: number;
  129147. private _scene;
  129148. private _promises;
  129149. private _positions;
  129150. private _indices;
  129151. private _normals;
  129152. private _colors;
  129153. private _uvs;
  129154. private _indices32;
  129155. private _positions32;
  129156. private _colors32;
  129157. private _uvs32;
  129158. private _updatable;
  129159. private _isVisibilityBoxLocked;
  129160. private _alwaysVisible;
  129161. private _groups;
  129162. private _groupCounter;
  129163. private _computeParticleColor;
  129164. private _computeParticleTexture;
  129165. private _computeParticleRotation;
  129166. private _computeBoundingBox;
  129167. private _isReady;
  129168. /**
  129169. * Creates a PCS (Points Cloud System) object
  129170. * @param name (String) is the PCS name, this will be the underlying mesh name
  129171. * @param pointSize (number) is the size for each point
  129172. * @param scene (Scene) is the scene in which the PCS is added
  129173. * @param options defines the options of the PCS e.g.
  129174. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  129175. */
  129176. constructor(name: string, pointSize: number, scene: Scene, options?: {
  129177. updatable?: boolean;
  129178. });
  129179. /**
  129180. * Builds the PCS underlying mesh. Returns a standard Mesh.
  129181. * If no points were added to the PCS, the returned mesh is just a single point.
  129182. * @returns a promise for the created mesh
  129183. */
  129184. buildMeshAsync(): Promise<Mesh>;
  129185. /**
  129186. * @hidden
  129187. */
  129188. private _buildMesh;
  129189. private _addParticle;
  129190. private _randomUnitVector;
  129191. private _getColorIndicesForCoord;
  129192. private _setPointsColorOrUV;
  129193. private _colorFromTexture;
  129194. private _calculateDensity;
  129195. /**
  129196. * Adds points to the PCS in random positions within a unit sphere
  129197. * @param nb (positive integer) the number of particles to be created from this model
  129198. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  129199. * @returns the number of groups in the system
  129200. */
  129201. addPoints(nb: number, pointFunction?: any): number;
  129202. /**
  129203. * Adds points to the PCS from the surface of the model shape
  129204. * @param mesh is any Mesh object that will be used as a surface model for the points
  129205. * @param nb (positive integer) the number of particles to be created from this model
  129206. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  129207. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  129208. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  129209. * @returns the number of groups in the system
  129210. */
  129211. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  129212. /**
  129213. * Adds points to the PCS inside the model shape
  129214. * @param mesh is any Mesh object that will be used as a surface model for the points
  129215. * @param nb (positive integer) the number of particles to be created from this model
  129216. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  129217. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  129218. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  129219. * @returns the number of groups in the system
  129220. */
  129221. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  129222. /**
  129223. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  129224. * This method calls `updateParticle()` for each particle of the SPS.
  129225. * For an animated SPS, it is usually called within the render loop.
  129226. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  129227. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  129228. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  129229. * @returns the PCS.
  129230. */
  129231. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  129232. /**
  129233. * Disposes the PCS.
  129234. */
  129235. dispose(): void;
  129236. /**
  129237. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  129238. * doc :
  129239. * @returns the PCS.
  129240. */
  129241. refreshVisibleSize(): PointsCloudSystem;
  129242. /**
  129243. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  129244. * @param size the size (float) of the visibility box
  129245. * note : this doesn't lock the PCS mesh bounding box.
  129246. * doc :
  129247. */
  129248. setVisibilityBox(size: number): void;
  129249. /**
  129250. * Gets whether the PCS is always visible or not
  129251. * doc :
  129252. */
  129253. /**
  129254. * Sets the PCS as always visible or not
  129255. * doc :
  129256. */
  129257. isAlwaysVisible: boolean;
  129258. /**
  129259. * Tells to `setParticles()` to compute the particle rotations or not
  129260. * Default value : false. The PCS is faster when it's set to false
  129261. * Note : particle rotations are only applied to parent particles
  129262. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  129263. */
  129264. computeParticleRotation: boolean;
  129265. /**
  129266. * Tells to `setParticles()` to compute the particle colors or not.
  129267. * Default value : true. The PCS is faster when it's set to false.
  129268. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  129269. */
  129270. /**
  129271. * Gets if `setParticles()` computes the particle colors or not.
  129272. * Default value : false. The PCS is faster when it's set to false.
  129273. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  129274. */
  129275. computeParticleColor: boolean;
  129276. /**
  129277. * Gets if `setParticles()` computes the particle textures or not.
  129278. * Default value : false. The PCS is faster when it's set to false.
  129279. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  129280. */
  129281. computeParticleTexture: boolean;
  129282. /**
  129283. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  129284. */
  129285. /**
  129286. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  129287. */
  129288. computeBoundingBox: boolean;
  129289. /**
  129290. * This function does nothing. It may be overwritten to set all the particle first values.
  129291. * The PCS doesn't call this function, you may have to call it by your own.
  129292. * doc :
  129293. */
  129294. initParticles(): void;
  129295. /**
  129296. * This function does nothing. It may be overwritten to recycle a particle
  129297. * The PCS doesn't call this function, you can to call it
  129298. * doc :
  129299. * @param particle The particle to recycle
  129300. * @returns the recycled particle
  129301. */
  129302. recycleParticle(particle: CloudPoint): CloudPoint;
  129303. /**
  129304. * Updates a particle : this function should be overwritten by the user.
  129305. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  129306. * doc :
  129307. * @example : just set a particle position or velocity and recycle conditions
  129308. * @param particle The particle to update
  129309. * @returns the updated particle
  129310. */
  129311. updateParticle(particle: CloudPoint): CloudPoint;
  129312. /**
  129313. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  129314. * This does nothing and may be overwritten by the user.
  129315. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  129316. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  129317. * @param update the boolean update value actually passed to setParticles()
  129318. */
  129319. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  129320. /**
  129321. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  129322. * This will be passed three parameters.
  129323. * This does nothing and may be overwritten by the user.
  129324. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  129325. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  129326. * @param update the boolean update value actually passed to setParticles()
  129327. */
  129328. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  129329. }
  129330. }
  129331. declare module BABYLON {
  129332. /**
  129333. * Represents one particle of a points cloud system.
  129334. */
  129335. export class CloudPoint {
  129336. /**
  129337. * particle global index
  129338. */
  129339. idx: number;
  129340. /**
  129341. * The color of the particle
  129342. */
  129343. color: Nullable<Color4>;
  129344. /**
  129345. * The world space position of the particle.
  129346. */
  129347. position: Vector3;
  129348. /**
  129349. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  129350. */
  129351. rotation: Vector3;
  129352. /**
  129353. * The world space rotation quaternion of the particle.
  129354. */
  129355. rotationQuaternion: Nullable<Quaternion>;
  129356. /**
  129357. * The uv of the particle.
  129358. */
  129359. uv: Nullable<Vector2>;
  129360. /**
  129361. * The current speed of the particle.
  129362. */
  129363. velocity: Vector3;
  129364. /**
  129365. * The pivot point in the particle local space.
  129366. */
  129367. pivot: Vector3;
  129368. /**
  129369. * Must the particle be translated from its pivot point in its local space ?
  129370. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  129371. * Default : false
  129372. */
  129373. translateFromPivot: boolean;
  129374. /**
  129375. * Index of this particle in the global "positions" array (Internal use)
  129376. * @hidden
  129377. */
  129378. _pos: number;
  129379. /**
  129380. * @hidden Index of this particle in the global "indices" array (Internal use)
  129381. */
  129382. _ind: number;
  129383. /**
  129384. * Group this particle belongs to
  129385. */
  129386. _group: PointsGroup;
  129387. /**
  129388. * Group id of this particle
  129389. */
  129390. groupId: number;
  129391. /**
  129392. * Index of the particle in its group id (Internal use)
  129393. */
  129394. idxInGroup: number;
  129395. /**
  129396. * @hidden Particle BoundingInfo object (Internal use)
  129397. */
  129398. _boundingInfo: BoundingInfo;
  129399. /**
  129400. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  129401. */
  129402. _pcs: PointsCloudSystem;
  129403. /**
  129404. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  129405. */
  129406. _stillInvisible: boolean;
  129407. /**
  129408. * @hidden Last computed particle rotation matrix
  129409. */
  129410. _rotationMatrix: number[];
  129411. /**
  129412. * Parent particle Id, if any.
  129413. * Default null.
  129414. */
  129415. parentId: Nullable<number>;
  129416. /**
  129417. * @hidden Internal global position in the PCS.
  129418. */
  129419. _globalPosition: Vector3;
  129420. /**
  129421. * Creates a Point Cloud object.
  129422. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  129423. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  129424. * @param group (PointsGroup) is the group the particle belongs to
  129425. * @param groupId (integer) is the group identifier in the PCS.
  129426. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  129427. * @param pcs defines the PCS it is associated to
  129428. */
  129429. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  129430. /**
  129431. * get point size
  129432. */
  129433. /**
  129434. * Set point size
  129435. */
  129436. size: Vector3;
  129437. /**
  129438. * Legacy support, changed quaternion to rotationQuaternion
  129439. */
  129440. /**
  129441. * Legacy support, changed quaternion to rotationQuaternion
  129442. */
  129443. quaternion: Nullable<Quaternion>;
  129444. /**
  129445. * Returns a boolean. True if the particle intersects a mesh, else false
  129446. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  129447. * @param target is the object (point or mesh) what the intersection is computed against
  129448. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  129449. * @returns true if it intersects
  129450. */
  129451. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  129452. /**
  129453. * get the rotation matrix of the particle
  129454. * @hidden
  129455. */
  129456. getRotationMatrix(m: Matrix): void;
  129457. }
  129458. /**
  129459. * Represents a group of points in a points cloud system
  129460. * * PCS internal tool, don't use it manually.
  129461. */
  129462. export class PointsGroup {
  129463. /**
  129464. * The group id
  129465. * @hidden
  129466. */
  129467. groupID: number;
  129468. /**
  129469. * image data for group (internal use)
  129470. * @hidden
  129471. */
  129472. _groupImageData: Nullable<ArrayBufferView>;
  129473. /**
  129474. * Image Width (internal use)
  129475. * @hidden
  129476. */
  129477. _groupImgWidth: number;
  129478. /**
  129479. * Image Height (internal use)
  129480. * @hidden
  129481. */
  129482. _groupImgHeight: number;
  129483. /**
  129484. * Custom position function (internal use)
  129485. * @hidden
  129486. */
  129487. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  129488. /**
  129489. * density per facet for surface points
  129490. * @hidden
  129491. */
  129492. _groupDensity: number[];
  129493. /**
  129494. * Only when points are colored by texture carries pointer to texture list array
  129495. * @hidden
  129496. */
  129497. _textureNb: number;
  129498. /**
  129499. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  129500. * PCS internal tool, don't use it manually.
  129501. * @hidden
  129502. */
  129503. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  129504. }
  129505. }
  129506. declare module BABYLON {
  129507. interface Scene {
  129508. /** @hidden (Backing field) */
  129509. _physicsEngine: Nullable<IPhysicsEngine>;
  129510. /** @hidden */
  129511. _physicsTimeAccumulator: number;
  129512. /**
  129513. * Gets the current physics engine
  129514. * @returns a IPhysicsEngine or null if none attached
  129515. */
  129516. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  129517. /**
  129518. * Enables physics to the current scene
  129519. * @param gravity defines the scene's gravity for the physics engine
  129520. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  129521. * @return a boolean indicating if the physics engine was initialized
  129522. */
  129523. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  129524. /**
  129525. * Disables and disposes the physics engine associated with the scene
  129526. */
  129527. disablePhysicsEngine(): void;
  129528. /**
  129529. * Gets a boolean indicating if there is an active physics engine
  129530. * @returns a boolean indicating if there is an active physics engine
  129531. */
  129532. isPhysicsEnabled(): boolean;
  129533. /**
  129534. * Deletes a physics compound impostor
  129535. * @param compound defines the compound to delete
  129536. */
  129537. deleteCompoundImpostor(compound: any): void;
  129538. /**
  129539. * An event triggered when physic simulation is about to be run
  129540. */
  129541. onBeforePhysicsObservable: Observable<Scene>;
  129542. /**
  129543. * An event triggered when physic simulation has been done
  129544. */
  129545. onAfterPhysicsObservable: Observable<Scene>;
  129546. }
  129547. interface AbstractMesh {
  129548. /** @hidden */
  129549. _physicsImpostor: Nullable<PhysicsImpostor>;
  129550. /**
  129551. * Gets or sets impostor used for physic simulation
  129552. * @see http://doc.babylonjs.com/features/physics_engine
  129553. */
  129554. physicsImpostor: Nullable<PhysicsImpostor>;
  129555. /**
  129556. * Gets the current physics impostor
  129557. * @see http://doc.babylonjs.com/features/physics_engine
  129558. * @returns a physics impostor or null
  129559. */
  129560. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  129561. /** Apply a physic impulse to the mesh
  129562. * @param force defines the force to apply
  129563. * @param contactPoint defines where to apply the force
  129564. * @returns the current mesh
  129565. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  129566. */
  129567. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  129568. /**
  129569. * Creates a physic joint between two meshes
  129570. * @param otherMesh defines the other mesh to use
  129571. * @param pivot1 defines the pivot to use on this mesh
  129572. * @param pivot2 defines the pivot to use on the other mesh
  129573. * @param options defines additional options (can be plugin dependent)
  129574. * @returns the current mesh
  129575. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  129576. */
  129577. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  129578. /** @hidden */
  129579. _disposePhysicsObserver: Nullable<Observer<Node>>;
  129580. }
  129581. /**
  129582. * Defines the physics engine scene component responsible to manage a physics engine
  129583. */
  129584. export class PhysicsEngineSceneComponent implements ISceneComponent {
  129585. /**
  129586. * The component name helpful to identify the component in the list of scene components.
  129587. */
  129588. readonly name: string;
  129589. /**
  129590. * The scene the component belongs to.
  129591. */
  129592. scene: Scene;
  129593. /**
  129594. * Creates a new instance of the component for the given scene
  129595. * @param scene Defines the scene to register the component in
  129596. */
  129597. constructor(scene: Scene);
  129598. /**
  129599. * Registers the component in a given scene
  129600. */
  129601. register(): void;
  129602. /**
  129603. * Rebuilds the elements related to this component in case of
  129604. * context lost for instance.
  129605. */
  129606. rebuild(): void;
  129607. /**
  129608. * Disposes the component and the associated ressources
  129609. */
  129610. dispose(): void;
  129611. }
  129612. }
  129613. declare module BABYLON {
  129614. /**
  129615. * A helper for physics simulations
  129616. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129617. */
  129618. export class PhysicsHelper {
  129619. private _scene;
  129620. private _physicsEngine;
  129621. /**
  129622. * Initializes the Physics helper
  129623. * @param scene Babylon.js scene
  129624. */
  129625. constructor(scene: Scene);
  129626. /**
  129627. * Applies a radial explosion impulse
  129628. * @param origin the origin of the explosion
  129629. * @param radiusOrEventOptions the radius or the options of radial explosion
  129630. * @param strength the explosion strength
  129631. * @param falloff possible options: Constant & Linear. Defaults to Constant
  129632. * @returns A physics radial explosion event, or null
  129633. */
  129634. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  129635. /**
  129636. * Applies a radial explosion force
  129637. * @param origin the origin of the explosion
  129638. * @param radiusOrEventOptions the radius or the options of radial explosion
  129639. * @param strength the explosion strength
  129640. * @param falloff possible options: Constant & Linear. Defaults to Constant
  129641. * @returns A physics radial explosion event, or null
  129642. */
  129643. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  129644. /**
  129645. * Creates a gravitational field
  129646. * @param origin the origin of the explosion
  129647. * @param radiusOrEventOptions the radius or the options of radial explosion
  129648. * @param strength the explosion strength
  129649. * @param falloff possible options: Constant & Linear. Defaults to Constant
  129650. * @returns A physics gravitational field event, or null
  129651. */
  129652. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  129653. /**
  129654. * Creates a physics updraft event
  129655. * @param origin the origin of the updraft
  129656. * @param radiusOrEventOptions the radius or the options of the updraft
  129657. * @param strength the strength of the updraft
  129658. * @param height the height of the updraft
  129659. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  129660. * @returns A physics updraft event, or null
  129661. */
  129662. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  129663. /**
  129664. * Creates a physics vortex event
  129665. * @param origin the of the vortex
  129666. * @param radiusOrEventOptions the radius or the options of the vortex
  129667. * @param strength the strength of the vortex
  129668. * @param height the height of the vortex
  129669. * @returns a Physics vortex event, or null
  129670. * A physics vortex event or null
  129671. */
  129672. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  129673. }
  129674. /**
  129675. * Represents a physics radial explosion event
  129676. */
  129677. class PhysicsRadialExplosionEvent {
  129678. private _scene;
  129679. private _options;
  129680. private _sphere;
  129681. private _dataFetched;
  129682. /**
  129683. * Initializes a radial explosioin event
  129684. * @param _scene BabylonJS scene
  129685. * @param _options The options for the vortex event
  129686. */
  129687. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  129688. /**
  129689. * Returns the data related to the radial explosion event (sphere).
  129690. * @returns The radial explosion event data
  129691. */
  129692. getData(): PhysicsRadialExplosionEventData;
  129693. /**
  129694. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  129695. * @param impostor A physics imposter
  129696. * @param origin the origin of the explosion
  129697. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  129698. */
  129699. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  129700. /**
  129701. * Triggers affecterd impostors callbacks
  129702. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  129703. */
  129704. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  129705. /**
  129706. * Disposes the sphere.
  129707. * @param force Specifies if the sphere should be disposed by force
  129708. */
  129709. dispose(force?: boolean): void;
  129710. /*** Helpers ***/
  129711. private _prepareSphere;
  129712. private _intersectsWithSphere;
  129713. }
  129714. /**
  129715. * Represents a gravitational field event
  129716. */
  129717. class PhysicsGravitationalFieldEvent {
  129718. private _physicsHelper;
  129719. private _scene;
  129720. private _origin;
  129721. private _options;
  129722. private _tickCallback;
  129723. private _sphere;
  129724. private _dataFetched;
  129725. /**
  129726. * Initializes the physics gravitational field event
  129727. * @param _physicsHelper A physics helper
  129728. * @param _scene BabylonJS scene
  129729. * @param _origin The origin position of the gravitational field event
  129730. * @param _options The options for the vortex event
  129731. */
  129732. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  129733. /**
  129734. * Returns the data related to the gravitational field event (sphere).
  129735. * @returns A gravitational field event
  129736. */
  129737. getData(): PhysicsGravitationalFieldEventData;
  129738. /**
  129739. * Enables the gravitational field.
  129740. */
  129741. enable(): void;
  129742. /**
  129743. * Disables the gravitational field.
  129744. */
  129745. disable(): void;
  129746. /**
  129747. * Disposes the sphere.
  129748. * @param force The force to dispose from the gravitational field event
  129749. */
  129750. dispose(force?: boolean): void;
  129751. private _tick;
  129752. }
  129753. /**
  129754. * Represents a physics updraft event
  129755. */
  129756. class PhysicsUpdraftEvent {
  129757. private _scene;
  129758. private _origin;
  129759. private _options;
  129760. private _physicsEngine;
  129761. private _originTop;
  129762. private _originDirection;
  129763. private _tickCallback;
  129764. private _cylinder;
  129765. private _cylinderPosition;
  129766. private _dataFetched;
  129767. /**
  129768. * Initializes the physics updraft event
  129769. * @param _scene BabylonJS scene
  129770. * @param _origin The origin position of the updraft
  129771. * @param _options The options for the updraft event
  129772. */
  129773. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  129774. /**
  129775. * Returns the data related to the updraft event (cylinder).
  129776. * @returns A physics updraft event
  129777. */
  129778. getData(): PhysicsUpdraftEventData;
  129779. /**
  129780. * Enables the updraft.
  129781. */
  129782. enable(): void;
  129783. /**
  129784. * Disables the updraft.
  129785. */
  129786. disable(): void;
  129787. /**
  129788. * Disposes the cylinder.
  129789. * @param force Specifies if the updraft should be disposed by force
  129790. */
  129791. dispose(force?: boolean): void;
  129792. private getImpostorHitData;
  129793. private _tick;
  129794. /*** Helpers ***/
  129795. private _prepareCylinder;
  129796. private _intersectsWithCylinder;
  129797. }
  129798. /**
  129799. * Represents a physics vortex event
  129800. */
  129801. class PhysicsVortexEvent {
  129802. private _scene;
  129803. private _origin;
  129804. private _options;
  129805. private _physicsEngine;
  129806. private _originTop;
  129807. private _tickCallback;
  129808. private _cylinder;
  129809. private _cylinderPosition;
  129810. private _dataFetched;
  129811. /**
  129812. * Initializes the physics vortex event
  129813. * @param _scene The BabylonJS scene
  129814. * @param _origin The origin position of the vortex
  129815. * @param _options The options for the vortex event
  129816. */
  129817. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  129818. /**
  129819. * Returns the data related to the vortex event (cylinder).
  129820. * @returns The physics vortex event data
  129821. */
  129822. getData(): PhysicsVortexEventData;
  129823. /**
  129824. * Enables the vortex.
  129825. */
  129826. enable(): void;
  129827. /**
  129828. * Disables the cortex.
  129829. */
  129830. disable(): void;
  129831. /**
  129832. * Disposes the sphere.
  129833. * @param force
  129834. */
  129835. dispose(force?: boolean): void;
  129836. private getImpostorHitData;
  129837. private _tick;
  129838. /*** Helpers ***/
  129839. private _prepareCylinder;
  129840. private _intersectsWithCylinder;
  129841. }
  129842. /**
  129843. * Options fot the radial explosion event
  129844. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129845. */
  129846. export class PhysicsRadialExplosionEventOptions {
  129847. /**
  129848. * The radius of the sphere for the radial explosion.
  129849. */
  129850. radius: number;
  129851. /**
  129852. * The strenth of the explosion.
  129853. */
  129854. strength: number;
  129855. /**
  129856. * The strenght of the force in correspondence to the distance of the affected object
  129857. */
  129858. falloff: PhysicsRadialImpulseFalloff;
  129859. /**
  129860. * Sphere options for the radial explosion.
  129861. */
  129862. sphere: {
  129863. segments: number;
  129864. diameter: number;
  129865. };
  129866. /**
  129867. * Sphere options for the radial explosion.
  129868. */
  129869. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  129870. }
  129871. /**
  129872. * Options fot the updraft event
  129873. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129874. */
  129875. export class PhysicsUpdraftEventOptions {
  129876. /**
  129877. * The radius of the cylinder for the vortex
  129878. */
  129879. radius: number;
  129880. /**
  129881. * The strenth of the updraft.
  129882. */
  129883. strength: number;
  129884. /**
  129885. * The height of the cylinder for the updraft.
  129886. */
  129887. height: number;
  129888. /**
  129889. * The mode for the the updraft.
  129890. */
  129891. updraftMode: PhysicsUpdraftMode;
  129892. }
  129893. /**
  129894. * Options fot the vortex event
  129895. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129896. */
  129897. export class PhysicsVortexEventOptions {
  129898. /**
  129899. * The radius of the cylinder for the vortex
  129900. */
  129901. radius: number;
  129902. /**
  129903. * The strenth of the vortex.
  129904. */
  129905. strength: number;
  129906. /**
  129907. * The height of the cylinder for the vortex.
  129908. */
  129909. height: number;
  129910. /**
  129911. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  129912. */
  129913. centripetalForceThreshold: number;
  129914. /**
  129915. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  129916. */
  129917. centripetalForceMultiplier: number;
  129918. /**
  129919. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  129920. */
  129921. centrifugalForceMultiplier: number;
  129922. /**
  129923. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  129924. */
  129925. updraftForceMultiplier: number;
  129926. }
  129927. /**
  129928. * The strenght of the force in correspondence to the distance of the affected object
  129929. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129930. */
  129931. export enum PhysicsRadialImpulseFalloff {
  129932. /** Defines that impulse is constant in strength across it's whole radius */
  129933. Constant = 0,
  129934. /** Defines that impulse gets weaker if it's further from the origin */
  129935. Linear = 1
  129936. }
  129937. /**
  129938. * The strength of the force in correspondence to the distance of the affected object
  129939. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129940. */
  129941. export enum PhysicsUpdraftMode {
  129942. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  129943. Center = 0,
  129944. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  129945. Perpendicular = 1
  129946. }
  129947. /**
  129948. * Interface for a physics hit data
  129949. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129950. */
  129951. export interface PhysicsHitData {
  129952. /**
  129953. * The force applied at the contact point
  129954. */
  129955. force: Vector3;
  129956. /**
  129957. * The contact point
  129958. */
  129959. contactPoint: Vector3;
  129960. /**
  129961. * The distance from the origin to the contact point
  129962. */
  129963. distanceFromOrigin: number;
  129964. }
  129965. /**
  129966. * Interface for radial explosion event data
  129967. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129968. */
  129969. export interface PhysicsRadialExplosionEventData {
  129970. /**
  129971. * A sphere used for the radial explosion event
  129972. */
  129973. sphere: Mesh;
  129974. }
  129975. /**
  129976. * Interface for gravitational field event data
  129977. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129978. */
  129979. export interface PhysicsGravitationalFieldEventData {
  129980. /**
  129981. * A sphere mesh used for the gravitational field event
  129982. */
  129983. sphere: Mesh;
  129984. }
  129985. /**
  129986. * Interface for updraft event data
  129987. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129988. */
  129989. export interface PhysicsUpdraftEventData {
  129990. /**
  129991. * A cylinder used for the updraft event
  129992. */
  129993. cylinder: Mesh;
  129994. }
  129995. /**
  129996. * Interface for vortex event data
  129997. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129998. */
  129999. export interface PhysicsVortexEventData {
  130000. /**
  130001. * A cylinder used for the vortex event
  130002. */
  130003. cylinder: Mesh;
  130004. }
  130005. /**
  130006. * Interface for an affected physics impostor
  130007. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  130008. */
  130009. export interface PhysicsAffectedImpostorWithData {
  130010. /**
  130011. * The impostor affected by the effect
  130012. */
  130013. impostor: PhysicsImpostor;
  130014. /**
  130015. * The data about the hit/horce from the explosion
  130016. */
  130017. hitData: PhysicsHitData;
  130018. }
  130019. }
  130020. declare module BABYLON {
  130021. /** @hidden */
  130022. export var blackAndWhitePixelShader: {
  130023. name: string;
  130024. shader: string;
  130025. };
  130026. }
  130027. declare module BABYLON {
  130028. /**
  130029. * Post process used to render in black and white
  130030. */
  130031. export class BlackAndWhitePostProcess extends PostProcess {
  130032. /**
  130033. * Linear about to convert he result to black and white (default: 1)
  130034. */
  130035. degree: number;
  130036. /**
  130037. * Creates a black and white post process
  130038. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  130039. * @param name The name of the effect.
  130040. * @param options The required width/height ratio to downsize to before computing the render pass.
  130041. * @param camera The camera to apply the render pass to.
  130042. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130043. * @param engine The engine which the post process will be applied. (default: current engine)
  130044. * @param reusable If the post process can be reused on the same frame. (default: false)
  130045. */
  130046. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  130047. }
  130048. }
  130049. declare module BABYLON {
  130050. /**
  130051. * This represents a set of one or more post processes in Babylon.
  130052. * A post process can be used to apply a shader to a texture after it is rendered.
  130053. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  130054. */
  130055. export class PostProcessRenderEffect {
  130056. private _postProcesses;
  130057. private _getPostProcesses;
  130058. private _singleInstance;
  130059. private _cameras;
  130060. private _indicesForCamera;
  130061. /**
  130062. * Name of the effect
  130063. * @hidden
  130064. */
  130065. _name: string;
  130066. /**
  130067. * Instantiates a post process render effect.
  130068. * A post process can be used to apply a shader to a texture after it is rendered.
  130069. * @param engine The engine the effect is tied to
  130070. * @param name The name of the effect
  130071. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  130072. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  130073. */
  130074. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  130075. /**
  130076. * Checks if all the post processes in the effect are supported.
  130077. */
  130078. readonly isSupported: boolean;
  130079. /**
  130080. * Updates the current state of the effect
  130081. * @hidden
  130082. */
  130083. _update(): void;
  130084. /**
  130085. * Attaches the effect on cameras
  130086. * @param cameras The camera to attach to.
  130087. * @hidden
  130088. */
  130089. _attachCameras(cameras: Camera): void;
  130090. /**
  130091. * Attaches the effect on cameras
  130092. * @param cameras The camera to attach to.
  130093. * @hidden
  130094. */
  130095. _attachCameras(cameras: Camera[]): void;
  130096. /**
  130097. * Detaches the effect on cameras
  130098. * @param cameras The camera to detatch from.
  130099. * @hidden
  130100. */
  130101. _detachCameras(cameras: Camera): void;
  130102. /**
  130103. * Detatches the effect on cameras
  130104. * @param cameras The camera to detatch from.
  130105. * @hidden
  130106. */
  130107. _detachCameras(cameras: Camera[]): void;
  130108. /**
  130109. * Enables the effect on given cameras
  130110. * @param cameras The camera to enable.
  130111. * @hidden
  130112. */
  130113. _enable(cameras: Camera): void;
  130114. /**
  130115. * Enables the effect on given cameras
  130116. * @param cameras The camera to enable.
  130117. * @hidden
  130118. */
  130119. _enable(cameras: Nullable<Camera[]>): void;
  130120. /**
  130121. * Disables the effect on the given cameras
  130122. * @param cameras The camera to disable.
  130123. * @hidden
  130124. */
  130125. _disable(cameras: Camera): void;
  130126. /**
  130127. * Disables the effect on the given cameras
  130128. * @param cameras The camera to disable.
  130129. * @hidden
  130130. */
  130131. _disable(cameras: Nullable<Camera[]>): void;
  130132. /**
  130133. * Gets a list of the post processes contained in the effect.
  130134. * @param camera The camera to get the post processes on.
  130135. * @returns The list of the post processes in the effect.
  130136. */
  130137. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  130138. }
  130139. }
  130140. declare module BABYLON {
  130141. /** @hidden */
  130142. export var extractHighlightsPixelShader: {
  130143. name: string;
  130144. shader: string;
  130145. };
  130146. }
  130147. declare module BABYLON {
  130148. /**
  130149. * 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.
  130150. */
  130151. export class ExtractHighlightsPostProcess extends PostProcess {
  130152. /**
  130153. * The luminance threshold, pixels below this value will be set to black.
  130154. */
  130155. threshold: number;
  130156. /** @hidden */
  130157. _exposure: number;
  130158. /**
  130159. * Post process which has the input texture to be used when performing highlight extraction
  130160. * @hidden
  130161. */
  130162. _inputPostProcess: Nullable<PostProcess>;
  130163. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  130164. }
  130165. }
  130166. declare module BABYLON {
  130167. /** @hidden */
  130168. export var bloomMergePixelShader: {
  130169. name: string;
  130170. shader: string;
  130171. };
  130172. }
  130173. declare module BABYLON {
  130174. /**
  130175. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  130176. */
  130177. export class BloomMergePostProcess extends PostProcess {
  130178. /** Weight of the bloom to be added to the original input. */
  130179. weight: number;
  130180. /**
  130181. * Creates a new instance of @see BloomMergePostProcess
  130182. * @param name The name of the effect.
  130183. * @param originalFromInput Post process which's input will be used for the merge.
  130184. * @param blurred Blurred highlights post process which's output will be used.
  130185. * @param weight Weight of the bloom to be added to the original input.
  130186. * @param options The required width/height ratio to downsize to before computing the render pass.
  130187. * @param camera The camera to apply the render pass to.
  130188. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130189. * @param engine The engine which the post process will be applied. (default: current engine)
  130190. * @param reusable If the post process can be reused on the same frame. (default: false)
  130191. * @param textureType Type of textures used when performing the post process. (default: 0)
  130192. * @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)
  130193. */
  130194. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  130195. /** Weight of the bloom to be added to the original input. */
  130196. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  130197. }
  130198. }
  130199. declare module BABYLON {
  130200. /**
  130201. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  130202. */
  130203. export class BloomEffect extends PostProcessRenderEffect {
  130204. private bloomScale;
  130205. /**
  130206. * @hidden Internal
  130207. */
  130208. _effects: Array<PostProcess>;
  130209. /**
  130210. * @hidden Internal
  130211. */
  130212. _downscale: ExtractHighlightsPostProcess;
  130213. private _blurX;
  130214. private _blurY;
  130215. private _merge;
  130216. /**
  130217. * The luminance threshold to find bright areas of the image to bloom.
  130218. */
  130219. threshold: number;
  130220. /**
  130221. * The strength of the bloom.
  130222. */
  130223. weight: number;
  130224. /**
  130225. * Specifies the size of the bloom blur kernel, relative to the final output size
  130226. */
  130227. kernel: number;
  130228. /**
  130229. * Creates a new instance of @see BloomEffect
  130230. * @param scene The scene the effect belongs to.
  130231. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  130232. * @param bloomKernel The size of the kernel to be used when applying the blur.
  130233. * @param bloomWeight The the strength of bloom.
  130234. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  130235. * @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)
  130236. */
  130237. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  130238. /**
  130239. * Disposes each of the internal effects for a given camera.
  130240. * @param camera The camera to dispose the effect on.
  130241. */
  130242. disposeEffects(camera: Camera): void;
  130243. /**
  130244. * @hidden Internal
  130245. */
  130246. _updateEffects(): void;
  130247. /**
  130248. * Internal
  130249. * @returns if all the contained post processes are ready.
  130250. * @hidden
  130251. */
  130252. _isReady(): boolean;
  130253. }
  130254. }
  130255. declare module BABYLON {
  130256. /** @hidden */
  130257. export var chromaticAberrationPixelShader: {
  130258. name: string;
  130259. shader: string;
  130260. };
  130261. }
  130262. declare module BABYLON {
  130263. /**
  130264. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  130265. */
  130266. export class ChromaticAberrationPostProcess extends PostProcess {
  130267. /**
  130268. * The amount of seperation of rgb channels (default: 30)
  130269. */
  130270. aberrationAmount: number;
  130271. /**
  130272. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  130273. */
  130274. radialIntensity: number;
  130275. /**
  130276. * 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))
  130277. */
  130278. direction: Vector2;
  130279. /**
  130280. * 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))
  130281. */
  130282. centerPosition: Vector2;
  130283. /**
  130284. * Creates a new instance ChromaticAberrationPostProcess
  130285. * @param name The name of the effect.
  130286. * @param screenWidth The width of the screen to apply the effect on.
  130287. * @param screenHeight The height of the screen to apply the effect on.
  130288. * @param options The required width/height ratio to downsize to before computing the render pass.
  130289. * @param camera The camera to apply the render pass to.
  130290. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130291. * @param engine The engine which the post process will be applied. (default: current engine)
  130292. * @param reusable If the post process can be reused on the same frame. (default: false)
  130293. * @param textureType Type of textures used when performing the post process. (default: 0)
  130294. * @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)
  130295. */
  130296. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  130297. }
  130298. }
  130299. declare module BABYLON {
  130300. /** @hidden */
  130301. export var circleOfConfusionPixelShader: {
  130302. name: string;
  130303. shader: string;
  130304. };
  130305. }
  130306. declare module BABYLON {
  130307. /**
  130308. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  130309. */
  130310. export class CircleOfConfusionPostProcess extends PostProcess {
  130311. /**
  130312. * 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.
  130313. */
  130314. lensSize: number;
  130315. /**
  130316. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  130317. */
  130318. fStop: number;
  130319. /**
  130320. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  130321. */
  130322. focusDistance: number;
  130323. /**
  130324. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  130325. */
  130326. focalLength: number;
  130327. private _depthTexture;
  130328. /**
  130329. * Creates a new instance CircleOfConfusionPostProcess
  130330. * @param name The name of the effect.
  130331. * @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.
  130332. * @param options The required width/height ratio to downsize to before computing the render pass.
  130333. * @param camera The camera to apply the render pass to.
  130334. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130335. * @param engine The engine which the post process will be applied. (default: current engine)
  130336. * @param reusable If the post process can be reused on the same frame. (default: false)
  130337. * @param textureType Type of textures used when performing the post process. (default: 0)
  130338. * @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)
  130339. */
  130340. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  130341. /**
  130342. * 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.
  130343. */
  130344. depthTexture: RenderTargetTexture;
  130345. }
  130346. }
  130347. declare module BABYLON {
  130348. /** @hidden */
  130349. export var colorCorrectionPixelShader: {
  130350. name: string;
  130351. shader: string;
  130352. };
  130353. }
  130354. declare module BABYLON {
  130355. /**
  130356. *
  130357. * This post-process allows the modification of rendered colors by using
  130358. * a 'look-up table' (LUT). This effect is also called Color Grading.
  130359. *
  130360. * The object needs to be provided an url to a texture containing the color
  130361. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  130362. * Use an image editing software to tweak the LUT to match your needs.
  130363. *
  130364. * For an example of a color LUT, see here:
  130365. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  130366. * For explanations on color grading, see here:
  130367. * @see http://udn.epicgames.com/Three/ColorGrading.html
  130368. *
  130369. */
  130370. export class ColorCorrectionPostProcess extends PostProcess {
  130371. private _colorTableTexture;
  130372. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  130373. }
  130374. }
  130375. declare module BABYLON {
  130376. /** @hidden */
  130377. export var convolutionPixelShader: {
  130378. name: string;
  130379. shader: string;
  130380. };
  130381. }
  130382. declare module BABYLON {
  130383. /**
  130384. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  130385. * input texture to perform effects such as edge detection or sharpening
  130386. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  130387. */
  130388. export class ConvolutionPostProcess extends PostProcess {
  130389. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  130390. kernel: number[];
  130391. /**
  130392. * Creates a new instance ConvolutionPostProcess
  130393. * @param name The name of the effect.
  130394. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  130395. * @param options The required width/height ratio to downsize to before computing the render pass.
  130396. * @param camera The camera to apply the render pass to.
  130397. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130398. * @param engine The engine which the post process will be applied. (default: current engine)
  130399. * @param reusable If the post process can be reused on the same frame. (default: false)
  130400. * @param textureType Type of textures used when performing the post process. (default: 0)
  130401. */
  130402. constructor(name: string,
  130403. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  130404. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  130405. /**
  130406. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  130407. */
  130408. static EdgeDetect0Kernel: number[];
  130409. /**
  130410. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  130411. */
  130412. static EdgeDetect1Kernel: number[];
  130413. /**
  130414. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  130415. */
  130416. static EdgeDetect2Kernel: number[];
  130417. /**
  130418. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  130419. */
  130420. static SharpenKernel: number[];
  130421. /**
  130422. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  130423. */
  130424. static EmbossKernel: number[];
  130425. /**
  130426. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  130427. */
  130428. static GaussianKernel: number[];
  130429. }
  130430. }
  130431. declare module BABYLON {
  130432. /**
  130433. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  130434. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  130435. * based on samples that have a large difference in distance than the center pixel.
  130436. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  130437. */
  130438. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  130439. direction: Vector2;
  130440. /**
  130441. * Creates a new instance CircleOfConfusionPostProcess
  130442. * @param name The name of the effect.
  130443. * @param scene The scene the effect belongs to.
  130444. * @param direction The direction the blur should be applied.
  130445. * @param kernel The size of the kernel used to blur.
  130446. * @param options The required width/height ratio to downsize to before computing the render pass.
  130447. * @param camera The camera to apply the render pass to.
  130448. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  130449. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  130450. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130451. * @param engine The engine which the post process will be applied. (default: current engine)
  130452. * @param reusable If the post process can be reused on the same frame. (default: false)
  130453. * @param textureType Type of textures used when performing the post process. (default: 0)
  130454. * @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)
  130455. */
  130456. 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);
  130457. }
  130458. }
  130459. declare module BABYLON {
  130460. /** @hidden */
  130461. export var depthOfFieldMergePixelShader: {
  130462. name: string;
  130463. shader: string;
  130464. };
  130465. }
  130466. declare module BABYLON {
  130467. /**
  130468. * Options to be set when merging outputs from the default pipeline.
  130469. */
  130470. export class DepthOfFieldMergePostProcessOptions {
  130471. /**
  130472. * The original image to merge on top of
  130473. */
  130474. originalFromInput: PostProcess;
  130475. /**
  130476. * Parameters to perform the merge of the depth of field effect
  130477. */
  130478. depthOfField?: {
  130479. circleOfConfusion: PostProcess;
  130480. blurSteps: Array<PostProcess>;
  130481. };
  130482. /**
  130483. * Parameters to perform the merge of bloom effect
  130484. */
  130485. bloom?: {
  130486. blurred: PostProcess;
  130487. weight: number;
  130488. };
  130489. }
  130490. /**
  130491. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  130492. */
  130493. export class DepthOfFieldMergePostProcess extends PostProcess {
  130494. private blurSteps;
  130495. /**
  130496. * Creates a new instance of DepthOfFieldMergePostProcess
  130497. * @param name The name of the effect.
  130498. * @param originalFromInput Post process which's input will be used for the merge.
  130499. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  130500. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  130501. * @param options The required width/height ratio to downsize to before computing the render pass.
  130502. * @param camera The camera to apply the render pass to.
  130503. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130504. * @param engine The engine which the post process will be applied. (default: current engine)
  130505. * @param reusable If the post process can be reused on the same frame. (default: false)
  130506. * @param textureType Type of textures used when performing the post process. (default: 0)
  130507. * @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)
  130508. */
  130509. 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);
  130510. /**
  130511. * Updates the effect with the current post process compile time values and recompiles the shader.
  130512. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  130513. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  130514. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  130515. * @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
  130516. * @param onCompiled Called when the shader has been compiled.
  130517. * @param onError Called if there is an error when compiling a shader.
  130518. */
  130519. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  130520. }
  130521. }
  130522. declare module BABYLON {
  130523. /**
  130524. * Specifies the level of max blur that should be applied when using the depth of field effect
  130525. */
  130526. export enum DepthOfFieldEffectBlurLevel {
  130527. /**
  130528. * Subtle blur
  130529. */
  130530. Low = 0,
  130531. /**
  130532. * Medium blur
  130533. */
  130534. Medium = 1,
  130535. /**
  130536. * Large blur
  130537. */
  130538. High = 2
  130539. }
  130540. /**
  130541. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  130542. */
  130543. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  130544. private _circleOfConfusion;
  130545. /**
  130546. * @hidden Internal, blurs from high to low
  130547. */
  130548. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  130549. private _depthOfFieldBlurY;
  130550. private _dofMerge;
  130551. /**
  130552. * @hidden Internal post processes in depth of field effect
  130553. */
  130554. _effects: Array<PostProcess>;
  130555. /**
  130556. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  130557. */
  130558. focalLength: number;
  130559. /**
  130560. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  130561. */
  130562. fStop: number;
  130563. /**
  130564. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  130565. */
  130566. focusDistance: number;
  130567. /**
  130568. * 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.
  130569. */
  130570. lensSize: number;
  130571. /**
  130572. * Creates a new instance DepthOfFieldEffect
  130573. * @param scene The scene the effect belongs to.
  130574. * @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.
  130575. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  130576. * @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)
  130577. */
  130578. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  130579. /**
  130580. * Get the current class name of the current effet
  130581. * @returns "DepthOfFieldEffect"
  130582. */
  130583. getClassName(): string;
  130584. /**
  130585. * 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.
  130586. */
  130587. depthTexture: RenderTargetTexture;
  130588. /**
  130589. * Disposes each of the internal effects for a given camera.
  130590. * @param camera The camera to dispose the effect on.
  130591. */
  130592. disposeEffects(camera: Camera): void;
  130593. /**
  130594. * @hidden Internal
  130595. */
  130596. _updateEffects(): void;
  130597. /**
  130598. * Internal
  130599. * @returns if all the contained post processes are ready.
  130600. * @hidden
  130601. */
  130602. _isReady(): boolean;
  130603. }
  130604. }
  130605. declare module BABYLON {
  130606. /** @hidden */
  130607. export var displayPassPixelShader: {
  130608. name: string;
  130609. shader: string;
  130610. };
  130611. }
  130612. declare module BABYLON {
  130613. /**
  130614. * DisplayPassPostProcess which produces an output the same as it's input
  130615. */
  130616. export class DisplayPassPostProcess extends PostProcess {
  130617. /**
  130618. * Creates the DisplayPassPostProcess
  130619. * @param name The name of the effect.
  130620. * @param options The required width/height ratio to downsize to before computing the render pass.
  130621. * @param camera The camera to apply the render pass to.
  130622. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130623. * @param engine The engine which the post process will be applied. (default: current engine)
  130624. * @param reusable If the post process can be reused on the same frame. (default: false)
  130625. */
  130626. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  130627. }
  130628. }
  130629. declare module BABYLON {
  130630. /** @hidden */
  130631. export var filterPixelShader: {
  130632. name: string;
  130633. shader: string;
  130634. };
  130635. }
  130636. declare module BABYLON {
  130637. /**
  130638. * Applies a kernel filter to the image
  130639. */
  130640. export class FilterPostProcess extends PostProcess {
  130641. /** The matrix to be applied to the image */
  130642. kernelMatrix: Matrix;
  130643. /**
  130644. *
  130645. * @param name The name of the effect.
  130646. * @param kernelMatrix The matrix to be applied to the image
  130647. * @param options The required width/height ratio to downsize to before computing the render pass.
  130648. * @param camera The camera to apply the render pass to.
  130649. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130650. * @param engine The engine which the post process will be applied. (default: current engine)
  130651. * @param reusable If the post process can be reused on the same frame. (default: false)
  130652. */
  130653. constructor(name: string,
  130654. /** The matrix to be applied to the image */
  130655. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  130656. }
  130657. }
  130658. declare module BABYLON {
  130659. /** @hidden */
  130660. export var fxaaPixelShader: {
  130661. name: string;
  130662. shader: string;
  130663. };
  130664. }
  130665. declare module BABYLON {
  130666. /** @hidden */
  130667. export var fxaaVertexShader: {
  130668. name: string;
  130669. shader: string;
  130670. };
  130671. }
  130672. declare module BABYLON {
  130673. /**
  130674. * Fxaa post process
  130675. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  130676. */
  130677. export class FxaaPostProcess extends PostProcess {
  130678. /** @hidden */
  130679. texelWidth: number;
  130680. /** @hidden */
  130681. texelHeight: number;
  130682. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  130683. private _getDefines;
  130684. }
  130685. }
  130686. declare module BABYLON {
  130687. /** @hidden */
  130688. export var grainPixelShader: {
  130689. name: string;
  130690. shader: string;
  130691. };
  130692. }
  130693. declare module BABYLON {
  130694. /**
  130695. * The GrainPostProcess adds noise to the image at mid luminance levels
  130696. */
  130697. export class GrainPostProcess extends PostProcess {
  130698. /**
  130699. * The intensity of the grain added (default: 30)
  130700. */
  130701. intensity: number;
  130702. /**
  130703. * If the grain should be randomized on every frame
  130704. */
  130705. animated: boolean;
  130706. /**
  130707. * Creates a new instance of @see GrainPostProcess
  130708. * @param name The name of the effect.
  130709. * @param options The required width/height ratio to downsize to before computing the render pass.
  130710. * @param camera The camera to apply the render pass to.
  130711. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130712. * @param engine The engine which the post process will be applied. (default: current engine)
  130713. * @param reusable If the post process can be reused on the same frame. (default: false)
  130714. * @param textureType Type of textures used when performing the post process. (default: 0)
  130715. * @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)
  130716. */
  130717. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  130718. }
  130719. }
  130720. declare module BABYLON {
  130721. /** @hidden */
  130722. export var highlightsPixelShader: {
  130723. name: string;
  130724. shader: string;
  130725. };
  130726. }
  130727. declare module BABYLON {
  130728. /**
  130729. * Extracts highlights from the image
  130730. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  130731. */
  130732. export class HighlightsPostProcess extends PostProcess {
  130733. /**
  130734. * Extracts highlights from the image
  130735. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  130736. * @param name The name of the effect.
  130737. * @param options The required width/height ratio to downsize to before computing the render pass.
  130738. * @param camera The camera to apply the render pass to.
  130739. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130740. * @param engine The engine which the post process will be applied. (default: current engine)
  130741. * @param reusable If the post process can be reused on the same frame. (default: false)
  130742. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  130743. */
  130744. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  130745. }
  130746. }
  130747. declare module BABYLON {
  130748. /** @hidden */
  130749. export var mrtFragmentDeclaration: {
  130750. name: string;
  130751. shader: string;
  130752. };
  130753. }
  130754. declare module BABYLON {
  130755. /** @hidden */
  130756. export var geometryPixelShader: {
  130757. name: string;
  130758. shader: string;
  130759. };
  130760. }
  130761. declare module BABYLON {
  130762. /** @hidden */
  130763. export var geometryVertexShader: {
  130764. name: string;
  130765. shader: string;
  130766. };
  130767. }
  130768. declare module BABYLON {
  130769. /** @hidden */
  130770. interface ISavedTransformationMatrix {
  130771. world: Matrix;
  130772. viewProjection: Matrix;
  130773. }
  130774. /**
  130775. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  130776. */
  130777. export class GeometryBufferRenderer {
  130778. /**
  130779. * Constant used to retrieve the position texture index in the G-Buffer textures array
  130780. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  130781. */
  130782. static readonly POSITION_TEXTURE_TYPE: number;
  130783. /**
  130784. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  130785. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  130786. */
  130787. static readonly VELOCITY_TEXTURE_TYPE: number;
  130788. /**
  130789. * Dictionary used to store the previous transformation matrices of each rendered mesh
  130790. * in order to compute objects velocities when enableVelocity is set to "true"
  130791. * @hidden
  130792. */
  130793. _previousTransformationMatrices: {
  130794. [index: number]: ISavedTransformationMatrix;
  130795. };
  130796. /**
  130797. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  130798. * in order to compute objects velocities when enableVelocity is set to "true"
  130799. * @hidden
  130800. */
  130801. _previousBonesTransformationMatrices: {
  130802. [index: number]: Float32Array;
  130803. };
  130804. /**
  130805. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  130806. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  130807. */
  130808. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  130809. private _scene;
  130810. private _multiRenderTarget;
  130811. private _ratio;
  130812. private _enablePosition;
  130813. private _enableVelocity;
  130814. private _positionIndex;
  130815. private _velocityIndex;
  130816. protected _effect: Effect;
  130817. protected _cachedDefines: string;
  130818. /**
  130819. * Set the render list (meshes to be rendered) used in the G buffer.
  130820. */
  130821. renderList: Mesh[];
  130822. /**
  130823. * Gets wether or not G buffer are supported by the running hardware.
  130824. * This requires draw buffer supports
  130825. */
  130826. readonly isSupported: boolean;
  130827. /**
  130828. * Returns the index of the given texture type in the G-Buffer textures array
  130829. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  130830. * @returns the index of the given texture type in the G-Buffer textures array
  130831. */
  130832. getTextureIndex(textureType: number): number;
  130833. /**
  130834. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  130835. */
  130836. /**
  130837. * Sets whether or not objects positions are enabled for the G buffer.
  130838. */
  130839. enablePosition: boolean;
  130840. /**
  130841. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  130842. */
  130843. /**
  130844. * Sets wether or not objects velocities are enabled for the G buffer.
  130845. */
  130846. enableVelocity: boolean;
  130847. /**
  130848. * Gets the scene associated with the buffer.
  130849. */
  130850. readonly scene: Scene;
  130851. /**
  130852. * Gets the ratio used by the buffer during its creation.
  130853. * How big is the buffer related to the main canvas.
  130854. */
  130855. readonly ratio: number;
  130856. /** @hidden */
  130857. static _SceneComponentInitialization: (scene: Scene) => void;
  130858. /**
  130859. * Creates a new G Buffer for the scene
  130860. * @param scene The scene the buffer belongs to
  130861. * @param ratio How big is the buffer related to the main canvas.
  130862. */
  130863. constructor(scene: Scene, ratio?: number);
  130864. /**
  130865. * Checks wether everything is ready to render a submesh to the G buffer.
  130866. * @param subMesh the submesh to check readiness for
  130867. * @param useInstances is the mesh drawn using instance or not
  130868. * @returns true if ready otherwise false
  130869. */
  130870. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  130871. /**
  130872. * Gets the current underlying G Buffer.
  130873. * @returns the buffer
  130874. */
  130875. getGBuffer(): MultiRenderTarget;
  130876. /**
  130877. * Gets the number of samples used to render the buffer (anti aliasing).
  130878. */
  130879. /**
  130880. * Sets the number of samples used to render the buffer (anti aliasing).
  130881. */
  130882. samples: number;
  130883. /**
  130884. * Disposes the renderer and frees up associated resources.
  130885. */
  130886. dispose(): void;
  130887. protected _createRenderTargets(): void;
  130888. private _copyBonesTransformationMatrices;
  130889. }
  130890. }
  130891. declare module BABYLON {
  130892. interface Scene {
  130893. /** @hidden (Backing field) */
  130894. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  130895. /**
  130896. * Gets or Sets the current geometry buffer associated to the scene.
  130897. */
  130898. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  130899. /**
  130900. * Enables a GeometryBufferRender and associates it with the scene
  130901. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  130902. * @returns the GeometryBufferRenderer
  130903. */
  130904. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  130905. /**
  130906. * Disables the GeometryBufferRender associated with the scene
  130907. */
  130908. disableGeometryBufferRenderer(): void;
  130909. }
  130910. /**
  130911. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  130912. * in several rendering techniques.
  130913. */
  130914. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  130915. /**
  130916. * The component name helpful to identify the component in the list of scene components.
  130917. */
  130918. readonly name: string;
  130919. /**
  130920. * The scene the component belongs to.
  130921. */
  130922. scene: Scene;
  130923. /**
  130924. * Creates a new instance of the component for the given scene
  130925. * @param scene Defines the scene to register the component in
  130926. */
  130927. constructor(scene: Scene);
  130928. /**
  130929. * Registers the component in a given scene
  130930. */
  130931. register(): void;
  130932. /**
  130933. * Rebuilds the elements related to this component in case of
  130934. * context lost for instance.
  130935. */
  130936. rebuild(): void;
  130937. /**
  130938. * Disposes the component and the associated ressources
  130939. */
  130940. dispose(): void;
  130941. private _gatherRenderTargets;
  130942. }
  130943. }
  130944. declare module BABYLON {
  130945. /** @hidden */
  130946. export var motionBlurPixelShader: {
  130947. name: string;
  130948. shader: string;
  130949. };
  130950. }
  130951. declare module BABYLON {
  130952. /**
  130953. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  130954. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  130955. * As an example, all you have to do is to create the post-process:
  130956. * var mb = new BABYLON.MotionBlurPostProcess(
  130957. * 'mb', // The name of the effect.
  130958. * scene, // The scene containing the objects to blur according to their velocity.
  130959. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  130960. * camera // The camera to apply the render pass to.
  130961. * );
  130962. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  130963. */
  130964. export class MotionBlurPostProcess extends PostProcess {
  130965. /**
  130966. * Defines how much the image is blurred by the movement. Default value is equal to 1
  130967. */
  130968. motionStrength: number;
  130969. /**
  130970. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  130971. */
  130972. /**
  130973. * Sets the number of iterations to be used for motion blur quality
  130974. */
  130975. motionBlurSamples: number;
  130976. private _motionBlurSamples;
  130977. private _geometryBufferRenderer;
  130978. /**
  130979. * Creates a new instance MotionBlurPostProcess
  130980. * @param name The name of the effect.
  130981. * @param scene The scene containing the objects to blur according to their velocity.
  130982. * @param options The required width/height ratio to downsize to before computing the render pass.
  130983. * @param camera The camera to apply the render pass to.
  130984. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130985. * @param engine The engine which the post process will be applied. (default: current engine)
  130986. * @param reusable If the post process can be reused on the same frame. (default: false)
  130987. * @param textureType Type of textures used when performing the post process. (default: 0)
  130988. * @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)
  130989. */
  130990. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  130991. /**
  130992. * Excludes the given skinned mesh from computing bones velocities.
  130993. * 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.
  130994. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  130995. */
  130996. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  130997. /**
  130998. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  130999. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  131000. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  131001. */
  131002. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  131003. /**
  131004. * Disposes the post process.
  131005. * @param camera The camera to dispose the post process on.
  131006. */
  131007. dispose(camera?: Camera): void;
  131008. }
  131009. }
  131010. declare module BABYLON {
  131011. /** @hidden */
  131012. export var refractionPixelShader: {
  131013. name: string;
  131014. shader: string;
  131015. };
  131016. }
  131017. declare module BABYLON {
  131018. /**
  131019. * Post process which applies a refractin texture
  131020. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  131021. */
  131022. export class RefractionPostProcess extends PostProcess {
  131023. /** the base color of the refraction (used to taint the rendering) */
  131024. color: Color3;
  131025. /** simulated refraction depth */
  131026. depth: number;
  131027. /** the coefficient of the base color (0 to remove base color tainting) */
  131028. colorLevel: number;
  131029. private _refTexture;
  131030. private _ownRefractionTexture;
  131031. /**
  131032. * Gets or sets the refraction texture
  131033. * Please note that you are responsible for disposing the texture if you set it manually
  131034. */
  131035. refractionTexture: Texture;
  131036. /**
  131037. * Initializes the RefractionPostProcess
  131038. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  131039. * @param name The name of the effect.
  131040. * @param refractionTextureUrl Url of the refraction texture to use
  131041. * @param color the base color of the refraction (used to taint the rendering)
  131042. * @param depth simulated refraction depth
  131043. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  131044. * @param camera The camera to apply the render pass to.
  131045. * @param options The required width/height ratio to downsize to before computing the render pass.
  131046. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  131047. * @param engine The engine which the post process will be applied. (default: current engine)
  131048. * @param reusable If the post process can be reused on the same frame. (default: false)
  131049. */
  131050. constructor(name: string, refractionTextureUrl: string,
  131051. /** the base color of the refraction (used to taint the rendering) */
  131052. color: Color3,
  131053. /** simulated refraction depth */
  131054. depth: number,
  131055. /** the coefficient of the base color (0 to remove base color tainting) */
  131056. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  131057. /**
  131058. * Disposes of the post process
  131059. * @param camera Camera to dispose post process on
  131060. */
  131061. dispose(camera: Camera): void;
  131062. }
  131063. }
  131064. declare module BABYLON {
  131065. /** @hidden */
  131066. export var sharpenPixelShader: {
  131067. name: string;
  131068. shader: string;
  131069. };
  131070. }
  131071. declare module BABYLON {
  131072. /**
  131073. * The SharpenPostProcess applies a sharpen kernel to every pixel
  131074. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  131075. */
  131076. export class SharpenPostProcess extends PostProcess {
  131077. /**
  131078. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  131079. */
  131080. colorAmount: number;
  131081. /**
  131082. * How much sharpness should be applied (default: 0.3)
  131083. */
  131084. edgeAmount: number;
  131085. /**
  131086. * Creates a new instance ConvolutionPostProcess
  131087. * @param name The name of the effect.
  131088. * @param options The required width/height ratio to downsize to before computing the render pass.
  131089. * @param camera The camera to apply the render pass to.
  131090. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  131091. * @param engine The engine which the post process will be applied. (default: current engine)
  131092. * @param reusable If the post process can be reused on the same frame. (default: false)
  131093. * @param textureType Type of textures used when performing the post process. (default: 0)
  131094. * @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)
  131095. */
  131096. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  131097. }
  131098. }
  131099. declare module BABYLON {
  131100. /**
  131101. * PostProcessRenderPipeline
  131102. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  131103. */
  131104. export class PostProcessRenderPipeline {
  131105. private engine;
  131106. private _renderEffects;
  131107. private _renderEffectsForIsolatedPass;
  131108. /**
  131109. * List of inspectable custom properties (used by the Inspector)
  131110. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  131111. */
  131112. inspectableCustomProperties: IInspectable[];
  131113. /**
  131114. * @hidden
  131115. */
  131116. protected _cameras: Camera[];
  131117. /** @hidden */
  131118. _name: string;
  131119. /**
  131120. * Gets pipeline name
  131121. */
  131122. readonly name: string;
  131123. /** Gets the list of attached cameras */
  131124. readonly cameras: Camera[];
  131125. /**
  131126. * Initializes a PostProcessRenderPipeline
  131127. * @param engine engine to add the pipeline to
  131128. * @param name name of the pipeline
  131129. */
  131130. constructor(engine: Engine, name: string);
  131131. /**
  131132. * Gets the class name
  131133. * @returns "PostProcessRenderPipeline"
  131134. */
  131135. getClassName(): string;
  131136. /**
  131137. * If all the render effects in the pipeline are supported
  131138. */
  131139. readonly isSupported: boolean;
  131140. /**
  131141. * Adds an effect to the pipeline
  131142. * @param renderEffect the effect to add
  131143. */
  131144. addEffect(renderEffect: PostProcessRenderEffect): void;
  131145. /** @hidden */
  131146. _rebuild(): void;
  131147. /** @hidden */
  131148. _enableEffect(renderEffectName: string, cameras: Camera): void;
  131149. /** @hidden */
  131150. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  131151. /** @hidden */
  131152. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  131153. /** @hidden */
  131154. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  131155. /** @hidden */
  131156. _attachCameras(cameras: Camera, unique: boolean): void;
  131157. /** @hidden */
  131158. _attachCameras(cameras: Camera[], unique: boolean): void;
  131159. /** @hidden */
  131160. _detachCameras(cameras: Camera): void;
  131161. /** @hidden */
  131162. _detachCameras(cameras: Nullable<Camera[]>): void;
  131163. /** @hidden */
  131164. _update(): void;
  131165. /** @hidden */
  131166. _reset(): void;
  131167. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  131168. /**
  131169. * Disposes of the pipeline
  131170. */
  131171. dispose(): void;
  131172. }
  131173. }
  131174. declare module BABYLON {
  131175. /**
  131176. * PostProcessRenderPipelineManager class
  131177. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  131178. */
  131179. export class PostProcessRenderPipelineManager {
  131180. private _renderPipelines;
  131181. /**
  131182. * Initializes a PostProcessRenderPipelineManager
  131183. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  131184. */
  131185. constructor();
  131186. /**
  131187. * Gets the list of supported render pipelines
  131188. */
  131189. readonly supportedPipelines: PostProcessRenderPipeline[];
  131190. /**
  131191. * Adds a pipeline to the manager
  131192. * @param renderPipeline The pipeline to add
  131193. */
  131194. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  131195. /**
  131196. * Attaches a camera to the pipeline
  131197. * @param renderPipelineName The name of the pipeline to attach to
  131198. * @param cameras the camera to attach
  131199. * @param unique if the camera can be attached multiple times to the pipeline
  131200. */
  131201. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  131202. /**
  131203. * Detaches a camera from the pipeline
  131204. * @param renderPipelineName The name of the pipeline to detach from
  131205. * @param cameras the camera to detach
  131206. */
  131207. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  131208. /**
  131209. * Enables an effect by name on a pipeline
  131210. * @param renderPipelineName the name of the pipeline to enable the effect in
  131211. * @param renderEffectName the name of the effect to enable
  131212. * @param cameras the cameras that the effect should be enabled on
  131213. */
  131214. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  131215. /**
  131216. * Disables an effect by name on a pipeline
  131217. * @param renderPipelineName the name of the pipeline to disable the effect in
  131218. * @param renderEffectName the name of the effect to disable
  131219. * @param cameras the cameras that the effect should be disabled on
  131220. */
  131221. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  131222. /**
  131223. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  131224. */
  131225. update(): void;
  131226. /** @hidden */
  131227. _rebuild(): void;
  131228. /**
  131229. * Disposes of the manager and pipelines
  131230. */
  131231. dispose(): void;
  131232. }
  131233. }
  131234. declare module BABYLON {
  131235. interface Scene {
  131236. /** @hidden (Backing field) */
  131237. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  131238. /**
  131239. * Gets the postprocess render pipeline manager
  131240. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  131241. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  131242. */
  131243. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  131244. }
  131245. /**
  131246. * Defines the Render Pipeline scene component responsible to rendering pipelines
  131247. */
  131248. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  131249. /**
  131250. * The component name helpfull to identify the component in the list of scene components.
  131251. */
  131252. readonly name: string;
  131253. /**
  131254. * The scene the component belongs to.
  131255. */
  131256. scene: Scene;
  131257. /**
  131258. * Creates a new instance of the component for the given scene
  131259. * @param scene Defines the scene to register the component in
  131260. */
  131261. constructor(scene: Scene);
  131262. /**
  131263. * Registers the component in a given scene
  131264. */
  131265. register(): void;
  131266. /**
  131267. * Rebuilds the elements related to this component in case of
  131268. * context lost for instance.
  131269. */
  131270. rebuild(): void;
  131271. /**
  131272. * Disposes the component and the associated ressources
  131273. */
  131274. dispose(): void;
  131275. private _gatherRenderTargets;
  131276. }
  131277. }
  131278. declare module BABYLON {
  131279. /**
  131280. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  131281. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  131282. */
  131283. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  131284. private _scene;
  131285. private _camerasToBeAttached;
  131286. /**
  131287. * ID of the sharpen post process,
  131288. */
  131289. private readonly SharpenPostProcessId;
  131290. /**
  131291. * @ignore
  131292. * ID of the image processing post process;
  131293. */
  131294. readonly ImageProcessingPostProcessId: string;
  131295. /**
  131296. * @ignore
  131297. * ID of the Fast Approximate Anti-Aliasing post process;
  131298. */
  131299. readonly FxaaPostProcessId: string;
  131300. /**
  131301. * ID of the chromatic aberration post process,
  131302. */
  131303. private readonly ChromaticAberrationPostProcessId;
  131304. /**
  131305. * ID of the grain post process
  131306. */
  131307. private readonly GrainPostProcessId;
  131308. /**
  131309. * Sharpen post process which will apply a sharpen convolution to enhance edges
  131310. */
  131311. sharpen: SharpenPostProcess;
  131312. private _sharpenEffect;
  131313. private bloom;
  131314. /**
  131315. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  131316. */
  131317. depthOfField: DepthOfFieldEffect;
  131318. /**
  131319. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  131320. */
  131321. fxaa: FxaaPostProcess;
  131322. /**
  131323. * Image post processing pass used to perform operations such as tone mapping or color grading.
  131324. */
  131325. imageProcessing: ImageProcessingPostProcess;
  131326. /**
  131327. * Chromatic aberration post process which will shift rgb colors in the image
  131328. */
  131329. chromaticAberration: ChromaticAberrationPostProcess;
  131330. private _chromaticAberrationEffect;
  131331. /**
  131332. * Grain post process which add noise to the image
  131333. */
  131334. grain: GrainPostProcess;
  131335. private _grainEffect;
  131336. /**
  131337. * Glow post process which adds a glow to emissive areas of the image
  131338. */
  131339. private _glowLayer;
  131340. /**
  131341. * Animations which can be used to tweak settings over a period of time
  131342. */
  131343. animations: Animation[];
  131344. private _imageProcessingConfigurationObserver;
  131345. private _sharpenEnabled;
  131346. private _bloomEnabled;
  131347. private _depthOfFieldEnabled;
  131348. private _depthOfFieldBlurLevel;
  131349. private _fxaaEnabled;
  131350. private _imageProcessingEnabled;
  131351. private _defaultPipelineTextureType;
  131352. private _bloomScale;
  131353. private _chromaticAberrationEnabled;
  131354. private _grainEnabled;
  131355. private _buildAllowed;
  131356. /**
  131357. * Gets active scene
  131358. */
  131359. readonly scene: Scene;
  131360. /**
  131361. * Enable or disable the sharpen process from the pipeline
  131362. */
  131363. sharpenEnabled: boolean;
  131364. private _resizeObserver;
  131365. private _hardwareScaleLevel;
  131366. private _bloomKernel;
  131367. /**
  131368. * Specifies the size of the bloom blur kernel, relative to the final output size
  131369. */
  131370. bloomKernel: number;
  131371. /**
  131372. * Specifies the weight of the bloom in the final rendering
  131373. */
  131374. private _bloomWeight;
  131375. /**
  131376. * Specifies the luma threshold for the area that will be blurred by the bloom
  131377. */
  131378. private _bloomThreshold;
  131379. private _hdr;
  131380. /**
  131381. * The strength of the bloom.
  131382. */
  131383. bloomWeight: number;
  131384. /**
  131385. * The strength of the bloom.
  131386. */
  131387. bloomThreshold: number;
  131388. /**
  131389. * The scale of the bloom, lower value will provide better performance.
  131390. */
  131391. bloomScale: number;
  131392. /**
  131393. * Enable or disable the bloom from the pipeline
  131394. */
  131395. bloomEnabled: boolean;
  131396. private _rebuildBloom;
  131397. /**
  131398. * If the depth of field is enabled.
  131399. */
  131400. depthOfFieldEnabled: boolean;
  131401. /**
  131402. * Blur level of the depth of field effect. (Higher blur will effect performance)
  131403. */
  131404. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  131405. /**
  131406. * If the anti aliasing is enabled.
  131407. */
  131408. fxaaEnabled: boolean;
  131409. private _samples;
  131410. /**
  131411. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  131412. */
  131413. samples: number;
  131414. /**
  131415. * If image processing is enabled.
  131416. */
  131417. imageProcessingEnabled: boolean;
  131418. /**
  131419. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  131420. */
  131421. glowLayerEnabled: boolean;
  131422. /**
  131423. * Gets the glow layer (or null if not defined)
  131424. */
  131425. readonly glowLayer: Nullable<GlowLayer>;
  131426. /**
  131427. * Enable or disable the chromaticAberration process from the pipeline
  131428. */
  131429. chromaticAberrationEnabled: boolean;
  131430. /**
  131431. * Enable or disable the grain process from the pipeline
  131432. */
  131433. grainEnabled: boolean;
  131434. /**
  131435. * @constructor
  131436. * @param name - The rendering pipeline name (default: "")
  131437. * @param hdr - If high dynamic range textures should be used (default: true)
  131438. * @param scene - The scene linked to this pipeline (default: the last created scene)
  131439. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  131440. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  131441. */
  131442. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  131443. /**
  131444. * Get the class name
  131445. * @returns "DefaultRenderingPipeline"
  131446. */
  131447. getClassName(): string;
  131448. /**
  131449. * Force the compilation of the entire pipeline.
  131450. */
  131451. prepare(): void;
  131452. private _hasCleared;
  131453. private _prevPostProcess;
  131454. private _prevPrevPostProcess;
  131455. private _setAutoClearAndTextureSharing;
  131456. private _depthOfFieldSceneObserver;
  131457. private _buildPipeline;
  131458. private _disposePostProcesses;
  131459. /**
  131460. * Adds a camera to the pipeline
  131461. * @param camera the camera to be added
  131462. */
  131463. addCamera(camera: Camera): void;
  131464. /**
  131465. * Removes a camera from the pipeline
  131466. * @param camera the camera to remove
  131467. */
  131468. removeCamera(camera: Camera): void;
  131469. /**
  131470. * Dispose of the pipeline and stop all post processes
  131471. */
  131472. dispose(): void;
  131473. /**
  131474. * Serialize the rendering pipeline (Used when exporting)
  131475. * @returns the serialized object
  131476. */
  131477. serialize(): any;
  131478. /**
  131479. * Parse the serialized pipeline
  131480. * @param source Source pipeline.
  131481. * @param scene The scene to load the pipeline to.
  131482. * @param rootUrl The URL of the serialized pipeline.
  131483. * @returns An instantiated pipeline from the serialized object.
  131484. */
  131485. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  131486. }
  131487. }
  131488. declare module BABYLON {
  131489. /** @hidden */
  131490. export var lensHighlightsPixelShader: {
  131491. name: string;
  131492. shader: string;
  131493. };
  131494. }
  131495. declare module BABYLON {
  131496. /** @hidden */
  131497. export var depthOfFieldPixelShader: {
  131498. name: string;
  131499. shader: string;
  131500. };
  131501. }
  131502. declare module BABYLON {
  131503. /**
  131504. * BABYLON.JS Chromatic Aberration GLSL Shader
  131505. * Author: Olivier Guyot
  131506. * Separates very slightly R, G and B colors on the edges of the screen
  131507. * Inspired by Francois Tarlier & Martins Upitis
  131508. */
  131509. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  131510. /**
  131511. * @ignore
  131512. * The chromatic aberration PostProcess id in the pipeline
  131513. */
  131514. LensChromaticAberrationEffect: string;
  131515. /**
  131516. * @ignore
  131517. * The highlights enhancing PostProcess id in the pipeline
  131518. */
  131519. HighlightsEnhancingEffect: string;
  131520. /**
  131521. * @ignore
  131522. * The depth-of-field PostProcess id in the pipeline
  131523. */
  131524. LensDepthOfFieldEffect: string;
  131525. private _scene;
  131526. private _depthTexture;
  131527. private _grainTexture;
  131528. private _chromaticAberrationPostProcess;
  131529. private _highlightsPostProcess;
  131530. private _depthOfFieldPostProcess;
  131531. private _edgeBlur;
  131532. private _grainAmount;
  131533. private _chromaticAberration;
  131534. private _distortion;
  131535. private _highlightsGain;
  131536. private _highlightsThreshold;
  131537. private _dofDistance;
  131538. private _dofAperture;
  131539. private _dofDarken;
  131540. private _dofPentagon;
  131541. private _blurNoise;
  131542. /**
  131543. * @constructor
  131544. *
  131545. * Effect parameters are as follow:
  131546. * {
  131547. * chromatic_aberration: number; // from 0 to x (1 for realism)
  131548. * edge_blur: number; // from 0 to x (1 for realism)
  131549. * distortion: number; // from 0 to x (1 for realism)
  131550. * grain_amount: number; // from 0 to 1
  131551. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  131552. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  131553. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  131554. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  131555. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  131556. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  131557. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  131558. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  131559. * }
  131560. * Note: if an effect parameter is unset, effect is disabled
  131561. *
  131562. * @param name The rendering pipeline name
  131563. * @param parameters - An object containing all parameters (see above)
  131564. * @param scene The scene linked to this pipeline
  131565. * @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)
  131566. * @param cameras The array of cameras that the rendering pipeline will be attached to
  131567. */
  131568. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  131569. /**
  131570. * Get the class name
  131571. * @returns "LensRenderingPipeline"
  131572. */
  131573. getClassName(): string;
  131574. /**
  131575. * Gets associated scene
  131576. */
  131577. readonly scene: Scene;
  131578. /**
  131579. * Gets or sets the edge blur
  131580. */
  131581. edgeBlur: number;
  131582. /**
  131583. * Gets or sets the grain amount
  131584. */
  131585. grainAmount: number;
  131586. /**
  131587. * Gets or sets the chromatic aberration amount
  131588. */
  131589. chromaticAberration: number;
  131590. /**
  131591. * Gets or sets the depth of field aperture
  131592. */
  131593. dofAperture: number;
  131594. /**
  131595. * Gets or sets the edge distortion
  131596. */
  131597. edgeDistortion: number;
  131598. /**
  131599. * Gets or sets the depth of field distortion
  131600. */
  131601. dofDistortion: number;
  131602. /**
  131603. * Gets or sets the darken out of focus amount
  131604. */
  131605. darkenOutOfFocus: number;
  131606. /**
  131607. * Gets or sets a boolean indicating if blur noise is enabled
  131608. */
  131609. blurNoise: boolean;
  131610. /**
  131611. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  131612. */
  131613. pentagonBokeh: boolean;
  131614. /**
  131615. * Gets or sets the highlight grain amount
  131616. */
  131617. highlightsGain: number;
  131618. /**
  131619. * Gets or sets the highlight threshold
  131620. */
  131621. highlightsThreshold: number;
  131622. /**
  131623. * Sets the amount of blur at the edges
  131624. * @param amount blur amount
  131625. */
  131626. setEdgeBlur(amount: number): void;
  131627. /**
  131628. * Sets edge blur to 0
  131629. */
  131630. disableEdgeBlur(): void;
  131631. /**
  131632. * Sets the amout of grain
  131633. * @param amount Amount of grain
  131634. */
  131635. setGrainAmount(amount: number): void;
  131636. /**
  131637. * Set grain amount to 0
  131638. */
  131639. disableGrain(): void;
  131640. /**
  131641. * Sets the chromatic aberration amount
  131642. * @param amount amount of chromatic aberration
  131643. */
  131644. setChromaticAberration(amount: number): void;
  131645. /**
  131646. * Sets chromatic aberration amount to 0
  131647. */
  131648. disableChromaticAberration(): void;
  131649. /**
  131650. * Sets the EdgeDistortion amount
  131651. * @param amount amount of EdgeDistortion
  131652. */
  131653. setEdgeDistortion(amount: number): void;
  131654. /**
  131655. * Sets edge distortion to 0
  131656. */
  131657. disableEdgeDistortion(): void;
  131658. /**
  131659. * Sets the FocusDistance amount
  131660. * @param amount amount of FocusDistance
  131661. */
  131662. setFocusDistance(amount: number): void;
  131663. /**
  131664. * Disables depth of field
  131665. */
  131666. disableDepthOfField(): void;
  131667. /**
  131668. * Sets the Aperture amount
  131669. * @param amount amount of Aperture
  131670. */
  131671. setAperture(amount: number): void;
  131672. /**
  131673. * Sets the DarkenOutOfFocus amount
  131674. * @param amount amount of DarkenOutOfFocus
  131675. */
  131676. setDarkenOutOfFocus(amount: number): void;
  131677. private _pentagonBokehIsEnabled;
  131678. /**
  131679. * Creates a pentagon bokeh effect
  131680. */
  131681. enablePentagonBokeh(): void;
  131682. /**
  131683. * Disables the pentagon bokeh effect
  131684. */
  131685. disablePentagonBokeh(): void;
  131686. /**
  131687. * Enables noise blur
  131688. */
  131689. enableNoiseBlur(): void;
  131690. /**
  131691. * Disables noise blur
  131692. */
  131693. disableNoiseBlur(): void;
  131694. /**
  131695. * Sets the HighlightsGain amount
  131696. * @param amount amount of HighlightsGain
  131697. */
  131698. setHighlightsGain(amount: number): void;
  131699. /**
  131700. * Sets the HighlightsThreshold amount
  131701. * @param amount amount of HighlightsThreshold
  131702. */
  131703. setHighlightsThreshold(amount: number): void;
  131704. /**
  131705. * Disables highlights
  131706. */
  131707. disableHighlights(): void;
  131708. /**
  131709. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  131710. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  131711. */
  131712. dispose(disableDepthRender?: boolean): void;
  131713. private _createChromaticAberrationPostProcess;
  131714. private _createHighlightsPostProcess;
  131715. private _createDepthOfFieldPostProcess;
  131716. private _createGrainTexture;
  131717. }
  131718. }
  131719. declare module BABYLON {
  131720. /** @hidden */
  131721. export var ssao2PixelShader: {
  131722. name: string;
  131723. shader: string;
  131724. };
  131725. }
  131726. declare module BABYLON {
  131727. /** @hidden */
  131728. export var ssaoCombinePixelShader: {
  131729. name: string;
  131730. shader: string;
  131731. };
  131732. }
  131733. declare module BABYLON {
  131734. /**
  131735. * Render pipeline to produce ssao effect
  131736. */
  131737. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  131738. /**
  131739. * @ignore
  131740. * The PassPostProcess id in the pipeline that contains the original scene color
  131741. */
  131742. SSAOOriginalSceneColorEffect: string;
  131743. /**
  131744. * @ignore
  131745. * The SSAO PostProcess id in the pipeline
  131746. */
  131747. SSAORenderEffect: string;
  131748. /**
  131749. * @ignore
  131750. * The horizontal blur PostProcess id in the pipeline
  131751. */
  131752. SSAOBlurHRenderEffect: string;
  131753. /**
  131754. * @ignore
  131755. * The vertical blur PostProcess id in the pipeline
  131756. */
  131757. SSAOBlurVRenderEffect: string;
  131758. /**
  131759. * @ignore
  131760. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  131761. */
  131762. SSAOCombineRenderEffect: string;
  131763. /**
  131764. * The output strength of the SSAO post-process. Default value is 1.0.
  131765. */
  131766. totalStrength: number;
  131767. /**
  131768. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  131769. */
  131770. maxZ: number;
  131771. /**
  131772. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  131773. */
  131774. minZAspect: number;
  131775. private _samples;
  131776. /**
  131777. * Number of samples used for the SSAO calculations. Default value is 8
  131778. */
  131779. samples: number;
  131780. private _textureSamples;
  131781. /**
  131782. * Number of samples to use for antialiasing
  131783. */
  131784. textureSamples: number;
  131785. /**
  131786. * Ratio object used for SSAO ratio and blur ratio
  131787. */
  131788. private _ratio;
  131789. /**
  131790. * Dynamically generated sphere sampler.
  131791. */
  131792. private _sampleSphere;
  131793. /**
  131794. * Blur filter offsets
  131795. */
  131796. private _samplerOffsets;
  131797. private _expensiveBlur;
  131798. /**
  131799. * If bilateral blur should be used
  131800. */
  131801. expensiveBlur: boolean;
  131802. /**
  131803. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  131804. */
  131805. radius: number;
  131806. /**
  131807. * The base color of the SSAO post-process
  131808. * The final result is "base + ssao" between [0, 1]
  131809. */
  131810. base: number;
  131811. /**
  131812. * Support test.
  131813. */
  131814. static readonly IsSupported: boolean;
  131815. private _scene;
  131816. private _depthTexture;
  131817. private _normalTexture;
  131818. private _randomTexture;
  131819. private _originalColorPostProcess;
  131820. private _ssaoPostProcess;
  131821. private _blurHPostProcess;
  131822. private _blurVPostProcess;
  131823. private _ssaoCombinePostProcess;
  131824. /**
  131825. * Gets active scene
  131826. */
  131827. readonly scene: Scene;
  131828. /**
  131829. * @constructor
  131830. * @param name The rendering pipeline name
  131831. * @param scene The scene linked to this pipeline
  131832. * @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 }
  131833. * @param cameras The array of cameras that the rendering pipeline will be attached to
  131834. */
  131835. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  131836. /**
  131837. * Get the class name
  131838. * @returns "SSAO2RenderingPipeline"
  131839. */
  131840. getClassName(): string;
  131841. /**
  131842. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  131843. */
  131844. dispose(disableGeometryBufferRenderer?: boolean): void;
  131845. private _createBlurPostProcess;
  131846. /** @hidden */
  131847. _rebuild(): void;
  131848. private _bits;
  131849. private _radicalInverse_VdC;
  131850. private _hammersley;
  131851. private _hemisphereSample_uniform;
  131852. private _generateHemisphere;
  131853. private _createSSAOPostProcess;
  131854. private _createSSAOCombinePostProcess;
  131855. private _createRandomTexture;
  131856. /**
  131857. * Serialize the rendering pipeline (Used when exporting)
  131858. * @returns the serialized object
  131859. */
  131860. serialize(): any;
  131861. /**
  131862. * Parse the serialized pipeline
  131863. * @param source Source pipeline.
  131864. * @param scene The scene to load the pipeline to.
  131865. * @param rootUrl The URL of the serialized pipeline.
  131866. * @returns An instantiated pipeline from the serialized object.
  131867. */
  131868. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  131869. }
  131870. }
  131871. declare module BABYLON {
  131872. /** @hidden */
  131873. export var ssaoPixelShader: {
  131874. name: string;
  131875. shader: string;
  131876. };
  131877. }
  131878. declare module BABYLON {
  131879. /**
  131880. * Render pipeline to produce ssao effect
  131881. */
  131882. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  131883. /**
  131884. * @ignore
  131885. * The PassPostProcess id in the pipeline that contains the original scene color
  131886. */
  131887. SSAOOriginalSceneColorEffect: string;
  131888. /**
  131889. * @ignore
  131890. * The SSAO PostProcess id in the pipeline
  131891. */
  131892. SSAORenderEffect: string;
  131893. /**
  131894. * @ignore
  131895. * The horizontal blur PostProcess id in the pipeline
  131896. */
  131897. SSAOBlurHRenderEffect: string;
  131898. /**
  131899. * @ignore
  131900. * The vertical blur PostProcess id in the pipeline
  131901. */
  131902. SSAOBlurVRenderEffect: string;
  131903. /**
  131904. * @ignore
  131905. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  131906. */
  131907. SSAOCombineRenderEffect: string;
  131908. /**
  131909. * The output strength of the SSAO post-process. Default value is 1.0.
  131910. */
  131911. totalStrength: number;
  131912. /**
  131913. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  131914. */
  131915. radius: number;
  131916. /**
  131917. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  131918. * Must not be equal to fallOff and superior to fallOff.
  131919. * Default value is 0.0075
  131920. */
  131921. area: number;
  131922. /**
  131923. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  131924. * Must not be equal to area and inferior to area.
  131925. * Default value is 0.000001
  131926. */
  131927. fallOff: number;
  131928. /**
  131929. * The base color of the SSAO post-process
  131930. * The final result is "base + ssao" between [0, 1]
  131931. */
  131932. base: number;
  131933. private _scene;
  131934. private _depthTexture;
  131935. private _randomTexture;
  131936. private _originalColorPostProcess;
  131937. private _ssaoPostProcess;
  131938. private _blurHPostProcess;
  131939. private _blurVPostProcess;
  131940. private _ssaoCombinePostProcess;
  131941. private _firstUpdate;
  131942. /**
  131943. * Gets active scene
  131944. */
  131945. readonly scene: Scene;
  131946. /**
  131947. * @constructor
  131948. * @param name - The rendering pipeline name
  131949. * @param scene - The scene linked to this pipeline
  131950. * @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 }
  131951. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  131952. */
  131953. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  131954. /**
  131955. * Get the class name
  131956. * @returns "SSAORenderingPipeline"
  131957. */
  131958. getClassName(): string;
  131959. /**
  131960. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  131961. */
  131962. dispose(disableDepthRender?: boolean): void;
  131963. private _createBlurPostProcess;
  131964. /** @hidden */
  131965. _rebuild(): void;
  131966. private _createSSAOPostProcess;
  131967. private _createSSAOCombinePostProcess;
  131968. private _createRandomTexture;
  131969. }
  131970. }
  131971. declare module BABYLON {
  131972. /** @hidden */
  131973. export var standardPixelShader: {
  131974. name: string;
  131975. shader: string;
  131976. };
  131977. }
  131978. declare module BABYLON {
  131979. /**
  131980. * Standard rendering pipeline
  131981. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  131982. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  131983. */
  131984. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  131985. /**
  131986. * Public members
  131987. */
  131988. /**
  131989. * Post-process which contains the original scene color before the pipeline applies all the effects
  131990. */
  131991. originalPostProcess: Nullable<PostProcess>;
  131992. /**
  131993. * Post-process used to down scale an image x4
  131994. */
  131995. downSampleX4PostProcess: Nullable<PostProcess>;
  131996. /**
  131997. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  131998. */
  131999. brightPassPostProcess: Nullable<PostProcess>;
  132000. /**
  132001. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  132002. */
  132003. blurHPostProcesses: PostProcess[];
  132004. /**
  132005. * Post-process array storing all the vertical blur post-processes used by the pipeline
  132006. */
  132007. blurVPostProcesses: PostProcess[];
  132008. /**
  132009. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  132010. */
  132011. textureAdderPostProcess: Nullable<PostProcess>;
  132012. /**
  132013. * Post-process used to create volumetric lighting effect
  132014. */
  132015. volumetricLightPostProcess: Nullable<PostProcess>;
  132016. /**
  132017. * Post-process used to smooth the previous volumetric light post-process on the X axis
  132018. */
  132019. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  132020. /**
  132021. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  132022. */
  132023. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  132024. /**
  132025. * Post-process used to merge the volumetric light effect and the real scene color
  132026. */
  132027. volumetricLightMergePostProces: Nullable<PostProcess>;
  132028. /**
  132029. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  132030. */
  132031. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  132032. /**
  132033. * Base post-process used to calculate the average luminance of the final image for HDR
  132034. */
  132035. luminancePostProcess: Nullable<PostProcess>;
  132036. /**
  132037. * Post-processes used to create down sample post-processes in order to get
  132038. * the average luminance of the final image for HDR
  132039. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  132040. */
  132041. luminanceDownSamplePostProcesses: PostProcess[];
  132042. /**
  132043. * Post-process used to create a HDR effect (light adaptation)
  132044. */
  132045. hdrPostProcess: Nullable<PostProcess>;
  132046. /**
  132047. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  132048. */
  132049. textureAdderFinalPostProcess: Nullable<PostProcess>;
  132050. /**
  132051. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  132052. */
  132053. lensFlareFinalPostProcess: Nullable<PostProcess>;
  132054. /**
  132055. * Post-process used to merge the final HDR post-process and the real scene color
  132056. */
  132057. hdrFinalPostProcess: Nullable<PostProcess>;
  132058. /**
  132059. * Post-process used to create a lens flare effect
  132060. */
  132061. lensFlarePostProcess: Nullable<PostProcess>;
  132062. /**
  132063. * Post-process that merges the result of the lens flare post-process and the real scene color
  132064. */
  132065. lensFlareComposePostProcess: Nullable<PostProcess>;
  132066. /**
  132067. * Post-process used to create a motion blur effect
  132068. */
  132069. motionBlurPostProcess: Nullable<PostProcess>;
  132070. /**
  132071. * Post-process used to create a depth of field effect
  132072. */
  132073. depthOfFieldPostProcess: Nullable<PostProcess>;
  132074. /**
  132075. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  132076. */
  132077. fxaaPostProcess: Nullable<FxaaPostProcess>;
  132078. /**
  132079. * Represents the brightness threshold in order to configure the illuminated surfaces
  132080. */
  132081. brightThreshold: number;
  132082. /**
  132083. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  132084. */
  132085. blurWidth: number;
  132086. /**
  132087. * Sets if the blur for highlighted surfaces must be only horizontal
  132088. */
  132089. horizontalBlur: boolean;
  132090. /**
  132091. * Gets the overall exposure used by the pipeline
  132092. */
  132093. /**
  132094. * Sets the overall exposure used by the pipeline
  132095. */
  132096. exposure: number;
  132097. /**
  132098. * Texture used typically to simulate "dirty" on camera lens
  132099. */
  132100. lensTexture: Nullable<Texture>;
  132101. /**
  132102. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  132103. */
  132104. volumetricLightCoefficient: number;
  132105. /**
  132106. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  132107. */
  132108. volumetricLightPower: number;
  132109. /**
  132110. * Used the set the blur intensity to smooth the volumetric lights
  132111. */
  132112. volumetricLightBlurScale: number;
  132113. /**
  132114. * Light (spot or directional) used to generate the volumetric lights rays
  132115. * The source light must have a shadow generate so the pipeline can get its
  132116. * depth map
  132117. */
  132118. sourceLight: Nullable<SpotLight | DirectionalLight>;
  132119. /**
  132120. * For eye adaptation, represents the minimum luminance the eye can see
  132121. */
  132122. hdrMinimumLuminance: number;
  132123. /**
  132124. * For eye adaptation, represents the decrease luminance speed
  132125. */
  132126. hdrDecreaseRate: number;
  132127. /**
  132128. * For eye adaptation, represents the increase luminance speed
  132129. */
  132130. hdrIncreaseRate: number;
  132131. /**
  132132. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  132133. */
  132134. /**
  132135. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  132136. */
  132137. hdrAutoExposure: boolean;
  132138. /**
  132139. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  132140. */
  132141. lensColorTexture: Nullable<Texture>;
  132142. /**
  132143. * The overall strengh for the lens flare effect
  132144. */
  132145. lensFlareStrength: number;
  132146. /**
  132147. * Dispersion coefficient for lens flare ghosts
  132148. */
  132149. lensFlareGhostDispersal: number;
  132150. /**
  132151. * Main lens flare halo width
  132152. */
  132153. lensFlareHaloWidth: number;
  132154. /**
  132155. * Based on the lens distortion effect, defines how much the lens flare result
  132156. * is distorted
  132157. */
  132158. lensFlareDistortionStrength: number;
  132159. /**
  132160. * Configures the blur intensity used for for lens flare (halo)
  132161. */
  132162. lensFlareBlurWidth: number;
  132163. /**
  132164. * Lens star texture must be used to simulate rays on the flares and is available
  132165. * in the documentation
  132166. */
  132167. lensStarTexture: Nullable<Texture>;
  132168. /**
  132169. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  132170. * flare effect by taking account of the dirt texture
  132171. */
  132172. lensFlareDirtTexture: Nullable<Texture>;
  132173. /**
  132174. * Represents the focal length for the depth of field effect
  132175. */
  132176. depthOfFieldDistance: number;
  132177. /**
  132178. * Represents the blur intensity for the blurred part of the depth of field effect
  132179. */
  132180. depthOfFieldBlurWidth: number;
  132181. /**
  132182. * Gets how much the image is blurred by the movement while using the motion blur post-process
  132183. */
  132184. /**
  132185. * Sets how much the image is blurred by the movement while using the motion blur post-process
  132186. */
  132187. motionStrength: number;
  132188. /**
  132189. * Gets wether or not the motion blur post-process is object based or screen based.
  132190. */
  132191. /**
  132192. * Sets wether or not the motion blur post-process should be object based or screen based
  132193. */
  132194. objectBasedMotionBlur: boolean;
  132195. /**
  132196. * List of animations for the pipeline (IAnimatable implementation)
  132197. */
  132198. animations: Animation[];
  132199. /**
  132200. * Private members
  132201. */
  132202. private _scene;
  132203. private _currentDepthOfFieldSource;
  132204. private _basePostProcess;
  132205. private _fixedExposure;
  132206. private _currentExposure;
  132207. private _hdrAutoExposure;
  132208. private _hdrCurrentLuminance;
  132209. private _motionStrength;
  132210. private _isObjectBasedMotionBlur;
  132211. private _floatTextureType;
  132212. private _camerasToBeAttached;
  132213. private _ratio;
  132214. private _bloomEnabled;
  132215. private _depthOfFieldEnabled;
  132216. private _vlsEnabled;
  132217. private _lensFlareEnabled;
  132218. private _hdrEnabled;
  132219. private _motionBlurEnabled;
  132220. private _fxaaEnabled;
  132221. private _motionBlurSamples;
  132222. private _volumetricLightStepsCount;
  132223. private _samples;
  132224. /**
  132225. * @ignore
  132226. * Specifies if the bloom pipeline is enabled
  132227. */
  132228. BloomEnabled: boolean;
  132229. /**
  132230. * @ignore
  132231. * Specifies if the depth of field pipeline is enabed
  132232. */
  132233. DepthOfFieldEnabled: boolean;
  132234. /**
  132235. * @ignore
  132236. * Specifies if the lens flare pipeline is enabed
  132237. */
  132238. LensFlareEnabled: boolean;
  132239. /**
  132240. * @ignore
  132241. * Specifies if the HDR pipeline is enabled
  132242. */
  132243. HDREnabled: boolean;
  132244. /**
  132245. * @ignore
  132246. * Specifies if the volumetric lights scattering effect is enabled
  132247. */
  132248. VLSEnabled: boolean;
  132249. /**
  132250. * @ignore
  132251. * Specifies if the motion blur effect is enabled
  132252. */
  132253. MotionBlurEnabled: boolean;
  132254. /**
  132255. * Specifies if anti-aliasing is enabled
  132256. */
  132257. fxaaEnabled: boolean;
  132258. /**
  132259. * Specifies the number of steps used to calculate the volumetric lights
  132260. * Typically in interval [50, 200]
  132261. */
  132262. volumetricLightStepsCount: number;
  132263. /**
  132264. * Specifies the number of samples used for the motion blur effect
  132265. * Typically in interval [16, 64]
  132266. */
  132267. motionBlurSamples: number;
  132268. /**
  132269. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  132270. */
  132271. samples: number;
  132272. /**
  132273. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  132274. * @constructor
  132275. * @param name The rendering pipeline name
  132276. * @param scene The scene linked to this pipeline
  132277. * @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)
  132278. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  132279. * @param cameras The array of cameras that the rendering pipeline will be attached to
  132280. */
  132281. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  132282. private _buildPipeline;
  132283. private _createDownSampleX4PostProcess;
  132284. private _createBrightPassPostProcess;
  132285. private _createBlurPostProcesses;
  132286. private _createTextureAdderPostProcess;
  132287. private _createVolumetricLightPostProcess;
  132288. private _createLuminancePostProcesses;
  132289. private _createHdrPostProcess;
  132290. private _createLensFlarePostProcess;
  132291. private _createDepthOfFieldPostProcess;
  132292. private _createMotionBlurPostProcess;
  132293. private _getDepthTexture;
  132294. private _disposePostProcesses;
  132295. /**
  132296. * Dispose of the pipeline and stop all post processes
  132297. */
  132298. dispose(): void;
  132299. /**
  132300. * Serialize the rendering pipeline (Used when exporting)
  132301. * @returns the serialized object
  132302. */
  132303. serialize(): any;
  132304. /**
  132305. * Parse the serialized pipeline
  132306. * @param source Source pipeline.
  132307. * @param scene The scene to load the pipeline to.
  132308. * @param rootUrl The URL of the serialized pipeline.
  132309. * @returns An instantiated pipeline from the serialized object.
  132310. */
  132311. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  132312. /**
  132313. * Luminance steps
  132314. */
  132315. static LuminanceSteps: number;
  132316. }
  132317. }
  132318. declare module BABYLON {
  132319. /** @hidden */
  132320. export var tonemapPixelShader: {
  132321. name: string;
  132322. shader: string;
  132323. };
  132324. }
  132325. declare module BABYLON {
  132326. /** Defines operator used for tonemapping */
  132327. export enum TonemappingOperator {
  132328. /** Hable */
  132329. Hable = 0,
  132330. /** Reinhard */
  132331. Reinhard = 1,
  132332. /** HejiDawson */
  132333. HejiDawson = 2,
  132334. /** Photographic */
  132335. Photographic = 3
  132336. }
  132337. /**
  132338. * Defines a post process to apply tone mapping
  132339. */
  132340. export class TonemapPostProcess extends PostProcess {
  132341. private _operator;
  132342. /** Defines the required exposure adjustement */
  132343. exposureAdjustment: number;
  132344. /**
  132345. * Creates a new TonemapPostProcess
  132346. * @param name defines the name of the postprocess
  132347. * @param _operator defines the operator to use
  132348. * @param exposureAdjustment defines the required exposure adjustement
  132349. * @param camera defines the camera to use (can be null)
  132350. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  132351. * @param engine defines the hosting engine (can be ignore if camera is set)
  132352. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  132353. */
  132354. constructor(name: string, _operator: TonemappingOperator,
  132355. /** Defines the required exposure adjustement */
  132356. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  132357. }
  132358. }
  132359. declare module BABYLON {
  132360. /** @hidden */
  132361. export var depthVertexShader: {
  132362. name: string;
  132363. shader: string;
  132364. };
  132365. }
  132366. declare module BABYLON {
  132367. /** @hidden */
  132368. export var volumetricLightScatteringPixelShader: {
  132369. name: string;
  132370. shader: string;
  132371. };
  132372. }
  132373. declare module BABYLON {
  132374. /** @hidden */
  132375. export var volumetricLightScatteringPassVertexShader: {
  132376. name: string;
  132377. shader: string;
  132378. };
  132379. }
  132380. declare module BABYLON {
  132381. /** @hidden */
  132382. export var volumetricLightScatteringPassPixelShader: {
  132383. name: string;
  132384. shader: string;
  132385. };
  132386. }
  132387. declare module BABYLON {
  132388. /**
  132389. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  132390. */
  132391. export class VolumetricLightScatteringPostProcess extends PostProcess {
  132392. private _volumetricLightScatteringPass;
  132393. private _volumetricLightScatteringRTT;
  132394. private _viewPort;
  132395. private _screenCoordinates;
  132396. private _cachedDefines;
  132397. /**
  132398. * If not undefined, the mesh position is computed from the attached node position
  132399. */
  132400. attachedNode: {
  132401. position: Vector3;
  132402. };
  132403. /**
  132404. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  132405. */
  132406. customMeshPosition: Vector3;
  132407. /**
  132408. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  132409. */
  132410. useCustomMeshPosition: boolean;
  132411. /**
  132412. * If the post-process should inverse the light scattering direction
  132413. */
  132414. invert: boolean;
  132415. /**
  132416. * The internal mesh used by the post-process
  132417. */
  132418. mesh: Mesh;
  132419. /**
  132420. * @hidden
  132421. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  132422. */
  132423. useDiffuseColor: boolean;
  132424. /**
  132425. * Array containing the excluded meshes not rendered in the internal pass
  132426. */
  132427. excludedMeshes: AbstractMesh[];
  132428. /**
  132429. * Controls the overall intensity of the post-process
  132430. */
  132431. exposure: number;
  132432. /**
  132433. * Dissipates each sample's contribution in range [0, 1]
  132434. */
  132435. decay: number;
  132436. /**
  132437. * Controls the overall intensity of each sample
  132438. */
  132439. weight: number;
  132440. /**
  132441. * Controls the density of each sample
  132442. */
  132443. density: number;
  132444. /**
  132445. * @constructor
  132446. * @param name The post-process name
  132447. * @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)
  132448. * @param camera The camera that the post-process will be attached to
  132449. * @param mesh The mesh used to create the light scattering
  132450. * @param samples The post-process quality, default 100
  132451. * @param samplingModeThe post-process filtering mode
  132452. * @param engine The babylon engine
  132453. * @param reusable If the post-process is reusable
  132454. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  132455. */
  132456. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  132457. /**
  132458. * Returns the string "VolumetricLightScatteringPostProcess"
  132459. * @returns "VolumetricLightScatteringPostProcess"
  132460. */
  132461. getClassName(): string;
  132462. private _isReady;
  132463. /**
  132464. * Sets the new light position for light scattering effect
  132465. * @param position The new custom light position
  132466. */
  132467. setCustomMeshPosition(position: Vector3): void;
  132468. /**
  132469. * Returns the light position for light scattering effect
  132470. * @return Vector3 The custom light position
  132471. */
  132472. getCustomMeshPosition(): Vector3;
  132473. /**
  132474. * Disposes the internal assets and detaches the post-process from the camera
  132475. */
  132476. dispose(camera: Camera): void;
  132477. /**
  132478. * Returns the render target texture used by the post-process
  132479. * @return the render target texture used by the post-process
  132480. */
  132481. getPass(): RenderTargetTexture;
  132482. private _meshExcluded;
  132483. private _createPass;
  132484. private _updateMeshScreenCoordinates;
  132485. /**
  132486. * Creates a default mesh for the Volumeric Light Scattering post-process
  132487. * @param name The mesh name
  132488. * @param scene The scene where to create the mesh
  132489. * @return the default mesh
  132490. */
  132491. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  132492. }
  132493. }
  132494. declare module BABYLON {
  132495. interface Scene {
  132496. /** @hidden (Backing field) */
  132497. _boundingBoxRenderer: BoundingBoxRenderer;
  132498. /** @hidden (Backing field) */
  132499. _forceShowBoundingBoxes: boolean;
  132500. /**
  132501. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  132502. */
  132503. forceShowBoundingBoxes: boolean;
  132504. /**
  132505. * Gets the bounding box renderer associated with the scene
  132506. * @returns a BoundingBoxRenderer
  132507. */
  132508. getBoundingBoxRenderer(): BoundingBoxRenderer;
  132509. }
  132510. interface AbstractMesh {
  132511. /** @hidden (Backing field) */
  132512. _showBoundingBox: boolean;
  132513. /**
  132514. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  132515. */
  132516. showBoundingBox: boolean;
  132517. }
  132518. /**
  132519. * Component responsible of rendering the bounding box of the meshes in a scene.
  132520. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  132521. */
  132522. export class BoundingBoxRenderer implements ISceneComponent {
  132523. /**
  132524. * The component name helpfull to identify the component in the list of scene components.
  132525. */
  132526. readonly name: string;
  132527. /**
  132528. * The scene the component belongs to.
  132529. */
  132530. scene: Scene;
  132531. /**
  132532. * Color of the bounding box lines placed in front of an object
  132533. */
  132534. frontColor: Color3;
  132535. /**
  132536. * Color of the bounding box lines placed behind an object
  132537. */
  132538. backColor: Color3;
  132539. /**
  132540. * Defines if the renderer should show the back lines or not
  132541. */
  132542. showBackLines: boolean;
  132543. /**
  132544. * @hidden
  132545. */
  132546. renderList: SmartArray<BoundingBox>;
  132547. private _colorShader;
  132548. private _vertexBuffers;
  132549. private _indexBuffer;
  132550. private _fillIndexBuffer;
  132551. private _fillIndexData;
  132552. /**
  132553. * Instantiates a new bounding box renderer in a scene.
  132554. * @param scene the scene the renderer renders in
  132555. */
  132556. constructor(scene: Scene);
  132557. /**
  132558. * Registers the component in a given scene
  132559. */
  132560. register(): void;
  132561. private _evaluateSubMesh;
  132562. private _activeMesh;
  132563. private _prepareRessources;
  132564. private _createIndexBuffer;
  132565. /**
  132566. * Rebuilds the elements related to this component in case of
  132567. * context lost for instance.
  132568. */
  132569. rebuild(): void;
  132570. /**
  132571. * @hidden
  132572. */
  132573. reset(): void;
  132574. /**
  132575. * Render the bounding boxes of a specific rendering group
  132576. * @param renderingGroupId defines the rendering group to render
  132577. */
  132578. render(renderingGroupId: number): void;
  132579. /**
  132580. * In case of occlusion queries, we can render the occlusion bounding box through this method
  132581. * @param mesh Define the mesh to render the occlusion bounding box for
  132582. */
  132583. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  132584. /**
  132585. * Dispose and release the resources attached to this renderer.
  132586. */
  132587. dispose(): void;
  132588. }
  132589. }
  132590. declare module BABYLON {
  132591. /** @hidden */
  132592. export var depthPixelShader: {
  132593. name: string;
  132594. shader: string;
  132595. };
  132596. }
  132597. declare module BABYLON {
  132598. /**
  132599. * This represents a depth renderer in Babylon.
  132600. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  132601. */
  132602. export class DepthRenderer {
  132603. private _scene;
  132604. private _depthMap;
  132605. private _effect;
  132606. private readonly _storeNonLinearDepth;
  132607. private readonly _clearColor;
  132608. /** Get if the depth renderer is using packed depth or not */
  132609. readonly isPacked: boolean;
  132610. private _cachedDefines;
  132611. private _camera;
  132612. /**
  132613. * Specifiess that the depth renderer will only be used within
  132614. * the camera it is created for.
  132615. * This can help forcing its rendering during the camera processing.
  132616. */
  132617. useOnlyInActiveCamera: boolean;
  132618. /** @hidden */
  132619. static _SceneComponentInitialization: (scene: Scene) => void;
  132620. /**
  132621. * Instantiates a depth renderer
  132622. * @param scene The scene the renderer belongs to
  132623. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  132624. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  132625. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  132626. */
  132627. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  132628. /**
  132629. * Creates the depth rendering effect and checks if the effect is ready.
  132630. * @param subMesh The submesh to be used to render the depth map of
  132631. * @param useInstances If multiple world instances should be used
  132632. * @returns if the depth renderer is ready to render the depth map
  132633. */
  132634. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  132635. /**
  132636. * Gets the texture which the depth map will be written to.
  132637. * @returns The depth map texture
  132638. */
  132639. getDepthMap(): RenderTargetTexture;
  132640. /**
  132641. * Disposes of the depth renderer.
  132642. */
  132643. dispose(): void;
  132644. }
  132645. }
  132646. declare module BABYLON {
  132647. interface Scene {
  132648. /** @hidden (Backing field) */
  132649. _depthRenderer: {
  132650. [id: string]: DepthRenderer;
  132651. };
  132652. /**
  132653. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  132654. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  132655. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  132656. * @returns the created depth renderer
  132657. */
  132658. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  132659. /**
  132660. * Disables a depth renderer for a given camera
  132661. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  132662. */
  132663. disableDepthRenderer(camera?: Nullable<Camera>): void;
  132664. }
  132665. /**
  132666. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  132667. * in several rendering techniques.
  132668. */
  132669. export class DepthRendererSceneComponent implements ISceneComponent {
  132670. /**
  132671. * The component name helpfull to identify the component in the list of scene components.
  132672. */
  132673. readonly name: string;
  132674. /**
  132675. * The scene the component belongs to.
  132676. */
  132677. scene: Scene;
  132678. /**
  132679. * Creates a new instance of the component for the given scene
  132680. * @param scene Defines the scene to register the component in
  132681. */
  132682. constructor(scene: Scene);
  132683. /**
  132684. * Registers the component in a given scene
  132685. */
  132686. register(): void;
  132687. /**
  132688. * Rebuilds the elements related to this component in case of
  132689. * context lost for instance.
  132690. */
  132691. rebuild(): void;
  132692. /**
  132693. * Disposes the component and the associated ressources
  132694. */
  132695. dispose(): void;
  132696. private _gatherRenderTargets;
  132697. private _gatherActiveCameraRenderTargets;
  132698. }
  132699. }
  132700. declare module BABYLON {
  132701. /** @hidden */
  132702. export var outlinePixelShader: {
  132703. name: string;
  132704. shader: string;
  132705. };
  132706. }
  132707. declare module BABYLON {
  132708. /** @hidden */
  132709. export var outlineVertexShader: {
  132710. name: string;
  132711. shader: string;
  132712. };
  132713. }
  132714. declare module BABYLON {
  132715. interface Scene {
  132716. /** @hidden */
  132717. _outlineRenderer: OutlineRenderer;
  132718. /**
  132719. * Gets the outline renderer associated with the scene
  132720. * @returns a OutlineRenderer
  132721. */
  132722. getOutlineRenderer(): OutlineRenderer;
  132723. }
  132724. interface AbstractMesh {
  132725. /** @hidden (Backing field) */
  132726. _renderOutline: boolean;
  132727. /**
  132728. * Gets or sets a boolean indicating if the outline must be rendered as well
  132729. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  132730. */
  132731. renderOutline: boolean;
  132732. /** @hidden (Backing field) */
  132733. _renderOverlay: boolean;
  132734. /**
  132735. * Gets or sets a boolean indicating if the overlay must be rendered as well
  132736. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  132737. */
  132738. renderOverlay: boolean;
  132739. }
  132740. /**
  132741. * This class is responsible to draw bothe outline/overlay of meshes.
  132742. * It should not be used directly but through the available method on mesh.
  132743. */
  132744. export class OutlineRenderer implements ISceneComponent {
  132745. /**
  132746. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  132747. */
  132748. private static _StencilReference;
  132749. /**
  132750. * The name of the component. Each component must have a unique name.
  132751. */
  132752. name: string;
  132753. /**
  132754. * The scene the component belongs to.
  132755. */
  132756. scene: Scene;
  132757. /**
  132758. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  132759. */
  132760. zOffset: number;
  132761. private _engine;
  132762. private _effect;
  132763. private _cachedDefines;
  132764. private _savedDepthWrite;
  132765. /**
  132766. * Instantiates a new outline renderer. (There could be only one per scene).
  132767. * @param scene Defines the scene it belongs to
  132768. */
  132769. constructor(scene: Scene);
  132770. /**
  132771. * Register the component to one instance of a scene.
  132772. */
  132773. register(): void;
  132774. /**
  132775. * Rebuilds the elements related to this component in case of
  132776. * context lost for instance.
  132777. */
  132778. rebuild(): void;
  132779. /**
  132780. * Disposes the component and the associated ressources.
  132781. */
  132782. dispose(): void;
  132783. /**
  132784. * Renders the outline in the canvas.
  132785. * @param subMesh Defines the sumesh to render
  132786. * @param batch Defines the batch of meshes in case of instances
  132787. * @param useOverlay Defines if the rendering is for the overlay or the outline
  132788. */
  132789. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  132790. /**
  132791. * Returns whether or not the outline renderer is ready for a given submesh.
  132792. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  132793. * @param subMesh Defines the submesh to check readyness for
  132794. * @param useInstances Defines wheter wee are trying to render instances or not
  132795. * @returns true if ready otherwise false
  132796. */
  132797. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  132798. private _beforeRenderingMesh;
  132799. private _afterRenderingMesh;
  132800. }
  132801. }
  132802. declare module BABYLON {
  132803. /**
  132804. * Defines the basic options interface of a Sprite Frame Source Size.
  132805. */
  132806. export interface ISpriteJSONSpriteSourceSize {
  132807. /**
  132808. * number of the original width of the Frame
  132809. */
  132810. w: number;
  132811. /**
  132812. * number of the original height of the Frame
  132813. */
  132814. h: number;
  132815. }
  132816. /**
  132817. * Defines the basic options interface of a Sprite Frame Data.
  132818. */
  132819. export interface ISpriteJSONSpriteFrameData {
  132820. /**
  132821. * number of the x offset of the Frame
  132822. */
  132823. x: number;
  132824. /**
  132825. * number of the y offset of the Frame
  132826. */
  132827. y: number;
  132828. /**
  132829. * number of the width of the Frame
  132830. */
  132831. w: number;
  132832. /**
  132833. * number of the height of the Frame
  132834. */
  132835. h: number;
  132836. }
  132837. /**
  132838. * Defines the basic options interface of a JSON Sprite.
  132839. */
  132840. export interface ISpriteJSONSprite {
  132841. /**
  132842. * string name of the Frame
  132843. */
  132844. filename: string;
  132845. /**
  132846. * ISpriteJSONSpriteFrame basic object of the frame data
  132847. */
  132848. frame: ISpriteJSONSpriteFrameData;
  132849. /**
  132850. * boolean to flag is the frame was rotated.
  132851. */
  132852. rotated: boolean;
  132853. /**
  132854. * boolean to flag is the frame was trimmed.
  132855. */
  132856. trimmed: boolean;
  132857. /**
  132858. * ISpriteJSONSpriteFrame basic object of the source data
  132859. */
  132860. spriteSourceSize: ISpriteJSONSpriteFrameData;
  132861. /**
  132862. * ISpriteJSONSpriteFrame basic object of the source data
  132863. */
  132864. sourceSize: ISpriteJSONSpriteSourceSize;
  132865. }
  132866. /**
  132867. * Defines the basic options interface of a JSON atlas.
  132868. */
  132869. export interface ISpriteJSONAtlas {
  132870. /**
  132871. * Array of objects that contain the frame data.
  132872. */
  132873. frames: Array<ISpriteJSONSprite>;
  132874. /**
  132875. * object basic object containing the sprite meta data.
  132876. */
  132877. meta?: object;
  132878. }
  132879. }
  132880. declare module BABYLON {
  132881. /** @hidden */
  132882. export var spriteMapPixelShader: {
  132883. name: string;
  132884. shader: string;
  132885. };
  132886. }
  132887. declare module BABYLON {
  132888. /** @hidden */
  132889. export var spriteMapVertexShader: {
  132890. name: string;
  132891. shader: string;
  132892. };
  132893. }
  132894. declare module BABYLON {
  132895. /**
  132896. * Defines the basic options interface of a SpriteMap
  132897. */
  132898. export interface ISpriteMapOptions {
  132899. /**
  132900. * Vector2 of the number of cells in the grid.
  132901. */
  132902. stageSize?: Vector2;
  132903. /**
  132904. * Vector2 of the size of the output plane in World Units.
  132905. */
  132906. outputSize?: Vector2;
  132907. /**
  132908. * Vector3 of the position of the output plane in World Units.
  132909. */
  132910. outputPosition?: Vector3;
  132911. /**
  132912. * number of layers that the system will reserve in resources.
  132913. */
  132914. layerCount?: number;
  132915. /**
  132916. * number of max animation frames a single cell will reserve in resources.
  132917. */
  132918. maxAnimationFrames?: number;
  132919. /**
  132920. * number cell index of the base tile when the system compiles.
  132921. */
  132922. baseTile?: number;
  132923. /**
  132924. * boolean flip the sprite after its been repositioned by the framing data.
  132925. */
  132926. flipU?: boolean;
  132927. /**
  132928. * Vector3 scalar of the global RGB values of the SpriteMap.
  132929. */
  132930. colorMultiply?: Vector3;
  132931. }
  132932. /**
  132933. * Defines the IDisposable interface in order to be cleanable from resources.
  132934. */
  132935. export interface ISpriteMap extends IDisposable {
  132936. /**
  132937. * String name of the SpriteMap.
  132938. */
  132939. name: string;
  132940. /**
  132941. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  132942. */
  132943. atlasJSON: ISpriteJSONAtlas;
  132944. /**
  132945. * Texture of the SpriteMap.
  132946. */
  132947. spriteSheet: Texture;
  132948. /**
  132949. * The parameters to initialize the SpriteMap with.
  132950. */
  132951. options: ISpriteMapOptions;
  132952. }
  132953. /**
  132954. * Class used to manage a grid restricted sprite deployment on an Output plane.
  132955. */
  132956. export class SpriteMap implements ISpriteMap {
  132957. /** The Name of the spriteMap */
  132958. name: string;
  132959. /** The JSON file with the frame and meta data */
  132960. atlasJSON: ISpriteJSONAtlas;
  132961. /** The systems Sprite Sheet Texture */
  132962. spriteSheet: Texture;
  132963. /** Arguments passed with the Constructor */
  132964. options: ISpriteMapOptions;
  132965. /** Public Sprite Storage array, parsed from atlasJSON */
  132966. sprites: Array<ISpriteJSONSprite>;
  132967. /** Returns the Number of Sprites in the System */
  132968. readonly spriteCount: number;
  132969. /** Returns the Position of Output Plane*/
  132970. /** Returns the Position of Output Plane*/
  132971. position: Vector3;
  132972. /** Sets the AnimationMap*/
  132973. /** Sets the AnimationMap*/
  132974. animationMap: RawTexture;
  132975. /** Scene that the SpriteMap was created in */
  132976. private _scene;
  132977. /** Texture Buffer of Float32 that holds tile frame data*/
  132978. private _frameMap;
  132979. /** Texture Buffers of Float32 that holds tileMap data*/
  132980. private _tileMaps;
  132981. /** Texture Buffer of Float32 that holds Animation Data*/
  132982. private _animationMap;
  132983. /** Custom ShaderMaterial Central to the System*/
  132984. private _material;
  132985. /** Custom ShaderMaterial Central to the System*/
  132986. private _output;
  132987. /** Systems Time Ticker*/
  132988. private _time;
  132989. /**
  132990. * Creates a new SpriteMap
  132991. * @param name defines the SpriteMaps Name
  132992. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  132993. * @param spriteSheet is the Texture that the Sprites are on.
  132994. * @param options a basic deployment configuration
  132995. * @param scene The Scene that the map is deployed on
  132996. */
  132997. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  132998. /**
  132999. * Returns tileID location
  133000. * @returns Vector2 the cell position ID
  133001. */
  133002. getTileID(): Vector2;
  133003. /**
  133004. * Gets the UV location of the mouse over the SpriteMap.
  133005. * @returns Vector2 the UV position of the mouse interaction
  133006. */
  133007. getMousePosition(): Vector2;
  133008. /**
  133009. * Creates the "frame" texture Buffer
  133010. * -------------------------------------
  133011. * Structure of frames
  133012. * "filename": "Falling-Water-2.png",
  133013. * "frame": {"x":69,"y":103,"w":24,"h":32},
  133014. * "rotated": true,
  133015. * "trimmed": true,
  133016. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  133017. * "sourceSize": {"w":32,"h":32}
  133018. * @returns RawTexture of the frameMap
  133019. */
  133020. private _createFrameBuffer;
  133021. /**
  133022. * Creates the tileMap texture Buffer
  133023. * @param buffer normally and array of numbers, or a false to generate from scratch
  133024. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  133025. * @returns RawTexture of the tileMap
  133026. */
  133027. private _createTileBuffer;
  133028. /**
  133029. * Modifies the data of the tileMaps
  133030. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  133031. * @param pos is the iVector2 Coordinates of the Tile
  133032. * @param tile The SpriteIndex of the new Tile
  133033. */
  133034. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  133035. /**
  133036. * Creates the animationMap texture Buffer
  133037. * @param buffer normally and array of numbers, or a false to generate from scratch
  133038. * @returns RawTexture of the animationMap
  133039. */
  133040. private _createTileAnimationBuffer;
  133041. /**
  133042. * Modifies the data of the animationMap
  133043. * @param cellID is the Index of the Sprite
  133044. * @param _frame is the target Animation frame
  133045. * @param toCell is the Target Index of the next frame of the animation
  133046. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  133047. * @param speed is a global scalar of the time variable on the map.
  133048. */
  133049. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  133050. /**
  133051. * Exports the .tilemaps file
  133052. */
  133053. saveTileMaps(): void;
  133054. /**
  133055. * Imports the .tilemaps file
  133056. * @param url of the .tilemaps file
  133057. */
  133058. loadTileMaps(url: string): void;
  133059. /**
  133060. * Release associated resources
  133061. */
  133062. dispose(): void;
  133063. }
  133064. }
  133065. declare module BABYLON {
  133066. /**
  133067. * Class used to manage multiple sprites of different sizes on the same spritesheet
  133068. * @see http://doc.babylonjs.com/babylon101/sprites
  133069. */
  133070. export class SpritePackedManager extends SpriteManager {
  133071. /** defines the packed manager's name */
  133072. name: string;
  133073. /**
  133074. * Creates a new sprite manager from a packed sprite sheet
  133075. * @param name defines the manager's name
  133076. * @param imgUrl defines the sprite sheet url
  133077. * @param capacity defines the maximum allowed number of sprites
  133078. * @param scene defines the hosting scene
  133079. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  133080. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  133081. * @param samplingMode defines the smapling mode to use with spritesheet
  133082. * @param fromPacked set to true; do not alter
  133083. */
  133084. constructor(
  133085. /** defines the packed manager's name */
  133086. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  133087. }
  133088. }
  133089. declare module BABYLON {
  133090. /**
  133091. * Defines the list of states available for a task inside a AssetsManager
  133092. */
  133093. export enum AssetTaskState {
  133094. /**
  133095. * Initialization
  133096. */
  133097. INIT = 0,
  133098. /**
  133099. * Running
  133100. */
  133101. RUNNING = 1,
  133102. /**
  133103. * Done
  133104. */
  133105. DONE = 2,
  133106. /**
  133107. * Error
  133108. */
  133109. ERROR = 3
  133110. }
  133111. /**
  133112. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  133113. */
  133114. export abstract class AbstractAssetTask {
  133115. /**
  133116. * Task name
  133117. */ name: string;
  133118. /**
  133119. * Callback called when the task is successful
  133120. */
  133121. onSuccess: (task: any) => void;
  133122. /**
  133123. * Callback called when the task is not successful
  133124. */
  133125. onError: (task: any, message?: string, exception?: any) => void;
  133126. /**
  133127. * Creates a new AssetsManager
  133128. * @param name defines the name of the task
  133129. */
  133130. constructor(
  133131. /**
  133132. * Task name
  133133. */ name: string);
  133134. private _isCompleted;
  133135. private _taskState;
  133136. private _errorObject;
  133137. /**
  133138. * Get if the task is completed
  133139. */
  133140. readonly isCompleted: boolean;
  133141. /**
  133142. * Gets the current state of the task
  133143. */
  133144. readonly taskState: AssetTaskState;
  133145. /**
  133146. * Gets the current error object (if task is in error)
  133147. */
  133148. readonly errorObject: {
  133149. message?: string;
  133150. exception?: any;
  133151. };
  133152. /**
  133153. * Internal only
  133154. * @hidden
  133155. */
  133156. _setErrorObject(message?: string, exception?: any): void;
  133157. /**
  133158. * Execute the current task
  133159. * @param scene defines the scene where you want your assets to be loaded
  133160. * @param onSuccess is a callback called when the task is successfully executed
  133161. * @param onError is a callback called if an error occurs
  133162. */
  133163. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  133164. /**
  133165. * Execute the current task
  133166. * @param scene defines the scene where you want your assets to be loaded
  133167. * @param onSuccess is a callback called when the task is successfully executed
  133168. * @param onError is a callback called if an error occurs
  133169. */
  133170. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  133171. /**
  133172. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  133173. * This can be used with failed tasks that have the reason for failure fixed.
  133174. */
  133175. reset(): void;
  133176. private onErrorCallback;
  133177. private onDoneCallback;
  133178. }
  133179. /**
  133180. * Define the interface used by progress events raised during assets loading
  133181. */
  133182. export interface IAssetsProgressEvent {
  133183. /**
  133184. * Defines the number of remaining tasks to process
  133185. */
  133186. remainingCount: number;
  133187. /**
  133188. * Defines the total number of tasks
  133189. */
  133190. totalCount: number;
  133191. /**
  133192. * Defines the task that was just processed
  133193. */
  133194. task: AbstractAssetTask;
  133195. }
  133196. /**
  133197. * Class used to share progress information about assets loading
  133198. */
  133199. export class AssetsProgressEvent implements IAssetsProgressEvent {
  133200. /**
  133201. * Defines the number of remaining tasks to process
  133202. */
  133203. remainingCount: number;
  133204. /**
  133205. * Defines the total number of tasks
  133206. */
  133207. totalCount: number;
  133208. /**
  133209. * Defines the task that was just processed
  133210. */
  133211. task: AbstractAssetTask;
  133212. /**
  133213. * Creates a AssetsProgressEvent
  133214. * @param remainingCount defines the number of remaining tasks to process
  133215. * @param totalCount defines the total number of tasks
  133216. * @param task defines the task that was just processed
  133217. */
  133218. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  133219. }
  133220. /**
  133221. * Define a task used by AssetsManager to load meshes
  133222. */
  133223. export class MeshAssetTask extends AbstractAssetTask {
  133224. /**
  133225. * Defines the name of the task
  133226. */
  133227. name: string;
  133228. /**
  133229. * Defines the list of mesh's names you want to load
  133230. */
  133231. meshesNames: any;
  133232. /**
  133233. * Defines the root url to use as a base to load your meshes and associated resources
  133234. */
  133235. rootUrl: string;
  133236. /**
  133237. * Defines the filename of the scene to load from
  133238. */
  133239. sceneFilename: string;
  133240. /**
  133241. * Gets the list of loaded meshes
  133242. */
  133243. loadedMeshes: Array<AbstractMesh>;
  133244. /**
  133245. * Gets the list of loaded particle systems
  133246. */
  133247. loadedParticleSystems: Array<IParticleSystem>;
  133248. /**
  133249. * Gets the list of loaded skeletons
  133250. */
  133251. loadedSkeletons: Array<Skeleton>;
  133252. /**
  133253. * Gets the list of loaded animation groups
  133254. */
  133255. loadedAnimationGroups: Array<AnimationGroup>;
  133256. /**
  133257. * Callback called when the task is successful
  133258. */
  133259. onSuccess: (task: MeshAssetTask) => void;
  133260. /**
  133261. * Callback called when the task is successful
  133262. */
  133263. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  133264. /**
  133265. * Creates a new MeshAssetTask
  133266. * @param name defines the name of the task
  133267. * @param meshesNames defines the list of mesh's names you want to load
  133268. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  133269. * @param sceneFilename defines the filename of the scene to load from
  133270. */
  133271. constructor(
  133272. /**
  133273. * Defines the name of the task
  133274. */
  133275. name: string,
  133276. /**
  133277. * Defines the list of mesh's names you want to load
  133278. */
  133279. meshesNames: any,
  133280. /**
  133281. * Defines the root url to use as a base to load your meshes and associated resources
  133282. */
  133283. rootUrl: string,
  133284. /**
  133285. * Defines the filename of the scene to load from
  133286. */
  133287. sceneFilename: string);
  133288. /**
  133289. * Execute the current task
  133290. * @param scene defines the scene where you want your assets to be loaded
  133291. * @param onSuccess is a callback called when the task is successfully executed
  133292. * @param onError is a callback called if an error occurs
  133293. */
  133294. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  133295. }
  133296. /**
  133297. * Define a task used by AssetsManager to load text content
  133298. */
  133299. export class TextFileAssetTask extends AbstractAssetTask {
  133300. /**
  133301. * Defines the name of the task
  133302. */
  133303. name: string;
  133304. /**
  133305. * Defines the location of the file to load
  133306. */
  133307. url: string;
  133308. /**
  133309. * Gets the loaded text string
  133310. */
  133311. text: string;
  133312. /**
  133313. * Callback called when the task is successful
  133314. */
  133315. onSuccess: (task: TextFileAssetTask) => void;
  133316. /**
  133317. * Callback called when the task is successful
  133318. */
  133319. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  133320. /**
  133321. * Creates a new TextFileAssetTask object
  133322. * @param name defines the name of the task
  133323. * @param url defines the location of the file to load
  133324. */
  133325. constructor(
  133326. /**
  133327. * Defines the name of the task
  133328. */
  133329. name: string,
  133330. /**
  133331. * Defines the location of the file to load
  133332. */
  133333. url: string);
  133334. /**
  133335. * Execute the current task
  133336. * @param scene defines the scene where you want your assets to be loaded
  133337. * @param onSuccess is a callback called when the task is successfully executed
  133338. * @param onError is a callback called if an error occurs
  133339. */
  133340. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  133341. }
  133342. /**
  133343. * Define a task used by AssetsManager to load binary data
  133344. */
  133345. export class BinaryFileAssetTask extends AbstractAssetTask {
  133346. /**
  133347. * Defines the name of the task
  133348. */
  133349. name: string;
  133350. /**
  133351. * Defines the location of the file to load
  133352. */
  133353. url: string;
  133354. /**
  133355. * Gets the lodaded data (as an array buffer)
  133356. */
  133357. data: ArrayBuffer;
  133358. /**
  133359. * Callback called when the task is successful
  133360. */
  133361. onSuccess: (task: BinaryFileAssetTask) => void;
  133362. /**
  133363. * Callback called when the task is successful
  133364. */
  133365. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  133366. /**
  133367. * Creates a new BinaryFileAssetTask object
  133368. * @param name defines the name of the new task
  133369. * @param url defines the location of the file to load
  133370. */
  133371. constructor(
  133372. /**
  133373. * Defines the name of the task
  133374. */
  133375. name: string,
  133376. /**
  133377. * Defines the location of the file to load
  133378. */
  133379. url: string);
  133380. /**
  133381. * Execute the current task
  133382. * @param scene defines the scene where you want your assets to be loaded
  133383. * @param onSuccess is a callback called when the task is successfully executed
  133384. * @param onError is a callback called if an error occurs
  133385. */
  133386. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  133387. }
  133388. /**
  133389. * Define a task used by AssetsManager to load images
  133390. */
  133391. export class ImageAssetTask extends AbstractAssetTask {
  133392. /**
  133393. * Defines the name of the task
  133394. */
  133395. name: string;
  133396. /**
  133397. * Defines the location of the image to load
  133398. */
  133399. url: string;
  133400. /**
  133401. * Gets the loaded images
  133402. */
  133403. image: HTMLImageElement;
  133404. /**
  133405. * Callback called when the task is successful
  133406. */
  133407. onSuccess: (task: ImageAssetTask) => void;
  133408. /**
  133409. * Callback called when the task is successful
  133410. */
  133411. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  133412. /**
  133413. * Creates a new ImageAssetTask
  133414. * @param name defines the name of the task
  133415. * @param url defines the location of the image to load
  133416. */
  133417. constructor(
  133418. /**
  133419. * Defines the name of the task
  133420. */
  133421. name: string,
  133422. /**
  133423. * Defines the location of the image to load
  133424. */
  133425. url: string);
  133426. /**
  133427. * Execute the current task
  133428. * @param scene defines the scene where you want your assets to be loaded
  133429. * @param onSuccess is a callback called when the task is successfully executed
  133430. * @param onError is a callback called if an error occurs
  133431. */
  133432. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  133433. }
  133434. /**
  133435. * Defines the interface used by texture loading tasks
  133436. */
  133437. export interface ITextureAssetTask<TEX extends BaseTexture> {
  133438. /**
  133439. * Gets the loaded texture
  133440. */
  133441. texture: TEX;
  133442. }
  133443. /**
  133444. * Define a task used by AssetsManager to load 2D textures
  133445. */
  133446. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  133447. /**
  133448. * Defines the name of the task
  133449. */
  133450. name: string;
  133451. /**
  133452. * Defines the location of the file to load
  133453. */
  133454. url: string;
  133455. /**
  133456. * Defines if mipmap should not be generated (default is false)
  133457. */
  133458. noMipmap?: boolean | undefined;
  133459. /**
  133460. * Defines if texture must be inverted on Y axis (default is false)
  133461. */
  133462. invertY?: boolean | undefined;
  133463. /**
  133464. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  133465. */
  133466. samplingMode: number;
  133467. /**
  133468. * Gets the loaded texture
  133469. */
  133470. texture: Texture;
  133471. /**
  133472. * Callback called when the task is successful
  133473. */
  133474. onSuccess: (task: TextureAssetTask) => void;
  133475. /**
  133476. * Callback called when the task is successful
  133477. */
  133478. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  133479. /**
  133480. * Creates a new TextureAssetTask object
  133481. * @param name defines the name of the task
  133482. * @param url defines the location of the file to load
  133483. * @param noMipmap defines if mipmap should not be generated (default is false)
  133484. * @param invertY defines if texture must be inverted on Y axis (default is false)
  133485. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  133486. */
  133487. constructor(
  133488. /**
  133489. * Defines the name of the task
  133490. */
  133491. name: string,
  133492. /**
  133493. * Defines the location of the file to load
  133494. */
  133495. url: string,
  133496. /**
  133497. * Defines if mipmap should not be generated (default is false)
  133498. */
  133499. noMipmap?: boolean | undefined,
  133500. /**
  133501. * Defines if texture must be inverted on Y axis (default is false)
  133502. */
  133503. invertY?: boolean | undefined,
  133504. /**
  133505. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  133506. */
  133507. samplingMode?: number);
  133508. /**
  133509. * Execute the current task
  133510. * @param scene defines the scene where you want your assets to be loaded
  133511. * @param onSuccess is a callback called when the task is successfully executed
  133512. * @param onError is a callback called if an error occurs
  133513. */
  133514. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  133515. }
  133516. /**
  133517. * Define a task used by AssetsManager to load cube textures
  133518. */
  133519. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  133520. /**
  133521. * Defines the name of the task
  133522. */
  133523. name: string;
  133524. /**
  133525. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  133526. */
  133527. url: string;
  133528. /**
  133529. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  133530. */
  133531. extensions?: string[] | undefined;
  133532. /**
  133533. * Defines if mipmaps should not be generated (default is false)
  133534. */
  133535. noMipmap?: boolean | undefined;
  133536. /**
  133537. * Defines the explicit list of files (undefined by default)
  133538. */
  133539. files?: string[] | undefined;
  133540. /**
  133541. * Gets the loaded texture
  133542. */
  133543. texture: CubeTexture;
  133544. /**
  133545. * Callback called when the task is successful
  133546. */
  133547. onSuccess: (task: CubeTextureAssetTask) => void;
  133548. /**
  133549. * Callback called when the task is successful
  133550. */
  133551. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  133552. /**
  133553. * Creates a new CubeTextureAssetTask
  133554. * @param name defines the name of the task
  133555. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  133556. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  133557. * @param noMipmap defines if mipmaps should not be generated (default is false)
  133558. * @param files defines the explicit list of files (undefined by default)
  133559. */
  133560. constructor(
  133561. /**
  133562. * Defines the name of the task
  133563. */
  133564. name: string,
  133565. /**
  133566. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  133567. */
  133568. url: string,
  133569. /**
  133570. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  133571. */
  133572. extensions?: string[] | undefined,
  133573. /**
  133574. * Defines if mipmaps should not be generated (default is false)
  133575. */
  133576. noMipmap?: boolean | undefined,
  133577. /**
  133578. * Defines the explicit list of files (undefined by default)
  133579. */
  133580. files?: string[] | undefined);
  133581. /**
  133582. * Execute the current task
  133583. * @param scene defines the scene where you want your assets to be loaded
  133584. * @param onSuccess is a callback called when the task is successfully executed
  133585. * @param onError is a callback called if an error occurs
  133586. */
  133587. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  133588. }
  133589. /**
  133590. * Define a task used by AssetsManager to load HDR cube textures
  133591. */
  133592. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  133593. /**
  133594. * Defines the name of the task
  133595. */
  133596. name: string;
  133597. /**
  133598. * Defines the location of the file to load
  133599. */
  133600. url: string;
  133601. /**
  133602. * Defines the desired size (the more it increases the longer the generation will be)
  133603. */
  133604. size: number;
  133605. /**
  133606. * Defines if mipmaps should not be generated (default is false)
  133607. */
  133608. noMipmap: boolean;
  133609. /**
  133610. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  133611. */
  133612. generateHarmonics: boolean;
  133613. /**
  133614. * 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)
  133615. */
  133616. gammaSpace: boolean;
  133617. /**
  133618. * Internal Use Only
  133619. */
  133620. reserved: boolean;
  133621. /**
  133622. * Gets the loaded texture
  133623. */
  133624. texture: HDRCubeTexture;
  133625. /**
  133626. * Callback called when the task is successful
  133627. */
  133628. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  133629. /**
  133630. * Callback called when the task is successful
  133631. */
  133632. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  133633. /**
  133634. * Creates a new HDRCubeTextureAssetTask object
  133635. * @param name defines the name of the task
  133636. * @param url defines the location of the file to load
  133637. * @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.
  133638. * @param noMipmap defines if mipmaps should not be generated (default is false)
  133639. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  133640. * @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)
  133641. * @param reserved Internal use only
  133642. */
  133643. constructor(
  133644. /**
  133645. * Defines the name of the task
  133646. */
  133647. name: string,
  133648. /**
  133649. * Defines the location of the file to load
  133650. */
  133651. url: string,
  133652. /**
  133653. * Defines the desired size (the more it increases the longer the generation will be)
  133654. */
  133655. size: number,
  133656. /**
  133657. * Defines if mipmaps should not be generated (default is false)
  133658. */
  133659. noMipmap?: boolean,
  133660. /**
  133661. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  133662. */
  133663. generateHarmonics?: boolean,
  133664. /**
  133665. * 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)
  133666. */
  133667. gammaSpace?: boolean,
  133668. /**
  133669. * Internal Use Only
  133670. */
  133671. reserved?: boolean);
  133672. /**
  133673. * Execute the current task
  133674. * @param scene defines the scene where you want your assets to be loaded
  133675. * @param onSuccess is a callback called when the task is successfully executed
  133676. * @param onError is a callback called if an error occurs
  133677. */
  133678. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  133679. }
  133680. /**
  133681. * Define a task used by AssetsManager to load Equirectangular cube textures
  133682. */
  133683. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  133684. /**
  133685. * Defines the name of the task
  133686. */
  133687. name: string;
  133688. /**
  133689. * Defines the location of the file to load
  133690. */
  133691. url: string;
  133692. /**
  133693. * Defines the desired size (the more it increases the longer the generation will be)
  133694. */
  133695. size: number;
  133696. /**
  133697. * Defines if mipmaps should not be generated (default is false)
  133698. */
  133699. noMipmap: boolean;
  133700. /**
  133701. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  133702. * but the standard material would require them in Gamma space) (default is true)
  133703. */
  133704. gammaSpace: boolean;
  133705. /**
  133706. * Gets the loaded texture
  133707. */
  133708. texture: EquiRectangularCubeTexture;
  133709. /**
  133710. * Callback called when the task is successful
  133711. */
  133712. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  133713. /**
  133714. * Callback called when the task is successful
  133715. */
  133716. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  133717. /**
  133718. * Creates a new EquiRectangularCubeTextureAssetTask object
  133719. * @param name defines the name of the task
  133720. * @param url defines the location of the file to load
  133721. * @param size defines the desired size (the more it increases the longer the generation will be)
  133722. * If the size is omitted this implies you are using a preprocessed cubemap.
  133723. * @param noMipmap defines if mipmaps should not be generated (default is false)
  133724. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  133725. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  133726. * (default is true)
  133727. */
  133728. constructor(
  133729. /**
  133730. * Defines the name of the task
  133731. */
  133732. name: string,
  133733. /**
  133734. * Defines the location of the file to load
  133735. */
  133736. url: string,
  133737. /**
  133738. * Defines the desired size (the more it increases the longer the generation will be)
  133739. */
  133740. size: number,
  133741. /**
  133742. * Defines if mipmaps should not be generated (default is false)
  133743. */
  133744. noMipmap?: boolean,
  133745. /**
  133746. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  133747. * but the standard material would require them in Gamma space) (default is true)
  133748. */
  133749. gammaSpace?: boolean);
  133750. /**
  133751. * Execute the current task
  133752. * @param scene defines the scene where you want your assets to be loaded
  133753. * @param onSuccess is a callback called when the task is successfully executed
  133754. * @param onError is a callback called if an error occurs
  133755. */
  133756. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  133757. }
  133758. /**
  133759. * This class can be used to easily import assets into a scene
  133760. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  133761. */
  133762. export class AssetsManager {
  133763. private _scene;
  133764. private _isLoading;
  133765. protected _tasks: AbstractAssetTask[];
  133766. protected _waitingTasksCount: number;
  133767. protected _totalTasksCount: number;
  133768. /**
  133769. * Callback called when all tasks are processed
  133770. */
  133771. onFinish: (tasks: AbstractAssetTask[]) => void;
  133772. /**
  133773. * Callback called when a task is successful
  133774. */
  133775. onTaskSuccess: (task: AbstractAssetTask) => void;
  133776. /**
  133777. * Callback called when a task had an error
  133778. */
  133779. onTaskError: (task: AbstractAssetTask) => void;
  133780. /**
  133781. * Callback called when a task is done (whatever the result is)
  133782. */
  133783. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  133784. /**
  133785. * Observable called when all tasks are processed
  133786. */
  133787. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  133788. /**
  133789. * Observable called when a task had an error
  133790. */
  133791. onTaskErrorObservable: Observable<AbstractAssetTask>;
  133792. /**
  133793. * Observable called when all tasks were executed
  133794. */
  133795. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  133796. /**
  133797. * Observable called when a task is done (whatever the result is)
  133798. */
  133799. onProgressObservable: Observable<IAssetsProgressEvent>;
  133800. /**
  133801. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  133802. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  133803. */
  133804. useDefaultLoadingScreen: boolean;
  133805. /**
  133806. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  133807. * when all assets have been downloaded.
  133808. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  133809. */
  133810. autoHideLoadingUI: boolean;
  133811. /**
  133812. * Creates a new AssetsManager
  133813. * @param scene defines the scene to work on
  133814. */
  133815. constructor(scene: Scene);
  133816. /**
  133817. * Add a MeshAssetTask to the list of active tasks
  133818. * @param taskName defines the name of the new task
  133819. * @param meshesNames defines the name of meshes to load
  133820. * @param rootUrl defines the root url to use to locate files
  133821. * @param sceneFilename defines the filename of the scene file
  133822. * @returns a new MeshAssetTask object
  133823. */
  133824. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  133825. /**
  133826. * Add a TextFileAssetTask to the list of active tasks
  133827. * @param taskName defines the name of the new task
  133828. * @param url defines the url of the file to load
  133829. * @returns a new TextFileAssetTask object
  133830. */
  133831. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  133832. /**
  133833. * Add a BinaryFileAssetTask to the list of active tasks
  133834. * @param taskName defines the name of the new task
  133835. * @param url defines the url of the file to load
  133836. * @returns a new BinaryFileAssetTask object
  133837. */
  133838. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  133839. /**
  133840. * Add a ImageAssetTask to the list of active tasks
  133841. * @param taskName defines the name of the new task
  133842. * @param url defines the url of the file to load
  133843. * @returns a new ImageAssetTask object
  133844. */
  133845. addImageTask(taskName: string, url: string): ImageAssetTask;
  133846. /**
  133847. * Add a TextureAssetTask to the list of active tasks
  133848. * @param taskName defines the name of the new task
  133849. * @param url defines the url of the file to load
  133850. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  133851. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  133852. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  133853. * @returns a new TextureAssetTask object
  133854. */
  133855. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  133856. /**
  133857. * Add a CubeTextureAssetTask to the list of active tasks
  133858. * @param taskName defines the name of the new task
  133859. * @param url defines the url of the file to load
  133860. * @param extensions defines the extension to use to load the cube map (can be null)
  133861. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  133862. * @param files defines the list of files to load (can be null)
  133863. * @returns a new CubeTextureAssetTask object
  133864. */
  133865. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  133866. /**
  133867. *
  133868. * Add a HDRCubeTextureAssetTask to the list of active tasks
  133869. * @param taskName defines the name of the new task
  133870. * @param url defines the url of the file to load
  133871. * @param size defines the size you want for the cubemap (can be null)
  133872. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  133873. * @param generateHarmonics defines if you want to automatically generate (true by default)
  133874. * @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)
  133875. * @param reserved Internal use only
  133876. * @returns a new HDRCubeTextureAssetTask object
  133877. */
  133878. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  133879. /**
  133880. *
  133881. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  133882. * @param taskName defines the name of the new task
  133883. * @param url defines the url of the file to load
  133884. * @param size defines the size you want for the cubemap (can be null)
  133885. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  133886. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  133887. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  133888. * @returns a new EquiRectangularCubeTextureAssetTask object
  133889. */
  133890. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  133891. /**
  133892. * Remove a task from the assets manager.
  133893. * @param task the task to remove
  133894. */
  133895. removeTask(task: AbstractAssetTask): void;
  133896. private _decreaseWaitingTasksCount;
  133897. private _runTask;
  133898. /**
  133899. * Reset the AssetsManager and remove all tasks
  133900. * @return the current instance of the AssetsManager
  133901. */
  133902. reset(): AssetsManager;
  133903. /**
  133904. * Start the loading process
  133905. * @return the current instance of the AssetsManager
  133906. */
  133907. load(): AssetsManager;
  133908. /**
  133909. * Start the loading process as an async operation
  133910. * @return a promise returning the list of failed tasks
  133911. */
  133912. loadAsync(): Promise<void>;
  133913. }
  133914. }
  133915. declare module BABYLON {
  133916. /**
  133917. * Wrapper class for promise with external resolve and reject.
  133918. */
  133919. export class Deferred<T> {
  133920. /**
  133921. * The promise associated with this deferred object.
  133922. */
  133923. readonly promise: Promise<T>;
  133924. private _resolve;
  133925. private _reject;
  133926. /**
  133927. * The resolve method of the promise associated with this deferred object.
  133928. */
  133929. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  133930. /**
  133931. * The reject method of the promise associated with this deferred object.
  133932. */
  133933. readonly reject: (reason?: any) => void;
  133934. /**
  133935. * Constructor for this deferred object.
  133936. */
  133937. constructor();
  133938. }
  133939. }
  133940. declare module BABYLON {
  133941. /**
  133942. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  133943. */
  133944. export class MeshExploder {
  133945. private _centerMesh;
  133946. private _meshes;
  133947. private _meshesOrigins;
  133948. private _toCenterVectors;
  133949. private _scaledDirection;
  133950. private _newPosition;
  133951. private _centerPosition;
  133952. /**
  133953. * Explodes meshes from a center mesh.
  133954. * @param meshes The meshes to explode.
  133955. * @param centerMesh The mesh to be center of explosion.
  133956. */
  133957. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  133958. private _setCenterMesh;
  133959. /**
  133960. * Get class name
  133961. * @returns "MeshExploder"
  133962. */
  133963. getClassName(): string;
  133964. /**
  133965. * "Exploded meshes"
  133966. * @returns Array of meshes with the centerMesh at index 0.
  133967. */
  133968. getMeshes(): Array<Mesh>;
  133969. /**
  133970. * Explodes meshes giving a specific direction
  133971. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  133972. */
  133973. explode(direction?: number): void;
  133974. }
  133975. }
  133976. declare module BABYLON {
  133977. /**
  133978. * Class used to help managing file picking and drag'n'drop
  133979. */
  133980. export class FilesInput {
  133981. /**
  133982. * List of files ready to be loaded
  133983. */
  133984. static readonly FilesToLoad: {
  133985. [key: string]: File;
  133986. };
  133987. /**
  133988. * Callback called when a file is processed
  133989. */
  133990. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  133991. private _engine;
  133992. private _currentScene;
  133993. private _sceneLoadedCallback;
  133994. private _progressCallback;
  133995. private _additionalRenderLoopLogicCallback;
  133996. private _textureLoadingCallback;
  133997. private _startingProcessingFilesCallback;
  133998. private _onReloadCallback;
  133999. private _errorCallback;
  134000. private _elementToMonitor;
  134001. private _sceneFileToLoad;
  134002. private _filesToLoad;
  134003. /**
  134004. * Creates a new FilesInput
  134005. * @param engine defines the rendering engine
  134006. * @param scene defines the hosting scene
  134007. * @param sceneLoadedCallback callback called when scene is loaded
  134008. * @param progressCallback callback called to track progress
  134009. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  134010. * @param textureLoadingCallback callback called when a texture is loading
  134011. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  134012. * @param onReloadCallback callback called when a reload is requested
  134013. * @param errorCallback callback call if an error occurs
  134014. */
  134015. 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);
  134016. private _dragEnterHandler;
  134017. private _dragOverHandler;
  134018. private _dropHandler;
  134019. /**
  134020. * Calls this function to listen to drag'n'drop events on a specific DOM element
  134021. * @param elementToMonitor defines the DOM element to track
  134022. */
  134023. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  134024. /**
  134025. * Release all associated resources
  134026. */
  134027. dispose(): void;
  134028. private renderFunction;
  134029. private drag;
  134030. private drop;
  134031. private _traverseFolder;
  134032. private _processFiles;
  134033. /**
  134034. * Load files from a drop event
  134035. * @param event defines the drop event to use as source
  134036. */
  134037. loadFiles(event: any): void;
  134038. private _processReload;
  134039. /**
  134040. * Reload the current scene from the loaded files
  134041. */
  134042. reload(): void;
  134043. }
  134044. }
  134045. declare module BABYLON {
  134046. /**
  134047. * Defines the root class used to create scene optimization to use with SceneOptimizer
  134048. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  134049. */
  134050. export class SceneOptimization {
  134051. /**
  134052. * Defines the priority of this optimization (0 by default which means first in the list)
  134053. */
  134054. priority: number;
  134055. /**
  134056. * Gets a string describing the action executed by the current optimization
  134057. * @returns description string
  134058. */
  134059. getDescription(): string;
  134060. /**
  134061. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  134062. * @param scene defines the current scene where to apply this optimization
  134063. * @param optimizer defines the current optimizer
  134064. * @returns true if everything that can be done was applied
  134065. */
  134066. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  134067. /**
  134068. * Creates the SceneOptimization object
  134069. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  134070. * @param desc defines the description associated with the optimization
  134071. */
  134072. constructor(
  134073. /**
  134074. * Defines the priority of this optimization (0 by default which means first in the list)
  134075. */
  134076. priority?: number);
  134077. }
  134078. /**
  134079. * Defines an optimization used to reduce the size of render target textures
  134080. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  134081. */
  134082. export class TextureOptimization extends SceneOptimization {
  134083. /**
  134084. * Defines the priority of this optimization (0 by default which means first in the list)
  134085. */
  134086. priority: number;
  134087. /**
  134088. * 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
  134089. */
  134090. maximumSize: number;
  134091. /**
  134092. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  134093. */
  134094. step: number;
  134095. /**
  134096. * Gets a string describing the action executed by the current optimization
  134097. * @returns description string
  134098. */
  134099. getDescription(): string;
  134100. /**
  134101. * Creates the TextureOptimization object
  134102. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  134103. * @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
  134104. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  134105. */
  134106. constructor(
  134107. /**
  134108. * Defines the priority of this optimization (0 by default which means first in the list)
  134109. */
  134110. priority?: number,
  134111. /**
  134112. * 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
  134113. */
  134114. maximumSize?: number,
  134115. /**
  134116. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  134117. */
  134118. step?: number);
  134119. /**
  134120. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  134121. * @param scene defines the current scene where to apply this optimization
  134122. * @param optimizer defines the current optimizer
  134123. * @returns true if everything that can be done was applied
  134124. */
  134125. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  134126. }
  134127. /**
  134128. * Defines an optimization used to increase or decrease the rendering resolution
  134129. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  134130. */
  134131. export class HardwareScalingOptimization extends SceneOptimization {
  134132. /**
  134133. * Defines the priority of this optimization (0 by default which means first in the list)
  134134. */
  134135. priority: number;
  134136. /**
  134137. * Defines the maximum scale to use (2 by default)
  134138. */
  134139. maximumScale: number;
  134140. /**
  134141. * Defines the step to use between two passes (0.5 by default)
  134142. */
  134143. step: number;
  134144. private _currentScale;
  134145. private _directionOffset;
  134146. /**
  134147. * Gets a string describing the action executed by the current optimization
  134148. * @return description string
  134149. */
  134150. getDescription(): string;
  134151. /**
  134152. * Creates the HardwareScalingOptimization object
  134153. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  134154. * @param maximumScale defines the maximum scale to use (2 by default)
  134155. * @param step defines the step to use between two passes (0.5 by default)
  134156. */
  134157. constructor(
  134158. /**
  134159. * Defines the priority of this optimization (0 by default which means first in the list)
  134160. */
  134161. priority?: number,
  134162. /**
  134163. * Defines the maximum scale to use (2 by default)
  134164. */
  134165. maximumScale?: number,
  134166. /**
  134167. * Defines the step to use between two passes (0.5 by default)
  134168. */
  134169. step?: number);
  134170. /**
  134171. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  134172. * @param scene defines the current scene where to apply this optimization
  134173. * @param optimizer defines the current optimizer
  134174. * @returns true if everything that can be done was applied
  134175. */
  134176. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  134177. }
  134178. /**
  134179. * Defines an optimization used to remove shadows
  134180. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  134181. */
  134182. export class ShadowsOptimization extends SceneOptimization {
  134183. /**
  134184. * Gets a string describing the action executed by the current optimization
  134185. * @return description string
  134186. */
  134187. getDescription(): string;
  134188. /**
  134189. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  134190. * @param scene defines the current scene where to apply this optimization
  134191. * @param optimizer defines the current optimizer
  134192. * @returns true if everything that can be done was applied
  134193. */
  134194. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  134195. }
  134196. /**
  134197. * Defines an optimization used to turn post-processes off
  134198. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  134199. */
  134200. export class PostProcessesOptimization extends SceneOptimization {
  134201. /**
  134202. * Gets a string describing the action executed by the current optimization
  134203. * @return description string
  134204. */
  134205. getDescription(): string;
  134206. /**
  134207. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  134208. * @param scene defines the current scene where to apply this optimization
  134209. * @param optimizer defines the current optimizer
  134210. * @returns true if everything that can be done was applied
  134211. */
  134212. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  134213. }
  134214. /**
  134215. * Defines an optimization used to turn lens flares off
  134216. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  134217. */
  134218. export class LensFlaresOptimization extends SceneOptimization {
  134219. /**
  134220. * Gets a string describing the action executed by the current optimization
  134221. * @return description string
  134222. */
  134223. getDescription(): string;
  134224. /**
  134225. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  134226. * @param scene defines the current scene where to apply this optimization
  134227. * @param optimizer defines the current optimizer
  134228. * @returns true if everything that can be done was applied
  134229. */
  134230. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  134231. }
  134232. /**
  134233. * Defines an optimization based on user defined callback.
  134234. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  134235. */
  134236. export class CustomOptimization extends SceneOptimization {
  134237. /**
  134238. * Callback called to apply the custom optimization.
  134239. */
  134240. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  134241. /**
  134242. * Callback called to get custom description
  134243. */
  134244. onGetDescription: () => string;
  134245. /**
  134246. * Gets a string describing the action executed by the current optimization
  134247. * @returns description string
  134248. */
  134249. getDescription(): string;
  134250. /**
  134251. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  134252. * @param scene defines the current scene where to apply this optimization
  134253. * @param optimizer defines the current optimizer
  134254. * @returns true if everything that can be done was applied
  134255. */
  134256. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  134257. }
  134258. /**
  134259. * Defines an optimization used to turn particles off
  134260. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  134261. */
  134262. export class ParticlesOptimization extends SceneOptimization {
  134263. /**
  134264. * Gets a string describing the action executed by the current optimization
  134265. * @return description string
  134266. */
  134267. getDescription(): string;
  134268. /**
  134269. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  134270. * @param scene defines the current scene where to apply this optimization
  134271. * @param optimizer defines the current optimizer
  134272. * @returns true if everything that can be done was applied
  134273. */
  134274. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  134275. }
  134276. /**
  134277. * Defines an optimization used to turn render targets off
  134278. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  134279. */
  134280. export class RenderTargetsOptimization extends SceneOptimization {
  134281. /**
  134282. * Gets a string describing the action executed by the current optimization
  134283. * @return description string
  134284. */
  134285. getDescription(): string;
  134286. /**
  134287. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  134288. * @param scene defines the current scene where to apply this optimization
  134289. * @param optimizer defines the current optimizer
  134290. * @returns true if everything that can be done was applied
  134291. */
  134292. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  134293. }
  134294. /**
  134295. * Defines an optimization used to merge meshes with compatible materials
  134296. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  134297. */
  134298. export class MergeMeshesOptimization extends SceneOptimization {
  134299. private static _UpdateSelectionTree;
  134300. /**
  134301. * Gets or sets a boolean which defines if optimization octree has to be updated
  134302. */
  134303. /**
  134304. * Gets or sets a boolean which defines if optimization octree has to be updated
  134305. */
  134306. static UpdateSelectionTree: boolean;
  134307. /**
  134308. * Gets a string describing the action executed by the current optimization
  134309. * @return description string
  134310. */
  134311. getDescription(): string;
  134312. private _canBeMerged;
  134313. /**
  134314. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  134315. * @param scene defines the current scene where to apply this optimization
  134316. * @param optimizer defines the current optimizer
  134317. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  134318. * @returns true if everything that can be done was applied
  134319. */
  134320. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  134321. }
  134322. /**
  134323. * Defines a list of options used by SceneOptimizer
  134324. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  134325. */
  134326. export class SceneOptimizerOptions {
  134327. /**
  134328. * Defines the target frame rate to reach (60 by default)
  134329. */
  134330. targetFrameRate: number;
  134331. /**
  134332. * Defines the interval between two checkes (2000ms by default)
  134333. */
  134334. trackerDuration: number;
  134335. /**
  134336. * Gets the list of optimizations to apply
  134337. */
  134338. optimizations: SceneOptimization[];
  134339. /**
  134340. * Creates a new list of options used by SceneOptimizer
  134341. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  134342. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  134343. */
  134344. constructor(
  134345. /**
  134346. * Defines the target frame rate to reach (60 by default)
  134347. */
  134348. targetFrameRate?: number,
  134349. /**
  134350. * Defines the interval between two checkes (2000ms by default)
  134351. */
  134352. trackerDuration?: number);
  134353. /**
  134354. * Add a new optimization
  134355. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  134356. * @returns the current SceneOptimizerOptions
  134357. */
  134358. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  134359. /**
  134360. * Add a new custom optimization
  134361. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  134362. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  134363. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  134364. * @returns the current SceneOptimizerOptions
  134365. */
  134366. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  134367. /**
  134368. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  134369. * @param targetFrameRate defines the target frame rate (60 by default)
  134370. * @returns a SceneOptimizerOptions object
  134371. */
  134372. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  134373. /**
  134374. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  134375. * @param targetFrameRate defines the target frame rate (60 by default)
  134376. * @returns a SceneOptimizerOptions object
  134377. */
  134378. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  134379. /**
  134380. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  134381. * @param targetFrameRate defines the target frame rate (60 by default)
  134382. * @returns a SceneOptimizerOptions object
  134383. */
  134384. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  134385. }
  134386. /**
  134387. * Class used to run optimizations in order to reach a target frame rate
  134388. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  134389. */
  134390. export class SceneOptimizer implements IDisposable {
  134391. private _isRunning;
  134392. private _options;
  134393. private _scene;
  134394. private _currentPriorityLevel;
  134395. private _targetFrameRate;
  134396. private _trackerDuration;
  134397. private _currentFrameRate;
  134398. private _sceneDisposeObserver;
  134399. private _improvementMode;
  134400. /**
  134401. * Defines an observable called when the optimizer reaches the target frame rate
  134402. */
  134403. onSuccessObservable: Observable<SceneOptimizer>;
  134404. /**
  134405. * Defines an observable called when the optimizer enables an optimization
  134406. */
  134407. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  134408. /**
  134409. * Defines an observable called when the optimizer is not able to reach the target frame rate
  134410. */
  134411. onFailureObservable: Observable<SceneOptimizer>;
  134412. /**
  134413. * Gets a boolean indicating if the optimizer is in improvement mode
  134414. */
  134415. readonly isInImprovementMode: boolean;
  134416. /**
  134417. * Gets the current priority level (0 at start)
  134418. */
  134419. readonly currentPriorityLevel: number;
  134420. /**
  134421. * Gets the current frame rate checked by the SceneOptimizer
  134422. */
  134423. readonly currentFrameRate: number;
  134424. /**
  134425. * Gets or sets the current target frame rate (60 by default)
  134426. */
  134427. /**
  134428. * Gets or sets the current target frame rate (60 by default)
  134429. */
  134430. targetFrameRate: number;
  134431. /**
  134432. * Gets or sets the current interval between two checks (every 2000ms by default)
  134433. */
  134434. /**
  134435. * Gets or sets the current interval between two checks (every 2000ms by default)
  134436. */
  134437. trackerDuration: number;
  134438. /**
  134439. * Gets the list of active optimizations
  134440. */
  134441. readonly optimizations: SceneOptimization[];
  134442. /**
  134443. * Creates a new SceneOptimizer
  134444. * @param scene defines the scene to work on
  134445. * @param options defines the options to use with the SceneOptimizer
  134446. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  134447. * @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)
  134448. */
  134449. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  134450. /**
  134451. * Stops the current optimizer
  134452. */
  134453. stop(): void;
  134454. /**
  134455. * Reset the optimizer to initial step (current priority level = 0)
  134456. */
  134457. reset(): void;
  134458. /**
  134459. * Start the optimizer. By default it will try to reach a specific framerate
  134460. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  134461. */
  134462. start(): void;
  134463. private _checkCurrentState;
  134464. /**
  134465. * Release all resources
  134466. */
  134467. dispose(): void;
  134468. /**
  134469. * Helper function to create a SceneOptimizer with one single line of code
  134470. * @param scene defines the scene to work on
  134471. * @param options defines the options to use with the SceneOptimizer
  134472. * @param onSuccess defines a callback to call on success
  134473. * @param onFailure defines a callback to call on failure
  134474. * @returns the new SceneOptimizer object
  134475. */
  134476. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  134477. }
  134478. }
  134479. declare module BABYLON {
  134480. /**
  134481. * Class used to serialize a scene into a string
  134482. */
  134483. export class SceneSerializer {
  134484. /**
  134485. * Clear cache used by a previous serialization
  134486. */
  134487. static ClearCache(): void;
  134488. /**
  134489. * Serialize a scene into a JSON compatible object
  134490. * @param scene defines the scene to serialize
  134491. * @returns a JSON compatible object
  134492. */
  134493. static Serialize(scene: Scene): any;
  134494. /**
  134495. * Serialize a mesh into a JSON compatible object
  134496. * @param toSerialize defines the mesh to serialize
  134497. * @param withParents defines if parents must be serialized as well
  134498. * @param withChildren defines if children must be serialized as well
  134499. * @returns a JSON compatible object
  134500. */
  134501. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  134502. }
  134503. }
  134504. declare module BABYLON {
  134505. /**
  134506. * Class used to host texture specific utilities
  134507. */
  134508. export class TextureTools {
  134509. /**
  134510. * Uses the GPU to create a copy texture rescaled at a given size
  134511. * @param texture Texture to copy from
  134512. * @param width defines the desired width
  134513. * @param height defines the desired height
  134514. * @param useBilinearMode defines if bilinear mode has to be used
  134515. * @return the generated texture
  134516. */
  134517. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  134518. }
  134519. }
  134520. declare module BABYLON {
  134521. /**
  134522. * This represents the different options available for the video capture.
  134523. */
  134524. export interface VideoRecorderOptions {
  134525. /** Defines the mime type of the video. */
  134526. mimeType: string;
  134527. /** Defines the FPS the video should be recorded at. */
  134528. fps: number;
  134529. /** Defines the chunk size for the recording data. */
  134530. recordChunckSize: number;
  134531. /** The audio tracks to attach to the recording. */
  134532. audioTracks?: MediaStreamTrack[];
  134533. }
  134534. /**
  134535. * This can help with recording videos from BabylonJS.
  134536. * This is based on the available WebRTC functionalities of the browser.
  134537. *
  134538. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  134539. */
  134540. export class VideoRecorder {
  134541. private static readonly _defaultOptions;
  134542. /**
  134543. * Returns whether or not the VideoRecorder is available in your browser.
  134544. * @param engine Defines the Babylon Engine.
  134545. * @returns true if supported otherwise false.
  134546. */
  134547. static IsSupported(engine: Engine): boolean;
  134548. private readonly _options;
  134549. private _canvas;
  134550. private _mediaRecorder;
  134551. private _recordedChunks;
  134552. private _fileName;
  134553. private _resolve;
  134554. private _reject;
  134555. /**
  134556. * True when a recording is already in progress.
  134557. */
  134558. readonly isRecording: boolean;
  134559. /**
  134560. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  134561. * @param engine Defines the BabylonJS Engine you wish to record.
  134562. * @param options Defines options that can be used to customize the capture.
  134563. */
  134564. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  134565. /**
  134566. * Stops the current recording before the default capture timeout passed in the startRecording function.
  134567. */
  134568. stopRecording(): void;
  134569. /**
  134570. * Starts recording the canvas for a max duration specified in parameters.
  134571. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  134572. * If null no automatic download will start and you can rely on the promise to get the data back.
  134573. * @param maxDuration Defines the maximum recording time in seconds.
  134574. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  134575. * @return A promise callback at the end of the recording with the video data in Blob.
  134576. */
  134577. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  134578. /**
  134579. * Releases internal resources used during the recording.
  134580. */
  134581. dispose(): void;
  134582. private _handleDataAvailable;
  134583. private _handleError;
  134584. private _handleStop;
  134585. }
  134586. }
  134587. declare module BABYLON {
  134588. /**
  134589. * Class containing a set of static utilities functions for screenshots
  134590. */
  134591. export class ScreenshotTools {
  134592. /**
  134593. * Captures a screenshot of the current rendering
  134594. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  134595. * @param engine defines the rendering engine
  134596. * @param camera defines the source camera
  134597. * @param size This parameter can be set to a single number or to an object with the
  134598. * following (optional) properties: precision, width, height. If a single number is passed,
  134599. * it will be used for both width and height. If an object is passed, the screenshot size
  134600. * will be derived from the parameters. The precision property is a multiplier allowing
  134601. * rendering at a higher or lower resolution
  134602. * @param successCallback defines the callback receives a single parameter which contains the
  134603. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  134604. * src parameter of an <img> to display it
  134605. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  134606. * Check your browser for supported MIME types
  134607. */
  134608. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  134609. /**
  134610. * Captures a screenshot of the current rendering
  134611. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  134612. * @param engine defines the rendering engine
  134613. * @param camera defines the source camera
  134614. * @param size This parameter can be set to a single number or to an object with the
  134615. * following (optional) properties: precision, width, height. If a single number is passed,
  134616. * it will be used for both width and height. If an object is passed, the screenshot size
  134617. * will be derived from the parameters. The precision property is a multiplier allowing
  134618. * rendering at a higher or lower resolution
  134619. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  134620. * Check your browser for supported MIME types
  134621. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  134622. * to the src parameter of an <img> to display it
  134623. */
  134624. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  134625. /**
  134626. * Generates an image screenshot from the specified camera.
  134627. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  134628. * @param engine The engine to use for rendering
  134629. * @param camera The camera to use for rendering
  134630. * @param size This parameter can be set to a single number or to an object with the
  134631. * following (optional) properties: precision, width, height. If a single number is passed,
  134632. * it will be used for both width and height. If an object is passed, the screenshot size
  134633. * will be derived from the parameters. The precision property is a multiplier allowing
  134634. * rendering at a higher or lower resolution
  134635. * @param successCallback The callback receives a single parameter which contains the
  134636. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  134637. * src parameter of an <img> to display it
  134638. * @param mimeType The MIME type of the screenshot image (default: image/png).
  134639. * Check your browser for supported MIME types
  134640. * @param samples Texture samples (default: 1)
  134641. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  134642. * @param fileName A name for for the downloaded file.
  134643. */
  134644. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  134645. /**
  134646. * Generates an image screenshot from the specified camera.
  134647. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  134648. * @param engine The engine to use for rendering
  134649. * @param camera The camera to use for rendering
  134650. * @param size This parameter can be set to a single number or to an object with the
  134651. * following (optional) properties: precision, width, height. If a single number is passed,
  134652. * it will be used for both width and height. If an object is passed, the screenshot size
  134653. * will be derived from the parameters. The precision property is a multiplier allowing
  134654. * rendering at a higher or lower resolution
  134655. * @param mimeType The MIME type of the screenshot image (default: image/png).
  134656. * Check your browser for supported MIME types
  134657. * @param samples Texture samples (default: 1)
  134658. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  134659. * @param fileName A name for for the downloaded file.
  134660. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  134661. * to the src parameter of an <img> to display it
  134662. */
  134663. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  134664. /**
  134665. * Gets height and width for screenshot size
  134666. * @private
  134667. */
  134668. private static _getScreenshotSize;
  134669. }
  134670. }
  134671. declare module BABYLON {
  134672. /**
  134673. * Interface for a data buffer
  134674. */
  134675. export interface IDataBuffer {
  134676. /**
  134677. * Reads bytes from the data buffer.
  134678. * @param byteOffset The byte offset to read
  134679. * @param byteLength The byte length to read
  134680. * @returns A promise that resolves when the bytes are read
  134681. */
  134682. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  134683. /**
  134684. * The byte length of the buffer.
  134685. */
  134686. readonly byteLength: number;
  134687. }
  134688. /**
  134689. * Utility class for reading from a data buffer
  134690. */
  134691. export class DataReader {
  134692. /**
  134693. * The data buffer associated with this data reader.
  134694. */
  134695. readonly buffer: IDataBuffer;
  134696. /**
  134697. * The current byte offset from the beginning of the data buffer.
  134698. */
  134699. byteOffset: number;
  134700. private _dataView;
  134701. private _dataByteOffset;
  134702. /**
  134703. * Constructor
  134704. * @param buffer The buffer to read
  134705. */
  134706. constructor(buffer: IDataBuffer);
  134707. /**
  134708. * Loads the given byte length.
  134709. * @param byteLength The byte length to load
  134710. * @returns A promise that resolves when the load is complete
  134711. */
  134712. loadAsync(byteLength: number): Promise<void>;
  134713. /**
  134714. * Read a unsigned 32-bit integer from the currently loaded data range.
  134715. * @returns The 32-bit integer read
  134716. */
  134717. readUint32(): number;
  134718. /**
  134719. * Read a byte array from the currently loaded data range.
  134720. * @param byteLength The byte length to read
  134721. * @returns The byte array read
  134722. */
  134723. readUint8Array(byteLength: number): Uint8Array;
  134724. /**
  134725. * Read a string from the currently loaded data range.
  134726. * @param byteLength The byte length to read
  134727. * @returns The string read
  134728. */
  134729. readString(byteLength: number): string;
  134730. /**
  134731. * Skips the given byte length the currently loaded data range.
  134732. * @param byteLength The byte length to skip
  134733. */
  134734. skipBytes(byteLength: number): void;
  134735. }
  134736. }
  134737. declare module BABYLON {
  134738. /**
  134739. * A cursor which tracks a point on a path
  134740. */
  134741. export class PathCursor {
  134742. private path;
  134743. /**
  134744. * Stores path cursor callbacks for when an onchange event is triggered
  134745. */
  134746. private _onchange;
  134747. /**
  134748. * The value of the path cursor
  134749. */
  134750. value: number;
  134751. /**
  134752. * The animation array of the path cursor
  134753. */
  134754. animations: Animation[];
  134755. /**
  134756. * Initializes the path cursor
  134757. * @param path The path to track
  134758. */
  134759. constructor(path: Path2);
  134760. /**
  134761. * Gets the cursor point on the path
  134762. * @returns A point on the path cursor at the cursor location
  134763. */
  134764. getPoint(): Vector3;
  134765. /**
  134766. * Moves the cursor ahead by the step amount
  134767. * @param step The amount to move the cursor forward
  134768. * @returns This path cursor
  134769. */
  134770. moveAhead(step?: number): PathCursor;
  134771. /**
  134772. * Moves the cursor behind by the step amount
  134773. * @param step The amount to move the cursor back
  134774. * @returns This path cursor
  134775. */
  134776. moveBack(step?: number): PathCursor;
  134777. /**
  134778. * Moves the cursor by the step amount
  134779. * If the step amount is greater than one, an exception is thrown
  134780. * @param step The amount to move the cursor
  134781. * @returns This path cursor
  134782. */
  134783. move(step: number): PathCursor;
  134784. /**
  134785. * Ensures that the value is limited between zero and one
  134786. * @returns This path cursor
  134787. */
  134788. private ensureLimits;
  134789. /**
  134790. * Runs onchange callbacks on change (used by the animation engine)
  134791. * @returns This path cursor
  134792. */
  134793. private raiseOnChange;
  134794. /**
  134795. * Executes a function on change
  134796. * @param f A path cursor onchange callback
  134797. * @returns This path cursor
  134798. */
  134799. onchange(f: (cursor: PathCursor) => void): PathCursor;
  134800. }
  134801. }
  134802. declare module BABYLON {
  134803. /** @hidden */
  134804. export var blurPixelShader: {
  134805. name: string;
  134806. shader: string;
  134807. };
  134808. }
  134809. declare module BABYLON {
  134810. /** @hidden */
  134811. export var pointCloudVertexDeclaration: {
  134812. name: string;
  134813. shader: string;
  134814. };
  134815. }
  134816. // Mixins
  134817. interface Window {
  134818. mozIndexedDB: IDBFactory;
  134819. webkitIndexedDB: IDBFactory;
  134820. msIndexedDB: IDBFactory;
  134821. webkitURL: typeof URL;
  134822. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  134823. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  134824. WebGLRenderingContext: WebGLRenderingContext;
  134825. MSGesture: MSGesture;
  134826. CANNON: any;
  134827. AudioContext: AudioContext;
  134828. webkitAudioContext: AudioContext;
  134829. PointerEvent: any;
  134830. Math: Math;
  134831. Uint8Array: Uint8ArrayConstructor;
  134832. Float32Array: Float32ArrayConstructor;
  134833. mozURL: typeof URL;
  134834. msURL: typeof URL;
  134835. VRFrameData: any; // WebVR, from specs 1.1
  134836. DracoDecoderModule: any;
  134837. setImmediate(handler: (...args: any[]) => void): number;
  134838. }
  134839. interface HTMLCanvasElement {
  134840. requestPointerLock(): void;
  134841. msRequestPointerLock?(): void;
  134842. mozRequestPointerLock?(): void;
  134843. webkitRequestPointerLock?(): void;
  134844. /** Track wether a record is in progress */
  134845. isRecording: boolean;
  134846. /** Capture Stream method defined by some browsers */
  134847. captureStream(fps?: number): MediaStream;
  134848. }
  134849. interface CanvasRenderingContext2D {
  134850. msImageSmoothingEnabled: boolean;
  134851. }
  134852. interface MouseEvent {
  134853. mozMovementX: number;
  134854. mozMovementY: number;
  134855. webkitMovementX: number;
  134856. webkitMovementY: number;
  134857. msMovementX: number;
  134858. msMovementY: number;
  134859. }
  134860. interface Navigator {
  134861. mozGetVRDevices: (any: any) => any;
  134862. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  134863. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  134864. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  134865. webkitGetGamepads(): Gamepad[];
  134866. msGetGamepads(): Gamepad[];
  134867. webkitGamepads(): Gamepad[];
  134868. }
  134869. interface HTMLVideoElement {
  134870. mozSrcObject: any;
  134871. }
  134872. interface Math {
  134873. fround(x: number): number;
  134874. imul(a: number, b: number): number;
  134875. }
  134876. interface WebGLRenderingContext {
  134877. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  134878. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  134879. vertexAttribDivisor(index: number, divisor: number): void;
  134880. createVertexArray(): any;
  134881. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  134882. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  134883. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  134884. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  134885. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  134886. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  134887. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  134888. // Queries
  134889. createQuery(): WebGLQuery;
  134890. deleteQuery(query: WebGLQuery): void;
  134891. beginQuery(target: number, query: WebGLQuery): void;
  134892. endQuery(target: number): void;
  134893. getQueryParameter(query: WebGLQuery, pname: number): any;
  134894. getQuery(target: number, pname: number): any;
  134895. MAX_SAMPLES: number;
  134896. RGBA8: number;
  134897. READ_FRAMEBUFFER: number;
  134898. DRAW_FRAMEBUFFER: number;
  134899. UNIFORM_BUFFER: number;
  134900. HALF_FLOAT_OES: number;
  134901. RGBA16F: number;
  134902. RGBA32F: number;
  134903. R32F: number;
  134904. RG32F: number;
  134905. RGB32F: number;
  134906. R16F: number;
  134907. RG16F: number;
  134908. RGB16F: number;
  134909. RED: number;
  134910. RG: number;
  134911. R8: number;
  134912. RG8: number;
  134913. UNSIGNED_INT_24_8: number;
  134914. DEPTH24_STENCIL8: number;
  134915. MIN: number;
  134916. MAX: number;
  134917. /* Multiple Render Targets */
  134918. drawBuffers(buffers: number[]): void;
  134919. readBuffer(src: number): void;
  134920. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  134921. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  134922. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  134923. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  134924. // Occlusion Query
  134925. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  134926. ANY_SAMPLES_PASSED: number;
  134927. QUERY_RESULT_AVAILABLE: number;
  134928. QUERY_RESULT: number;
  134929. }
  134930. interface WebGLProgram {
  134931. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  134932. }
  134933. interface EXT_disjoint_timer_query {
  134934. QUERY_COUNTER_BITS_EXT: number;
  134935. TIME_ELAPSED_EXT: number;
  134936. TIMESTAMP_EXT: number;
  134937. GPU_DISJOINT_EXT: number;
  134938. QUERY_RESULT_EXT: number;
  134939. QUERY_RESULT_AVAILABLE_EXT: number;
  134940. queryCounterEXT(query: WebGLQuery, target: number): void;
  134941. createQueryEXT(): WebGLQuery;
  134942. beginQueryEXT(target: number, query: WebGLQuery): void;
  134943. endQueryEXT(target: number): void;
  134944. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  134945. deleteQueryEXT(query: WebGLQuery): void;
  134946. }
  134947. interface WebGLUniformLocation {
  134948. _currentState: any;
  134949. }
  134950. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  134951. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  134952. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  134953. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  134954. interface WebGLRenderingContext {
  134955. readonly RASTERIZER_DISCARD: number;
  134956. readonly DEPTH_COMPONENT24: number;
  134957. readonly TEXTURE_3D: number;
  134958. readonly TEXTURE_2D_ARRAY: number;
  134959. readonly TEXTURE_COMPARE_FUNC: number;
  134960. readonly TEXTURE_COMPARE_MODE: number;
  134961. readonly COMPARE_REF_TO_TEXTURE: number;
  134962. readonly TEXTURE_WRAP_R: number;
  134963. readonly HALF_FLOAT: number;
  134964. readonly RGB8: number;
  134965. readonly RED_INTEGER: number;
  134966. readonly RG_INTEGER: number;
  134967. readonly RGB_INTEGER: number;
  134968. readonly RGBA_INTEGER: number;
  134969. readonly R8_SNORM: number;
  134970. readonly RG8_SNORM: number;
  134971. readonly RGB8_SNORM: number;
  134972. readonly RGBA8_SNORM: number;
  134973. readonly R8I: number;
  134974. readonly RG8I: number;
  134975. readonly RGB8I: number;
  134976. readonly RGBA8I: number;
  134977. readonly R8UI: number;
  134978. readonly RG8UI: number;
  134979. readonly RGB8UI: number;
  134980. readonly RGBA8UI: number;
  134981. readonly R16I: number;
  134982. readonly RG16I: number;
  134983. readonly RGB16I: number;
  134984. readonly RGBA16I: number;
  134985. readonly R16UI: number;
  134986. readonly RG16UI: number;
  134987. readonly RGB16UI: number;
  134988. readonly RGBA16UI: number;
  134989. readonly R32I: number;
  134990. readonly RG32I: number;
  134991. readonly RGB32I: number;
  134992. readonly RGBA32I: number;
  134993. readonly R32UI: number;
  134994. readonly RG32UI: number;
  134995. readonly RGB32UI: number;
  134996. readonly RGBA32UI: number;
  134997. readonly RGB10_A2UI: number;
  134998. readonly R11F_G11F_B10F: number;
  134999. readonly RGB9_E5: number;
  135000. readonly RGB10_A2: number;
  135001. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  135002. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  135003. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  135004. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  135005. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  135006. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  135007. 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;
  135008. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  135009. readonly TRANSFORM_FEEDBACK: number;
  135010. readonly INTERLEAVED_ATTRIBS: number;
  135011. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  135012. createTransformFeedback(): WebGLTransformFeedback;
  135013. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  135014. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  135015. beginTransformFeedback(primitiveMode: number): void;
  135016. endTransformFeedback(): void;
  135017. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  135018. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  135019. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  135020. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  135021. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  135022. }
  135023. interface ImageBitmap {
  135024. readonly width: number;
  135025. readonly height: number;
  135026. close(): void;
  135027. }
  135028. interface WebGLQuery extends WebGLObject {
  135029. }
  135030. declare var WebGLQuery: {
  135031. prototype: WebGLQuery;
  135032. new(): WebGLQuery;
  135033. };
  135034. interface WebGLSampler extends WebGLObject {
  135035. }
  135036. declare var WebGLSampler: {
  135037. prototype: WebGLSampler;
  135038. new(): WebGLSampler;
  135039. };
  135040. interface WebGLSync extends WebGLObject {
  135041. }
  135042. declare var WebGLSync: {
  135043. prototype: WebGLSync;
  135044. new(): WebGLSync;
  135045. };
  135046. interface WebGLTransformFeedback extends WebGLObject {
  135047. }
  135048. declare var WebGLTransformFeedback: {
  135049. prototype: WebGLTransformFeedback;
  135050. new(): WebGLTransformFeedback;
  135051. };
  135052. interface WebGLVertexArrayObject extends WebGLObject {
  135053. }
  135054. declare var WebGLVertexArrayObject: {
  135055. prototype: WebGLVertexArrayObject;
  135056. new(): WebGLVertexArrayObject;
  135057. };
  135058. // Type definitions for WebVR API
  135059. // Project: https://w3c.github.io/webvr/
  135060. // Definitions by: six a <https://github.com/lostfictions>
  135061. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  135062. interface VRDisplay extends EventTarget {
  135063. /**
  135064. * Dictionary of capabilities describing the VRDisplay.
  135065. */
  135066. readonly capabilities: VRDisplayCapabilities;
  135067. /**
  135068. * z-depth defining the far plane of the eye view frustum
  135069. * enables mapping of values in the render target depth
  135070. * attachment to scene coordinates. Initially set to 10000.0.
  135071. */
  135072. depthFar: number;
  135073. /**
  135074. * z-depth defining the near plane of the eye view frustum
  135075. * enables mapping of values in the render target depth
  135076. * attachment to scene coordinates. Initially set to 0.01.
  135077. */
  135078. depthNear: number;
  135079. /**
  135080. * An identifier for this distinct VRDisplay. Used as an
  135081. * association point in the Gamepad API.
  135082. */
  135083. readonly displayId: number;
  135084. /**
  135085. * A display name, a user-readable name identifying it.
  135086. */
  135087. readonly displayName: string;
  135088. readonly isConnected: boolean;
  135089. readonly isPresenting: boolean;
  135090. /**
  135091. * If this VRDisplay supports room-scale experiences, the optional
  135092. * stage attribute contains details on the room-scale parameters.
  135093. */
  135094. readonly stageParameters: VRStageParameters | null;
  135095. /**
  135096. * Passing the value returned by `requestAnimationFrame` to
  135097. * `cancelAnimationFrame` will unregister the callback.
  135098. * @param handle Define the hanle of the request to cancel
  135099. */
  135100. cancelAnimationFrame(handle: number): void;
  135101. /**
  135102. * Stops presenting to the VRDisplay.
  135103. * @returns a promise to know when it stopped
  135104. */
  135105. exitPresent(): Promise<void>;
  135106. /**
  135107. * Return the current VREyeParameters for the given eye.
  135108. * @param whichEye Define the eye we want the parameter for
  135109. * @returns the eye parameters
  135110. */
  135111. getEyeParameters(whichEye: string): VREyeParameters;
  135112. /**
  135113. * Populates the passed VRFrameData with the information required to render
  135114. * the current frame.
  135115. * @param frameData Define the data structure to populate
  135116. * @returns true if ok otherwise false
  135117. */
  135118. getFrameData(frameData: VRFrameData): boolean;
  135119. /**
  135120. * Get the layers currently being presented.
  135121. * @returns the list of VR layers
  135122. */
  135123. getLayers(): VRLayer[];
  135124. /**
  135125. * Return a VRPose containing the future predicted pose of the VRDisplay
  135126. * when the current frame will be presented. The value returned will not
  135127. * change until JavaScript has returned control to the browser.
  135128. *
  135129. * The VRPose will contain the position, orientation, velocity,
  135130. * and acceleration of each of these properties.
  135131. * @returns the pose object
  135132. */
  135133. getPose(): VRPose;
  135134. /**
  135135. * Return the current instantaneous pose of the VRDisplay, with no
  135136. * prediction applied.
  135137. * @returns the current instantaneous pose
  135138. */
  135139. getImmediatePose(): VRPose;
  135140. /**
  135141. * The callback passed to `requestAnimationFrame` will be called
  135142. * any time a new frame should be rendered. When the VRDisplay is
  135143. * presenting the callback will be called at the native refresh
  135144. * rate of the HMD. When not presenting this function acts
  135145. * identically to how window.requestAnimationFrame acts. Content should
  135146. * make no assumptions of frame rate or vsync behavior as the HMD runs
  135147. * asynchronously from other displays and at differing refresh rates.
  135148. * @param callback Define the eaction to run next frame
  135149. * @returns the request handle it
  135150. */
  135151. requestAnimationFrame(callback: FrameRequestCallback): number;
  135152. /**
  135153. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  135154. * Repeat calls while already presenting will update the VRLayers being displayed.
  135155. * @param layers Define the list of layer to present
  135156. * @returns a promise to know when the request has been fulfilled
  135157. */
  135158. requestPresent(layers: VRLayer[]): Promise<void>;
  135159. /**
  135160. * Reset the pose for this display, treating its current position and
  135161. * orientation as the "origin/zero" values. VRPose.position,
  135162. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  135163. * updated when calling resetPose(). This should be called in only
  135164. * sitting-space experiences.
  135165. */
  135166. resetPose(): void;
  135167. /**
  135168. * The VRLayer provided to the VRDisplay will be captured and presented
  135169. * in the HMD. Calling this function has the same effect on the source
  135170. * canvas as any other operation that uses its source image, and canvases
  135171. * created without preserveDrawingBuffer set to true will be cleared.
  135172. * @param pose Define the pose to submit
  135173. */
  135174. submitFrame(pose?: VRPose): void;
  135175. }
  135176. declare var VRDisplay: {
  135177. prototype: VRDisplay;
  135178. new(): VRDisplay;
  135179. };
  135180. interface VRLayer {
  135181. leftBounds?: number[] | Float32Array | null;
  135182. rightBounds?: number[] | Float32Array | null;
  135183. source?: HTMLCanvasElement | null;
  135184. }
  135185. interface VRDisplayCapabilities {
  135186. readonly canPresent: boolean;
  135187. readonly hasExternalDisplay: boolean;
  135188. readonly hasOrientation: boolean;
  135189. readonly hasPosition: boolean;
  135190. readonly maxLayers: number;
  135191. }
  135192. interface VREyeParameters {
  135193. /** @deprecated */
  135194. readonly fieldOfView: VRFieldOfView;
  135195. readonly offset: Float32Array;
  135196. readonly renderHeight: number;
  135197. readonly renderWidth: number;
  135198. }
  135199. interface VRFieldOfView {
  135200. readonly downDegrees: number;
  135201. readonly leftDegrees: number;
  135202. readonly rightDegrees: number;
  135203. readonly upDegrees: number;
  135204. }
  135205. interface VRFrameData {
  135206. readonly leftProjectionMatrix: Float32Array;
  135207. readonly leftViewMatrix: Float32Array;
  135208. readonly pose: VRPose;
  135209. readonly rightProjectionMatrix: Float32Array;
  135210. readonly rightViewMatrix: Float32Array;
  135211. readonly timestamp: number;
  135212. }
  135213. interface VRPose {
  135214. readonly angularAcceleration: Float32Array | null;
  135215. readonly angularVelocity: Float32Array | null;
  135216. readonly linearAcceleration: Float32Array | null;
  135217. readonly linearVelocity: Float32Array | null;
  135218. readonly orientation: Float32Array | null;
  135219. readonly position: Float32Array | null;
  135220. readonly timestamp: number;
  135221. }
  135222. interface VRStageParameters {
  135223. sittingToStandingTransform?: Float32Array;
  135224. sizeX?: number;
  135225. sizeY?: number;
  135226. }
  135227. interface Navigator {
  135228. getVRDisplays(): Promise<VRDisplay[]>;
  135229. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  135230. }
  135231. interface Window {
  135232. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  135233. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  135234. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  135235. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  135236. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  135237. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  135238. }
  135239. interface Gamepad {
  135240. readonly displayId: number;
  135241. }
  135242. type XRSessionMode =
  135243. | "inline"
  135244. | "immersive-vr"
  135245. | "immersive-ar";
  135246. type XRReferenceSpaceType =
  135247. | "viewer"
  135248. | "local"
  135249. | "local-floor"
  135250. | "bounded-floor"
  135251. | "unbounded";
  135252. type XREnvironmentBlendMode =
  135253. | "opaque"
  135254. | "additive"
  135255. | "alpha-blend";
  135256. type XRVisibilityState =
  135257. | "visible"
  135258. | "visible-blurred"
  135259. | "hidden";
  135260. type XRHandedness =
  135261. | "none"
  135262. | "left"
  135263. | "right";
  135264. type XRTargetRayMode =
  135265. | "gaze"
  135266. | "tracked-pointer"
  135267. | "screen";
  135268. type XREye =
  135269. | "none"
  135270. | "left"
  135271. | "right";
  135272. interface XRSpace extends EventTarget {
  135273. }
  135274. interface XRRenderState {
  135275. depthNear?: number;
  135276. depthFar?: number;
  135277. inlineVerticalFieldOfView?: number;
  135278. baseLayer?: XRWebGLLayer;
  135279. }
  135280. interface XRInputSource {
  135281. handedness: XRHandedness;
  135282. targetRayMode: XRTargetRayMode;
  135283. targetRaySpace: XRSpace;
  135284. gripSpace: XRSpace | undefined;
  135285. gamepad: Gamepad | undefined;
  135286. profiles: Array<string>;
  135287. }
  135288. interface XRSession {
  135289. addEventListener: Function;
  135290. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  135291. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  135292. requestAnimationFrame: Function;
  135293. end(): Promise<void>;
  135294. renderState: XRRenderState;
  135295. inputSources: Array<XRInputSource>;
  135296. }
  135297. interface XRReferenceSpace extends XRSpace {
  135298. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  135299. onreset: any;
  135300. }
  135301. interface XRFrame {
  135302. session: XRSession;
  135303. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  135304. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  135305. }
  135306. interface XRViewerPose extends XRPose {
  135307. views: Array<XRView>;
  135308. }
  135309. interface XRPose {
  135310. transform: XRRigidTransform;
  135311. emulatedPosition: boolean;
  135312. }
  135313. interface XRWebGLLayerOptions {
  135314. antialias ?: boolean;
  135315. depth ?: boolean;
  135316. stencil ?: boolean;
  135317. alpha ?: boolean;
  135318. multiview ?: boolean;
  135319. framebufferScaleFactor ?: number;
  135320. }
  135321. declare var XRWebGLLayer: {
  135322. prototype: XRWebGLLayer;
  135323. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  135324. };
  135325. interface XRWebGLLayer {
  135326. framebuffer: WebGLFramebuffer;
  135327. framebufferWidth: number;
  135328. framebufferHeight: number;
  135329. getViewport: Function;
  135330. }
  135331. interface XRRigidTransform {
  135332. position: DOMPointReadOnly;
  135333. orientation: DOMPointReadOnly;
  135334. matrix: Float32Array;
  135335. inverse: XRRigidTransform;
  135336. }
  135337. interface XRView {
  135338. eye: XREye;
  135339. projectionMatrix: Float32Array;
  135340. transform: XRRigidTransform;
  135341. }
  135342. interface XRInputSourceChangeEvent {
  135343. session: XRSession;
  135344. removed: Array<XRInputSource>;
  135345. added: Array<XRInputSource>;
  135346. }
  135347. interface XRInputSourceEvent extends Event {
  135348. readonly frame: XRFrame;
  135349. readonly inputSource: XRInputSource;
  135350. }